Пример #1
0
 /**
  * Execute a special page path.
  * The path	may contain parameters, e.g. Special:Name/Params
  * Extracts the special page name and call the execute method, passing the parameters
  *
  * Returns a title object if the page is redirected, false if there was no such special
  * page, and true if it was successful.
  *
  * @param $title          a title object
  * @param $including      output is being captured for use in {{special:whatever}}
  */
 static function executePath(&$title, $including = false)
 {
     global $wgOut, $wgTitle;
     $fname = 'SpecialPage::executePath';
     wfProfileIn($fname);
     $bits = split("/", $title->getDBkey(), 2);
     $name = $bits[0];
     if (!isset($bits[1])) {
         // bug 2087
         $par = NULL;
     } else {
         $par = $bits[1];
     }
     $page = SpecialPage::getPage($name);
     if (is_null($page)) {
         if ($including) {
             wfProfileOut($fname);
             return false;
         } else {
             $redir = SpecialPage::getRedirect($name);
             if (isset($redir)) {
                 if ($par) {
                     $redir = Title::makeTitle($redir->getNamespace(), $redir->getText() . '/' . $par);
                 }
                 $params = SpecialPage::getRedirectParams($name);
                 if ($params) {
                     $url = $redir->getFullUrl($params);
                 } else {
                     $url = $redir->getFullUrl();
                 }
                 $wgOut->redirect($url);
                 $retVal = $redir;
                 $wgOut->redirect($url);
                 $retVal = $redir;
             } else {
                 $wgOut->setArticleRelated(false);
                 $wgOut->setRobotpolicy('noindex,nofollow');
                 $wgOut->setStatusCode(404);
                 $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
                 $retVal = false;
             }
         }
     } else {
         if ($including && !$page->includable()) {
             wfProfileOut($fname);
             return false;
         } elseif (!$including) {
             if ($par !== NULL) {
                 $wgTitle = Title::makeTitle(NS_SPECIAL, $name);
             } else {
                 $wgTitle = $title;
             }
         }
         $page->including($including);
         $profName = 'Special:' . $page->getName();
         wfProfileIn($profName);
         $page->execute($par);
         wfProfileOut($profName);
         $retVal = true;
     }
     wfProfileOut($fname);
     return $retVal;
 }
Пример #2
0
 /**
  * Execute a special page path.
  * The path	may contain parameters, e.g. Special:Name/Params
  * Extracts the special page name and call the execute method, passing the parameters
  *
  * Returns a title object if the page is redirected, false if there was no such special
  * page, and true if it was successful.
  *
  * @param $title          a title object
  * @param $including      output is being captured for use in {{special:whatever}}
  */
 function executePath(&$title, $including = false)
 {
     global $wgSpecialPages, $wgOut, $wgTitle;
     $bits = split("/", $title->getDBkey(), 2);
     $name = $bits[0];
     if (!isset($bits[1])) {
         // bug 2087
         $par = NULL;
     } else {
         $par = $bits[1];
     }
     $page =& SpecialPage::getPage($name);
     if (is_null($page)) {
         if ($including) {
             return false;
         } else {
             $redir =& SpecialPage::getRedirect($name);
             if (isset($redir)) {
                 if (isset($par)) {
                     $wgOut->redirect($redir->getFullURL() . '/' . $par);
                 } else {
                     $wgOut->redirect($redir->getFullURL());
                 }
                 $retVal = $redir;
             } else {
                 $wgOut->setArticleRelated(false);
                 $wgOut->setRobotpolicy("noindex,follow");
                 $wgOut->errorpage("nosuchspecialpage", "nospecialpagetext");
                 $retVal = false;
             }
         }
     } else {
         if ($including && !$page->includable()) {
             return false;
         }
         if ($par !== NULL) {
             $wgTitle = Title::makeTitle(NS_SPECIAL, $name);
         } else {
             $wgTitle = $title;
         }
         $page->including($including);
         $page->execute($par);
         $retVal = true;
     }
     return $retVal;
 }