MediaWikiDoc:Article.php

From HypertWiki
Revision as of 14:26, 16 June 2005 by Woozle (talk | contribs) (finished with function list; going to try complete code paste, with headers)
Jump to navigation Jump to search

Techniques: MediaWiki: Article.php

Class Functions

function Article( &$title ) { function getTitle() { function clear() { function getRevisionText( $row, $prefix = 'old_' ) { function compressRevisionText( &$text ) { function getContent( $noredir ) { function getSection($text,$section) { function &getCurContentFields() { function &getOldContentFields() { function getOldID() { function loadContent( $noredir = false ) { function getContentWithoutUsingSoManyDamnGlobals( $oldid = 0, $noredir = false ) { function forUpdate( $x = NULL ) { function &getDB() { function getSelectOptions( $options = ) { function getID() { function getCount() {

    • Get the view count for this article

function isCountable( $text ) {

    • Would the given text make this article a "good" article (i.e., suitable for including in the article count)?
  • function isRedirect( $text = false ) {
    • Tests if the article text represents a redirect
  • function loadLastEdit() {
    • Loads everything from cur except cur_text
    • This isn't necessary for all uses, so it's only done if needed.

Data Access

  • function getTimestamp() {
  • function getUser() {
  • function getUserText() {
  • function getComment() {
  • function getMinorEdit() {

More Other Methods

  • function getContributors($limit = 0, $offset = 0)
  • function view()
    • This is the default action of the script: just view the page of the given title.
  • function insertNewArticle( $text, $summary, $isminor, $watchthis )
    • Theoretically we could defer these whole insert and update functions for after display, but that's taking a big leap of faith, and we want to be able to report database errors at some point.
  • function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = , $edittime = NULL)
    • Side effects: loads last edit if $edittime is NULL
  • function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = )
    • Change an existing article. Puts the previous version back into the old table, updates RC and all necessary caches, mostly via the deferred update array.
    • It is possible to call this function from a command-line script, but note that you should first set $wgUser, and clean up $wgDeferredUpdates after each edit.
  • function showArticle( $text, $subtitle , $sectionanchor = )
    • After we've either updated or inserted the article, update the link tables and redirect to the new page.
  • function validate ()
    • Validate article
  • function markpatrolled()
    • Mark this particular edit as patrolled
  • function watch()
    • Add this page to $wgUser's watchlist
  • function unwatch()
    • Stop watching a page
  • function protect( $limit = 'sysop' )
    • protect a page
  • function confirmProtect( $par, $reason, $limit = 'sysop' )
    • Output protection confirmation dialog
  • function unprotect()
    • Unprotect the pages
  • function delete()
    • UI entry point for page deletion
  • function confirmDelete( $par, $reason )
    • Output deletion confirmation dialog
  • function doDelete( $reason )
    • Perform a deletion and output success or failure messages
  • function doDeleteArticle( $reason )
    • Back-end article deletion
    • Deletes the article with database consistency, writes logs, purges caches
    • Returns success
  • function rollback()
    • Revert a modification
  • function viewUpdates()
    • Do standard deferred updates after page view
  • function editUpdates( $text )
    • Do standard deferred updates after page edit. Every 1000th edit, prune the recent changes table.
  • function setOldSubtitle( $oldid=0 )
  • function preSaveTransform( $text )
    • This function is called right before saving the wikitext, so we can do things like signatures and links-in-context.
  • function tryFileCache()
    • checkLastModified returns true if it has taken care of all output to the client that is necessary for this request (that is, it has sent a cached version of the page)
  • function isFileCacheable()
    • Check if the page can be cached
  • function checkTouched()
    • Loads cur_touched and returns a value indicating if it should be used
  • function quickEdit( $text, $comment = , $minor = 0 )
    • Edit an article without doing all that other stuff
  • function incViewCount( $id )
    • Used to increment the view counter

Event Hooks

The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of the specified actions are done. This is a good place to put code to clear caches, for instance.

  • function onArticleCreate($title_obj)
    • This is called on page move and undelete, as well as edit
  • function onArticleDelete($title_obj)
  • function onArticleEdit($title_obj)

More Other Functions

  • function info()
    • Info about this page
Editing is currently in progress on this article. Although editing is incomplete, the author or editor has saved their work to prevent loss. Please check back later by reloading the page, and do not edit while this message is still showing. Thank you.