本文整理汇总了PHP中WikiFactory::changeVariable方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::changeVariable方法的具体用法?PHP WikiFactory::changeVariable怎么用?PHP WikiFactory::changeVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::changeVariable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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"));
}
}