当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiFactory::getGroups方法代码示例

本文整理汇总了PHP中WikiFactory::getGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::getGroups方法的具体用法?PHP WikiFactory::getGroups怎么用?PHP WikiFactory::getGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WikiFactory的用法示例。


在下文中一共展示了WikiFactory::getGroups方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 function execute()
 {
     global $wgOut, $wgUser, $wgRequest, $wgTitle;
     $gVar = $wgRequest->getText('var');
     $gVal = $wgRequest->getVal('val', 'true');
     $gLikeVal = $wgRequest->getVal('likeValue', 'true');
     $gTypeVal = $wgRequest->getVal('searchType', 'bool');
     $wgOut->SetPageTitle(wfMsg('whereisextension'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     if (!$wgUser->isAllowed('WhereIsExtension')) {
         $this->displayRestrictionError();
         return;
     }
     $this->values = array(0 => array('true', true, '='), 1 => array('false', false, '='), 2 => array('not empty', '', '!='));
     $tagName = $wgRequest->getVal('wikiSelectTagName', null);
     $tagWikis = $wgRequest->getArray('wikiSelected');
     $tagResultInfo = '';
     if ($wgRequest->wasPosted() && !empty($tagName) && count($tagWikis)) {
         $tagResultInfo = $this->tagSelectedWikis($tagName, $tagWikis);
     }
     $formData['vars'] = $this->getListOfVars($gVar == '');
     $formData['vals'] = $this->values;
     $formData['selectedVal'] = $gVal;
     $formData['likeValue'] = $gLikeVal;
     $formData['searchType'] = $gTypeVal;
     $formData['selectedGroup'] = $gVar == '' ? 27 : '';
     //default group: extensions (or all groups when looking for variable, rt#16953)
     $formData['groups'] = WikiFactory::getGroups();
     $formData['actionURL'] = $wgTitle->getFullURL();
     // by default, we don't need a paginator
     $sPaginator = '';
     if (!empty($gVar)) {
         $formData['selectedVar'] = $gVar;
         // assume an empty result
         $formData['count'] = 0;
         $formData['wikis'] = array();
         if (isset($this->values[$gVal][1]) && isset($this->values[$gVal][2])) {
             // check how many wikis meet the conditions
             $formData['count'] = WikiFactory::getCountOfWikisWithVar($gVar, $gTypeVal, $this->values[$gVal][2], $this->values[$gVal][1], $gLikeVal);
             // if there are any, get the list and create a Paginator
             if (0 < $formData['count']) {
                 // determine the offset (from the requested page)
                 $iPage = $wgRequest->getVal('page', 1);
                 $iOffset = ($iPage - 1) * self::ITEMS_PER_PAGE;
                 // the list
                 $formData['wikis'] = WikiFactory::getListOfWikisWithVar($gVar, $gTypeVal, $this->values[$gVal][2], $this->values[$gVal][1], $gLikeVal, $iOffset, self::ITEMS_PER_PAGE);
                 // the Paginator, if we need more than one page
                 if (self::ITEMS_PER_PAGE < $formData['count']) {
                     $oPaginator = Paginator::newFromArray(array_fill(0, $formData['count'], ''), self::ITEMS_PER_PAGE, 5);
                     $oPaginator->setActivePage($iPage - 1);
                     $sPager = $oPaginator->getBarHTML(sprintf('%s?var=%s&val=%s&likeValue=%s&searchType=%s&page=%%s', $wgTitle->getFullURL(), $gVar, $gVal, $gLikeVal, $gTypeVal));
                 }
             }
         }
     }
     $oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $oTmpl->set_vars(array('formData' => $formData, 'tagResultInfo' => $tagResultInfo, 'sPager' => $sPager));
     $wgOut->addHTML($oTmpl->render('list'));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:59,代码来源:SpecialWhereIsExtension_body.php

示例2: index

 public function index()
 {
     global $wgOut, $wgUser, $wgRequest, $wgTitle;
     if (!$this->wg->User->isAllowed('batchvarnishpurgetool')) {
         $this->displayRestrictionError();
         return false;
         // skip rendering
     }
     $formErrors = array();
     $gUrl = $this->getVal('url', null);
     $gUrl = trim($gUrl, '/');
     if (!$gUrl) {
         $formErrors['url'] = wfMsg('batchvarnishpurgetool-error-url');
     }
     $gVar = $this->getVal('var', null);
     if (!$gVar) {
         $formErrors['var'] = wfMsg('batchvarnishpurgetool-error-var');
     }
     $gVal = $this->getVal('val', 'true');
     $gLikeVal = $this->getVal('likeValue', 'true');
     $gTypeVal = $this->getVal('searchType', 'bool');
     if (empty($formErrors)) {
         $purgedUrls = $this->purge($gUrl, $gVar, $gTypeVal, $gVal, $gLikeVal);
         $this->setVal('purgedUrls', $purgedUrls);
     }
     $formData['vars'] = $this->getListOfVars($gVar == '');
     $formData['vals'] = self::$values;
     $formData['selectedVal'] = $gVal;
     $formData['likeValue'] = $gLikeVal;
     $formData['searchType'] = $gTypeVal;
     $formData['selectedGroup'] = $gVar == '' ? 27 : '';
     //default group: extensions (or all groups when looking for variable, rt#16953)
     $formData['groups'] = WikiFactory::getGroups();
     $formData['actionURL'] = $wgTitle->getFullURL();
     $this->setVal('formData', $formData);
     $this->setVal('formErrors', $formErrors);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:37,代码来源:BatchVarnishPurgeToolController.class.php

示例3: axWFactorySubmitChangeVariable

/**
 * axWFactorySubmitChangeVariable
 *
 * Method for getting a change-variable form via AJAX request.
 * This is for changing the variable itself (discription, groups, etc.), NOT for
 * changing the values set on each wiki.
 *
 * @author Sean Colombo
 * @access public
 *
 * @return HTML code with variable-edit form
 */
function axWFactorySubmitChangeVariable()
{
    global $wgRequest, $wgUser, $wgOut;
    if (!$wgUser->isAllowed('wikifactory')) {
        $wgOut->readOnlyPage();
        #--- FIXME: later change to something reasonable
        return;
    }
    $cv_variable_id = $wgRequest->getVal("cv_variable_id");
    $city_id = $wgRequest->getVal("wiki");
    $cv_name = $wgRequest->getVal("cv_name");
    $cv_variable_type = $wgRequest->getVal("cv_variable_type");
    $cv_access_level = $wgRequest->getVal("cv_access_level");
    $cv_variable_group = $wgRequest->getVal("cv_variable_group");
    $cv_description = $wgRequest->getval("cv_description");
    // Verify that the form is filled out, then add the variable if it is (display an error if it isn't).
    $errMsg = "";
    if ($cv_name == "") {
        $errMsg .= "<li>Please enter a name for the variable.</li>\n";
    }
    if (!in_array($cv_variable_type, WikiFactory::$types)) {
        $errMsg .= "<li>The value \"{$cv_variable_type}\" was not recognized as a valid WikiFactory::\$type.</li>\n";
    }
    if (!in_array($cv_access_level, array_keys(WikiFactory::$levels))) {
        $errMsg .= "<li>The value \"{$cv_access_level}\" was not recognized as a valid key from WikiFactory::\$levels.</li>\n";
    }
    if (!in_array($cv_variable_group, array_keys(WikiFactory::getGroups()))) {
        $errMsg .= "<li>The value \"{$cv_variable_group}\" was not recognized as a valid group_id from city_variables_groups table as returned by WikiFactory::getGroups()</li>\n";
    }
    if ($cv_description == "") {
        $errMsg .= "<li>Please enter a description of what the variable is used for.</li>\n";
    }
    if ($errMsg == "") {
        $success = WikiFactory::changeVariable($cv_variable_id, $cv_name, $cv_variable_type, $cv_access_level, $cv_variable_group, $cv_description);
        if (!$success) {
            $errMsg .= "<li>There was a database error while trying to change the variable.  Please see the logs for more info.</li>";
        }
    }
    $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
    $variable = WikiFactory::getVarById($cv_variable_id, $city_id);
    if ($errMsg != "") {
        $errHtml = "";
        $errHtml .= "<div style='border:1px #f00 solid;background-color:#faa;padding:5px'>";
        $errHtml .= "<strong>ERROR: Unable to update variable!</strong>";
        $errHtml .= "<ul>\n{$errMsg}</ul>\n";
        $errHtml .= "</div>";
        $vars = array("error_message" => $errHtml, "title" => Title::makeTitle(NS_SPECIAL, 'WikiFactory'), "groups" => WikiFactory::getGroups(), "accesslevels" => WikiFactory::$levels, "types" => WikiFactory::$types, "cv_variable_id" => $cv_variable_id, "cv_name" => $cv_name, "cv_variable_type" => $cv_variable_type, "cv_access_level" => $cv_access_level, "cv_variable_group" => $cv_variable_group, "cv_description" => $cv_description);
        $oTmpl->set_vars($vars);
        return json_encode(array("div-body" => $oTmpl->render("change-variable"), "div-name" => "wk-variable-form"));
    } else {
        // Set it back to the normal form for just setting the variable's value for the current wiki.
        $oTmpl->set_vars(array("cityid" => $city_id, "variable" => WikiFactory::getVarById($cv_variable_id, $city_id), "groups" => WikiFactory::getGroups(), "accesslevels" => WikiFactory::$levels));
        // Inject a success message above the form so that the user know the updates worked.
        $html = "";
        $html .= "<div style='border:1px #0f0 solid;background-color:#afa;padding:5px'>";
        $html .= "<strong>{$variable->cv_name}</strong> successfully updated.";
        $html .= "</div>";
        return json_encode(array("div-body" => $html . $oTmpl->render("variable"), "div-name" => "wk-variable-form"));
    }
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:72,代码来源:SpecialWikiFactory_ajax.php

示例4: getCustomSettings

 function getCustomSettings()
 {
     global $wgExternalSharedDB;
     $city_list = 'city_list';
     $cv = 'city_variables';
     $cv_pool = 'city_variables_pool';
     $dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
     $res = $dbr->select(array($city_list, $cv, $cv_pool), array('cv_value', 'city_url', 'city_id'), array("{$city_list}.city_id = {$cv}.cv_city_id", "{$cv}.cv_variable_id = {$cv_pool}.cv_id", "{$cv_pool}.cv_id     = '{$this->varid}'"), __METHOD__);
     $variable = WikiFactory::getVarById($this->varid, 0);
     $data = array();
     $values = array();
     $row_count = $dbr->numRows($res);
     if ($row_count == 0) {
         $dbr->freeResult($res);
         $out = "no settings found in WikiFactory\n";
         return $out;
     }
     $this->over_limit = false;
     if ($row_count > 1000) {
         $this->over_limit = true;
     }
     if ($this->disable_limit) {
         $this->over_limit = false;
     }
     while ($row = $dbr->fetchObject($res)) {
         $city_id = $row->city_id;
         $cv_value = unserialize($row->cv_value);
         $nom_value = $cv_value;
         if (is_array($cv_value)) {
             asort($cv_value);
             $cv_value = join(', ', $cv_value);
             $nom_value = 'array';
         } elseif (is_bool($cv_value)) {
             $cv_value = $cv_value ? 'true' : 'false';
             $nom_value = $cv_value;
         } else {
             #$cv_value = 'Error. Not an array?!?';
         }
         if (preg_match('/http:\\/\\/([\\w\\.\\-]+)\\//', $row->city_url, $matches)) {
             $city_url = str_ireplace('.wikia.com', '', $matches[1]);
         } else {
             $city_url = 'Error. Unknown wiki?!?';
         }
         if (!empty($cv_value)) {
             if (count($data) <= 1000 || $this->disable_limit) {
                 $data[] = array('value' => $cv_value, 'url' => $city_url, 'city' => $city_id);
             }
             $values[] = $nom_value;
         }
     }
     $dbr->freeResult($res);
     $acv = array_count_values($values);
     asort($acv);
     unset($values);
     global $wgCityId;
     if ($wgCityId == 177) {
         #we're on central (or are faking it), so link locallly
         $WF_title = SpecialPage::getTitleFor('WikiFactory');
         $wie_title = SpecialPage::getTitleFor('WhereIsExtension');
     } else {
         #we're away from home, so make sure the links link back right
         $WF_title = GlobalTitle::newFromText('WikiFactory', NS_SPECIAL, 177);
         $wie_title = GlobalTitle::newFromText('WhereIsExtension', NS_SPECIAL, 177);
     }
     $wie_query = array('var' => $variable->cv_variable_id, 'searchType' => 'full', 'val' => 0);
     #likeValue is appended manually inside the template;
     $wie_base = $wie_title->getFullURL(http_build_query($wie_query));
     unset($wie_query);
     unset($wie_title);
     $limit_message = '';
     if ($this->over_limit) {
         $limit_message = Wikia::errorbox("Warning, this variable has {$row_count} entries. Only first 1000 shown");
         $QS = http_build_query(array('varid' => $variable->cv_variable_id, 'nolimit' => 1));
         $limit_message .= "<a href='/index.php?title=Special:WikiFactoryReporter&{$QS}'>Click here to load all results</a>\n";
     }
     $groups = WikiFactory::getGroups();
     $variable->var_group = $groups[$variable->cv_variable_group];
     unset($groups);
     $sprites = array('search' => "<img src='" . wfBlankImgUrl() . "' class='sprite search' alt='search' height='16' width='22'>", 'edit' => "<img src='" . wfBlankImgUrl() . "' class='sprite edit-pencil' alt='edit'>");
     $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $tmpl->set_vars(array('th' => array($variable->cv_name, 'wiki', 'city_id'), 'data' => $data, 'variable' => $variable, 'acv' => $acv, 'wf_base' => $WF_title->getFullUrl(), 'limit_message' => $limit_message, 'sprites' => $sprites, 'wie_base' => $wie_base));
     $out = $tmpl->render('reporter');
     return $out;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:84,代码来源:SpecialWikiFactoryReporter_body.php

示例5: doAddVariableForm

 /**
  * If there was a post to the add variable form, this will process it.
  *
  * @author Sean Colombo
  * @access private
  *
  * @param varOverrides array - array that will be filled (by reference) with any values
  *                             which should be used as overrides for form re-initialization
  *                             (for instance, if there was an error in the form we start where
  *                             the user left off instead of starting from scratch).
  *
  * @return any additional HTML that should be rendered as a result of the form post.
  */
 private function doAddVariableForm(&$varOverrides)
 {
     global $wgRequest;
     $html = "";
     if ($wgRequest->wasPosted()) {
         $cv_name = $wgRequest->getVal("cv_name");
         $cv_variable_type = $wgRequest->getVal("cv_variable_type");
         $cv_access_level = $wgRequest->getVal("cv_access_level");
         $cv_variable_group = $wgRequest->getVal("cv_variable_group");
         $cv_description = $wgRequest->getval("cv_description");
         $cv_is_unique = $wgRequest->getval("cv_is_unique", "0");
         // Verify that the form is filled out, then add the variable if it is (display an error if it isn't).
         $err = "";
         if ($cv_name == "") {
             $err .= "<li>Please enter a name for the variable.</li>\n";
         }
         if (!in_array($cv_variable_type, WikiFactory::$types)) {
             $err .= "<li>The value \"{$cv_variable_type}\" was not recognized as a valid WikiFactory::\$type.</li>\n";
         }
         if (!in_array($cv_access_level, array_keys(WikiFactory::$levels))) {
             $err .= "<li>The value \"{$cv_access_level}\" was not recognized as a valid key from WikiFactory::\$levels.</li>\n";
         }
         if (!in_array($cv_variable_group, array_keys(WikiFactory::getGroups()))) {
             $err .= "<li>The value \"{$cv_variable_group}\" was not recognized as a valid group_id from city_variables_groups table as returned by WikiFactory::getGroups()</li>\n";
         }
         if ($cv_description == "") {
             $err .= "<li>Please enter a description of what the variable is used for.</li>\n";
         }
         if ($err == "") {
             $success = WikiFactory::createVariable($cv_name, $cv_variable_type, $cv_access_level, $cv_variable_group, $cv_description, $cv_is_unique);
             if ($success) {
                 $html .= "<div style='border:1px #0f0 solid;background-color:#afa;padding:5px'><strong>{$cv_name}</strong> successfully added to WikiFactory.</div>";
             } else {
                 $html .= "<div style='border:1px #f00 solid;background-color:#faa;padding:5px'>";
                 $html .= "<strong>ERROR: There was a database error while trying to create the variable.  Please see the logs for more info.</strong>";
                 $html .= "</div>";
             }
         } else {
             $html .= "<div style='border:1px #f00 solid;background-color:#faa;padding:5px'>";
             $html .= "<strong>ERROR: Unable to add variable!</strong>";
             $html .= "<ul>\n{$err}</ul>\n";
             $html .= "</div>";
             $varOverrides['cv_name'] = $cv_name;
             $varOverrides['cv_variable_type'] = $cv_variable_type;
             $varOverrides['cv_access_level'] = $cv_access_level;
             $varOverrides['cv_variable_group'] = $cv_variable_group;
             $varOverrides['cv_description'] = $cv_description;
             $varOverrides['cv_is_unique'] = $cv_is_unique;
         }
     }
     return $html;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:65,代码来源:SpecialWikiFactory_body.php


注:本文中的WikiFactory::getGroups方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。