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


PHP WikiFactory::createVariable方法代码示例

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


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

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