MediaWiki
REL1_24
|
00001 <?php 00002 00009 class TestRecentChangesHelper { 00010 00011 public function makeEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid, 00012 $timestamp, $counter, $watchingUsers 00013 ) { 00014 00015 $attribs = array_merge( 00016 $this->getDefaultAttributes( $titleText, $timestamp ), 00017 array( 00018 'rc_user' => $user->getId(), 00019 'rc_user_text' => $user->getName(), 00020 'rc_this_oldid' => $thisid, 00021 'rc_last_oldid' => $lastid, 00022 'rc_cur_id' => $curid 00023 ) 00024 ); 00025 00026 return $this->makeRecentChange( $attribs, $counter, $watchingUsers ); 00027 } 00028 00029 public function makeLogRecentChange( $logType, $logAction, User $user, $titleText, $timestamp, $counter, 00030 $watchingUsers 00031 ) { 00032 $attribs = array_merge( 00033 $this->getDefaultAttributes( $titleText, $timestamp ), 00034 array( 00035 'rc_cur_id' => 0, 00036 'rc_user' => $user->getId(), 00037 'rc_user_text' => $user->getName(), 00038 'rc_this_oldid' => 0, 00039 'rc_last_oldid' => 0, 00040 'rc_old_len' => null, 00041 'rc_new_len' => null, 00042 'rc_type' => 3, 00043 'rc_logid' => 25, 00044 'rc_log_type' => $logType, 00045 'rc_log_action' => $logAction, 00046 'rc_source' => 'mw.log' 00047 ) 00048 ); 00049 00050 return $this->makeRecentChange( $attribs, $counter, $watchingUsers ); 00051 } 00052 00053 public function makeDeletedEditRecentChange( User $user, $titleText, $timestamp, $curid, 00054 $thisid, $lastid, $counter, $watchingUsers 00055 ) { 00056 $attribs = array_merge( 00057 $this->getDefaultAttributes( $titleText, $timestamp ), 00058 array( 00059 'rc_user' => $user->getId(), 00060 'rc_user_text' => $user->getName(), 00061 'rc_deleted' => 5, 00062 'rc_cur_id' => $curid, 00063 'rc_this_oldid' => $thisid, 00064 'rc_last_oldid' => $lastid 00065 ) 00066 ); 00067 00068 return $this->makeRecentChange( $attribs, $counter, $watchingUsers ); 00069 } 00070 00071 public function makeNewBotEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid, 00072 $timestamp, $counter, $watchingUsers 00073 ) { 00074 00075 $attribs = array_merge( 00076 $this->getDefaultAttributes( $titleText, $timestamp ), 00077 array( 00078 'rc_user' => $user->getId(), 00079 'rc_user_text' => $user->getName(), 00080 'rc_this_oldid' => $thisid, 00081 'rc_last_oldid' => $lastid, 00082 'rc_cur_id' => $curid, 00083 'rc_type' => 1, 00084 'rc_bot' => 1, 00085 'rc_source' => 'mw.new' 00086 ) 00087 ); 00088 00089 return $this->makeRecentChange( $attribs, $counter, $watchingUsers ); 00090 } 00091 00092 private function makeRecentChange( $attribs, $counter, $watchingUsers ) { 00093 $change = new RecentChange(); 00094 $change->setAttribs( $attribs ); 00095 $change->counter = $counter; 00096 $change->numberofWatchingusers = $watchingUsers; 00097 00098 return $change; 00099 } 00100 00101 private function getDefaultAttributes( $titleText, $timestamp ) { 00102 return array( 00103 'rc_id' => 545, 00104 'rc_user' => 0, 00105 'rc_user_text' => '127.0.0.1', 00106 'rc_ip' => '127.0.0.1', 00107 'rc_title' => $titleText, 00108 'rc_namespace' => 0, 00109 'rc_timestamp' => $timestamp, 00110 'rc_old_len' => 212, 00111 'rc_new_len' => 188, 00112 'rc_comment' => '', 00113 'rc_minor' => 0, 00114 'rc_bot' => 0, 00115 'rc_type' => 0, 00116 'rc_patrolled' => 1, 00117 'rc_deleted' => 0, 00118 'rc_logid' => 0, 00119 'rc_log_type' => null, 00120 'rc_log_action' => '', 00121 'rc_params' => '', 00122 'rc_source' => 'mw.edit' 00123 ); 00124 } 00125 00126 public function getTestContext( User $user ) { 00127 $context = new RequestContext(); 00128 $context->setLanguage( Language::factory( 'en' ) ); 00129 00130 $context->setUser( $user ); 00131 00132 $title = Title::newFromText( 'RecentChanges', NS_SPECIAL ); 00133 $context->setTitle( $title ); 00134 00135 return $context; 00136 } 00137 }