On 11-01-11 05:45 PM, [email protected] wrote: >>>>>> "DF" == Daniel Friesen<[email protected]> writes: > DF> That code is a mess... I would suggest not depending on the exact order > and > DF> equality of class strings, it's possible that future code changes > DF> may add new classes or change the order of those. > > OK, here is what I reduced it to. Note I totally depend on the var_dumps > to see what is coming my way, so perhaps you could tighten/loosen up my > code to make it more future-proof. Thanks. > > function JidanniLessRedNavigation($sktemplate,$links){ > // var_dump('BEFORE',$links); > if(!$sktemplate->mTitle->quickUserCan('createtalk')){ > foreach(array_keys($links['namespaces']) as $ns){ > if(strpos($ns,'talk')!==false){ > if('new'==$links['namespaces'][$ns]['class']){ > unset($links['namespaces'][$ns]);}}}} > if(isset($links['namespaces']['category']['class'])&& > 'selected new'==$links['namespaces']['category']['class']){ > $links['namespaces']['category']['class']='selected';} > // var_dump('AFTER',$links); > return true;} > $wgHooks['SkinTemplateNavigation'][]='JidanniLessRedNavigation'; Using in_array and array_diff on an exploded array should work fine. I suppose we could use some sort of Html::hasClass helper method.
Personally I wish we never even started using 'class' like this. Proper 'selected' => true, 'new' => true keys that get mapped to classes just before going off to the skin, or even better, let the skin actually choose which class it's going to use for selected things. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] -- ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
