function execute($params) { global $wgOut, $wgUser, $wgRequest; $wgOut->setPageTitle('WikiFactory Reporter'); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); if (!$wgUser->isAllowed('wikifactory')) { $this->displayRestrictionError(); return; } $this->varid = $wgRequest->getInt('varid'); $this->disable_limit = $wgRequest->getBool('nolimit'); /***********************************************/ $vars = WikiFactory::getVariables("cv_name", 0, 0); $select = new XmlSelect('varid', false, $this->varid); if (!empty($this->varid)) { //the cast is because the Xml select uses === to detect the default $select->setDefault((string) $this->varid); //change the name, using the var name $variable = WikiFactory::getVarById($this->varid, 0); $wgOut->setPageTitle('WikiFactory Reporter: ' . $variable->cv_name); } foreach ($vars as $variable) { $select->addOption("{$variable->cv_name} ({$variable->cv_id})", $variable->cv_id); } $action = self::getTitle()->getLocalURL(); $wgOut->addHTML("<form action='{$action}' method='get'>\n"); $wgOut->addHTML($select->getHTML()); $wgOut->addHTML("<input type='submit'>\n"); $wgOut->addHTML("</form>\n"); /***********************************************/ if (!empty($this->varid)) { $wgOut->addHTML($this->getCustomSettings()); } }
/** * axWFactoryFilterVariables * * Ajax call, return filtered group od variables * * @access public * @author eloy@wikia * * @return string: json string with array of variables */ function axWFactoryFilterVariables() { global $wgRequest; $defined = wfStrToBool($wgRequest->getVal("defined", "false")); $editable = wfStrToBool($wgRequest->getVal("editable", "false")); $wiki_id = $wgRequest->getVal("wiki", 0); $group = $wgRequest->getVal("group", 0); $string = $wgRequest->getVal("string", false); #--- cache it? $Variables = WikiFactory::getVariables("cv_name", $wiki_id, $group, $defined, $editable, $string); $selector = ""; foreach ($Variables as $Var) { $selector .= sprintf("<option value=\"%d\">%s</option>\n", $Var->cv_id, $Var->cv_name); } return json_encode(array("selector" => $selector)); }
/****************************************************/ $vars['L']['city'] = $wiki->city_id; $vars['L']['*'] = WikiFactory::getVariables("cv_id", $vars['L']['city'], 0, true); if ($to && $to == $wiki->city_id) { $to = null; print Wikia::errorbox("cant compare to self"); } #do we still have a R side? if ($to) { /****************************************************/ /* get right stuff */ /****************************************************/ $vars['R']['city'] = $to; $vars['R']['*'] = WikiFactory::getVariables("cv_id", $vars['R']['city'], 0, true); } $combined = array(); foreach ($vars as $side => $data) { foreach ($data['*'] as $item) { $combined[$item->cv_id]['*'] = $item->cv_name; $var = WikiFactory::getVarById($item->cv_id, $data['city']); $combined[$item->cv_id]['type'] = $var->cv_variable_type; $combined[$item->cv_id]['_'] = true; $val = unserialize($var->cv_value); switch ($var->cv_variable_type) { case "string": /*use as is*/ break; case "integer": /*use as is*/
/** * Quick form for choosing which variable to change. * * @author Sean Colombo * @access private * * @param varOverrides array - associative array of values to put into the template. These are assumed * to have been loaded as a form re-initialization and are given precedence * over the defaults. * * @return HTML to be rendered. */ private function chooseVariableToChange($varOverrides = array()) { $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $vars = array("hub" => WikiFactoryHub::getInstance(), "wiki" => $this->mWiki, "title" => $this->mTitle, "groups" => WikiFactory::getGroups(), "cluster" => WikiFactory::getVarValueByName("wgDBcluster", $this->mWiki->city_id), "domains" => WikiFactory::getDomains($this->mWiki->city_id), "statuses" => $this->mStatuses, "variables" => WikiFactory::getVariables(), "variableName" => $this->mVariableName); $vars = array_merge($vars, $varOverrides); $oTmpl->set_vars($vars); return $oTmpl->render("form-variables"); }