MediaWiki
REL1_19
|
00001 <?php 00012 class RevisionDeleter { 00024 protected static function checkItem( $desc, $field, $diff, $new, &$arr ) { 00025 if( $diff & $field ) { 00026 $arr[ ( $new & $field ) ? 0 : 1 ][] = $desc; 00027 } 00028 } 00029 00048 public static function getChanges( $n, $o ) { 00049 $diff = $n ^ $o; 00050 $ret = array( 0 => array(), 1 => array(), 2 => array() ); 00051 // Build bitfield changes in language 00052 self::checkItem( 'revdelete-content', 00053 Revision::DELETED_TEXT, $diff, $n, $ret ); 00054 self::checkItem( 'revdelete-summary', 00055 Revision::DELETED_COMMENT, $diff, $n, $ret ); 00056 self::checkItem( 'revdelete-uname', 00057 Revision::DELETED_USER, $diff, $n, $ret ); 00058 // Restriction application to sysops 00059 if( $diff & Revision::DELETED_RESTRICTED ) { 00060 if( $n & Revision::DELETED_RESTRICTED ) 00061 $ret[2][] = 'revdelete-restricted'; 00062 else 00063 $ret[2][] = 'revdelete-unrestricted'; 00064 } 00065 return $ret; 00066 } 00067 00073 public static function getRelationType( $typeName ) { 00074 if ( isset( SpecialRevisionDelete::$deprecatedTypeMap[$typeName] ) ) { 00075 $typeName = SpecialRevisionDelete::$deprecatedTypeMap[$typeName]; 00076 } 00077 if ( isset( SpecialRevisionDelete::$allowedTypes[$typeName] ) ) { 00078 $class = SpecialRevisionDelete::$allowedTypes[$typeName]['list-class']; 00079 return call_user_func( array( $class, 'getRelationType' ) ); 00080 } else { 00081 return null; 00082 } 00083 } 00084 00094 public static function checkRevisionExistence( $title, $revid ) { 00095 $dbr = wfGetDB( DB_SLAVE ); 00096 $exists = $dbr->selectField( 'revision', '1', 00097 array( 'rev_id' => $revid ), __METHOD__ ); 00098 00099 if ( $exists ) { 00100 return true; 00101 } 00102 00103 $timestamp = $dbr->selectField( 'archive', 'ar_timestamp', 00104 array( 'ar_namespace' => $title->getNamespace(), 00105 'ar_title' => $title->getDBkey(), 00106 'ar_rev_id' => $revid ), __METHOD__ ); 00107 00108 return $timestamp; 00109 } 00110 00119 public static function getLogLinks( $title, $paramArray, $messages ) { 00120 global $wgLang; 00121 00122 if ( count( $paramArray ) >= 2 ) { 00123 // Different revision types use different URL params... 00124 $key = $paramArray[0]; 00125 // $paramArray[1] is a CSV of the IDs 00126 $Ids = explode( ',', $paramArray[1] ); 00127 00128 $revert = array(); 00129 00130 // Diff link for single rev deletions 00131 if ( count( $Ids ) == 1 ) { 00132 // Live revision diffs... 00133 if ( in_array( $key, array( 'oldid', 'revision' ) ) ) { 00134 $revert[] = Linker::linkKnown( 00135 $title, 00136 $messages['diff'], 00137 array(), 00138 array( 00139 'diff' => intval( $Ids[0] ), 00140 'unhide' => 1 00141 ) 00142 ); 00143 // Deleted revision diffs... 00144 } elseif ( in_array( $key, array( 'artimestamp','archive' ) ) ) { 00145 $revert[] = Linker::linkKnown( 00146 SpecialPage::getTitleFor( 'Undelete' ), 00147 $messages['diff'], 00148 array(), 00149 array( 00150 'target' => $title->getPrefixedDBKey(), 00151 'diff' => 'prev', 00152 'timestamp' => $Ids[0] 00153 ) 00154 ); 00155 } 00156 } 00157 00158 // View/modify link... 00159 $revert[] = Linker::linkKnown( 00160 SpecialPage::getTitleFor( 'Revisiondelete' ), 00161 $messages['revdel-restore'], 00162 array(), 00163 array( 00164 'target' => $title->getPrefixedText(), 00165 'type' => $key, 00166 'ids' => implode(',', $Ids), 00167 ) 00168 ); 00169 00170 // Pipe links 00171 return wfMsg( 'parentheses', $wgLang->pipeList( $revert ) ); 00172 } 00173 return ''; 00174 } 00175 }