* 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;
private $target;
/**
- * Constructor
- *
* @param string $type One of '', 'block', 'protect', 'rights', 'delete',
* 'upload', 'move'
* @param bool $rc Whether to update recent changes as well as the logging table
// @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,
'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();
+ $newId = $dbw->insertId();
# And update recentchanges
if ( $this->updateRecentChanges ) {
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.
* @return string HTML
*/
public static function actionText( $type, $action, $title = null, $skin = null,
- $params = array(), $filterWikilinks = false
+ $params = [], $filterWikilinks = false
) {
global $wgLang, $wgContLang, $wgLogActions;
*
* @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 ) {
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 );
*/
public static function extractParams( $blob ) {
if ( $blob === '' ) {
- return array();
+ return [];
} else {
return explode( "\n", $blob );
}