Index: trunk/extensions/DSMW/DSMW_Settings.php |
— | — | @@ -37,13 +37,13 @@ |
38 | 38 | |
39 | 39 | |
40 | 40 | $wgGroupPermissions['*']['ArticleAdminPage'] = true;// sysop |
41 | | -require_once( "$IP/extensions/DSMW/specialPage/ArticleAdminPage.php" ); |
| 41 | +require_once( dirname( __FILE__ ) . '/specials/ArticleAdminPage.php' ); |
42 | 42 | |
43 | 43 | $wgGroupPermissions['*']['DSMWAdmin'] = true;// sysop |
44 | | -require_once( "$IP/extensions/DSMW/specialPage/DSMWAdmin.php" ); |
| 44 | +require_once( dirname( __FILE__ ) . '/specials/DSMWAdmin.php' ); |
45 | 45 | |
46 | 46 | $wgGroupPermissions['*']['DSMWGeneralExhibits'] = true;// sysop |
47 | | -require_once( "$IP/extensions/DSMW/specialPage/DSMWGeneralExhibits.php" ); |
| 47 | +require_once( dirname( __FILE__ ) . '/specials/DSMWGeneralExhibits.php' ); |
48 | 48 | |
49 | 49 | // semantic mediawiki extension |
50 | 50 | $smwgNamespaceIndex = 120; |
Index: trunk/extensions/DSMW/files/utils.php |
— | — | @@ -381,7 +381,6 @@ |
382 | 382 | break; |
383 | 383 | } |
384 | 384 | |
385 | | - |
386 | 385 | if ( $row1 === false ) { |
387 | 386 | break; |
388 | 387 | } |
Index: trunk/extensions/DSMW/specials/ArticleAdminPage.php |
— | — | @@ -0,0 +1,739 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * DSMW Special page |
| 6 | + * |
| 7 | + * @copyright INRIA-LORIA-ECOO project |
| 8 | + * |
| 9 | + * @author Hantz Marlene - jean-Philippe Muller |
| 10 | + */ |
| 11 | +class ArticleAdminPage extends SpecialPage { |
| 12 | + |
| 13 | + public function __construct() { |
| 14 | + global $wgHooks; |
| 15 | + |
| 16 | + # Add all our needed hooks |
| 17 | + $wgHooks["UnknownAction"][] = $this; |
| 18 | + $wgHooks["SkinTemplateTabs"][] = $this; |
| 19 | + $wgHooks['SkinTemplateNavigation'][] = $this; |
| 20 | + |
| 21 | + parent::__construct( 'ArticleAdminPage' ); |
| 22 | + } |
| 23 | + |
| 24 | + public function getDescription() { |
| 25 | + return wfMsg( 'dsmw-special-admin' ); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Executed the user opens the DSMW administration special page |
| 30 | + * Calculates the PushFeed list and the pullfeed list (and everything that |
| 31 | + * is displayed on the psecial page |
| 32 | + * |
| 33 | + * @global <Object> $wgOut Output page instance |
| 34 | + * @global <String> $wgServerName |
| 35 | + * @global <String> $wgScriptPath |
| 36 | + * @return <bool> |
| 37 | + */ |
| 38 | + public function execute() { |
| 39 | + global $wgOut, $wgServerName, $wgScriptPath, $wgScriptExtension; /*, $wgSitename, $wgCachePages, $wgUser, $wgTitle, $wgDenyAccessMessage, $wgAllowAnonUsers, $wgRequest, $wgMessageCache, $wgWatchingMessages, $wgDBtype, $namespace_titles;*/ |
| 40 | + |
| 41 | + $url = 'http://' . $wgServerName . $wgScriptPath . "/index{$wgScriptExtension}"; |
| 42 | + $urlServer = 'http://' . $wgServerName . $wgScriptPath; |
| 43 | + // $wgOut->addHeadItem('script', ArticleAdminPage::javascript()); |
| 44 | + |
| 45 | + |
| 46 | + $script1 = '<SCRIPT type="text/javascript"> function pushFeedDel(){ |
| 47 | + for (var i=0; i < document.getElementsByName("push[]").length; i++) |
| 48 | + { |
| 49 | + if (document.getElementsByName("push[]")[i].checked) |
| 50 | + { |
| 51 | + //alert(document.getElementsByName("push[]")[i].value); |
| 52 | + var feed = document.getElementsByName("push[]")[i].value; |
| 53 | + window.location.href = "' . $url . '/Special:ArticleAdminPage?FeedDel=true&feed="+feed; |
| 54 | + } |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +function pullFeedDel(){ |
| 59 | + for (var i=0; i < document.getElementsByName("pull[]").length; i++) |
| 60 | + { |
| 61 | + if (document.getElementsByName("pull[]")[i].checked) |
| 62 | + { |
| 63 | + // alert(document.getElementsByName("pull[]")[i].value); |
| 64 | + var feed = document.getElementsByName("pull[]")[i].value; |
| 65 | + window.location.href = "' . $url . '/Special:ArticleAdminPage?FeedDel=true&feed="+feed; |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +function displayRemotePatch(test){ |
| 70 | +//alert(test); |
| 71 | +if(test==true){ |
| 72 | + window.location.href = "' . $url . '/Special:ArticleAdminPage?display=true"; |
| 73 | +}else{ |
| 74 | + window.location.href = "' . $url . '/Special:ArticleAdminPage"; |
| 75 | +} |
| 76 | +} |
| 77 | +</SCRIPT>'; |
| 78 | + $wgOut->addScript( $script1 ); |
| 79 | + |
| 80 | + /// Special:ArticleAdminPage?FeedDel=true&feed=document.getElementsByName("push[]")[i].value |
| 81 | + if ( isset( $_GET['FeedDel'] ) ) $this->deleteFeed( $_GET['feed'] ); |
| 82 | + |
| 83 | + $wgOut->setPagetitle( "DSMW Administration" ); |
| 84 | + |
| 85 | + |
| 86 | + // Set the limit of rows returned |
| 87 | + $page_limit = 30; |
| 88 | + $i = 0; |
| 89 | + $db = &wfGetDB( DB_SLAVE ); |
| 90 | + |
| 91 | + $style = ' style="border-bottom: 2px solid #000;"'; |
| 92 | + $tableStyle = ' style=" clear:both; float: left; margin-left: 40px; margin-top: 20px"'; |
| 93 | + $output = ""; |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + ///////////// PULLFEEDS TABLE////////////////////////// |
| 98 | + $i = 0; |
| 99 | + $req = "[[PullFeed:+]][[deleted::false]]"; |
| 100 | + |
| 101 | + |
| 102 | + $pullFeeds = $this->getRequestedPages( $req ); |
| 103 | + |
| 104 | + |
| 105 | + $output .= ' |
| 106 | +<FORM name="formPull"> |
| 107 | + |
| 108 | +<table' . $tableStyle . ' > |
| 109 | + <a href="javascript:displayRemotePatch(true);">[Display]</a><a href="javascript:displayRemotePatch(false);">[Hide]</a> remote patches |
| 110 | + <tr bgcolor=#c0e8f0>'; |
| 111 | +if ( isset ( $_GET['display'] ) ) { $output .= ' <th colspan="5"' . $style . '>PULL: |
| 112 | + <a href=' . /*dirname($_SERVER['HTTP_REFERER'])*/$url . '?title=administration_pull_site_addition&action=addpullpage>[Add]</a>'; |
| 113 | +} else { |
| 114 | + $output .= ' <th colspan="4"' . $style . '>PULL: |
| 115 | + <a href=' . /*dirname($_SERVER['HTTP_REFERER'])*/$url . '?title=administration_pull_site_addition&action=addpullpage>[Add]</a>'; |
| 116 | +} |
| 117 | + if ( $pullFeeds != false ) { |
| 118 | + $output .= '<a href="javascript:pullFeedDel();">[Remove]</a> |
| 119 | + <input type="button" value="PULL" onClick="allpull(\'' . $url . '\');"></input></th> |
| 120 | + </tr> |
| 121 | + <tr> |
| 122 | + <th colspan="2" >Site</th> |
| 123 | + <th >Pages</th>'; |
| 124 | +if ( isset ( $_GET['display'] ) ) { $output .= ' <th>Remote <br>Patches</th>'; } |
| 125 | +$output .= ' <th >Local <br>Patches</th> |
| 126 | + |
| 127 | + |
| 128 | + </tr> |
| 129 | + '; |
| 130 | + foreach ( $pullFeeds as $pullFeed ) { |
| 131 | + $i = $i + 1; |
| 132 | + $pullFeed = str_replace( ' ', '_', $pullFeed ); |
| 133 | + |
| 134 | + // count the number of local page concerned by the current pullFeed |
| 135 | + $tabPage = utils::getPageConcernedByPull( $pullFeed ); |
| 136 | + |
| 137 | + // if connection failed |
| 138 | + if ( $tabPage === false )$pageConcerned = "-"; |
| 139 | + else $pageConcerned = count( $tabPage ); |
| 140 | + |
| 141 | + if ( isset ( $_GET['display'] ) ) { |
| 142 | + // count the number of remote patch concerned by the current pullFeed |
| 143 | + $pushServer = getPushURL( $pullFeed ); |
| 144 | + $pushName = getPushName( $pullFeed ); |
| 145 | + |
| 146 | + $published = utils::getPublishedPatchs( $pushServer, $pushName ); |
| 147 | + // if connection failed |
| 148 | + if ( $published === false ) $countRemotePatch = "-"; |
| 149 | + else $countRemotePatch = count( $published ); |
| 150 | + } |
| 151 | + |
| 152 | + // count the number of local patch concerned by the current pullFeed |
| 153 | + |
| 154 | + $results = array(); |
| 155 | + $pulledCS = utils::getSemanticQuery( '[[ChangeSet:+]][[inPullFeed::' . $pullFeed . ']]', '?hasPatch' ); |
| 156 | + if ( $pulledCS === false ) $countPulledPatch = "-"; |
| 157 | + else { |
| 158 | + $count = $pulledCS->getCount(); |
| 159 | + for ( $i = 0; $i < $count; $i++ ) { |
| 160 | + |
| 161 | + $row = $pulledCS->getNext(); |
| 162 | + if ( $row === false ) break; |
| 163 | + $row = $row[1]; |
| 164 | + |
| 165 | + $col = $row->getContent();// SMWResultArray object |
| 166 | + foreach ( $col as $object ) {// SMWDataValue object |
| 167 | + $wikiValue = $object->getWikiValue(); |
| 168 | + $results[] = $wikiValue; |
| 169 | + } |
| 170 | + } |
| 171 | + $countPulledPatch = count( $results ); |
| 172 | + } |
| 173 | + |
| 174 | + $pullFeedLink = str_replace( ' ', '_', $pullFeed ); |
| 175 | + $output .= ' |
| 176 | + <tr> |
| 177 | + <td align="center"><input type="checkbox" id="' . $i . '" name="pull[]" value="' . $pullFeed . '" /></td> |
| 178 | + <td ><a href=' . $url . '?title=' . $pullFeedLink . '>' . $pullFeed . '</a></td> |
| 179 | + <td align="center" title="Number of locally concerned pages">[' . $pageConcerned . ']</td>'; |
| 180 | + if ( isset ( $_GET['display'] ) ) { $output .= ' |
| 181 | + <td align="center" title="Published patches">[' . $countRemotePatch . ']</td>'; } |
| 182 | +$output .= ' <td align="center" title="Local patches">[' . $countPulledPatch . ']</td> |
| 183 | + </tr>'; |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + |
| 188 | + $output .= ' |
| 189 | + |
| 190 | +</table> |
| 191 | +</FORM>'; |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + ///////////// PUSHFEEDS TABLE////////////////////////// |
| 196 | + |
| 197 | + $i = 0; |
| 198 | + $req = "[[PushFeed:+]][[deleted::false]]"; |
| 199 | + |
| 200 | + $pushFeeds = $this->getRequestedPages( $req ); |
| 201 | + |
| 202 | + $output .= ' |
| 203 | +<FORM name="formPush"> |
| 204 | +<table' . $tableStyle . ' > |
| 205 | + <tr bgcolor=#c0e8f0> |
| 206 | + <th colspan="6"' . $style . '>PUSH: |
| 207 | + <a href=' . /*dirname($_SERVER['HTTP_REFERER'])*/$url . '?title=administration_push_site_addition&action=addpushpage>[Add]</a>'; |
| 208 | + if ( $pushFeeds != false ) { |
| 209 | + |
| 210 | + |
| 211 | + $output .= ' <a href="javascript:pushFeedDel();">[Remove]</a> |
| 212 | + <input type="button" value="PUSH" onClick="allpush(\'' . $url . '\');"></input></th> |
| 213 | + </tr> |
| 214 | + <tr> |
| 215 | + <th colspan="2" >Site</th> |
| 216 | + <th >Pages</th> |
| 217 | + <th>All patches</th> |
| 218 | + <th>Published <br>Patches</th> |
| 219 | + <th >Unpublished <br>Patches</th> |
| 220 | + |
| 221 | + |
| 222 | + </tr> |
| 223 | + '; |
| 224 | + foreach ( $pushFeeds as $pushFeed ) { |
| 225 | + $i = $i + 1; |
| 226 | + |
| 227 | + $pushName = str_replace( ' ', '_', $pushFeed ); |
| 228 | + // count the number of page concerned by the current pushFeed |
| 229 | + $request = getPushFeedRequest( $pushName ); |
| 230 | + |
| 231 | + |
| 232 | + |
| 233 | + $results1 = array(); |
| 234 | + $tabPage = utils::getSemanticQuery( $request ); |
| 235 | + // if connection failed |
| 236 | + if ( $tabPage === false ) { |
| 237 | + $countConcernedPage = "-"; |
| 238 | + $countPatchs = "-"; |
| 239 | + } |
| 240 | + else { |
| 241 | + |
| 242 | + $count = $tabPage->getCount(); |
| 243 | + for ( $i = 0; $i < $count; $i++ ) { |
| 244 | + |
| 245 | + $row = $tabPage->getNext(); |
| 246 | + if ( $row === false ) break; |
| 247 | + $row = $row[0]; |
| 248 | + |
| 249 | + $col = $row->getContent();// SMWResultArray object |
| 250 | + foreach ( $col as $object ) {// SMWDataValue object |
| 251 | + $wikiValue = $object->getWikiValue(); |
| 252 | + $results1[] = $wikiValue; |
| 253 | + } |
| 254 | + } |
| 255 | + $countConcernedPage = count( $results1 ); |
| 256 | + |
| 257 | + // count the number of patchs from the page concerned |
| 258 | + $countPatchs = 0; |
| 259 | + foreach ( $results1 as $page ) { |
| 260 | + $results = array(); |
| 261 | + $patchs = utils::getSemanticQuery( '[[Patch:+]][[onPage::' . $page . ']]', '?patchID' ); |
| 262 | + |
| 263 | + $count = $patchs->getCount(); |
| 264 | + for ( $i = 0; $i < $count; $i++ ) { |
| 265 | + |
| 266 | + $row = $patchs->getNext(); |
| 267 | + if ( $row === false ) break; |
| 268 | + $row = $row[0]; |
| 269 | + |
| 270 | + $col = $row->getContent();// SMWResultArray object |
| 271 | + foreach ( $col as $object ) {// SMWDataValue object |
| 272 | + $wikiValue = $object->getWikiValue(); |
| 273 | + $results[] = $wikiValue; |
| 274 | + } |
| 275 | + } |
| 276 | + |
| 277 | + $countPatchs += count( $results ); |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + // count the number of patchs published by the current pushFeed |
| 282 | + $published = utils::getPublishedPatchs( $urlServer, $pushName ); |
| 283 | + |
| 284 | + if ( $published === false ) $countPublished = "-"; |
| 285 | + else $countPublished = count( $published ); |
| 286 | + |
| 287 | + // count the number of patchs unpublished |
| 288 | + if ( $results1 === false || $published === false ) $countUnpublished = "-"; |
| 289 | + else $countUnpublished = $countPatchs - $countPublished; |
| 290 | + |
| 291 | + $pushFeedLink = str_replace( ' ', '_', $pushFeed ); |
| 292 | + |
| 293 | + $output .= ' |
| 294 | + <tr> |
| 295 | + <td align="center"><input type="checkbox" id="' . $i . '" name="push[]" value="' . $pushFeed . '" /></td> |
| 296 | + <td ><a href=' . $url . '?title=' . $pushFeedLink . '>' . $pushFeed . '</a></td> |
| 297 | + <td align="center" title="Number of concerned pages">[' . $countConcernedPage . ']</td> |
| 298 | + <td align="center" title="Sum of all the patches">[' . $countPatchs . ']</td> |
| 299 | + <td align="center" title="Published patches">[' . $countPublished . ']</td> |
| 300 | + <td align="center" title="Unpublished patches">[' . $countUnpublished . ']</td> |
| 301 | + </tr>'; |
| 302 | + } |
| 303 | + } |
| 304 | + $output .= ' |
| 305 | + |
| 306 | +</table> |
| 307 | +</FORM> |
| 308 | +<div id="pullstatus" style="display: none; width: 100%; clear: both;" > |
| 309 | +<a name="PULL_Progress_:" id="PULL_Progress_:"></a><h2> <span class="mw-headline"> PULL Progress : </span></h2> |
| 310 | +<div id="statepull" ></div><br /> |
| 311 | +</div> |
| 312 | +<div id="pushstatus" style="display: none; width: 100%; clear: both;" > |
| 313 | +<a name="PUSH_Progress_:" id="PUSH_Progress_:"></a><h2> <span class="mw-headline"> PUSH Progress : </span></h2> |
| 314 | +<div id="statepush" ></div><br /> |
| 315 | +</div> |
| 316 | +'; |
| 317 | + |
| 318 | +// if (!$this->getArticle('Property:ChangeSetID')->exists()) { |
| 319 | +// $output .=' |
| 320 | +// <FORM METHOD="POST" ACTION="'.$urlServer.'/extensions/DSMW/bot/DSMWBot.php" name="scriptExec"> |
| 321 | +// <table'.$tableStyle.'><td><button type="submit"><b>[UPDATE PROPERTY TYPE]</b></button> |
| 322 | +// </td></table> |
| 323 | +// <input type="hidden" name="server" value="'.$urlServer.'"> |
| 324 | +// </form>'; |
| 325 | +// } |
| 326 | + |
| 327 | + $wgOut->addHTML( $output ); |
| 328 | + return false; |
| 329 | + } |
| 330 | + |
| 331 | + /** |
| 332 | + * $action=admin is generated when the administration tab is clicked |
| 333 | + * Calculates every that is displayed on this page (cf user manual) |
| 334 | + * |
| 335 | + * @global <Object> $wgOut output page instance |
| 336 | + * @global <Object> $wgCachePages |
| 337 | + * @global <String> $wgServerName |
| 338 | + * @global <String> $wgScriptPath |
| 339 | + * @param <String> $action |
| 340 | + * @param <Object> $article |
| 341 | + * @return <bool> |
| 342 | + */ |
| 343 | + function onUnknownAction( $action, $article ) { |
| 344 | + global $wgOut, $wgCachePages, $wgServerName, $wgScriptPath, $wgScriptExtension; |
| 345 | + |
| 346 | + $urlServer = 'http://' . $wgServerName . $wgScriptPath; |
| 347 | + |
| 348 | + $wgCachePages = false; |
| 349 | + // Verify that the action coming in is "admin" |
| 350 | + if ( $action == "admin" ) { |
| 351 | + wfDebugLog( 'p2p', 'Admin page' ); |
| 352 | + if ( $article->mTitle->getNamespace() == 0 ) $title = $article->mTitle->getText(); |
| 353 | + else $title = $article->mTitle->getNsText() . ':' . $article->mTitle->getText(); |
| 354 | + wfDebugLog( 'p2p', ' -> title : ' . $title ); |
| 355 | + $wgOut->setPagetitle( 'DSMW on ' . $title ); |
| 356 | + |
| 357 | + // part list of patch |
| 358 | + $patchs = utils::orderPatchByPrevious( $title ); |
| 359 | +$wgOut->addWikiText( '[[Special:ArticleAdminPage|DSMW Admin functions]] |
| 360 | + |
| 361 | +==Features==' ); |
| 362 | + $output = '<div style="width:60%;height:40%;overflow:auto;"> |
| 363 | +<table style="border-bottom: 2px solid #000;"> |
| 364 | +<caption><b>List of patchs</b></caption>'; |
| 365 | + |
| 366 | + // color the remote patch of the current page |
| 367 | + foreach ( $patchs as $patch ) { |
| 368 | + wfDebugLog( 'p2p', ' -> patchId : ' . $patch ); |
| 369 | + if ( !utils::isRemote( $patch ) ) { |
| 370 | + wfDebugLog( 'p2p', ' -> remote patch' ); |
| 371 | + $output .= '<tr BGCOLOR="#CCCCCC"><td>' . wfTimestamp( TS_RFC2822, $article->getTimestamp() ) . ' : </td>'; |
| 372 | + // $output .= '<tr><td BGCOLOR="#33CC00"><a href="'.$_SERVER['PHP_SELF'].'?title='.$patch.'">'.$patch.'</a></td>'; |
| 373 | + } else { |
| 374 | + wfDebugLog( 'p2p', ' -> local patch' ); |
| 375 | + $output .= '<tr><td>' . wfTimestamp( TS_RFC2822, $article->getTimestamp() ) . ' : </td>'; |
| 376 | + // $output .= '<tr><td><a href="'.$_SERVER['PHP_SELF'].'?title='.$patch.'">'.$patch.'</a></td>'; |
| 377 | + |
| 378 | + } |
| 379 | + |
| 380 | + // count the number of delete and insert operations into the patch |
| 381 | + |
| 382 | + |
| 383 | + $results = array(); |
| 384 | + $op = utils::getSemanticQuery( '[[Patch:+]][[patchID::' . $patch . ']]', '?hasOperation' ); |
| 385 | + $count = $op->getCount(); |
| 386 | + for ( $i = 0; $i < $count; $i++ ) { |
| 387 | + |
| 388 | + $row = $op->getNext(); |
| 389 | + if ( $row === false ) break; |
| 390 | + $row = $row[1]; |
| 391 | + |
| 392 | + $col = $row->getContent();// SMWResultArray object |
| 393 | + foreach ( $col as $object ) {// SMWDataValue object |
| 394 | + $wikiValue = $object->getWikiValue(); |
| 395 | + $results[] = $wikiValue; |
| 396 | + } |
| 397 | + } |
| 398 | + |
| 399 | + |
| 400 | + $countOp = utils::countOperation( $results );// old code passed $op parameter |
| 401 | + $output .= '<td>' . $countOp['insert'] . ' insert, ' . $countOp['delete'] . ' delete</td>'; |
| 402 | + $output .= '<td>(<a href="' . $_SERVER['PHP_SELF'] . '?title=' . $patch . '">' . $patch . '</a>)</td></tr>'; |
| 403 | + /*$titlePatch = Title::newFromText( $patch,PATCH ); |
| 404 | + $article = new Article( $title );*/ |
| 405 | + } |
| 406 | + $output .= '</table></div>'; |
| 407 | + |
| 408 | + // list of push |
| 409 | + |
| 410 | + |
| 411 | + $pushs = array(); |
| 412 | + $res = utils::getSemanticQuery( '[[ChangeSet:+]][[hasPatch::' . $patchs[0] . ']][[inPushFeed::+]]', '?inPushFeed' ); |
| 413 | + $count = $res->getCount(); |
| 414 | + for ( $i = 0; $i < $count; $i++ ) { |
| 415 | + |
| 416 | + $row = $res->getNext(); |
| 417 | + if ( $row === false ) break; |
| 418 | + $row = $row[1]; |
| 419 | + |
| 420 | + $col = $row->getContent();// SMWResultArray object |
| 421 | + foreach ( $col as $object ) {// SMWDataValue object |
| 422 | + $wikiValue = $object->getWikiValue(); |
| 423 | + $pushs[] = $wikiValue; |
| 424 | + } |
| 425 | + } |
| 426 | + |
| 427 | + |
| 428 | + if ( !empty ( $pushs ) ) { |
| 429 | + |
| 430 | + $output .= '<br><div style="width:60%;height:40%;overflow:auto;"><table style="border-bottom: 2px solid #000;"><caption><b>List of pushs</b></caption>'; |
| 431 | + foreach ( $pushs as $push ) { |
| 432 | + |
| 433 | + $pushName = $push; |
| 434 | + |
| 435 | + $output .= '<tr><td align="right" width="50%"><a href="' . $_SERVER['PHP_SELF'] . '?title=' . $pushName . '">' . $pushName . '</a> : </td>'; |
| 436 | + |
| 437 | + // count the number of published patchs by the current pushFeed for the current page |
| 438 | + $published = utils::getPublishedPatchs( $urlServer, $pushName, $title ); |
| 439 | + |
| 440 | + // $publishedInPush = utils::getSemanticRequest('http://'.$wgServerName.$wgScriptPath, '', $param); |
| 441 | + // count the number of unpublished patchs |
| 442 | + $unpublished = array_diff( $patchs, $published ); |
| 443 | + if ( !is_null( $unpublished ) && count( $unpublished ) > 0 ) { |
| 444 | + $output .= '<td align="left" width="50%">' . count( $unpublished ) . ' unpublished patchs on ' . count( $patchs ) . ' </td></tr>'; |
| 445 | + } else { |
| 446 | + $output .= '<td align="left" width="50%"> all ' . $title . "'" . 'patchs are pushed </td></tr>'; |
| 447 | + } |
| 448 | + } |
| 449 | + $output .= '</table></div>'; |
| 450 | + |
| 451 | + }// end if empty $pushs |
| 452 | + |
| 453 | + // part list of pull |
| 454 | + |
| 455 | + $pulls = array(); |
| 456 | + $res = utils::getSemanticQuery( '[[ChangeSet:+]][[hasPatch::' . $patchs[0] . ']][[inPullFeed::+]]', '?inPullFeed' ); |
| 457 | + $count = $res->getCount(); |
| 458 | + for ( $i = 0; $i < $count; $i++ ) { |
| 459 | + |
| 460 | + $row = $res->getNext(); |
| 461 | + if ( $row === false ) break; |
| 462 | + $row = $row[1]; |
| 463 | + |
| 464 | + $col = $row->getContent();// SMWResultArray object |
| 465 | + foreach ( $col as $object ) {// SMWDataValue object |
| 466 | + $wikiValue = $object->getWikiValue(); |
| 467 | + $pulls[] = $wikiValue; |
| 468 | + } |
| 469 | + } |
| 470 | + |
| 471 | + |
| 472 | + if ( !empty ( $pulls ) ) { |
| 473 | + |
| 474 | + $output .= '<br><div style="width:60%;height:40%;overflow:auto;"><table style="border-bottom: 2px solid #000;"><caption><b>List of pull</b></caption>'; |
| 475 | + foreach ( $pulls as $pull ) { |
| 476 | + |
| 477 | + |
| 478 | + $pullName = $pull; |
| 479 | + $pushServer = getPushURL( $pullName ); |
| 480 | + $pushName = getPushName( $pullName ); |
| 481 | + $output .= '<tr><td align="right" width="50%"><a href="' . $_SERVER['PHP_SELF'] . '?title=' . $pullName . '">' . $pullName . '</a> : </td>'; |
| 482 | + |
| 483 | + $pulledPatch = utils::getPulledPatches( $pullName ); |
| 484 | + $patchs = array(); |
| 485 | + foreach ( $pulledPatch as $patch ) { |
| 486 | + |
| 487 | + $onPage = array(); |
| 488 | + $res = utils::getSemanticQuery( '[[Patch:+]][[patchID::' . $patch . ']]', '?onPage' ); |
| 489 | + $count = $res->getCount(); |
| 490 | + for ( $i = 0; $i < $count; $i++ ) { |
| 491 | + |
| 492 | + $row = $res->getNext(); |
| 493 | + if ( $row === false ) break; |
| 494 | + $row = $row[1]; |
| 495 | + |
| 496 | + $col = $row->getContent();// SMWResultArray object |
| 497 | + foreach ( $col as $object ) {// SMWDataValue object |
| 498 | + $wikiValue = $object->getWikiValue(); |
| 499 | + $onPage[] = $wikiValue; |
| 500 | + } |
| 501 | + } |
| 502 | + if ( $onPage[0] == $title ) { |
| 503 | + $patchs[] = $patch; |
| 504 | + } |
| 505 | + } |
| 506 | + |
| 507 | + $published = utils::getPublishedPatchs( $pushServer, $pushName, $title ); |
| 508 | + |
| 509 | + if ( !is_null( $published ) ) { |
| 510 | + $unpublished = array_diff( $patchs, $published ); |
| 511 | + $t = count( $published ); |
| 512 | + $t = count( $patchs ); |
| 513 | + $count = count( $published ) - count( $patchs ); |
| 514 | + $output .= '<td align="left" width="50%"> ' . $count . ' unpulled patchs </td></tr>'; |
| 515 | + } else { |
| 516 | + $output .= '<td align="left" width="50%"> up to date </td></tr>'; |
| 517 | + } |
| 518 | + } |
| 519 | + $output .= '</table></div>'; |
| 520 | + |
| 521 | + }// end if empty $pulls |
| 522 | + |
| 523 | + // part push page |
| 524 | + $url = "http://" . $wgServerName . $wgScriptPath . "/index{$wgScriptExtension}"; |
| 525 | + $output .= ' |
| 526 | +<h2>Actions</h2> |
| 527 | +<div><FORM name="formPush"> |
| 528 | +<table > |
| 529 | +<tr><td> <input type="button" value="PUSH" onClick="pushpage(\'' . $url . '\',\'' . $title . '\');"></input></td></tr></table></form></div> |
| 530 | +This [Push page : "' . $title . '"] action will create a PushFeed and |
| 531 | +publish the modifications of the "' . $title . '" article |
| 532 | + |
| 533 | +<div id="pushstatus" style="display: none; width: 100%; clear: both;" > |
| 534 | +<a name="PUSH_Progress_:" id="PUSH_Progress_:"></a><h2> <span class="mw-headline"> PUSH Progress : </span></h2> |
| 535 | +<div id="statepush" ></div><br /> |
| 536 | +</div> |
| 537 | +'; |
| 538 | + |
| 539 | + |
| 540 | + $wgOut->addHTML( $output ); |
| 541 | + return false; |
| 542 | + } |
| 543 | + else { |
| 544 | + return true; |
| 545 | + } |
| 546 | + } |
| 547 | + |
| 548 | + /** |
| 549 | + * Defines the "Article Admin tab" |
| 550 | + * |
| 551 | + * @global <type> $wgRequest |
| 552 | + * @global <type> $wgServerName |
| 553 | + * @global <type> $wgScriptPath |
| 554 | + * @param <type> $skin |
| 555 | + * @param <type> $content_actions |
| 556 | + * @return <type> |
| 557 | + */ |
| 558 | + function onSkinTemplateTabs( $skin, $content_actions ) { |
| 559 | + global $wgRequest, $wgServerName, $wgScriptPath; |
| 560 | + $urlServer = 'http://' . $wgServerName . $wgScriptPath; |
| 561 | + |
| 562 | + $action = $wgRequest->getText( "action" ); |
| 563 | + $db = &wfGetDB( DB_SLAVE ); |
| 564 | + |
| 565 | + $patchCount = 0; |
| 566 | + if ( $skin->mTitle->getNamespace() == 0 ) $title = $skin->mTitle->getText(); |
| 567 | + else $title = $skin->mTitle->getNsText() . ':' . $skin->mTitle->getText(); |
| 568 | + |
| 569 | + $patchList = array(); |
| 570 | + $res = utils::getSemanticQuery( '[[Patch:+]][[onPage::' . $title . ']]', '?patchID' ); |
| 571 | + $count = $res->getCount(); |
| 572 | + for ( $i = 0; $i < $count; $i++ ) { |
| 573 | + |
| 574 | + $row = $res->getNext(); |
| 575 | + if ( $row === false ) break; |
| 576 | + $row = $row[1]; |
| 577 | + |
| 578 | + $col = $row->getContent();// SMWResultArray object |
| 579 | + foreach ( $col as $object ) {// SMWDataValue object |
| 580 | + $wikiValue = $object->getWikiValue(); |
| 581 | + $patchList[] = $wikiValue; |
| 582 | + } |
| 583 | + } |
| 584 | + |
| 585 | + $patchCount = count( $patchList ); |
| 586 | + if ( $skin->mTitle->mNamespace == PATCH |
| 587 | + || $skin->mTitle->mNamespace == PULLFEED |
| 588 | + || $skin->mTitle->mNamespace == PUSHFEED |
| 589 | + || $skin->mTitle->mNamespace == CHANGESET |
| 590 | + ) { |
| 591 | + } else { |
| 592 | + |
| 593 | + $content_actions["admin"] = array( |
| 594 | + "class" => ( $action == "admin" ) ? "selected" : false, |
| 595 | + "text" => "DSMW (" . $patchCount . " patches)", |
| 596 | + "href" => $skin->mTitle->getLocalURL( "action=admin" ) |
| 597 | + ); |
| 598 | + } |
| 599 | + return false; |
| 600 | + } |
| 601 | + |
| 602 | + /** |
| 603 | + * Defines the "Article Admin tab" |
| 604 | + * |
| 605 | + * @global <type> $wgRequest |
| 606 | + * @global <type> $wgServerName |
| 607 | + * @global <type> $wgScriptPath |
| 608 | + * @param <type> $skin |
| 609 | + * @param <type> $content_actions |
| 610 | + * @return <type> |
| 611 | + */ |
| 612 | + function onSkinTemplateNavigation( $skin, $content_actions ) { |
| 613 | + global $wgRequest, $wgServerName, $wgScriptPath; |
| 614 | + $urlServer = 'http://' . $wgServerName . $wgScriptPath; |
| 615 | + |
| 616 | + $action = $wgRequest->getText( "action" ); |
| 617 | + $db = &wfGetDB( DB_SLAVE ); |
| 618 | + |
| 619 | + $patchCount = 0; |
| 620 | + if ( $skin->mTitle->getNamespace() == 0 ) $title = $skin->mTitle->getText(); |
| 621 | + else $title = $skin->mTitle->getNsText() . ':' . $skin->mTitle->getText(); |
| 622 | + |
| 623 | + $patchList = array(); |
| 624 | + $res = utils::getSemanticQuery( '[[Patch:+]][[onPage::' . $title . ']]', '?patchID' ); |
| 625 | + $count = $res->getCount(); |
| 626 | + for ( $i = 0; $i < $count; $i++ ) { |
| 627 | + |
| 628 | + $row = $res->getNext(); |
| 629 | + if ( $row === false ) break; |
| 630 | + $row = $row[1]; |
| 631 | + |
| 632 | + $col = $row->getContent();// SMWResultArray object |
| 633 | + foreach ( $col as $object ) {// SMWDataValue object |
| 634 | + $wikiValue = $object->getWikiValue(); |
| 635 | + $patchList[] = $wikiValue; |
| 636 | + } |
| 637 | + } |
| 638 | + |
| 639 | + $patchCount = count( $patchList ); |
| 640 | + if ( $skin->mTitle->mNamespace == PATCH |
| 641 | + || $skin->mTitle->mNamespace == PULLFEED |
| 642 | + || $skin->mTitle->mNamespace == PUSHFEED |
| 643 | + || $skin->mTitle->mNamespace == CHANGESET |
| 644 | + ) { |
| 645 | + } else { |
| 646 | + |
| 647 | + $content_actions['views']["admin"] = array( |
| 648 | + "class" => ( $action == "admin" ) ? "selected" : false, |
| 649 | + "text" => "DSMW (" . $patchCount . " patches)", |
| 650 | + "href" => $skin->mTitle->getLocalURL( "action=admin" ) |
| 651 | + ); |
| 652 | + } |
| 653 | + return true; |
| 654 | + } |
| 655 | + |
| 656 | + /** |
| 657 | + *replaces the deleted semantic attribute in the feed page (pullfeed:.... or |
| 658 | + * pushfeed:....) |
| 659 | + * This aims to "virtualy" delete the article, it will no longer appear in the |
| 660 | + * special page (Special:ArticleAdminPage) |
| 661 | + * |
| 662 | + * @param <String> $feed |
| 663 | + * @return <boolean> |
| 664 | + */ |
| 665 | + function deleteFeed( $feed ) { |
| 666 | + // if the browser page is refreshed, feed keeps the same value |
| 667 | + // but [[deleted::false| ]] isn't found and nothing is done |
| 668 | + preg_match( "/^(.+?)_*:_*(.*)$/S", $feed, $m ); |
| 669 | + $articleName = $m[2]; |
| 670 | + if ( $m[1] == "PullFeed" ) $title = Title::newFromText( $articleName, PULLFEED ); |
| 671 | + elseif ( $m[1] == "PushFeed" ) $title = Title::newFromText( $articleName, PUSHFEED ); |
| 672 | + else throw new MWException( __METHOD__ . ': no valid namespace detected' ); |
| 673 | + // get PushFeed by name |
| 674 | + |
| 675 | + $dbr = wfGetDB( DB_SLAVE ); |
| 676 | + $revision = Revision::loadFromTitle( $dbr, $title ); |
| 677 | + $pageContent = $revision->getText(); |
| 678 | + |
| 679 | + $dbr = wfGetDB( DB_SLAVE ); |
| 680 | + $revision = Revision::loadFromTitle( $dbr, $title ); |
| 681 | + $pageContent = $revision->getText(); |
| 682 | + |
| 683 | + // update deleted Value |
| 684 | + $result = str_replace( "[[deleted::false| ]]", "[[deleted::true| ]]", $pageContent ); |
| 685 | + if ( $result == "" ) return true; |
| 686 | + $pageContent = $result; |
| 687 | + |
| 688 | + // save update |
| 689 | + $article = new Article( $title ); |
| 690 | + $article->doEdit( $pageContent, $summary = "" ); |
| 691 | + |
| 692 | + return true; |
| 693 | + } |
| 694 | + |
| 695 | + /** |
| 696 | + * @param <String> $title |
| 697 | + * @return <String> |
| 698 | + */ |
| 699 | + function getPageIdWithTitle( $title ) { |
| 700 | + $dbr = wfGetDB( DB_SLAVE ); |
| 701 | + $id = $dbr->selectField( 'page', 'page_id', array( |
| 702 | + 'page_title' => $title ) ); |
| 703 | + return $id; |
| 704 | + } |
| 705 | + |
| 706 | + /** |
| 707 | + * returns an array of page titles received via the request |
| 708 | + */ |
| 709 | + function getRequestedPages( $request ) { |
| 710 | + |
| 711 | + $results = array(); |
| 712 | + $res = utils::getSemanticQuery( $request ); |
| 713 | + $count = $res->getCount(); |
| 714 | + for ( $i = 0; $i < $count; $i++ ) { |
| 715 | + |
| 716 | + $row = $res->getNext(); |
| 717 | + if ( $row === false ) break; |
| 718 | + $row = $row[0]; |
| 719 | + |
| 720 | + $col = $row->getContent();// SMWResultArray object |
| 721 | + foreach ( $col as $object ) {// SMWDataValue object |
| 722 | + $wikiValue = $object->getWikiValue(); |
| 723 | + $results[] = $wikiValue; |
| 724 | + } |
| 725 | + } |
| 726 | + |
| 727 | + return $results; |
| 728 | + } |
| 729 | + |
| 730 | + function getArticle( $article_title ) { |
| 731 | + $title = Title::newFromText( $article_title ); |
| 732 | + |
| 733 | + // Can't load page if title is invalid. |
| 734 | + if ( $title == null ) return null; |
| 735 | + $article = new Article( $title ); |
| 736 | + |
| 737 | + return $article; |
| 738 | + } |
| 739 | + |
| 740 | +} |
Property changes on: trunk/extensions/DSMW/specials/ArticleAdminPage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 741 | + native |
Index: trunk/extensions/DSMW/specials/SPFunctions.js |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +function process (id, title, wiki){ |
| 3 | + |
| 4 | +//alert(id+" "+title+" "+wiki); |
| 5 | + var xhr_object = null; |
| 6 | + |
| 7 | + if(window.XMLHttpRequest) // Firefox |
| 8 | + xhr_object = new XMLHttpRequest(); |
| 9 | + else if(window.ActiveXObject) // Internet Explorer |
| 10 | + xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); |
| 11 | + else { |
| 12 | + alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); |
| 13 | + return; |
| 14 | + } |
| 15 | + |
| 16 | + xhr_object.open("POST", document.URL+"?title="+title+"&action=admin", true); |
| 17 | + |
| 18 | + xhr_object.onreadystatechange = function() { |
| 19 | + if(xhr_object.readyState == 4) { |
| 20 | +//alert(xhr_object.responseText); |
| 21 | + eval(xhr_object.responseText); |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
| 26 | + // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT : |
| 27 | + var data = "id="+id+"&title="+title+"&wiki="+wiki; |
| 28 | + xhr_object.send(data); |
| 29 | + |
| 30 | + |
| 31 | +} |
| 32 | + |
| 33 | + |
Property changes on: trunk/extensions/DSMW/specials/SPFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 34 | + native |
Index: trunk/extensions/DSMW/specials/DSMWAdmin.php |
— | — | @@ -0,0 +1,142 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * DSMW Special page |
| 6 | + * |
| 7 | + * @copyright INRIA-LORIA-ECOO project |
| 8 | + * |
| 9 | + * @author jean-Philippe Muller |
| 10 | + */ |
| 11 | + |
| 12 | +class DSMWAdmin extends SpecialPage { |
| 13 | + |
| 14 | + public function __construct() { |
| 15 | + global $wgHooks; |
| 16 | + |
| 17 | + # Add all our needed hooks |
| 18 | + $wgHooks['SkinTemplateTabs'][] = $this; |
| 19 | + |
| 20 | + parent::__construct( 'DSMWAdmin' ); |
| 21 | + } |
| 22 | + |
| 23 | + public function getDescription() { |
| 24 | + return wfMsg( 'dsmw-special-settings' ); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Executed when the user opens the DSMW administration special page |
| 29 | + * Calculates the PushFeed list and the pullfeed list (and everything that |
| 30 | + * is displayed on the psecial page |
| 31 | + * |
| 32 | + * @global <Object> $wgOut Output page instance |
| 33 | + * @global <String> $wgServerName |
| 34 | + * @global <String> $wgScriptPath |
| 35 | + * @return <bool> |
| 36 | + */ |
| 37 | + public function execute() { |
| 38 | + global $wgOut, $wgRequest, $wgServerName, $wgScriptPath, $wgDSMWIP, $wgServerName, $wgScriptPath; |
| 39 | + |
| 40 | + /**** Get status of refresh job, if any ****/ |
| 41 | + $dbr =& wfGetDB( DB_SLAVE ); |
| 42 | + $row = $dbr->selectRow( 'job', '*', array( 'job_cmd' => 'DSMWUpdateJob' ), __METHOD__ ); |
| 43 | + |
| 44 | + if ( $row !== false ) { // similar to Job::pop_type, but without deleting the job |
| 45 | + $title = Title::makeTitleSafe( $row->job_namespace, $row->job_title ); |
| 46 | + $updatejob = Job::factory( $row->job_cmd, $title, Job::extractBlob( $row->job_params ), $row->job_id ); |
| 47 | + } else { |
| 48 | + $updatejob = NULL; |
| 49 | + } |
| 50 | + |
| 51 | + $row1 = $dbr->selectRow( 'job', '*', array( 'job_cmd' => 'DSMWPropertyTypeJob' ), __METHOD__ ); |
| 52 | + if ( $row1 !== false ) { // similar to Job::pop_type, but without deleting the job |
| 53 | + $title = Title::makeTitleSafe( $row1->job_namespace, $row1->job_title ); |
| 54 | + $propertiesjob = Job::factory( $row1->job_cmd, $title, Job::extractBlob( $row1->job_params ), $row1->job_id ); |
| 55 | + } else { |
| 56 | + $propertiesjob = NULL; |
| 57 | + } |
| 58 | + /**** Execute actions if any ****/ |
| 59 | + |
| 60 | + $action = $wgRequest->getText( 'action' ); |
| 61 | + |
| 62 | + if ( $action == 'logootize' ) { |
| 63 | + if ( $updatejob === NULL ) { // careful, there might be race conditions here |
| 64 | + $title = Title::makeTitle( NS_SPECIAL, 'DSMWAdmin' ); |
| 65 | + $newjob = new DSMWUpdateJob( $title ); |
| 66 | + $newjob->insert(); |
| 67 | + $wgOut->addHTML( '<p><font color="red"><b>' . wfMsg( 'dsmw-special-admin-articleupstarted' ) . '</b></font></p>' ); |
| 68 | + } else { |
| 69 | + $wgOut->addHTML( '<p><font color="red"><b>' . wfMsg( 'dsmw-special-admin-articleuprunning' ) . '</b></font></p>' ); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + elseif ( $action == 'addProperties' ) { |
| 74 | + if ( $propertiesjob === NULL ) { |
| 75 | + $title1 = Title::makeTitle( NS_SPECIAL, 'DSMWAdmin' ); |
| 76 | + $newjob1 = new DSMWPropertyTypeJob( $title1 ); |
| 77 | + $newjob1->insert(); |
| 78 | + $wgOut->addHTML( '<p><font color="red"><b>' . wfMsg( 'dsmw-special-admin-typeupstarted' ) . '</b></font></p>' ); |
| 79 | + } else { |
| 80 | + $wgOut->addHTML( '<p><font color="red"><b>' . wfMsg( 'dsmw-special-admin-typeuprunning' ) . '</b></font></p>' ); |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + $wgOut->setPagetitle( 'DSMW Settings' ); |
| 85 | + |
| 86 | + $wgOut->addHTML( |
| 87 | + Html::element( |
| 88 | + 'p', |
| 89 | + array(), |
| 90 | + wfMsg( 'dsmw-special-admin-intro' ) |
| 91 | + ) |
| 92 | + ); |
| 93 | + |
| 94 | + $wgOut->addHTML( |
| 95 | + Html::rawElement( |
| 96 | + 'form', |
| 97 | + array( 'name' => 'properties', 'action' => '', 'method' => 'POST' ), |
| 98 | + Html::hidden( 'action', 'addProperties' ) . '<br />' . |
| 99 | + Html::element( |
| 100 | + 'h2', |
| 101 | + array(), |
| 102 | + wfMsg( 'dsmw-special-admin-propheader' ) |
| 103 | + ) . |
| 104 | + Html::element( |
| 105 | + 'p', |
| 106 | + array(), |
| 107 | + wfMsg( 'dsmw-special-admin-proptext' ) |
| 108 | + ) . |
| 109 | + Html::input( |
| 110 | + 'updateProperties', |
| 111 | + wfMsg( 'dsmw-special-admin-propheader' ), |
| 112 | + 'submit' |
| 113 | + ) |
| 114 | + ) |
| 115 | + ); |
| 116 | + |
| 117 | + $wgOut->addHTML( |
| 118 | + Html::rawElement( |
| 119 | + 'form', |
| 120 | + array( 'name' => 'logoot', 'action' => '', 'method' => 'POST' ), |
| 121 | + Html::hidden( 'action', 'logootize' ) . '<br />' . |
| 122 | + Html::element( |
| 123 | + 'h2', |
| 124 | + array(), |
| 125 | + wfMsg( 'dsmw-special-admin-upheader' ) |
| 126 | + ) . |
| 127 | + Html::element( |
| 128 | + 'p', |
| 129 | + array(), |
| 130 | + wfMsg( 'dsmw-special-admin-uptext' ) |
| 131 | + ) . |
| 132 | + Html::input( |
| 133 | + 'updateArticles', |
| 134 | + wfMsg( 'dsmw-special-admin-upbutton' ), |
| 135 | + 'submit' |
| 136 | + ) |
| 137 | + ) |
| 138 | + ); |
| 139 | + |
| 140 | + return false; |
| 141 | + } |
| 142 | + |
| 143 | +} |
Property changes on: trunk/extensions/DSMW/specials/DSMWAdmin.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 144 | + native |
Index: trunk/extensions/DSMW/specials/DSMWGeneralExhibits.php |
— | — | @@ -0,0 +1,125 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * DSMW Special page |
| 6 | + * |
| 7 | + * TODO: only load when SRF is available? |
| 8 | + * |
| 9 | + * @copyright INRIA-LORIA-SCORE Team |
| 10 | + * |
| 11 | + * @author jean-Philippe Muller |
| 12 | + */ |
| 13 | +class DSMWGeneralExhibits extends SpecialPage { |
| 14 | + |
| 15 | + public function __construct() { |
| 16 | + parent::__construct( 'DSMWGeneralExhibits' ); |
| 17 | + } |
| 18 | + |
| 19 | + public function getDescription() { |
| 20 | + return wfMsg( 'dsmw-special-exhibits' ); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Executed when the user opens the "DSMW general exhibits" special page |
| 25 | + * Displays information about DSMW, e.g. all the DSMW PushFeeds in a timeline |
| 26 | + * (This special page works only when the Semantic Results Format extension is installed) |
| 27 | + * |
| 28 | + * There are 3 links used to see informations about Patches, PullFeeds or PushFeeds |
| 29 | + */ |
| 30 | + public function execute() { |
| 31 | + global $wgOut, $wgRequest; |
| 32 | + |
| 33 | + $output = '<p>This page displays general informations about Distributed Semantic MediaWiki.</p>'; |
| 34 | + |
| 35 | + $returntitle1 = Title::makeTitle( NS_SPECIAL, 'DSMWGeneralExhibits' ); |
| 36 | + $output .= '<b><a href="' . htmlspecialchars( $returntitle1->getFullURL() ) . '?action=pushdisplay">[PushFeed data] </a></b>'; |
| 37 | + |
| 38 | + $returntitle1 = Title::makeTitle( NS_SPECIAL, 'DSMWGeneralExhibits' ); |
| 39 | + $output .= '<b><a href="' . htmlspecialchars( $returntitle1->getFullURL() ) . '?action=pulldisplay">[PullFeed data] </a></b>'; |
| 40 | + |
| 41 | + $returntitle1 = Title::makeTitle( NS_SPECIAL, 'DSMWGeneralExhibits' ); |
| 42 | + $output .= '<b><a href="' . htmlspecialchars( $returntitle1->getFullURL() ) . '?action=patchdisplay">[Patches data] </a></b>'; |
| 43 | + |
| 44 | + |
| 45 | + $action = $wgRequest->getText( 'action' ); |
| 46 | + |
| 47 | + switch ( $action ) { |
| 48 | + case "pushdisplay": |
| 49 | + $wikitext = ' |
| 50 | +==PushFeeds== |
| 51 | +{{#ask: [[PushFeed:+]] |
| 52 | +|?name |
| 53 | +|?modification date |
| 54 | +|?pushFeedServer |
| 55 | +|?pushFeedName |
| 56 | +|?hasPushHead |
| 57 | +| format=exhibit |
| 58 | +| views=timeline, table, tabular |
| 59 | +| sort=modification date |
| 60 | +| timelineHeight=400 |
| 61 | +|facets=modification date |
| 62 | +|limit=500 |
| 63 | +}} |
| 64 | +'; |
| 65 | + break; |
| 66 | + case "pulldisplay": |
| 67 | + $wikitext = ' |
| 68 | +==PullFeeds== |
| 69 | +{{#ask: [[PullFeed:+]] |
| 70 | +|?name |
| 71 | +|?modification date |
| 72 | +|?pushFeedName |
| 73 | +|?pushFeedServer |
| 74 | +| format=exhibit |
| 75 | +| views=timeline, table, tabular |
| 76 | +| sort=modification date |
| 77 | +| timelineHeight=400 |
| 78 | +|facets=modification date |
| 79 | +|limit=500 |
| 80 | +}} |
| 81 | +'; |
| 82 | + break; |
| 83 | + case "patchdisplay": |
| 84 | + $wikitext = ' |
| 85 | +==Patches== |
| 86 | +{{#ask: [[Patch:+]] |
| 87 | +|?patchID |
| 88 | +|?modification date |
| 89 | +|?onPage |
| 90 | +|?previous |
| 91 | +| format=exhibit |
| 92 | +| views=timeline, table, tabular |
| 93 | +| sort=modification date |
| 94 | +| timelineHeight=400 |
| 95 | +|facets=onPage, modification date |
| 96 | +|limit=500 |
| 97 | +}} |
| 98 | +'; |
| 99 | + break; |
| 100 | + |
| 101 | + default: |
| 102 | + $wikitext = ' |
| 103 | +==Patches== |
| 104 | +{{#ask: [[Patch:+]] |
| 105 | +|?patchID |
| 106 | +|?modification date |
| 107 | +|?onPage |
| 108 | +|?previous |
| 109 | +| format=exhibit |
| 110 | +| views=timeline, table, tabular |
| 111 | +| sort=modification date |
| 112 | +| timelineHeight=400 |
| 113 | +|facets=onPage, modification date |
| 114 | +|limit=500 |
| 115 | +}} |
| 116 | +'; |
| 117 | + break; |
| 118 | + } |
| 119 | + |
| 120 | + $wgOut->addHTML( $output ); |
| 121 | + $wgOut->addWikiText( $wikitext ); |
| 122 | + |
| 123 | + return false; |
| 124 | + } |
| 125 | + |
| 126 | +} |
Property changes on: trunk/extensions/DSMW/specials/DSMWGeneralExhibits.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 127 | + native |