From: Antoine Musso Date: Thu, 2 Sep 2004 23:28:24 +0000 (+0000) Subject: Changing comments layout preparing for generated documentation with Phpdocumentor X-Git-Tag: 1.5.0alpha1~2157 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=90155b8a9719ada6522a320a3315b4e698fdd970;p=lhc%2Fweb%2Fwiklou.git Changing comments layout preparing for generated documentation with Phpdocumentor --- diff --git a/includes/Article.php b/includes/Article.php index f12a5f2f62..0c71859f3d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1,32 +1,50 @@ mTitle =& $title; $this->clear(); } - /* private */ function clear() { + /** + * Clear the object + * @private + */ + function clear() { $this->mContentLoaded = false; $this->mCurID = $this->mUser = $this->mCounter = -1; # Not loaded $this->mRedirectedFrom = $this->mUserText = @@ -36,9 +54,16 @@ class Article { $this->mForUpdate = false; } - # Get revision text associated with an old or archive row - # $row is usually an object from wfFetchRow(), both the flags and the text field must be included - /* static */ function getRevisionText( $row, $prefix = 'old_' ) { + /** + * Get revision text associated with an old or archive row + * $row is usually an object from wfFetchRow(), both the flags and the text + * field must be included + * @static + * @param integer $row Id of a row + * @param string $prefix table prefix (default 'old_') + * @return string $text the text requested + */ + function getRevisionText( $row, $prefix = 'old_' ) { # Get data $textField = $prefix . 'text'; $flagsField = $prefix . 'flags'; @@ -67,7 +92,13 @@ class Article { return $text; } - /* static */ function compressRevisionText( &$text ) { + /** + * If $wgCompressRevisions is enabled, we will compress datas + * @static + * @param reference to a text + * @return string 'gzip' if it get compressed, '' overwise + */ + function compressRevisionText( &$text ) { global $wgCompressRevisions; if( !$wgCompressRevisions ) { return ''; @@ -80,8 +111,11 @@ class Article { return 'gzip'; } - # Returns the text associated with a "link" type old table row - /* static */ function followLink( $link ) { + /** + * Returns the text associated with a "link" type old table row + * @static + */ + function followLink( $link ) { # Split the link into fields and values $lines = explode( '\n', $link ); $hash = ''; @@ -119,7 +153,10 @@ class Article { return $text; } - /* static */ function fetchFromLocation( $location, $hash ) { + /** + * @static + */ + function fetchFromLocation( $location, $hash ) { global $wgLoadBalancer; $fname = 'fetchFromLocation'; wfProfileIn( $fname ); @@ -195,10 +232,12 @@ class Article { return $text; } - # Note that getContent/loadContent may follow redirects if - # not told otherwise, and so may cause a change to mTitle. - - # Return the text of this revision + /** + * Note that getContent/loadContent may follow redirects if + * not told otherwise, and so may cause a change to mTitle. + * + * Return the text of this revision + */ function getContent( $noredir ) { global $wgRequest; @@ -246,12 +285,13 @@ class Article { } } - # This function returns the text of a section, specified by a number ($section). - # A section is text under a heading like == Heading == or

Heading

, or - # the first section before any such heading (section 0). - # - # If a section contains subsections, these are also returned. - # + /** + * This function returns the text of a section, specified by a number ($section). + * A section is text under a heading like == Heading == or

Heading

, or + * the first section before any such heading (section 0). + * + * If a section contains subsections, these are also returned. + */ function getSection($text,$section) { # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML @@ -310,7 +350,9 @@ class Article { } - # Return an array of the columns of the "cur"-table + /** + * Return an array of the columns of the "cur"-table + */ function &getCurContentFields() { global $wgArticleCurContentFields; if ( !$wgArticleCurContentFields ) { @@ -320,7 +362,9 @@ class Article { return $wgArticleCurContentFields; } - # Return an array of the columns of the "old"-table + /** + * Return an array of the columns of the "old"-table + */ function &getOldContentFields() { global $wgArticleOldContentFields; if ( !$wgArticleOldContentFields ) { @@ -330,7 +374,9 @@ class Article { return $wgArticleOldContentFields; } - # Load the revision (including cur_text) into this object + /** + * Load the revision (including cur_text) into this object + */ function loadContent( $noredir = false ) { global $wgOut, $wgMwRedir, $wgRequest; @@ -431,8 +477,10 @@ class Article { return $this->mContent; } - # Gets the article text without using so many damn globals - # Returns false on error + /** + * Gets the article text without using so many damn globals + * Returns false on error + */ function getContentWithoutUsingSoManyDamnGlobals( $oldid = 0, $noredir = false ) { global $wgMwRedir; @@ -501,12 +549,16 @@ class Article { return $this->mContent; } - # Read/write accessor to select FOR UPDATE + /** + * Read/write accessor to select FOR UPDATE + */ function forUpdate( $x = NULL ) { return wfSetVar( $this->mForUpdate, $x ); } - # Get the database which should be used for reads + /** + * Get the database which should be used for reads + */ function &getDB() { if ( $this->mForUpdate ) { return wfGetDB( DB_MASTER ); @@ -515,8 +567,10 @@ class Article { } } - # Get options for all SELECT statements - # Can pass an option array, to which the class-wide options will be appended + /** + * Get options for all SELECT statements + * Can pass an option array, to which the class-wide options will be appended + */ function getSelectOptions( $options = '' ) { if ( $this->mForUpdate ) { if ( $options ) { @@ -528,6 +582,9 @@ class Article { return $options; } + /** + * Return the Article ID + */ function getID() { if( $this->mTitle ) { return $this->mTitle->getArticleID(); @@ -536,6 +593,9 @@ class Article { } } + /* + * @todo document function + */ function getCount() { if ( -1 == $this->mCounter ) { $id = $this->getID(); @@ -546,8 +606,10 @@ class Article { return $this->mCounter; } - # Would the given text make this article a "good" article (i.e., - # suitable for including in the article count)? + /** + * Would the given text make this article a "good" article (i.e., + * suitable for including in the article count)? + */ function isCountable( $text ) { global $wgUseCommaCount, $wgMwRedir; @@ -558,9 +620,12 @@ class Article { return 1; } - # Loads everything from cur except cur_text - # This isn't necessary for all uses, so it's only done if needed. - /* private */ function loadLastEdit() { + /** + * Loads everything from cur except cur_text + * This isn't necessary for all uses, so it's only done if needed. + * @private + */ + function loadLastEdit() { global $wgOut; if ( -1 != $this->mUser ) return; @@ -640,9 +705,10 @@ class Article { return $contribs; } - # This is the default action of the script: just view the page of - # the given title. - + /** + * This is the default action of the script: just view the page of + * the given title. + */ function view() { global $wgUser, $wgOut, $wgLang, $wgRequest, $wgMwRedir, $wgOnlySysopsCanPatrol; global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol; @@ -769,12 +835,14 @@ class Article { wfProfileOut( $fname ); } - # 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. - - /* private */ 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. + * @private + */ + function insertNewArticle( $text, $summary, $isminor, $watchthis ) { global $wgOut, $wgUser, $wgMwRedir; global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer; @@ -843,7 +911,9 @@ class Article { } - /* Side effects: loads last edit */ + /** + * Side effects: loads last edit + */ function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '') { $this->loadLastEdit(); $oldtext = $this->getContent( true ); @@ -919,6 +989,9 @@ class Article { return $text; } + /** + * @todo document this function + */ function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { global $wgOut, $wgUser; global $wgDBtransactions, $wgMwRedir; @@ -1053,9 +1126,10 @@ class Article { return $good; } - # After we've either updated or inserted the article, update - # the link tables and redirect to the new page. - + /** + * After we've either updated or inserted the article, update + * the link tables and redirect to the new page. + */ function showArticle( $text, $subtitle , $sectionanchor = '' ) { global $wgOut, $wgUser, $wgLinkCache; global $wgMwRedir; @@ -1082,8 +1156,10 @@ class Article { $wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor ); } - # Validate article - + /** + * Validate article + * @todo document this function a bit more + */ function validate () { global $wgOut, $wgUseValidation; if( $wgUseValidation ) { @@ -1101,7 +1177,9 @@ class Article { } } - # Mark this particular edit as patrolled + /** + * Mark this particular edit as patrolled + */ function markpatrolled() { global $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgUseRCPatrol, $wgUser; $wgOut->setRobotpolicy( 'noindex,follow' ); @@ -1136,8 +1214,9 @@ class Article { } - # Add this page to my watchlist - + /** + * Add or remove this page to my watchlist based on value of $add + */ function watch( $add = true ) { global $wgUser, $wgOut, $wgLang; global $wgDeferredUpdateList; @@ -1173,12 +1252,16 @@ class Article { $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() ); } + /** + * Stop watching a page, it act just like a call to watch(false) + */ function unwatch() { $this->watch( false ); } - # protect a page - + /** + * protect a page + */ function protect( $limit = 'sysop' ) { global $wgUser, $wgOut, $wgRequest; @@ -1224,8 +1307,9 @@ class Article { } } - # Output protection confirmation dialog - + /** + * Output protection confirmation dialog + */ function confirmProtect( $par, $reason, $limit = 'sysop' ) { global $wgOut; @@ -1289,12 +1373,16 @@ class Article { $wgOut->returnToMain( false ); } + /** + * Unprotect the pages + */ function unprotect() { return $this->protect( '' ); } - # UI entry point for page deletion - + /* + * UI entry point for page deletion + */ function delete() { global $wgUser, $wgOut, $wgMessageCache, $wgRequest; $fname = 'Article::delete'; @@ -1401,8 +1489,9 @@ class Article { return $this->confirmDelete( '', $reason ); } - # Output deletion confirmation dialog - + /** + * Output deletion confirmation dialog + */ function confirmDelete( $par, $reason ) { global $wgOut; @@ -1454,8 +1543,9 @@ class Article { } - # Perform a deletion and output success or failure messages - + /** + * Perform a deletion and output success or failure messages + */ function doDelete( $reason ) { global $wgOut, $wgUser, $wgLang; $fname = 'Article::doDelete'; @@ -1480,9 +1570,11 @@ class Article { } } - # Back-end article deletion - # Deletes the article with database consistency, writes logs, purges caches - # Returns success + /** + * Back-end article deletion + * Deletes the article with database consistency, writes logs, purges caches + * Returns success + */ function doDeleteArticle( $reason ) { global $wgUser, $wgLang; global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer; @@ -1601,6 +1693,9 @@ class Article { return true; } + /** + * Revert a modification + */ function rollback() { global $wgUser, $wgLang, $wgOut, $wgRequest; $fname = 'Article::rollback'; @@ -1691,9 +1786,11 @@ class Article { } - # Do standard deferred updates after page view - - /* private */ function viewUpdates() { + /** + * Do standard deferred updates after page view + * @private + */ + function viewUpdates() { global $wgDeferredUpdateList; if ( 0 != $this->getID() ) { global $wgDisableCounters; @@ -1708,10 +1805,12 @@ class Article { array_push( $wgDeferredUpdateList, $u ); } - # Do standard deferred updates after page edit. - # Every 1000th edit, prune the recent changes table. - - /* private */ function editUpdates( $text ) { + /** + * Do standard deferred updates after page edit. + * Every 1000th edit, prune the recent changes table. + * @private + */ + function editUpdates( $text ) { global $wgDeferredUpdateList, $wgDBname, $wgMemc; global $wgMessageCache; @@ -1745,7 +1844,11 @@ class Article { } } - /* private */ function setOldSubtitle() { + /** + * @todo document this function + * @private + */ + function setOldSubtitle() { global $wgLang, $wgOut, $wgUser; $td = $wgLang->timeanddate( $this->mTimestamp, true ); @@ -1755,9 +1858,10 @@ class Article { $wgOut->setSubtitle( $r ); } - # This function is called right before saving the wikitext, - # so we can do things like signatures and links-in-context. - + /** + * This function is called right before saving the wikitext, + * so we can do things like signatures and links-in-context. + */ function preSaveTransform( $text ) { global $wgParser, $wgUser; return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) ); @@ -1939,14 +2043,18 @@ class Article { $dbw->ignoreErrors( $oldignore ); } - # 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. - - # This is called on page move and undelete, as well as edit - /* static */ function onArticleCreate($title_obj) { + /** + * 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. + * + * This is called on page move and undelete, as well as edit + * @static + * @param $title_obj a title object + */ + function onArticleCreate($title_obj) { global $wgUseSquid, $wgDeferredUpdateList; $titles = $title_obj->getBrokenLinksTo(); @@ -1965,17 +2073,24 @@ class Article { LinkCache::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() ); } - /* static */ function onArticleDelete($title_obj) { + /** + * @static + */ + function onArticleDelete($title_obj) { LinkCache::linksccClearLinksTo( $title_obj->getArticleID() ); } - /* static */ function onArticleEdit($title_obj) { + /** + * @static + */ + function onArticleEdit($title_obj) { LinkCache::linksccClearPage( $title_obj->getArticleID() ); } - # Info about this page - + /** + * Info about this page + */ function info() { global $wgUser, $wgTitle, $wgOut, $wgLang, $wgAllowPageInfo; $fname = 'Article::info'; diff --git a/includes/Block.php b/includes/Block.php index 823fb5a794..5cb81c4f2e 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -1,18 +1,23 @@ mTitle->getNamespace() ) { $this->openShowCategory(); } @@ -25,8 +26,7 @@ class CategoryPage extends Article { } } - function openShowCategory() - { + function openShowCategory() { # For overloading } @@ -36,8 +36,7 @@ class CategoryPage extends Article { # languages due to sorting issues, so they might want to turn it # off. - function closeShowCategory() - { + function closeShowCategory() { global $wgOut; $msg = wfMsg('usenewcategorypage'); if ( '0' == @$msg[0] ) diff --git a/includes/Credits.php b/includes/Credits.php index 312d4f1c57..a92c9f9289 100644 --- a/includes/Credits.php +++ b/includes/Credits.php @@ -1,6 +1,7 @@ . * * This program is free software; you can redistribute it and/or modify @@ -16,12 +17,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @author */ -/* This is largely cadged from PageHistory::history */ - -function showCreditsPage($article) -{ +/** + * This is largely cadged from PageHistory::history + */ +function showCreditsPage($article) { global $wgOut; $fname = 'showCreditsPage'; @@ -59,8 +62,10 @@ function getCredits($article, $cnt, $showIfMax=true) { return $s; } -function getAuthorCredits($article) { - +/** + * + */ +function getAuthorCredits($article) { global $wgLang; $last_author = $article->getUser(); @@ -88,6 +93,9 @@ function getAuthorCredits($article) { return wfMsg('lastmodifiedby', $d, $author_credit); } +/** + * + */ function getContributorCredits($article, $cnt, $showIfMax) { global $wgLang, $wgAllowRealName; @@ -156,6 +164,9 @@ function getContributorCredits($article, $cnt, $showIfMax) { return (empty($creds)) ? '' : wfMsg('othercontribs', $creds); } +/** + * + */ function creditLink($user_name, $link_text = '') { global $wgUser, $wgLang; $skin = $wgUser->getSkin(); @@ -163,6 +174,9 @@ function creditLink($user_name, $link_text = '') { (empty($link_text)) ? $user_name : $link_text); } +/** + * + */ function creditOthersLink($article) { global $wgUser, $wgLang; $skin = $wgUser->getSkin(); diff --git a/includes/Database.php b/includes/Database.php index 49b9039c24..5d0951c6a3 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1,8 +1,13 @@ mConn; } - # Closes a database connection, if it is open - # Returns success, true if already closed - function close() - { + /** + * Closes a database connection, if it is open + * Returns success, true if already closed + */ + function close() { $this->mOpened = false; if ( $this->mConn ) { return pg_close( $this->mConn ); @@ -88,6 +99,7 @@ class DatabasePgsql extends Database { wfDebugDieBacktrace( "Unable to free PostgreSQL result\n" ); } } + function fetchObject( $res ) { @$row = pg_fetch_object( $res ); # FIXME: HACK HACK HACK HACK debug @@ -119,7 +131,9 @@ class DatabasePgsql extends Database { function numFields( $res ) { return pg_num_fields( $res ); } function fieldName( $res, $n ) { return pg_field_name( $res, $n ); } - # This must be called after nextSequenceVal + /** + * This must be called after nextSequenceVal + */ function insertId() { return $this->mInsertId; } @@ -132,10 +146,11 @@ class DatabasePgsql extends Database { return pg_affected_rows( $this->mLastResult ); } - # Returns information about an index - # If errors are explicitly ignored, returns NULL on failure - function indexInfo( $table, $index, $fname = 'Database::indexExists' ) - { + /** + * Returns information about an index + * If errors are explicitly ignored, returns NULL on failure + */ + function indexInfo( $table, $index, $fname = 'Database::indexExists' ) { $sql = "SELECT indexname FROM pg_indexes WHERE tablename='$table'"; $res = $this->query( $sql, $fname ); if ( !$res ) { @@ -150,8 +165,7 @@ class DatabasePgsql extends Database { return false; } - function fieldInfo( $table, $field ) - { + function fieldInfo( $table, $field ) { wfDebugDieBacktrace( 'Database::fieldInfo() error : mysql_fetch_field() not implemented for postgre' ); /* $res = $this->query( "SELECT * FROM '$table' LIMIT 1" ); @@ -223,15 +237,19 @@ class DatabasePgsql extends Database { return pg_escape_string( $s ); } - # Return the next in a sequence, save the value for retrieval via insertId() + /** + * Return the next in a sequence, save the value for retrieval via insertId() + */ function nextSequenceValue( $seqName ) { $value = $this->getField(''," nextval('" . $seqName . "')"); $this->mInsertId = $value; return $value; } - # USE INDEX clause - # PostgreSQL doesn't have them and returns "" + /** + * USE INDEX clause + * PostgreSQL doesn't have them and returns "" + */ function useIndexClause( $index ) { return ''; } @@ -343,7 +361,9 @@ class DatabasePgsql extends Database { } } -# Just an alias. +/** + * Just an alias. + */ class DatabasePostgreSQL extends DatabasePgsql { } diff --git a/includes/DateFormatter.php b/includes/DateFormatter.php index 2d3fdef36c..6a8abf977e 100755 --- a/includes/DateFormatter.php +++ b/includes/DateFormatter.php @@ -1,4 +1,12 @@ diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index eee7c61870..e478689388 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -1,6 +1,11 @@ _lines = array(); @@ -1198,6 +1223,9 @@ class _HWLDF_WordAccumulator { } } +/** + * @todo document + */ class WordLevelDiff extends MappedDiff { function WordLevelDiff ($orig_lines, $closing_lines) { @@ -1245,7 +1273,7 @@ class WordLevelDiff extends MappedDiff /** * Wikipedia Table style diff formatter. - * + * @todo document */ class TableDiffFormatter extends DiffFormatter { diff --git a/includes/EditPage.php b/includes/EditPage.php index 83f3034637..02cba8786a 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1,11 +1,15 @@ 'RSSFeed', 'atom' => 'AtomFeed', ); +/** + * @todo document + */ class FeedItem { var $Title = 'Wiki'; var $Description = ''; @@ -73,6 +83,9 @@ class FeedItem { } } +/** + * @todo document + */ class ChannelFeed extends FeedItem { /* Abstract functions, override! */ function outHeader() { @@ -99,6 +112,10 @@ class ChannelFeed extends FeedItem { } } +/** + * Generate a RSS feed + * @todo document + */ class RSSFeed extends ChannelFeed { function formatTime( $ts ) { @@ -140,6 +157,10 @@ class RSSFeed extends ChannelFeed { } } +/** + * Generate an Atom feed + * @todo document + */ class AtomFeed extends ChannelFeed { function formatTime( $ts ) { // need to use RFC 822 time format at least for rss2.0 diff --git a/includes/FulltextStoplist.php b/includes/FulltextStoplist.php index 132fcb2905..81feb36c78 100644 --- a/includes/FulltextStoplist.php +++ b/includes/FulltextStoplist.php @@ -1,21 +1,30 @@ > 6 & 0x3f | 0xc0) . @@ -154,7 +169,9 @@ function wfUtf8Sequence( $codepoint ) { return "&#$codepoint;"; } -# Converts numeric character entities to UTF-8 +/** + * Converts numeric character entities to UTF-8 + */ function wfMungeToUtf8( $string ) { global $wgInputEncoding; # This is debatable #$string = iconv($wgInputEncoding, "UTF-8", $string); @@ -164,8 +181,10 @@ function wfMungeToUtf8( $string ) { return $string; } -# Converts a single UTF-8 character into the corresponding HTML character entity -# (for use with preg_replace_callback) +/** + * Converts a single UTF-8 character into the corresponding HTML character + * entity (for use with preg_replace_callback) + */ function wfUtf8Entity( $matches ) { $char = $matches[0]; # Find the length @@ -201,11 +220,17 @@ function wfUtf8Entity( $matches ) { return "&#$z;"; } -# Converts all multi-byte characters in a UTF-8 string into the appropriate character entity +/** + * Converts all multi-byte characters in a UTF-8 string into the appropriate + * character entity + */ function wfUtf8ToHTML($string) { return preg_replace_callback( '/[\\xc0-\\xfd][\\x80-\\xbf]*/', 'wfUtf8Entity', $string ); } +/** + * @todo document + */ function wfDebug( $text, $logonly = false ) { global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage; @@ -223,7 +248,9 @@ function wfDebug( $text, $logonly = false ) } } -# Log for database errors +/** + * Log for database errors + */ function wfLogDBError( $text ) { global $wgDBerrorLog; if ( $wgDBerrorLog ) { @@ -232,6 +259,9 @@ function wfLogDBError( $text ) { } } +/** + * @todo document + */ function logProfilingData() { global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest; @@ -263,8 +293,11 @@ function logProfilingData() } } -# Check if the wiki read-only lock file is present. This can be used to lock off -# editing functions, but doesn't guarantee that the database will not be modified. +/** + * Check if the wiki read-only lock file is present. This can be used to lock + * off editing functions, but doesn't guarantee that the database will not be + * modified. + */ function wfReadOnly() { global $wgReadOnlyFile; @@ -276,7 +309,9 @@ function wfReadOnly() { $wgReplacementKeys = array( '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9' ); -# Get a message from anywhere +/** + * Get a message from anywhere + */ function wfMsg( $key ) { global $wgRequest; if ( $wgRequest->getVal( 'debugmsg' ) ) { @@ -292,7 +327,9 @@ function wfMsg( $key ) { return wfMsgReal( $key, $args, true ); } -# Get a message from the language file +/** + * Get a message from the language file + */ function wfMsgNoDB( $key ) { $args = func_get_args(); if ( count( $args ) ) { @@ -301,7 +338,9 @@ function wfMsgNoDB( $key ) { return wfMsgReal( $key, $args, false ); } -# Really get a message +/** + * Really get a message + */ function wfMsgReal( $key, $args, $useDB ) { global $wgReplacementKeys, $wgMessageCache, $wgLang; @@ -324,8 +363,10 @@ function wfMsgReal( $key, $args, $useDB ) { return $message; } -# Just like exit() but makes a note of it. -# Commits open transactions except if the error parameter is set +/** + * Just like exit() but makes a note of it. + * Commits open transactions except if the error parameter is set + */ function wfAbruptExit( $error = false ){ global $wgLoadBalancer; static $called = false; @@ -350,13 +391,17 @@ function wfAbruptExit( $error = false ){ exit(); } +/** + * @todo document + */ function wfErrorExit() { wfAbruptExit( true ); } -# This is meant as a debugging aid to track down where bad data comes from. -# Shouldn't be used in production code except maybe in "shouldn't happen" areas. -# +/** + * This is meant as a debugging aid to track down where bad data comes from. + * Shouldn't be used in production code except maybe in "shouldn't happen" areas. + */ function wfDebugDieBacktrace( $msg = '' ) { global $wgCommandLineMode; @@ -466,18 +511,22 @@ function wfClientAcceptsGzip() { return false; } -# Yay, more global functions! +/** + * Yay, more global functions! + */ function wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) { global $wgRequest; return $wgRequest->getLimitOffset( $deflimit, $optionname ); } -# Escapes the given text so that it may be output using addWikiText() -# without any linking, formatting, etc. making its way through. This -# is achieved by substituting certain characters with HTML entities. -# As required by the callers, is not used. It currently does -# not filter out characters which have special meaning only at the -# start of a line, such as "*". +/** + * Escapes the given text so that it may be output using addWikiText() + * without any linking, formatting, etc. making its way through. This + * is achieved by substituting certain characters with HTML entities. + * As required by the callers, is not used. It currently does + * not filter out characters which have special meaning only at the + * start of a line, such as "*". + */ function wfEscapeWikiText( $text ) { $text = str_replace( @@ -511,15 +560,19 @@ function wfTime(){ return (float)$st[0] + (float)$st[1]; } -# Changes the first character to an HTML entity +/** + * Changes the first character to an HTML entity + */ function wfHtmlEscapeFirst( $text ) { $ord = ord($text); $newText = substr($text, 1); return "&#$ord;$newText"; } -# Sets dest to source and returns the original value of dest -# If source is NULL, it just returns the value, it doesn't set the variable +/** + * Sets dest to source and returns the original value of dest + * If source is NULL, it just returns the value, it doesn't set the variable + */ function wfSetVar( &$dest, $source ) { $temp = $dest; @@ -529,7 +582,9 @@ function wfSetVar( &$dest, $source ) return $temp; } -# As for wfSetVar except setting a bit +/** + * As for wfSetVar except setting a bit + */ function wfSetBit( &$dest, $bit, $state = true ) { $temp = (bool)($dest & $bit ); if ( !is_null( $state ) ) { @@ -542,9 +597,11 @@ function wfSetBit( &$dest, $bit, $state = true ) { return $temp; } -# This function takes two arrays as input, and returns a CGI-style string, e.g. -# "days=7&limit=100". Options in the first array override options in the second. -# Options set to "" will not be output. +/** + * This function takes two arrays as input, and returns a CGI-style string, e.g. + * "days=7&limit=100". Options in the first array override options in the second. + * Options set to "" will not be output. + */ function wfArrayToCGI( $array1, $array2 = NULL ) { if ( !is_null( $array2 ) ) { @@ -563,14 +620,19 @@ function wfArrayToCGI( $array1, $array2 = NULL ) return $cgi; } -# This is obsolete, use SquidUpdate::purge() +/** + * This is obsolete, use SquidUpdate::purge() + * @deprecated + */ function wfPurgeSquidServers ($urlArr) { SquidUpdate::purge( $urlArr ); } -# Windows-compatible version of escapeshellarg() -# Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() -# function puts single quotes in regardless of OS +/** + * Windows-compatible version of escapeshellarg() + * Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() + * function puts single quotes in regardless of OS + */ function wfEscapeShellArg( ) { $args = func_get_args(); @@ -592,9 +654,10 @@ function wfEscapeShellArg( ) return $retVal; } -# wfMerge attempts to merge differences between three texts. -# Returns true for a clean merge and false for failure or a conflict. - +/** + * wfMerge attempts to merge differences between three texts. + * Returns true for a clean merge and false for failure or a conflict. + */ function wfMerge( $old, $mine, $yours, &$result ){ global $wgDiff3; @@ -645,6 +708,9 @@ function wfMerge( $old, $mine, $yours, &$result ){ return ! $conflict; } +/** + * @todo document + */ function wfVarDump( $var ) { global $wgOut; @@ -656,7 +722,9 @@ function wfVarDump( $var ) } } -# Provide a simple HTTP error. +/** + * Provide a simple HTTP error. + */ function wfHttpError( $code, $label, $desc ) { global $wgOut; $wgOut->disable(); @@ -671,7 +739,10 @@ function wfHttpError( $code, $label, $desc ) { } } -# Converts an Accept-* header into an array mapping string values to quality factors +/** + * Converts an Accept-* header into an array mapping string values to quality + * factors + */ function wfAcceptToPrefs( $accept, $def = '*/*' ) { # No arg means accept anything (per HTTP spec) if( !$accept ) { @@ -695,7 +766,11 @@ function wfAcceptToPrefs( $accept, $def = '*/*' ) { return $prefs; } -/* private */ function mimeTypeMatch( $type, $avail ) { +/** + * @todo document + * @private + */ +function mimeTypeMatch( $type, $avail ) { if( array_key_exists($type, $avail) ) { return $type; } else { @@ -710,8 +785,10 @@ function wfAcceptToPrefs( $accept, $def = '*/*' ) { } } -# FIXME: doesn't handle params like 'text/plain; charset=UTF-8' -# XXX: generalize to negotiate other stuff +/** + * @todo FIXME: doesn't handle params like 'text/plain; charset=UTF-8' + * XXX: generalize to negotiate other stuff + */ function wfNegotiateType( $cprefs, $sprefs ) { $combine = array(); @@ -748,16 +825,21 @@ function wfNegotiateType( $cprefs, $sprefs ) { return $besttype; } -# Array lookup -# Returns an array where the values in the first array are replaced by the -# values in the second array with the corresponding keys +/** + * Array lookup + * Returns an array where the values in the first array are replaced by the + * values in the second array with the corresponding keys + */ function wfArrayLookup( $a, $b ) { return array_flip( array_intersect( array_flip( $a ), array_keys( $b ) ) ); } -# Ideally we'd be using actual time fields in the db +/** + * Ideally we'd be using actual time fields in the db + * @todo fixme + */ function wfTimestamp2Unix( $ts ) { return gmmktime( ( (int)substr( $ts, 8, 2) ), (int)substr( $ts, 10, 2 ), (int)substr( $ts, 12, 2 ), @@ -774,7 +856,9 @@ function wfTimestampNow() { return gmdate( 'YmdHis' ); } -# Sorting hack for MySQL 3, which doesn't use index sorts for DESC +/** + * Sorting hack for MySQL 3, which doesn't use index sorts for DESC + */ function wfInvertTimestamp( $ts ) { return strtr( $ts, @@ -783,7 +867,9 @@ function wfInvertTimestamp( $ts ) { ); } -# Reference-counted warning suppression +/** + * Reference-counted warning suppression + */ function wfSuppressWarnings( $end = false ) { static $suppressCount = 0; static $originalLevel = false; @@ -803,7 +889,9 @@ function wfSuppressWarnings( $end = false ) { } } -# Restore error level to previous value +/** + * Restore error level to previous value + */ function wfRestoreWarnings() { wfSuppressWarnings( true ); } @@ -813,6 +901,9 @@ define('TS_UNIX',0); # Standard unix timestamp (number of seconds since 1 Jan 19 define('TS_MW',1); # Mediawiki concatenated string timestamp (yyyymmddhhmmss) define('TS_DB',2); # Standard database timestamp (yyyy-mm-dd hh:mm:ss) +/** + * @todo document + */ function wfTimestamp($outputtype=TS_UNIX,$ts=0) { if (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/",$ts,$da)) { # TS_DB @@ -844,6 +935,9 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) { } } +/** + * @todo document + */ function wfIsWindows() { if (substr(php_uname(), 0, 7) == 'Windows') { return true; diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index cf170b7595..10251fb2c3 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -1,6 +1,11 @@ name; } - //********************************************************************** - // Create a thumbnail of the image having the specified width. - // The thumbnail will not be created if the width is larger than the - // image's width. Let the browser do the scaling in this case. - // The thumbnail is stored on disk and is only computed if the thumbnail - // file does not exist OR if it is older than the image. - // Returns the URL. + /** + * Create a thumbnail of the image having the specified width. + * The thumbnail will not be created if the width is larger than the + * image's width. Let the browser do the scaling in this case. + * The thumbnail is stored on disk and is only computed if the thumbnail + * file does not exist OR if it is older than the image. + * Returns the URL. + */ function createThumb( $width ) { global $wgUploadDirectory; global $wgImageMagickConvertCommand; @@ -254,13 +261,14 @@ class Image return $thumbUrl; } // END OF function createThumb - //********************************************************************** - // Return the image history of this image, line by line. - // starts with current version, then old versions. - // uses $this->historyLine to check which line to return: - // 0 return line for current version - // 1 query for old versions, return first one - // 2, ... return next old version from above query + /** + * Return the image history of this image, line by line. + * starts with current version, then old versions. + * uses $this->historyLine to check which line to return: + * 0 return line for current version + * 1 query for old versions, return first one + * 2, ... return next old version from above query + */ function nextHistoryLine() { $fname = 'Image::nextHistoryLine()'; diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 49251f1c9c..42c219e0ed 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -1,11 +1,16 @@ diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 10aac8b9f4..ce4594b6b6 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -1,11 +1,19 @@ mActive = true; $this->mPreFilled = false; $this->mForUpdate = false; @@ -34,13 +41,14 @@ class LinkCache { $this->mOldBadLinks = array(); } - # General accessor to get/set whether SELECT FOR UPDATE should be used + /** + * General accessor to get/set whether SELECT FOR UPDATE should be used + */ function forUpdate( $update = NULL ) { return wfSetVar( $this->mForUpdate, $update ); } - function getGoodLinkID( $title ) - { + function getGoodLinkID( $title ) { if ( array_key_exists( $title, $this->mGoodLinks ) ) { return $this->mGoodLinks[$title]; } else { @@ -48,32 +56,27 @@ class LinkCache { } } - function isBadLink( $title ) - { + function isBadLink( $title ) { return array_key_exists( $title, $this->mBadLinks ); } - function addGoodLink( $id, $title ) - { + function addGoodLink( $id, $title ) { if ( $this->mActive ) { $this->mGoodLinks[$title] = $id; } } - function addBadLink( $title ) - { + function addBadLink( $title ) { if ( $this->mActive && ( ! $this->isBadLink( $title ) ) ) { $this->mBadLinks[$title] = 1; } } - function addImageLink( $title ) - { + function addImageLink( $title ) { if ( $this->mActive ) { $this->mImageLinks[$title] = 1; } } - function addImageLinkObj( $nt ) - { + function addImageLinkObj( $nt ) { if ( $this->mActive ) { $this->mImageLinks[$nt->getDBkey()] = 1; } } @@ -85,14 +88,12 @@ class LinkCache { $this->addCategoryLink( $nt->getDBkey(), $sortkey ); } - function clearBadLink( $title ) - { + function clearBadLink( $title ) { unset( $this->mBadLinks[$title] ); $this->clearLink( $title ); } - function clearLink( $title ) - { + function clearLink( $title ) { global $wgMemc, $wgLinkCacheMemcached; if( $wgLinkCacheMemcached ) $wgMemc->delete( $this->getKey( $title ) ); @@ -105,8 +106,7 @@ class LinkCache { function getImageLinks() { return $this->mImageLinks; } function getCategoryLinks() { return $this->mCategoryLinks; } - function addLink( $title ) - { + function addLink( $title ) { $nt = Title::newFromDBkey( $title ); if( $nt ) { return $this->addLinkObj( $nt ); @@ -115,8 +115,7 @@ class LinkCache { } } - function addLinkObj( &$nt ) - { + function addLinkObj( &$nt ) { global $wgMemc, $wgLinkCacheMemcached; $title = $nt->getPrefixedDBkey(); if ( $this->isBadLink( $title ) ) { return 0; } @@ -160,8 +159,7 @@ class LinkCache { return $id; } - function preFill( &$fromtitle ) - { + function preFill( &$fromtitle ) { global $wgEnablePersistentLC; $fname = 'LinkCache::preFill'; @@ -220,44 +218,43 @@ class LinkCache { wfProfileOut( $fname ); } - function getGoodAdditions() - { + function getGoodAdditions() { return array_diff( $this->mGoodLinks, $this->mOldGoodLinks ); } - function getBadAdditions() - { + function getBadAdditions() { #wfDebug( "mOldBadLinks: " . implode( ', ', array_keys( $this->mOldBadLinks ) ) . "\n" ); #wfDebug( "mBadLinks: " . implode( ', ', array_keys( $this->mBadLinks ) ) . "\n" ); return array_values( array_diff( array_keys( $this->mBadLinks ), array_keys( $this->mOldBadLinks ) ) ); } - function getImageAdditions() - { + function getImageAdditions() { return array_diff_assoc( $this->mImageLinks, $this->mOldImageLinks ); } - function getGoodDeletions() - { + function getGoodDeletions() { return array_diff( $this->mOldGoodLinks, $this->mGoodLinks ); } - function getBadDeletions() - { + function getBadDeletions() { return array_values( array_diff( array_keys( $this->mOldBadLinks ), array_keys( $this->mBadLinks ) )); } - function getImageDeletions() - { + function getImageDeletions() { return array_diff_assoc( $this->mOldImageLinks, $this->mImageLinks ); } - # Parameters: $which is one of the LINKCACHE_xxx constants, $del and $add are - # the incremental update arrays which will be filled. Returns whether or not it's - # worth doing the incremental version. For example, if [[List of mathematical topics]] - # was blanked, it would take a long, long time to do incrementally. - function incrementalSetup( $which, &$del, &$add ) - { + /** + * Parameters: + * @param $which is one of the LINKCACHE_xxx constants + * @param $del,$add are the incremental update arrays which will be filled. + * + * @return Returns whether or not it's worth doing the incremental version. + * + * For example, if [[List of mathematical topics]] was blanked, + * it would take a long, long time to do incrementally. + */ + function incrementalSetup( $which, &$del, &$add ) { if ( ! $this->mPreFilled ) { return false; } @@ -282,15 +279,19 @@ class LinkCache { return true; } - # Clears cache but leaves old preFill copies alone - function clear() - { + /** + * Clears cache but leaves old preFill copies alone + */ + function clear() { $this->mGoodLinks = array(); $this->mBadLinks = array(); $this->mImageLinks = array(); } - /* private */ function fillFromLinkscc( $id ){ + /** + * @access private + */ + function fillFromLinkscc( $id ){ $fname = 'LinkCache::fillFromLinkscc'; $id = IntVal( $id ); @@ -325,7 +326,10 @@ class LinkCache { } - /* private */ function saveToLinkscc( $pid ){ + /** + * @access private + */ + function saveToLinkscc( $pid ){ global $wgCompressedPersistentLC; if( $wgCompressedPersistentLC and function_exists( 'gzcompress' ) ) { $ser = gzcompress( serialize( $this ), 3 ); @@ -336,9 +340,12 @@ class LinkCache { $db->replace( 'linkscc', array( 'lcc_pageid' ), array( 'lcc_pageid' => $pid, 'lcc_cacheobj' => $ser ) ); } - # Delete linkscc rows which link to here - # $pid is a page id - /* static */ function linksccClearLinksTo( $pid ){ + /** + * Delete linkscc rows which link to here + * @param $pid is a page id + * @static + */ + function linksccClearLinksTo( $pid ){ global $wgEnablePersistentLC; if ( $wgEnablePersistentLC ) { $fname = 'LinkCache::linksccClearLinksTo'; @@ -352,9 +359,12 @@ class LinkCache { } - # Delete linkscc rows with broken links to here - # $title is a prefixed db title, for example like Title->getPrefixedDBkey() returns. - /* static */ function linksccClearBrokenLinksTo( $title ){ + /** + * Delete linkscc rows with broken links to here + * @param $title is a prefixed db title for example like Title->getPrefixedDBkey() returns. + * @static + */ + function linksccClearBrokenLinksTo( $title ){ global $wgEnablePersistentLC; $fname = 'LinkCache::linksccClearBrokenLinksTo'; @@ -364,8 +374,11 @@ class LinkCache { } } - # $pid is a page id - /* static */ function linksccClearPage( $pid ){ + /** + * @param $pid is a page id + * @static + */ + function linksccClearPage( $pid ){ global $wgEnablePersistentLC; if ( $wgEnablePersistentLC ) { $pid = intval( $pid ); diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 5b9cf54629..b9e3f03183 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -1,6 +1,11 @@ mConnections[$i]; } - # Open a connection to the server given by the specified index - # Index must be an actual index into the array - /* private */ function openConnection( $i, $fail = false ) { + /** + * Open a connection to the server given by the specified index + * Index must be an actual index into the array + * @private + */ + function openConnection( $i, $fail = false ) { $fname = 'LoadBalancer::openConnection'; wfProfileIn( $fname ); @@ -258,8 +278,11 @@ class LoadBalancer { wfProfileOut( $fname ); } - # Test if the specified index represents an open connection - /* private */ function isOpen( $index ) { + /** + * Test if the specified index represents an open connection + * @private + */ + function isOpen( $index ) { if( !is_integer( $index ) ) { return false; } @@ -272,8 +295,11 @@ class LoadBalancer { } } - # Really opens a connection - /* private */ function reallyOpenConnection( &$server ) { + /** + * Really opens a connection + * @private + */ + function reallyOpenConnection( &$server ) { extract( $server ); # Get class for this database type $class = 'Database' . ucfirst( $type ); @@ -323,12 +349,16 @@ class LoadBalancer { return array_key_exists( $i, $this->mServers ); } - # Get the number of defined servers (not the number of open connections) + /** + * Get the number of defined servers (not the number of open connections) + */ function getServerCount() { return count( $this->mServers ); } - # Save master pos to the session and to memcached, if the session exists + /** + * Save master pos to the session and to memcached, if the session exists + */ function saveMasterPos() { global $wgSessionStarted; if ( $wgSessionStarted && count( $this->mServers ) > 1 ) { @@ -350,14 +380,18 @@ class LoadBalancer { } } - # Loads the master pos from the session, waits for it if necessary + /** + * Loads the master pos from the session, waits for it if necessary + */ function loadMasterPos() { if ( isset( $_SESSION['master_log_file'] ) && isset( $_SESSION['master_pos'] ) ) { $this->waitFor( $_SESSION['master_log_file'], $_SESSION['master_pos'] ); } } - # Close all open connections + /** + * Close all open connections + */ function closeAll() { foreach( $this->mConnections as $i => $conn ) { if ( $this->isOpen( $i ) ) { diff --git a/includes/LogPage.php b/includes/LogPage.php index 590daa04f8..c2f0d6ad55 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -19,10 +19,15 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html -# Class to simplify the use of log pages. -# The logs are now kept in a table which is easier to manage and trim -# than ever-growing wiki pages. +/** + * Contain log classes + */ +/** + * Class to simplify the use of log pages. + * The logs are now kept in a table which is easier to manage and trim + * than ever-growing wiki pages. + */ class LogPage { /* private */ var $type, $action, $comment; var $updateRecentChanges = true; @@ -66,12 +71,18 @@ class LogPage { return true; } - /* static */ function validTypes() { + /** + * @static + */ + function validTypes() { static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload' ); return $types; } - /* static */ function validActions( $type ) { + /** + * @static + */ + function validActions( $type ) { static $actions = array( '' => NULL, 'block' => array( 'block', 'unblock' ), @@ -83,11 +94,17 @@ class LogPage { return $actions[$type]; } - /* static */ function isLogType( $type ) { + /** + * @static + */ + function isLogType( $type ) { return in_array( $type, LogPage::validTypes() ); } - /* static */ function logName( $type ) { + /** + * @static + */ + function logName( $type ) { static $typeText = array( '' => 'log', 'block' => 'blocklogpage', @@ -99,7 +116,10 @@ class LogPage { return str_replace( '_', ' ', wfMsg( $typeText[$type] ) ); } - /* static */ function logHeader( $type ) { + /** + * @static + */ + function logHeader( $type ) { static $headerText = array( '' => 'alllogstext', 'block' => 'blocklogtext', @@ -111,7 +131,10 @@ class LogPage { return wfMsg( $headerText[$type] ); } - /* static */ function actionText( $type, $action, $titleLink = NULL ) { + /** + * @static + */ + function actionText( $type, $action, $titleLink = NULL ) { static $actions = array( 'block/block' => 'blocklogentry', 'block/unblock' => 'blocklogentry', diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 707e8a34ff..64a2e83e1a 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -1,17 +1,13 @@ match( $text ) ) -# -# Possible future improvements: -# * Simultaneous searching for a number of magic words -# * $wgMagicWords in shared memory -# -# Please avoid reading the data out of one of these objects and then writing -# special case code. If possible, add another match()-like function here. +/** + * private + */ +$wgMagicFound = false; -/*private*/ $wgMagicFound = false; define('MAG_REDIRECT', 0); define('MAG_NOTOC', 1); @@ -65,6 +61,18 @@ $wgVariableIDs = array( MAG_NAMESPACE ); +/** + * This class encapsulates "magic words" such as #redirect, __NOTOC__, etc. + * Usage: + * if (MagicWord::get( MAG_REDIRECT )->match( $text ) ) + * + * Possible future improvements: + * * Simultaneous searching for a number of magic words + * * $wgMagicWords in shared memory + * + * Please avoid reading the data out of one of these objects and then writing + * special case code. If possible, add another match()-like function here. + */ class MagicWord { /*private*/ var $mId, $mSynonyms, $mCaseSensitive, $mRegex; /*private*/ var $mRegexStart, $mBaseRegex, $mVariableRegex; @@ -81,8 +89,11 @@ class MagicWord { $this->mModified = false; } - # Factory: creates an object representing an ID - /*static*/ function &get( $id ) { + /** + * Factory: creates an object representing an ID + * @static + */ + function &get( $id ) { global $wgMagicWords; if ( !is_array( $wgMagicWords ) ) { @@ -103,8 +114,11 @@ class MagicWord { $wgLang->getMagic( $this ); } - # Preliminary initialisation - /* private */ function initRegex() { + /** + * Preliminary initialisation + * @private + */ + function initRegex() { $variableClass = Title::legalChars(); $escSyn = array_map( 'preg_quote', $this->mSynonyms ); $this->mBaseRegex = implode( '|', $escSyn ); @@ -116,7 +130,9 @@ class MagicWord { "/^({$this->mBaseRegex})$/{$case}" ); } - # Gets a regex representing matching the word + /** + * Gets a regex representing matching the word + */ function getRegex() { if ($this->mRegex == '' ) { $this->initRegex(); @@ -124,8 +140,9 @@ class MagicWord { return $this->mRegex; } - # Gets a regex matching the word, if it is at the - # string start + /** + * Gets a regex matching the word, if it is at the string start + */ function getRegexStart() { if ($this->mRegex == '' ) { $this->initRegex(); @@ -133,7 +150,9 @@ class MagicWord { return $this->mRegexStart; } - # regex without the slashes and what not + /** + * regex without the slashes and what not + */ function getBaseRegex() { if ($this->mRegex == '') { $this->initRegex(); @@ -141,20 +160,28 @@ class MagicWord { return $this->mBaseRegex; } - # Returns true if the text contains the word + /** + * Returns true if the text contains the word + * @return bool + */ function match( $text ) { return preg_match( $this->getRegex(), $text ); } - # Returns true if the text starts with the word + /** + * Returns true if the text starts with the word + * @return bool + */ function matchStart( $text ) { return preg_match( $this->getRegexStart(), $text ); } - # Returns NULL if there's no match, the value of $1 otherwise - # The return code is the matched string, if there's no variable - # part in the regex and the matched variable part ($1) if there - # is one. + /** + * Returns NULL if there's no match, the value of $1 otherwise + * The return code is the matched string, if there's no variable + * part in the regex and the matched variable part ($1) if there + * is one. + */ function matchVariableStartToEnd( $text ) { $matchcount = preg_match( $this->getVariableStartToEndRegex(), $text, $matches ); if ( $matchcount == 0 ) { @@ -167,8 +194,10 @@ class MagicWord { } - # Returns true if the text matches the word, and alters the - # input string, removing all instances of the word + /** + * Returns true if the text matches the word, and alters the + * input string, removing all instances of the word + */ function matchAndRemove( &$text ) { global $wgMagicFound; $wgMagicFound = false; @@ -184,16 +213,20 @@ class MagicWord { } - # Replaces the word with something else + /** + * Replaces the word with something else + */ function replace( $replacement, $subject ) { $res = preg_replace( $this->getRegex(), $replacement, $subject ); $this->mModified = !($res === $subject); return $res; } - # Variable handling: {{SUBST:xxx}} style words - # Calls back a function to determine what to replace xxx with - # Input word must contain $1 + /** + * Variable handling: {{SUBST:xxx}} style words + * Calls back a function to determine what to replace xxx with + * Input word must contain $1 + */ function substituteCallback( $text, $callback ) { $regex = $this->getVariableRegex(); $res = preg_replace_callback( $this->getVariableRegex(), $callback, $text ); @@ -201,7 +234,9 @@ class MagicWord { return $res; } - # Matches the word, where $1 is a wildcard + /** + * Matches the word, where $1 is a wildcard + */ function getVariableRegex() { if ( $this->mVariableRegex == '' ) { $this->initRegex(); @@ -209,7 +244,9 @@ class MagicWord { return $this->mVariableRegex; } - # Matches the entire string, where $1 is a wildcard + /** + * Matches the entire string, where $1 is a wildcard + */ function getVariableStartToEndRegex() { if ( $this->mVariableStartToEndRegex == '' ) { $this->initRegex(); @@ -217,23 +254,29 @@ class MagicWord { return $this->mVariableStartToEndRegex; } - # Accesses the synonym list directly + /** + * Accesses the synonym list directly + */ function getSynonym( $i ) { return $this->mSynonyms[$i]; } - # Returns true if the last call to replace() or substituteCallback() - # returned a modified text, otherwise false. + /** + * Returns true if the last call to replace() or substituteCallback() + * returned a modified text, otherwise false. + */ function getWasModified(){ return $this->mModified; } - # $magicarr is an associative array of (magic word ID => replacement) - # This method uses the php feature to do several replacements at the same time, - # thereby gaining some efficiency. The result is placed in the out variable - # $result. The return value is true if something was replaced. - - /* static */ function replaceMultiple( $magicarr, $subject, &$result ){ + /** + * $magicarr is an associative array of (magic word ID => replacement) + * This method uses the php feature to do several replacements at the same time, + * thereby gaining some efficiency. The result is placed in the out variable + * $result. The return value is true if something was replaced. + * @static + **/ + function replaceMultiple( $magicarr, $subject, &$result ){ $search = array(); $replace = array(); foreach( $magicarr as $id => $replacement ){ @@ -246,7 +289,10 @@ class MagicWord { return !($result === $subject); } - # Adds all the synonyms of this MagicWord to an array, to allow quick lookup in a list of magic words + /** + * Adds all the synonyms of this MagicWord to an array, to allow quick + * lookup in a list of magic words + */ function addToArray( &$array, $value ) { foreach ( $this->mSynonyms as $syn ) { $array[$syn] = $value; @@ -254,8 +300,11 @@ class MagicWord { } } -# Used in matchAndRemove() -/*private*/ function pregRemoveAndRecord( $match ) { +/** + * Used in matchAndRemove() + * @private + **/ +function pregRemoveAndRecord( $match ) { global $wgMagicFound; $wgMagicFound = true; return ''; diff --git a/includes/Math.php b/includes/Math.php index f22226c1d5..9b7a996f6d 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -1,12 +1,15 @@ parsing + */ +/** + * Takes LaTeX fragments, sends them to a helper program (texvc) for rendering + * to rasterized PNG and HTML and MathML approximations. An appropriate + * rendering form is picked and returned. + * + * by Tomasz Wegrzanowski, with additions by Brion Vibber (2003, 2004) + */ class MathRenderer { var $mode = MW_MATH_MODERN; var $tex = ''; @@ -174,7 +177,9 @@ class MathRenderer { return false; } - # Select among PNG, HTML, or MathML output depending on + /** + * Select among PNG, HTML, or MathML output depending on + */ function _doRender() { if( $this->mode == MW_MATH_MATHML && $this->mathml != '' ) { return "{$this->mathml}"; diff --git a/includes/MemcachedSessions.php b/includes/MemcachedSessions.php index 304cceb869..289ea36961 100644 --- a/includes/MemcachedSessions.php +++ b/includes/MemcachedSessions.php @@ -1,30 +1,39 @@ get( memsess_key( $id ) ); @@ -32,18 +41,27 @@ function memsess_read( $id ) { return $data; } +/** + * @todo document + */ function memsess_write( $id, $data ) { global $wgMemc; $wgMemc->set( memsess_key( $id ), $data, 3600 ); return true; } +/** + * @todo document + */ function memsess_destroy( $id ) { global $wgMemc; $wgMemc->delete( memsess_key( $id ) ); return true; } +/** + * @todo document + */ function memsess_gc( $maxlifetime ) { # NOP: Memcached performs garbage collection. return true; diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 485b10eb3a..8f480e666a 100755 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -1,12 +1,19 @@ select( 'cur', @@ -122,7 +132,9 @@ class MessageCache $dbr->freeResult( $res ); } - # Not really needed anymore + /** + * Not really needed anymore + */ function getKeys() { global $wgAllMessagesEn, $wgLang; if ( !$this->mKeys ) { @@ -134,7 +146,9 @@ class MessageCache return $this->mKeys; } - # Obsolete + /** + * Obsolete + */ function isCacheable( $key ) { return true; /* @@ -154,8 +168,10 @@ class MessageCache $this->unlock(); } - # Returns success - # Represents a write lock on the messages key + /** + * Returns success + * Represents a write lock on the messages key + */ function lock() { if ( !$this->mUseCache ) { return true; @@ -255,7 +271,9 @@ class MessageCache } } - # Clear all stored messages. Mainly used after a mass rebuild. + /** + * Clear all stored messages. Mainly used after a mass rebuild. + */ function clear() { if( $this->mUseCache ) { $this->mMemc->delete( $this->mMemcKey ); diff --git a/includes/Metadata.php b/includes/Metadata.php index bf1869be1e..edea045cf8 100644 --- a/includes/Metadata.php +++ b/includes/Metadata.php @@ -1,5 +1,6 @@ . * * This program is free software; you can redistribute it and/or modify @@ -15,8 +16,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @author Evan Prodromou */ +/** + * + */ define('RDF_TYPE_PREFS', "application/rdf+xml,text/xml;q=0.7,application/xml;q=0.5,text/rdf;q=0.1"); function wfDublinCoreRdf($article) { @@ -60,7 +66,10 @@ function wfCreativeCommonsRdf($article) { ccEpilogue(); } -/* private */ function rdfSetup() { +/** + * @private + */ +function rdfSetup() { global $wgOut, $wgRdfMimeType, $_SERVER; $rdftype = wfNegotiateType(wfAcceptToPrefs($_SERVER['HTTP_ACCEPT']), wfAcceptToPrefs(RDF_TYPE_PREFS)); @@ -76,7 +85,10 @@ function wfCreativeCommonsRdf($article) { } } -/* private */ function dcPrologue($url) { +/** + * @private + */ +function dcPrologue($url) { global $wgOutputEncoding; $url = htmlspecialchars( $url ); @@ -90,14 +102,20 @@ function wfCreativeCommonsRdf($article) { "; } -/* private */ function dcEpilogue() { +/** + * @private + */ +function dcEpilogue() { print " "; } -/* private */ function dcBasics($article) { +/** + * @private + */ +function dcBasics($article) { global $wgLanguageCode, $wgSitename; dcElement('title', $article->mTitle->getText()); @@ -126,7 +144,10 @@ function wfCreativeCommonsRdf($article) { dcRights($article); } -/* private */ function ccPrologue() { +/** + * @private + */ +function ccPrologue() { global $wgOutputEncoding; echo "<" . "?xml version='1.0' encoding='{$wgOutputEncoding}' ?" . "> @@ -137,16 +158,25 @@ function wfCreativeCommonsRdf($article) { "; } -/* private */ function ccSubPrologue($type, $url) { +/** + * @private + */ +function ccSubPrologue($type, $url) { $url = htmlspecialchars( $url ); echo " \n"; } -/* private */ function ccSubEpilogue($type) { +/** + * @private + */ +function ccSubEpilogue($type) { echo " \n"; } -/* private */ function ccLicense($terms) { +/** + * @private + */ +function ccLicense($terms) { foreach ($terms as $term) { switch ($term) { @@ -170,30 +200,48 @@ function wfCreativeCommonsRdf($article) { } } -/* private */ function ccTerm($term, $name) { +/** + * @private + */ +function ccTerm($term, $name) { print " \n"; } -/* private */ function ccEpilogue() { +/** + * @private + */ +function ccEpilogue() { echo "\n"; } -/* private */ function dcElement($name, $value) { +/** + * @private + */ +function dcElement($name, $value) { $value = htmlspecialchars( $value ); print " {$value}\n"; } -/* private */ function dcDate($timestamp) { +/** + * @private + */ +function dcDate($timestamp) { return substr($timestamp, 0, 4) . '-' . substr($timestamp, 4, 2) . '-' . substr($timestamp, 6, 2); } -/* private */ function dcReallyFullUrl($title) { +/** + * @private + */ +function dcReallyFullUrl($title) { return $title->getFullURL(); } -/* private */ function dcPageOrString($name, $page, $str) { +/** + * @private + */ +function dcPageOrString($name, $page, $str) { $nt = Title::newFromText($page); if (!$nt || $nt->getArticleID() == 0) { @@ -203,16 +251,25 @@ function wfCreativeCommonsRdf($article) { } } -/* private */ function dcPage($name, $title) { +/** + * @private + */ +function dcPage($name, $title) { dcUrl($name, dcReallyFullUrl($title)); } -/* private */ function dcUrl($name, $url) { +/** + * @private + */ +function dcUrl($name, $url) { $url = htmlspecialchars( $url ); print " \n"; } -/* private */ function dcPerson($name, $id, $user_name='', $user_real_name='') { +/** + * @private + */ +function dcPerson($name, $id, $user_name='', $user_real_name='') { global $wgLang; if ($id == 0) { @@ -228,10 +285,12 @@ function wfCreativeCommonsRdf($article) { } } -/* Takes an arg, for future enhancement with different rights for - different pages. */ - -/* private */ function dcRights($article) { +/** + * Takes an arg, for future enhancement with different rights for + * different pages. + * @private + */ +function dcRights($article) { global $wgRightsPage, $wgRightsUrl, $wgRightsText; @@ -246,7 +305,10 @@ function wfCreativeCommonsRdf($article) { } } -/* private */ function ccGetTerms($url) { +/** + * @private + */ +function ccGetTerms($url) { global $wgLicenseTerms; if (isset($wgLicenseTerms)) { @@ -257,7 +319,10 @@ function wfCreativeCommonsRdf($article) { } } -/* private */ function getKnownLicenses() { +/** + * @private + */ +function getKnownLicenses() { $ccLicenses = array('by', 'by-nd', 'by-nd-nc', 'by-nc', 'by-nc-sa', 'by-sa'); diff --git a/includes/Namespace.php b/includes/Namespace.php index b02542da97..81c4a491c1 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -1,18 +1,19 @@ 'Media', NS_SPECIAL => 'Special', NS_TALK => 'Talk', @@ -36,26 +37,45 @@ if(isset($wgExtraNamespaces)) { $wgCanonicalNamespaceNames=$wgCanonicalNamespaceNames+$wgExtraNamespaces; } +/** + * This is a utility class with only static functions + * for dealing with namespaces that encodes all the + * "magic" behaviors of them based on index. The textual + * names of the namespaces are handled by Language.php. + * + * These are synonyms for the names given in the language file + * Users and translators should not change them +*/ class Namespace { - /* These functions are deprecated */ + /**#@+ + * These functions are deprecated + * @deprecated + */ function getSpecial() { return NS_SPECIAL; } function getUser() { return NS_USER; } function getWikipedia() { return NS_PROJECT; } function getImage() { return NS_IMAGE; } function getMedia() { return NS_MEDIA; } function getCategory() { return NS_CATEGORY; } + /**#@-*/ - function isMovable( $index ) - { + /** + * Check if the given namespace might be moved + * @return bool + */ + function isMovable( $index ) { if ( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY ) { return false; } return true; } - function isTalk( $index ) - { + /** + * Check if the give namespace is a talk page + * @return bool + */ + function isTalk( $index ) { global $wgExtraNamespaces; return ( $index == NS_TALK || $index == NS_USER_TALK || $index == NS_PROJECT_TALK || $index == NS_IMAGE_TALK || @@ -66,10 +86,10 @@ class Namespace { } - # Get the talk namespace corresponding to the given index - # - function getTalk( $index ) - { + /** + * Get the talk namespace corresponding to the given index + */ + function getTalk( $index ) { if ( Namespace::isTalk( $index ) ) { return $index; } else { @@ -78,8 +98,7 @@ class Namespace { } } - function getSubject( $index ) - { + function getSubject( $index ) { if ( Namespace::isTalk( $index ) ) { return $index - 1; } else { @@ -87,17 +106,19 @@ class Namespace { } } - # Returns the canonical (English Wikipedia) name for a given index - function &getCanonicalName( $index ) - { + /** + * Returns the canonical (English Wikipedia) name for a given index + */ + function &getCanonicalName( $index ) { global $wgCanonicalNamespaceNames; return $wgCanonicalNamespaceNames[$index]; } - # Returns the index for a given canonical name, or NULL - # The input *must* be converted to lower case first - function &getCanonicalIndex( $name ) - { + /** + * Returns the index for a given canonical name, or NULL + * The input *must* be converted to lower case first + */ + function &getCanonicalIndex( $name ) { global $wgCanonicalNamespaceNames; static $xNamespaces = false; if ( $xNamespaces === false ) { diff --git a/includes/ObjectCache.php b/includes/ObjectCache.php index 101ae7fbcc..fc74066139 100644 --- a/includes/ObjectCache.php +++ b/includes/ObjectCache.php @@ -18,16 +18,23 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html - -# Simple generic object store -# interface is intended to be more or less compatible with -# the PHP memcached client. -# -# backends for local hash array and SQL table included: -# $bag = new HashBagOStuff(); -# $bag = new MysqlBagOStuff($tablename); # connect to db first - -class /* abstract */ BagOStuff { +/** + * + */ + +/** + * Simple generic object store + * + * interface is intended to be more or less compatible with + * the PHP memcached client. + * + * backends for local hash array and SQL table included: + * $bag = new HashBagOStuff(); + * $bag = new MysqlBagOStuff($tablename); # connect to db first + * + * @abstract + */ +class BagOStuff { var $debugmode; function BagOStuff() { @@ -142,7 +149,10 @@ class /* abstract */ BagOStuff { } -/* Functional versions! */ +/** + * Functional versions! + * @todo document + */ class HashBagOStuff extends BagOStuff { /* This is a test of the interface, mainly. It stores @@ -194,7 +204,12 @@ CREATE TABLE objectcache ( key (exptime) ); */ -class /* abstract */ SqlBagOStuff extends BagOStuff { + +/** + * @todo document + * @abstract + */ +class SqlBagOStuff extends BagOStuff { var $table; function SqlBagOStuff($tablename = 'objectcache') { @@ -307,6 +322,9 @@ class /* abstract */ SqlBagOStuff extends BagOStuff { } } +/** + * @todo document + */ class MediaWikiBagOStuff extends SqlBagOStuff { var $tableInitialised = false; @@ -346,6 +364,9 @@ class MediaWikiBagOStuff extends SqlBagOStuff { } } +/** + * @todo document + */ class TurckBagOStuff extends BagOStuff { function get($key) { return mmcache_get( $key ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6e3cc1be0c..8c561d6a22 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1,6 +1,11 @@ output() have no effect. The method - # returns true iff cache-ok headers was sent. + /** + * checkLastModified tells the client to use the client-cached page if + * possible. If sucessful, the OutputPage is disabled so that + * any future call to OutputPage->output() have no effect. The method + * returns true iff cache-ok headers was sent. + */ function checkLastModified ( $timestamp ) { global $wgLang, $wgCachePages, $wgUser; @@ -218,8 +228,9 @@ class OutputPage { return wfSetVar( $this->mParserOptions, $options ); } - # Convert wikitext to HTML and add it to the buffer - # + /** + * Convert wikitext to HTML and add it to the buffer + */ function addWikiText( $text, $linestart = true ) { global $wgParser, $wgTitle; @@ -230,9 +241,10 @@ class OutputPage { $this->addHTML( $parserOutput->getText() ); } - # Add wikitext to the buffer, assuming that this is the primary text for a page view - # Saves the text into the parser cache if possible - # + /** + * Add wikitext to the buffer, assuming that this is the primary text for a page view + * Saves the text into the parser cache if possible + */ function addPrimaryWikiText( $text, $cacheArticle ) { global $wgParser, $wgParserCache, $wgUser, $wgTitle; @@ -265,12 +277,16 @@ class OutputPage { } } - # Set the maximum cache time on the Squid in seconds + /** + * Set the maximum cache time on the Squid in seconds + */ function setSquidMaxage( $maxage ) { $this->mSquidMaxage = $maxage; } - # Use enableClientCache(false) to force it to send nocache headers + /** + * Use enableClientCache(false) to force it to send nocache headers + */ function enableClientCache( $state ) { return wfSetVar( $this->mEnableClientCache, $state ); } @@ -321,9 +337,10 @@ class OutputPage { } } - # Finally, all the text has been munged and accumulated into - # the object, let's actually output it: - # + /** + * Finally, all the text has been munged and accumulated into + * the object, let's actually output it: + */ function output() { global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration; @@ -384,8 +401,7 @@ class OutputPage { # flush(); } - function out( $ins ) - { + function out( $ins ) { global $wgInputEncoding, $wgOutputEncoding, $wgLang; if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) { $outs = $ins; @@ -396,8 +412,7 @@ class OutputPage { print $outs; } - function setEncodings() - { + function setEncodings() { global $wgInputEncoding, $wgOutputEncoding; global $wgUser, $wgLang; @@ -444,10 +459,11 @@ class OutputPage { $wgOutputEncoding = $wgInputEncoding; } - # Returns a HTML comment with the elapsed time since request. - # This method has no side effects. - function reportTime() - { + /** + * Returns a HTML comment with the elapsed time since request. + * This method has no side effects. + */ + function reportTime() { global $wgRequestTime; $now = wfTime(); @@ -473,10 +489,10 @@ class OutputPage { return $com; } - # Note: these arguments are keys into wfMsg(), not text! - # - function errorpage( $title, $msg ) - { + /** + * Note: these arguments are keys into wfMsg(), not text! + */ + function errorpage( $title, $msg ) { global $wgTitle; $this->mDebugtext .= 'Original title: ' . @@ -496,8 +512,7 @@ class OutputPage { wfErrorExit(); } - function sysopRequired() - { + function sysopRequired() { global $wgUser; $this->setPageTitle( wfMsg( 'sysoptitle' ) ); @@ -512,8 +527,7 @@ class OutputPage { $this->returnToMain(); } - function developerRequired() - { + function developerRequired() { global $wgUser; $this->setPageTitle( wfMsg( 'developertitle' ) ); @@ -528,8 +542,7 @@ class OutputPage { $this->returnToMain(); } - function loginToUse() - { + function loginToUse() { global $wgUser, $wgTitle, $wgLang; $this->setPageTitle( wfMsg( 'loginreqtitle' ) ); @@ -548,8 +561,7 @@ class OutputPage { $this->returnToMain(); # Flip back to the main page after 10 seconds. } - function databaseError( $fname, $sql, $error, $errno ) - { + function databaseError( $fname, $sql, $error, $errno ) { global $wgUser, $wgCommandLineMode; $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) ); @@ -575,8 +587,7 @@ class OutputPage { wfErrorExit(); } - function readOnlyPage( $source = null, $protected = false ) - { + function readOnlyPage( $source = null, $protected = false ) { global $wgUser, $wgReadOnlyFile; $this->setRobotpolicy( 'noindex,nofollow' ); @@ -605,8 +616,7 @@ class OutputPage { $this->returnToMain( false ); } - function fatalError( $message ) - { + function fatalError( $message ) { $this->setPageTitle( wfMsg( "internalerror" ) ); $this->setRobotpolicy( "noindex,nofollow" ); $this->setArticleRelated( false ); @@ -618,36 +628,32 @@ class OutputPage { wfErrorExit(); } - function unexpectedValueError( $name, $val ) - { + function unexpectedValueError( $name, $val ) { $this->fatalError( wfMsg( 'unexpected', $name, $val ) ); } - function fileCopyError( $old, $new ) - { + function fileCopyError( $old, $new ) { $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) ); } - function fileRenameError( $old, $new ) - { + function fileRenameError( $old, $new ) { $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) ); } - function fileDeleteError( $name ) - { + function fileDeleteError( $name ) { $this->fatalError( wfMsg( 'filedeleteerror', $name ) ); } - function fileNotFoundError( $name ) - { + function fileNotFoundError( $name ) { $this->fatalError( wfMsg( 'filenotfound', $name ) ); } - // return from error messages or notes - // auto: automatically redirect the user after 10 seconds - // returnto: page title to return to. Default is Main Page. - function returnToMain( $auto = true, $returnto = NULL ) - { + /** + * return from error messages or notes + * @param $auto automatically redirect the user after 10 seconds + * @param $returnto page title to return to. Default is Main Page. + */ + function returnToMain( $auto = true, $returnto = NULL ) { global $wgUser, $wgOut, $wgRequest; if ( $returnto == NULL ) { @@ -668,10 +674,11 @@ class OutputPage { $wgOut->addHTML( "\n

$r

\n" ); } - # This function takes the existing and broken links for the page - # and uses the first 10 of them for META keywords - function addMetaTags () - { + /** + * This function takes the existing and broken links for the page + * and uses the first 10 of them for META keywords + */ + function addMetaTags () { global $wgLinkCache , $wgOut ; $good = array_keys ( $wgLinkCache->mGoodLinks ) ; $bad = array_keys ( $wgLinkCache->mBadLinks ) ; @@ -687,8 +694,10 @@ class OutputPage { $wgOut->addMeta ( 'KEYWORDS' , $a ) ; } - /* private */ function headElement() - { + /** + * @private + */ + function headElement() { global $wgDocType, $wgDTD, $wgLanguageCode, $wgOutputEncoding, $wgMimeType; global $wgUser, $wgLang, $wgRequest; @@ -777,19 +786,22 @@ class OutputPage { return $ret; } - # Run any necessary pre-output transformations on the buffer text - function transformBuffer( $options = 0 ) - { + /** + * Run any necessary pre-output transformations on the buffer text + */ + function transformBuffer( $options = 0 ) { $this->replaceLinkHolders( $this->mBodytext, $options ); } - # Replace link placeholders with actual links, in the buffer - # Placeholders created in Skin::makeLinkObj() - # Returns an array of links found, indexed by PDBK: - # 0 - broken - # 1 - normal link - # 2 - stub - # $options is a bit field, RLH_FOR_UPDATE to select for update + /** + * Replace link placeholders with actual links, in the buffer + * Placeholders created in Skin::makeLinkObj() + * Returns an array of links found, indexed by PDBK: + * 0 - broken + * 1 - normal link + * 2 - stub + * $options is a bit field, RLH_FOR_UPDATE to select for update + */ function replaceLinkHolders( &$text, $options = 0 ) { global $wgUser, $wgLinkCache, $wgUseOldExistenceCheck; diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 2c3d445596..bc01ce4b51 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -1,9 +1,13 @@ lastdate = $this->lastline = ''; $s = '

' . wfMsg( 'histlegend' ) . '

'; @@ -129,8 +131,7 @@ class PageHistory { return $s; } - function endHistoryList( $skip = false ) - { + function endHistoryList( $skip = false ) { $last = wfMsg( 'last' ); $s = $skip ? '' : preg_replace( "/!OLDID![0-9]+!/", $last, $this->lastline ); @@ -140,8 +141,7 @@ class PageHistory { return $s; } - function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor, $counter = '' ) - { + function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor, $counter = '' ) { global $wgLang; $artname = Title::makeName( $ns, $ttl ); diff --git a/includes/Parser.php b/includes/Parser.php index 4f3dae67c2..14436b92f0 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2,36 +2,40 @@ // require_once('Tokenizer.php'); -# PHP Parser -# -# Processes wiki markup -# -# There are two main entry points into the Parser class: -# parse() -# produces HTML output -# preSaveTransform(). -# produces altered wiki markup. -# -# Globals used: -# objects: $wgLang, $wgDateFormatter, $wgLinkCache, $wgCurParser -# -# NOT $wgArticle, $wgUser or $wgTitle. Keep them away! -# -# settings: -# $wgUseTex*, $wgUseDynamicDates*, $wgInterwikiMagic*, -# $wgNamespacesWithSubpages, $wgLanguageCode, $wgAllowExternalImages*, -# $wgLocaltimezone -# -# * only within ParserOptions -# -#---------------------------------------- -# Variable substitution O(N^2) attack -#----------------------------------------- -# Without countermeasures, it would be possible to attack the parser by saving -# a page filled with a large number of inclusions of large pages. The size of -# the generated page would be proportional to the square of the input size. -# Hence, we limit the number of inclusions of any given page, thus bringing any -# attack back to O(N). +/** + * PHP Parser + * + * Processes wiki markup + * + * There are two main entry points into the Parser class: + * parse() + * produces HTML output + * preSaveTransform(). + * produces altered wiki markup. + * + * Globals used: + * objects: $wgLang, $wgDateFormatter, $wgLinkCache, $wgCurParser + * + * NOT $wgArticle, $wgUser or $wgTitle. Keep them away! + * + * settings: + * $wgUseTex*, $wgUseDynamicDates*, $wgInterwikiMagic*, + * $wgNamespacesWithSubpages, $wgLanguageCode, $wgAllowExternalImages*, + * $wgLocaltimezone + * + * * only within ParserOptions + * + */ + +/** + * Variable substitution O(N^2) attack + * +* Without countermeasures, it would be possible to attack the parser by saving +* a page filled with a large number of inclusions of large pages. The size of +* the generated page would be proportional to the square of the input size. +* Hence, we limit the number of inclusions of any given page, thus bringing any +* attack back to O(N). +*/ define( 'MAX_INCLUDE_REPEAT', 100 ); define( 'MAX_INCLUDE_SIZE', 1000000 ); // 1 Million @@ -66,6 +70,9 @@ define( 'EXT_IMAGE_REGEX', '('.EXT_IMAGE_FNAME_CLASS.'+)\\.((?i)'.EXT_IMAGE_EXTENSIONS.')$/S' # Filename ); +/** + * @todo document + */ class Parser { # Persistent: @@ -2321,6 +2328,9 @@ class Parser } } +/** + * @todo document + */ class ParserOutput { var $mText, $mLanguageLinks, $mCategoryLinks, $mContainsOldMagic; @@ -2355,6 +2365,10 @@ class ParserOutput } +/** + * Set options of the Parser + * @todo document + */ class ParserOptions { # All variables are private @@ -2446,7 +2460,9 @@ function wfVariableSubstitution( $matches ) { return $wgCurParser->variableSubstitution( $matches ); } -# Return the total number of articles +/** + * Return the total number of articles + */ function wfNumberOfArticles() { global $wgNumberOfArticles; @@ -2454,8 +2470,11 @@ function wfNumberOfArticles() { return $wgNumberOfArticles; } -# Get various statistics from the database -/* private */ function wfLoadSiteStats() { +/** + * Get various statistics from the database + * @private + */ +function wfLoadSiteStats() { global $wgNumberOfArticles, $wgTotalViews, $wgTotalEdits; $fname = 'wfLoadSiteStats'; diff --git a/includes/ParserCache.php b/includes/ParserCache.php index 2d2f4e0291..59522e446c 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -1,5 +1,11 @@ (X)HTML parser -# Based on work by Jan Hidders and Magnus Manske +/** + * This should one day become the XML->(X)HTML parser + * Based on work by Jan Hidders and Magnus Manske + */ -// the base class for an element +/** + * the base class for an element + */ class element { var $name = ''; var $attrs = array(); @@ -68,7 +72,10 @@ function wgXMLcharacterData($parser, $data) { } -# Here's the class that generates a nice tree +/** + * Here's the class that generates a nice tree + * package parserxml + */ class xml2php { function &scanFile( $filename ) { diff --git a/includes/Profiling.php b/includes/Profiling.php index 5c5f3de158..163c4bc3ec 100755 --- a/includes/Profiling.php +++ b/includes/Profiling.php @@ -1,13 +1,20 @@ profileIn( $functionname ); } -function wfProfileOut( $functionname = 'missing' ) -{ +/** + * @param $functioname name of the function we have profiled + */ +function wfProfileOut( $functionname = 'missing' ) { global $wgProfiler; $wgProfiler->profileOut( $functionname ); } @@ -17,8 +24,7 @@ function wfGetProfilingOutput( $start, $elapsed ) { return $wgProfiler->getOutput( $start, $elapsed ); } -function wfProfileClose() -{ +function wfProfileClose() { global $wgProfiler; $wgProfiler->close(); } @@ -30,6 +36,9 @@ if( !function_exists( 'memory_get_usage' ) ) { } } +/** + * @todo document + */ class Profiler { var $mStack = array(), $mWorkStack = array(), $mCollated = array(); @@ -43,8 +52,7 @@ class Profiler } */ - function profileIn( $functionname ) - { + function profileIn( $functionname ) { global $wgDebugFunctionEntry; if ( $wgDebugFunctionEntry && function_exists( 'wfDebug' ) ) { wfDebug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering '.$functionname."\n" ); @@ -52,8 +60,7 @@ class Profiler array_push( $this->mWorkStack, array($functionname, count( $this->mWorkStack ), microtime(), memory_get_usage() ) ); } - function profileOut( $functionname ) - { + function profileOut( $functionname ) { $memory = memory_get_usage(); global $wgDebugProfiling, $wgDebugFunctionEntry; @@ -79,15 +86,13 @@ class Profiler } } - function close() - { + function close() { while ( count( $this->mWorkStack ) ) { $this->profileOut( 'close' ); } } - function getOutput() - { + function getOutput() { global $wgDebugFunctionEntry; $wgDebugFunctionEntry = false; @@ -165,8 +170,10 @@ class Profiler } - /* static */ function logToDB($name, $timeSum, $eventCount) - { + /** + * @static + */ + function logToDB($name, $timeSum, $eventCount) { $dbw =& wfGetDB( DB_MASTER ); $profiling = $dbw->tableName( 'profiling' ); diff --git a/includes/QueryPage.php b/includes/QueryPage.php index ce602fe596..5b1df4b5cd 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -1,38 +1,52 @@ sortDescending() ? 'DESC' : ''); } - # Is this query expensive (for some definition of expensive)? Then we - # don't let it run in miser mode. $wgDisableQueryPages causes all query - # pages to be declared expensive. Some query pages are always expensive. + /** + * Is this query expensive (for some definition of expensive)? Then we + * don't let it run in miser mode. $wgDisableQueryPages causes all query + * pages to be declared expensive. Some query pages are always expensive. + */ function isExpensive( ) { global $wgDisableQueryPages; return $wgDisableQueryPages; } - # Formats the results of the query for display. The skin is the current - # skin; you can use it for making links. The result is a single row of - # result data. You should be able to grab SQL results off of it. - + /** + * Formats the results of the query for display. The skin is the current + * skin; you can use it for making links. The result is a single row of + * result data. You should be able to grab SQL results off of it. + */ function formatResult( $skin, $result ) { return ''; } - # The content returned by this function will be output before any result - + /** + * The content returned by this function will be output before any result + */ function getPageHeader( ) { return ''; } - # This is the actual workhorse. It does everything needed to make a - # real, honest-to-gosh query page. - + /** + * This is the actual workhorse. It does everything needed to make a + * real, honest-to-gosh query page. + * + * @param $offset database query offset + * @param $limit database query limit + */ function doQuery( $offset, $limit ) { global $wgUser, $wgOut, $wgLang, $wgRequest; global $wgMiserMode; @@ -163,7 +185,9 @@ class QueryPage { $wgOut->addHTML( "

{$sl}

\n" ); } - # Similar to above, but packaging in a syndicated feed instead of a web page + /** + * Similar to above, but packaging in a syndicated feed instead of a web page + */ function doFeed( $class = '' ) { global $wgFeedClasses; global $wgOut, $wgLanguageCode, $wgLang; @@ -190,7 +214,10 @@ class QueryPage { } } - # Override for custom handling. If the titles/links are ok, just do feedItemDesc() + /** + * Override for custom handling. If the titles/links are ok, just do + * feedItemDesc() + */ function feedResult( $row ) { if( !isset( $row->title ) ) { return NULL; @@ -262,10 +289,11 @@ class QueryPage { } } -# This is a subclass for very simple queries that are just looking for page -# titles that match some criteria. It formats each result item as a link to -# that page. - +/** + * This is a subclass for very simple queries that are just looking for page + * titles that match some criteria. It formats each result item as a link to + * that page. + */ class PageQueryPage extends QueryPage { function formatResult( $skin, $result ) { diff --git a/includes/RawPage.php b/includes/RawPage.php index 4a8c936aae..17a9ee4abe 100644 --- a/includes/RawPage.php +++ b/includes/RawPage.php @@ -1,10 +1,17 @@ -# http://www.aulinx.de/ -# Based on PageHistory and SpecialExport -# -# License: GPL (http://www.gnu.org/copyleft/gpl.html) +/** + * Copyright (C) 2004 Gabriel Wicke + * http://www.aulinx.de/ + * Based on PageHistory and SpecialExport + * + * License: GPL (http://www.gnu.org/copyleft/gpl.html) + * + * @author Gabriel Wicke + */ +/** + * @todo document + */ class RawPage { function RawPage( $article ) { @@ -40,6 +47,7 @@ class RawPage { $this->mContentType = $ctype; } } + function view() { global $wgUser, $wgOut; header( "Content-type: ".$this->mContentType.'; charset='.$this->mCharset ); diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 11931c54d2..e7d16257a0 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -1,6 +1,11 @@ mAttribs['rc_type'] == RC_EDIT ) { diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 1f37fe4dfe..2b8d29f10b 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -1,9 +1,18 @@ db =& wfGetDB( DB_SLAVE ); } - # Return a partial WHERE clause to limit the search to the given namespaces + /** + * Return a partial WHERE clause to limit the search to the given namespaces + */ function queryNamespaces() { $namespaces = implode( ',', $this->namespacesToSearch ); if ($namespaces == '') { @@ -40,7 +51,9 @@ class SearchEngine { return "AND cur_namespace IN (" . $namespaces . ')'; } - # Return a partial WHERE clause to include or exclude redirects from results + /** + * Return a partial WHERE clause to include or exclude redirects from results + */ function searchRedirects() { if ( $this->doSearchRedirects ) { return ''; @@ -49,8 +62,9 @@ class SearchEngine { } } - /* private */ function initNamespaceCheckbox( $i ) - { + /** + * @access private + */ function initNamespaceCheckbox( $i ) { global $wgUser, $wgNamespacesToBeSearchedDefault; if ($wgUser->getID()) { @@ -62,8 +76,10 @@ class SearchEngine { } } - # Display the "power search" footer. Does not actually perform the search, - # that is done by showResults() + /** + * Display the "power search" footer. Does not actually perform the search, + * that is done by showResults() + */ function powersearch() { global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest; $sk =& $wgUser->getSkin(); @@ -158,7 +174,9 @@ class SearchEngine { $wgOut->setRobotpolicy( 'noindex,nofollow' ); } - # Perform the search and construct the results page + /** + * Perform the search and construct the results page + */ function showResults() { global $wgUser, $wgTitle, $wgOut, $wgLang; global $wgDisableTextSearch, $wgInputEncoding; @@ -500,7 +518,10 @@ class SearchEngine { } } - /* static */ function doFuzzyTitleSearch( $search, $namespace ){ + /** + * @static + */ + function doFuzzyTitleSearch( $search, $namespace ){ global $wgLang, $wgOut; $this->setupPage(); @@ -531,7 +552,10 @@ class SearchEngine { return false; } - /* static */ function fuzzyTitles( $sstr, $namespace = NS_MAIN ){ + /** + * @static + */ + function fuzzyTitles( $sstr, $namespace = NS_MAIN ){ $span = 0.10; // weed on title length before doing levenshtein. $tolerance = 0.35; // allowed percentage of erronous characters $slen = strlen($sstr); @@ -556,7 +580,10 @@ class SearchEngine { return $result; } - /* static */ function getTitlesByLength($aLength, $aNamespace = 0){ + /** + * static + */ + function getTitlesByLength($aLength, $aNamespace = 0){ global $wgMemc, $wgDBname; $fname = 'SearchEngin::getTitlesByLength'; @@ -604,6 +631,10 @@ class SearchEngine { } } -/* private static */ function SearchEngine_pcmp($a, $b){ return $a[0] - $b[0]; } +/** + * @access private + * @static + */ +function SearchEngine_pcmp($a, $b){ return $a[0] - $b[0]; } ?> diff --git a/includes/SearchUpdate.php b/includes/SearchUpdate.php index c6563a004c..6a59fba685 100644 --- a/includes/SearchUpdate.php +++ b/includes/SearchUpdate.php @@ -1,14 +1,18 @@ mId = $id; @@ -23,8 +27,7 @@ class SearchUpdate { } } - function doUpdate() - { + function doUpdate() { global $wgDBminWordLen, $wgLang, $wgDisableSearchUpdate; if( $wgDisableSearchUpdate || !$this->mId ) { diff --git a/includes/Setup.php b/includes/Setup.php index 701a02281f..881c017fa0 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -1,6 +1,12 @@ mViews = $views; $this->mEdits = $edits; $this->mGood = $good; } - function doUpdate() - { + function doUpdate() { $a = array(); if ( $this->mViews < 0 ) { $m = '-1'; } diff --git a/includes/Skin.php b/includes/Skin.php index 9b9f9c219a..28fa550435 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,6 +1,12 @@ postParseLinkColour, $setting ); } @@ -216,10 +231,14 @@ class Skin { return $s."\n"; } - # placeholder, returns generated js in monobook + /** + * placeholder, returns generated js in monobook + */ function getUserJs() { return; } - # Return html code that include User stylesheets + /** + * Return html code that include User stylesheets + */ function getUserStyles() { global $wgOut, $wgStylePath, $wgLang; $s = "