コード例 #1
0
 /**
  * execute
  *
  * main entry point
  *
  * @access public
  *
  * @param string $subpage: subpage of Title
  *
  * @return nothing
  */
 public function execute($subpage)
 {
     global $wgUser, $wgOut, $wgRequest;
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('wikifactory')) {
         $this->displayRestrictionError();
         return;
     }
     $this->mTitle = Title::makeTitle(NS_SPECIAL, 'WikiFactory');
     $this->mDomain = false;
     /**
      * initial output
      */
     $wgOut->setPageTitle(wfMsg('wikifactorypagetitle'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     #--- handle chagelog
     if ($subpage === "change.log") {
         $oPager = new ChangeLogPager();
         $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
         $oTmpl->set_vars(array("limit" => $oPager->getForm(), "body" => $oPager->getBody(), "nav" => $oPager->getNavigationBar()));
         $wgOut->addHTML($oTmpl->render("changelog"));
     } elseif (in_array(strtolower($subpage), array("metrics", "metrics/main", "metrics/monthly", "metrics/daily"))) {
         $oAWCMetrics = new WikiMetrics();
         $oAWCMetrics->show($subpage);
     } elseif (strpos($subpage, "short.stats") === 0) {
         $subpageOptions = explode('/', $subpage);
         $lang = isset($subpageOptions[1]) ? $subpageOptions[1] : null;
         $wgOut->addHTML($this->shortStats($lang));
     } elseif (strpos($subpage, "long.stats") === 0) {
         $subpageOptions = explode('/', $subpage);
         $lang = isset($subpageOptions[1]) ? $subpageOptions[1] : null;
         $wgOut->addHTML($this->longStats($lang));
     } elseif (strtolower($subpage) === "add.variable") {
         $varOverrides = array();
         $wgOut->addHTML($this->doAddVariableForm($varOverrides));
         // process the post (if relevant).
         $wgOut->addHTML($this->addVariableForm($varOverrides));
         // display the form
     } else {
         $subpage = $subpage == "/" ? null : $subpage;
         $oWiki = $this->getWikiData($subpage);
         if (!isset($oWiki->city_id)) {
             $this->doWikiSelector();
         } else {
             $this->mWiki = $oWiki;
             $this->mTags = new WikiFactoryTags($this->mWiki->city_id);
             $this->doWikiForm();
         }
     }
 }
コード例 #2
0
/**
 * axAWCMetrics
 *
 * Ajax call, return filtered list of all wikis with some metrics data
 *
 * @access public
 * @author moli@wikia
 *
 * @return string: json string
 */
function axAWCMetricsAllWikis()
{
    global $wgUser, $wgRequest;
    if (wfReadOnly()) {
        return;
    }
    if (!in_array('staff', $wgUser->getGroups())) {
        return "";
    }
    if ($wgUser->isBlocked()) {
        return "";
    }
    $aResponse = array('nbr_records' => 0, 'data' => '');
    $OAWCMetrics = new WikiMetrics();
    $res = $OAWCMetrics->getFilteredWikis();
    if (!empty($res)) {
        $aResponse['data'] = $res;
        $aResponse['nbr_records'] = count($res);
    }
    return json_encode($aResponse);
}