示例#1
0
文件: Push_Tab.php 项目: BITPlan/Push
 /**
  * Outputs the HTML for the push options.
  * 
  * @since 0.4
  */
 protected static function displayPushOptions()
 {
     global $wgOut, $wgUser, $wgTitle;
     $wgOut->addHTML('<h3>' . htmlspecialchars(wfMsg('push-tab-push-options')) . '</h3>');
     $usedTemplates = array_keys(PushFunctions::getTemplates(array($wgTitle->getFullText()), array($wgTitle->getFullText() => true)));
     // Get rid of the page itself.
     array_shift($usedTemplates);
     self::displayIncTemplatesOption($usedTemplates);
     if ($wgUser->isAllowed('filepush')) {
         self::displayIncFilesOption($usedTemplates);
     }
 }
示例#2
0
 /**
  * Outputs the HTML to indicate a push is occurring and
  * the JavaScript to needed by the push.
  *
  * @since 0.2
  *
  * @param string $pages
  */
 protected function doPush($pages)
 {
     global $wgSitename, $egPushTargets, $egPushBulkWorkers, $egPushBatchSize;
     $pageSet = array();
     // Inverted index of all pages to look up
     // Split up and normalize input
     foreach (explode("\n", $pages) as $pageName) {
         $pageName = trim($pageName);
         $title = Title::newFromText($pageName);
         if ($title && $title->getInterwiki() == '' && $title->getText() !== '') {
             // Only record each page once!
             $pageSet[$title->getPrefixedText()] = true;
         }
     }
     // Look up any linked pages if asked...
     if ($this->getRequest()->getCheck('templates')) {
         $pageSet = PushFunctions::getTemplates(array_keys($pageSet), $pageSet);
     }
     $pages = array_keys($pageSet);
     $targets = array();
     $links = array();
     if (count($egPushTargets) > 1) {
         foreach ($egPushTargets as $targetName => $targetUrl) {
             if ($this->getRequest()->getCheck(str_replace(' ', '_', $targetName))) {
                 $targets[$targetName] = $targetUrl;
                 $links[] = "[{$targetUrl} {$targetName}]";
             }
         }
     } else {
         $targets = $egPushTargets;
     }
     $out = $this->getOutput();
     $out->addWikiMsg('push-special-pushing-desc', $this->getLanguage()->listToText($links), $this->getLanguage()->formatNum(count($pages)));
     $out->addHTML(Html::hidden('siteName', $wgSitename, array('id' => 'siteName')) . Html::rawElement('div', array('id' => 'pushResultDiv', 'style' => 'width: 100%; height: 300px; overflow: auto'), Html::rawElement('div', array('class' => 'innerResultBox'), Html::element('ul', array('id' => 'pushResultList')))) . '<br />' . Html::element('a', array('href' => $this->getPageTitle()->getInternalURL()), wfMsg('push-special-return')));
     $out->addInlineScript('var wgPushPages = ' . FormatJson::encode($pages) . ';' . 'var wgPushTargets = ' . FormatJson::encode($targets) . ';' . 'var wgPushWorkerCount = ' . $egPushBulkWorkers . ';' . 'var wgPushBatchSize = ' . $egPushBatchSize . ';' . 'var wgPushIncFiles = ' . ($this->getRequest()->getCheck('files') ? 'true' : 'false') . ';');
     $this->loadJs();
 }