Mass edit pages on MediaWiki site -
i have extension code runs hooks $wghooks['parserfirstcallinit'][] = 'adssetup'; $wghooks['editpage::showeditform:initial'][] = 'checkhastag';
when click edit on page check page using javascript text, if isn't there adds <tag>
.
then save page , tag there. have on 1,000 pages on site. don't want have click edit on each page run extension. there way mass edit pages run extension?
i want run on pages namespace = 'main'
, exclude pages.
this extension code:
<?php $wghooks['parserfirstcallinit'][] = 'adssetup'; $wghooks['editpage::showeditform:initial'][] = 'checkhastag'; function adssetup( &$parser ) { $parser->sethook( 'ads', 'adsrender' ); return true;} function adsrender( $input, $args, $parser, $frame ) { $output = '<div id="googlead"><script type="text/javascript"> google_ad_client = "xxx"; google_ad_width = 300; google_ad_height = 250; </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>'; return array( $output, "markertype" => 'nowiki' ); } // check if content has <googleads1> tag function checkhastag($editpage){ global $wgout; $wgout->addscript('<script type="text/javascript"> var edittextboxtext = document.getelementbyid("wptextbox1").value; var searchfor = "googleads1"; var searchresult = edittextboxtext.search(searchfor); console.log("testing console12"); if(searchresult == -1){ var = edittextboxtext; var b = "\n<ads media=googleads1 />\n"; var findp = "\n"; var p = edittextboxtext.search(findp); var position = p; document.getelementbyid("wptextbox1").value = a.substring(0, position) + b + a.substring(position); } </script>'); return true; }
how run extension without having edit each page individually?
have had @ replace text extension? easy way global search-and-replace in namespace. caveat searches presence of string or regex, rather absence.
there isn't enough detail in description know whether it's going possible test absence of string regex, might able add <tag>
pages, search pages containing <tag>
, target string, , remove <tag>
pages.
Comments
Post a Comment