X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flogging%2FLogPage.php;h=64102b7ec93814b4147249e581aeea7e216cd729;hb=b94b9830fa5a53776535d0c86ede8128e9ef11a7;hp=30dee812a83ae516dbf3c1d308c8aa9d31cdfc9d;hpb=ea3646b476fa588a2166d792ca26a5c802545362;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 30dee812a8..64102b7ec9 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -27,7 +27,6 @@ * 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 { const DELETED_ACTION = 1; @@ -97,7 +96,7 @@ class LogPage { // @todo FIXME private/protected/public property? $this->timestamp = $now = wfTimestampNow(); - $data = array( + $data = [ 'log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, @@ -109,7 +108,7 @@ class LogPage { 'log_page' => $this->target->getArticleID(), 'log_comment' => $this->comment, 'log_params' => $this->params - ); + ]; $dbw->insert( 'logging', $data, __METHOD__ ); $newId = !is_null( $log_id ) ? $log_id : $dbw->insertId(); @@ -211,42 +210,6 @@ class LogPage { return in_array( $type, LogPage::validTypes() ); } - /** - * Get the name for the given log type - * - * @param string $type Log type - * @return string Log name - * @deprecated since 1.19, warnings in 1.21. Use getName() - */ - public static function logName( $type ) { - global $wgLogNames; - - wfDeprecated( __METHOD__, '1.21' ); - - if ( isset( $wgLogNames[$type] ) ) { - return str_replace( '_', ' ', wfMessage( $wgLogNames[$type] )->text() ); - } else { - // Bogus log types? Perhaps an extension was removed. - return $type; - } - } - - /** - * Get the log header for the given log type - * - * @todo handle missing log types - * @param string $type Logtype - * @return string Header text of this logtype - * @deprecated since 1.19, warnings in 1.21. Use getDescription() - */ - public static function logHeader( $type ) { - global $wgLogHeaders; - - wfDeprecated( __METHOD__, '1.21' ); - - return wfMessage( $wgLogHeaders[$type] )->parse(); - } - /** * Generate text for a log entry. * Only LogFormatter should call this function. @@ -261,7 +224,7 @@ class LogPage { * @return string HTML */ public static function actionText( $type, $action, $title = null, $skin = null, - $params = array(), $filterWikilinks = false + $params = [], $filterWikilinks = false ) { global $wgLang, $wgContLang, $wgLogActions; @@ -285,30 +248,10 @@ class LogPage { $rv = wfMessage( $wgLogActions[$key] )->rawParams( $titleLink ) ->inLanguage( $langObj )->escaped(); } else { - $details = ''; array_unshift( $params, $titleLink ); - // Page protections - if ( $type == 'protect' && count( $params ) == 3 ) { - // Restrictions and expiries - if ( $skin ) { - $details .= $wgLang->getDirMark() . htmlspecialchars( " {$params[1]}" ); - } else { - $details .= " {$params[1]}"; - } - - // Cascading flag... - if ( $params[2] ) { - $text = wfMessage( 'protect-summary-cascade' ) - ->inLanguage( $langObj )->text(); - $details .= ' '; - $details .= wfMessage( 'brackets', $text )->inLanguage( $langObj )->text(); - - } - } - $rv = wfMessage( $wgLogActions[$key] )->rawParams( $params ) - ->inLanguage( $langObj )->escaped() . $details; + ->inLanguage( $langObj )->escaped(); } } } else { @@ -387,11 +330,11 @@ class LogPage { * * @return int The log_id of the inserted log entry */ - public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) { + public function addEntry( $action, $target, $comment, $params = [], $doer = null ) { global $wgContLang; if ( !is_array( $params ) ) { - $params = array( $params ); + $params = [ $params ]; } if ( $comment === null ) { @@ -422,6 +365,10 @@ class LogPage { $logEntry->setTarget( $target ); $logEntry->setPerformer( $doer ); $logEntry->setParameters( $params ); + // All log entries using the LogPage to insert into the logging table + // are using the old logging system and therefore the legacy flag is + // needed to say the LogFormatter the parameters have numeric keys + $logEntry->setLegacy( true ); $formatter = LogFormatter::newFromEntry( $logEntry ); $context = RequestContext::newExtraneousContext( $target ); @@ -446,14 +393,14 @@ class LogPage { return false; // nothing } - $data = array(); + $data = []; foreach ( $values as $value ) { - $data[] = array( + $data[] = [ 'ls_field' => $field, 'ls_value' => $value, 'ls_log_id' => $logid - ); + ]; } $dbw = wfGetDB( DB_MASTER ); @@ -480,7 +427,7 @@ class LogPage { */ public static function extractParams( $blob ) { if ( $blob === '' ) { - return array(); + return []; } else { return explode( "\n", $blob ); }