[Mediawiki-l] PHP code to create/edit pages/sections

Jim Hu jimhu at tamu.edu
Mon Jul 23 04:08:05 UTC 2007


On Jul 22, 2007, at 8:33 PM, Kelly Jones wrote:

> I want to write PHP code for a MediaWiki I own (I have command-line +
> admin access) that:
>
> % Checks if a given article exists, and creates it if not.

 From the shell or from a browser?  In general, you can do a lot of  
the things you want by pulling the current version of an article from  
the database, manipulating it with liberal use of regular  
expressions, saving the new version to an XML file compatible with  
importDump, and importing it.

You can also skip the importDump part by using some of the interfaces  
available via other maintenance scripts.  I've been doing a lot of  
this for my wiki project.  I hope to make some code available after  
it's been worked over to make it less obviously hacky!

JH

>
> % Checks if a given section exists in an article, and creates it if  
> not.
>
> % Edits a given section in a given article.
>
> I want the edit to be done just as if a user had gone in and edited
> the page: it should create a history entry, update all the appropriate
> tables, update the page in the cache, etc.
>
> Can I use MediaWiki's PHP functions/libraries to do this?
>
> I realize I can use wget/curl/lynx/elinks to do this, but was looking
> for something more "internal".
>
> On a related note, does MediaWiki come w/ any maintenance tools?  
> Examples:
>
> % Auto-fix all double redirects (if X -> Y -> Z, just edit X to
> redirect directly to Z).
>
> % Find all instances of certain words (eg, spam), and revert to the
> previous version of each page that contains those words (crude
> anti-vandalism tool). Delete pages where there is no previous version.
>
> % For commonly misspelled articles, find all instances of [[wrong
> spelling]] and change them to [[correct spelling]] (redirecting "wrong
> spelling" to "right spelling" sort of works, but it still leaves the
> link misspelled on many pages)
>
> I realize SQL queries can do some of this, but they won't update the
> history, won't handle caching issues properly, etc. I'm looking for
> something that works within MediaWiki's framework, not an outside
> hack.
>
> -- 
> We're just a Bunch Of Regular Guys, a collective group that's trying
> to understand and assimilate technology. We feel that resistance to
> new ideas and technology is unwise and ultimately futile.
>
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at lists.wikimedia.org
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-l

=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054




More information about the MediaWiki-l mailing list