Esempio n. 1
0
 /**
  * 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);
     }
 }
Esempio n. 2
0
 /**
  * Pushes the image to the specified wiki.
  *
  * @since 0.5
  *
  * @param Title $title
  * @param string $target
  * @param string $token
  */
 protected function pushToTarget(Title $title, $target, $token)
 {
     global $egPushDirectFileUploads;
     $imagePage = new ImagePage($title);
     $requestData = array('action' => 'upload', 'format' => 'json', 'token' => $token, 'filename' => $title->getText(), 'ignorewarnings' => '1');
     if ($egPushDirectFileUploads) {
         $requestData['file'] = '@' . $imagePage->getFile()->getPath();
     } else {
         $requestData['url'] = $imagePage->getDisplayedFile()->getFullUrl();
     }
     $reqArgs = array('method' => 'POST', 'timeout' => 'default', 'postData' => $requestData);
     if ($egPushDirectFileUploads) {
         if (!function_exists('curl_init')) {
             $this->dieUsage(wfMsg('push-api-err-nocurl'), 'image-push-nocurl');
         } elseif (!defined('CurlHttpRequest::SUPPORTS_FILE_POSTS') || !CurlHttpRequest::SUPPORTS_FILE_POSTS) {
             $this->dieUsage(wfMsg('push-api-err-nofilesupport'), 'image-push-nofilesupport');
         } else {
             $req = new CurlHttpRequest($target, $reqArgs);
         }
     } else {
         $req = PushFunctions::getHttpRequest($target, $reqArgs);
     }
     if (array_key_exists($target, $this->cookieJars)) {
         $req->setCookieJar($this->cookieJars[$target]);
     }
     $status = $req->execute();
     if ($status->isOK()) {
         $response = $req->getContent();
         $this->getResult()->addValue(null, null, FormatJson::decode($response));
         wfRunHooks('PushAPIAfterImagePush', array($title, $target, $token, $response));
     } else {
         $this->dieUsage(wfMsg('push-special-err-push-failed'), 'page-push-failed');
     }
 }
Esempio n. 3
0
 /**
  * Loads the needed JavaScript.
  * Takes care of non-RL compatibility.
  *
  * @since 0.2
  */
 protected function loadJs()
 {
     $out = $this->getOutput();
     // For backward compatibility with MW < 1.17.
     if (is_callable(array($out, 'addModules'))) {
         $out->addModules('ext.push.special');
     } else {
         global $egPushScriptPath;
         PushFunctions::addJSLocalisation();
         $out->addHeadItem('ext.push.special', Html::linkedScript($egPushScriptPath . '/specials/ext.push.special.js'));
     }
 }
Esempio n. 4
0
 /**
  * Pushes the page content to the specified wiki.
  *
  * @since 0.3
  *
  * @param Title $title
  * @param array $revision
  * @param string $target
  * @param string $token
  */
 protected function pushToTarget(Title $title, array $revision, $target, $token)
 {
     global $wgSitename;
     $summary = wfMsgExt('push-import-revision-message', 'parsemag', $wgSitename);
     $requestData = array('action' => 'edit', 'title' => $title->getFullText(), 'format' => 'json', 'summary' => $summary, 'text' => $revision['*'], 'token' => $token);
     $req = PushFunctions::getHttpRequest($target, array('method' => 'POST', 'timeout' => 'default', 'postData' => $requestData));
     if (array_key_exists($target, $this->cookieJars)) {
         $req->setCookieJar($this->cookieJars[$target]);
     }
     $status = $req->execute();
     if ($status->isOK()) {
         $response = $req->getContent();
         $this->editResponses[] = $response;
         Hooks::run('PushAPIAfterPush', array($title, $revision, $target, $token, $response));
     } else {
         $this->dieUsage(wfMsg('push-special-err-push-failed'), 'page-push-failed');
     }
 }
Esempio n. 5
0
 /**
  * Loads the needed JavaScript.
  * Takes care of non-RL compatibility.
  *
  * @since 0.2
  */
 protected static function loadJs()
 {
     global $wgOut;
     // For backward compatibility with MW < 1.17.
     if (is_callable(array($wgOut, 'addModules'))) {
         $wgOut->addModules('ext.push.special');
     } else {
         global $egPushScriptPath;
         PushFunctions::addJSLocalisation();
         $wgOut->includeJQuery();
         $wgOut->addHeadItem('ext.push.special', Html::linkedScript($egPushScriptPath . '/specials/ext.push.special.js'));
     }
 }