function testbug14404()
 {
     global $wgUser, $wgContLang, $wgLanguageCode, $wgLang;
     $title = Title::newFromText("Bug 14404");
     $article = new Article($title);
     $wgUser = new User();
     $wgUser->mRights = array('createpage', 'edit', 'purge');
     $wgLanguageCode = 'es';
     $wgContLang = Language::factory('es');
     $wgLang = Language::factory('fr');
     $status = $article->doEdit('{{:{{int:history}}}}', 'Test code for bug 14404', 0);
     $templates1 = $article->getUsedTemplates();
     $wgLang = Language::factory('de');
     $article->mParserOptions = null;
     // Let it pick the new user language
     $article->mPreparedEdit = false;
     // In order to force the rerendering of the same wikitext
     // We need an edit, a purge is not enough to regenerate the tables
     $status = $article->doEdit('{{:{{int:history}}}}', 'Test code for bug 14404', EDIT_UPDATE);
     $templates2 = $article->getUsedTemplates();
     $this->assertEquals($templates1, $templates2);
     $this->assertEquals($templates1[0]->getFullText(), 'Historial');
 }
 /**
  * @return Array
  */
 function getTemplates()
 {
     if ($this->preview || $this->section != '') {
         $templates = array();
         if (!isset($this->mParserOutput)) {
             return $templates;
         }
         foreach ($this->mParserOutput->getTemplates() as $ns => $template) {
             foreach (array_keys($template) as $dbk) {
                 $templates[] = Title::makeTitle($ns, $dbk);
             }
         }
         return $templates;
     } else {
         return $this->mArticle->getUsedTemplates();
     }
 }
Example #3
0
 /**
  * Display a page stating that the Wiki is in read-only mode,
  * and optionally show the source of the page that the user
  * was trying to edit.  Should only be called (for this
  * purpose) after wfReadOnly() has returned true.
  *
  * For historical reasons, this function is _also_ used to
  * show the error message when a user tries to edit a page
  * they are not allowed to edit.  (Unless it's because they're
  * blocked, then we show blockedPage() instead.)  In this
  * case, the second parameter should be set to true and a list
  * of reasons supplied as the third parameter.
  *
  * @todo Needs to be split into multiple functions.
  *
  * @param string $source    Source code to show (or null).
  * @param bool   $protected Is this a permissions error?
  * @param array  $reasons   List of reasons for this error, as returned by Title::getUserPermissionsErrors().
  */
 public function readOnlyPage($source = null, $protected = false, $reasons = array(), $action = null)
 {
     global $wgUser, $wgTitle;
     $skin = $wgUser->getSkin();
     $this->setRobotPolicy('noindex,nofollow');
     $this->setArticleRelated(false);
     // If no reason is given, just supply a default "I can't let you do
     // that, Dave" message.  Should only occur if called by legacy code.
     if ($protected && empty($reasons)) {
         $reasons[] = array('badaccess-group0');
     }
     if (!empty($reasons)) {
         // Permissions error
         if ($source) {
             $this->setPageTitle(wfMsg('viewsource'));
             $this->setSubtitle(wfMsg('viewsourcefor', $skin->makeKnownLinkObj($wgTitle)));
         } else {
             $this->setPageTitle(wfMsg('badaccess'));
         }
         $this->addWikiText($this->formatPermissionsErrorMessage($reasons, $action));
     } else {
         // Wiki is read only
         $this->setPageTitle(wfMsg('readonly'));
         $reason = wfReadOnlyReason();
         $this->wrapWikiMsg('<div class="mw-readonly-error">$1</div>', array('readonlytext', $reason));
     }
     // Show source, if supplied
     if (is_string($source)) {
         $this->addWikiMsg('viewsourcetext');
         $text = Xml::openElement('textarea', array('id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $wgUser->getOption('cols'), 'rows' => $wgUser->getOption('rows'), 'readonly' => 'readonly'));
         $text .= htmlspecialchars($source);
         $text .= Xml::closeElement('textarea');
         $this->addHTML($text);
         // Show templates used by this article
         $skin = $wgUser->getSkin();
         $article = new Article($wgTitle);
         $this->addHTML("<div class='templatesUsed'>\n{$skin->formatTemplates($article->getUsedTemplates())}\n</div>\n");
     }
     # If the title doesn't exist, it's fairly pointless to print a return
     # link to it.  After all, you just tried editing it and couldn't, so
     # what's there to do there?
     if ($wgTitle->exists()) {
         $this->returnToMain(null, $wgTitle);
     }
 }
Example #4
0
 /**
  * Display a page stating that the Wiki is in read-only mode,
  * and optionally show the source of the page that the user
  * was trying to edit.  Should only be called (for this
  * purpose) after wfReadOnly() has returned true.
  *
  * For historical reasons, this function is _also_ used to
  * show the error message when a user tries to edit a page
  * they are not allowed to edit.  (Unless it's because they're
  * blocked, then we show blockedPage() instead.)  In this
  * case, the second parameter should be set to true and a list
  * of reasons supplied as the third parameter.
  *
  * @todo Needs to be split into multiple functions.
  *
  * @param $source    String: source code to show (or null).
  * @param $protected Boolean: is this a permissions error?
  * @param $reasons   Array: list of reasons for this error, as returned by Title::getUserPermissionsErrors().
  * @param $action    String: action that was denied or null if unknown
  */
 public function readOnlyPage($source = null, $protected = false, $reasons = array(), $action = null)
 {
     $this->setRobotPolicy('noindex,nofollow');
     $this->setArticleRelated(false);
     // If no reason is given, just supply a default "I can't let you do
     // that, Dave" message.  Should only occur if called by legacy code.
     if ($protected && empty($reasons)) {
         $reasons[] = array('badaccess-group0');
     }
     if (!empty($reasons)) {
         // Permissions error
         if ($source) {
             $this->setPageTitle(wfMsg('viewsource'));
             $this->setSubtitle(wfMsg('viewsourcefor', Linker::linkKnown($this->getTitle())));
         } else {
             $this->setPageTitle(wfMsg('badaccess'));
         }
         $this->addWikiText($this->formatPermissionsErrorMessage($reasons, $action));
     } else {
         // Wiki is read only
         throw new ReadOnlyError();
     }
     // Show source, if supplied
     if (is_string($source)) {
         $this->addWikiMsg('viewsourcetext');
         $params = array('id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $this->getUser()->getOption('cols'), 'rows' => $this->getUser()->getOption('rows'), 'readonly' => 'readonly');
         $this->addHTML(Html::element('textarea', $params, $source));
         // Show templates used by this article
         $article = new Article($this->getTitle());
         $templates = Linker::formatTemplates($article->getUsedTemplates());
         $this->addHTML("<div class='templatesUsed'>\n{$templates}\n</div>\n");
     }
     # If the title doesn't exist, it's fairly pointless to print a return
     # link to it.  After all, you just tried editing it and couldn't, so
     # what's there to do there?
     if ($this->getTitle()->exists()) {
         $this->returnToMain(null, $this->getTitle());
     }
 }
Example #5
0
 function getNextToPatrolHTML()
 {
     global $wgOut;
     if (!$this->mResult) {
         // nothing to patrol
         return null;
     }
     // construct the HTML to reply
     // load the page
     $t = Title::newFromID($this->mResult->qc_page);
     if (!$t) {
         $this->deleteBad($this->mResult->qc_page);
         return "<!--{$this->mResult->qc_page}-->error creating title, oops, please <a href='#' onclick='window.location.reload()'>refresh</a>";
     }
     // get current revsion
     $r = Revision::newFromId($this->mResult->qc_rev_id);
     if (!$r) {
         return "Error creating revision";
     }
     // grab the intro image
     $text = $r->getText();
     $intro = Article::getSection($text, 0);
     //ignore if we have a {{nointroimg}} template in there
     $a = new Article($t);
     $templates = $a->getUsedTemplates();
     if (in_array('Template:Nointroimg', $templates)) {
         $this->deleteBad($this->mResult->qc_page);
         return "<!--{$this->mResult->qc_page}--><p></p><p>Intro images have been disabled for this article. Please <a href='#' onclick='window.location.reload()'>refresh</a> for the next article.</p>";
     }
     $html = "";
     $changedby = self::getChangedBy("Image added by: ");
     $pic = self::getPicture($intro);
     if ($pic) {
         //make sure it's not too big
         if ($pic->width > 600) {
             $pic = $pic->getThumbnail(600);
         }
         if ($r->getPrevious()) {
             $old = $r->getPrevious()->getID();
         } else {
             $old = -1;
         }
         $thumbresult['new'] = $r->getID();
         $thumbresult['old'] = $old;
         $thumbresult['title'] = $t;
         $pic_width = (632 - $pic->width) / 2 + $pic->width - 32;
         //31px = thumbbutton width
         $thumbs = ThumbsUp::getThumbsUpButton($thumbresult);
         $style = " style='margin-left:" . $pic_width . "px;'";
         $thumbs = "<div class='qc_changedby_inset'{$style}>{$thumbs}</div>";
         $html .= "<div id='qc_bigpic'>\n\t\t\t\t\t\t" . $thumbs . "\n\t\t\t\t\t\t<img class='qc_bigpic_img' src='" . $pic->getURL() . "' width='" . $pic->width . "' height='" . $pic->height . "' />\n\t\t\t\t\t\t</div>";
     } else {
         $html .= "<br />" . wfMsg('qc_nothing_found');
     }
     $html = "<div id='quickeditlink'></div>";
     $html .= "<div id='qc_box'>" . $changedby . $html . "</div>";
     $popts = $wgOut->parserOptions();
     $popts->setTidy(true);
     $html .= WikihowArticleHTML::processArticleHTML($wgOut->parse($text, $t, $popts), array('ns' => $t->getNamespace()));
     $html .= "<input type='hidden' name='qc_id' value='{$this->mResult->qc_id}'/>";
     $html .= "<div id='numqcusers'>{$this->mUsers}</div>";
     return $html;
 }
Example #6
0
 /**
  * @todo document
  * @param bool  $protected Is the reason the page can't be reached because it's protected?
  * @param mixed $source
  */
 public function readOnlyPage($source = null, $protected = false)
 {
     global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle;
     $skin = $wgUser->getSkin();
     $this->setRobotpolicy('noindex,nofollow');
     $this->setArticleRelated(false);
     if ($protected) {
         $this->setPageTitle(wfMsg('viewsource'));
         $this->setSubtitle(wfMsg('viewsourcefor', $skin->makeKnownLinkObj($wgTitle)));
         # Determine if protection is due to the page being a system message
         # and show an appropriate explanation
         if ($wgTitle->getNamespace() == NS_MEDIAWIKI && !$wgUser->isAllowed('editinterface')) {
             $this->addWikiText(wfMsg('protectedinterface'));
         } else {
             $this->addWikiText(wfMsg('protectedpagetext'));
         }
     } else {
         $this->setPageTitle(wfMsg('readonly'));
         if ($wgReadOnly) {
             $reason = $wgReadOnly;
         } else {
             $reason = file_get_contents($wgReadOnlyFile);
         }
         $this->addWikiText(wfMsg('readonlytext', $reason));
     }
     if (is_string($source)) {
         $this->addWikiText(wfMsg('viewsourcetext'));
         if ($source === '') {
             global $wgTitle;
             if ($wgTitle->getNamespace() == NS_MEDIAWIKI) {
                 $source = wfMsgWeirdKey($wgTitle->getText());
             } else {
                 $source = '';
             }
         }
         $rows = $wgUser->getIntOption('rows');
         $cols = $wgUser->getIntOption('cols');
         $text = "\n<textarea name='wpTextbox1' id='wpTextbox1' cols='{$cols}' rows='{$rows}' readonly='readonly'>" . htmlspecialchars($source) . "\n</textarea>";
         $this->addHTML($text);
     }
     $article = new Article($wgTitle);
     $this->addHTML($skin->formatTemplates($article->getUsedTemplates()));
     $this->returnToMain(false);
 }