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


PHP Horde_Form::setSection方法代码示例

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


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

示例1: setupEditForm

 /**
  * Create a permission editing form.
  *
  * @param Horde_Perms_Permission $permission  TODO
  */
 public function setupEditForm($permission)
 {
     /* Initialise form if required. */
     $this->_formInit();
     $this->_form->setButtons(Horde_Core_Translation::t("Update"), true);
     $this->_vars->set('perm_id', $this->_perms->getPermissionId($permission));
     $this->_form->addHidden('', 'perm_id', 'text', false);
     /* Get permission configuration. */
     $this->_type = $permission->get('type');
     $params = $this->_corePerms->getParams($permission->getName());
     /* Default permissions. */
     $perm_val = $permission->getDefaultPermissions();
     $this->_form->setSection('default', Horde_Core_Translation::t("All Authenticated Users"), Horde_Themes_Image::tag('perms.png'), false);
     /* We MUST use 'deflt' for the variable name because 'default' is a
      * reserved word in JavaScript. */
     if ($this->_type == 'matrix') {
         /* Set up the columns for the permissions matrix. */
         $cols = Horde_Perms::getPermsArray();
         /* Define a single matrix row for default perms. */
         $matrix = array(Horde_Perms::integerToArray($perm_val));
         $this->_form->addVariable('', 'deflt', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
     } else {
         $var = $this->_form->addVariable('', 'deflt', $this->_type, false, false, null, $params);
         $var->setDefault($perm_val);
     }
     /* Guest permissions. */
     $perm_val = $permission->getGuestPermissions();
     $this->_form->setSection('guest', Horde_Core_Translation::t("Guest Permissions"), '', false);
     if ($this->_type == 'matrix') {
         /* Define a single matrix row for guest perms. */
         $matrix = array(Horde_Perms::integerToArray($perm_val));
         $this->_form->addVariable('', 'guest', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
     } else {
         $var = $this->_form->addVariable('', 'guest', $this->_type, false, false, null, $params);
         $var->setDefault($perm_val);
     }
     /* Object creator permissions. */
     $perm_val = $permission->getCreatorPermissions();
     $this->_form->setSection('creator', Horde_Core_Translation::t("Creator Permissions"), Horde_Themes_Image::tag('user.png'), false);
     if ($this->_type == 'matrix') {
         /* Define a single matrix row for creator perms. */
         $matrix = array(Horde_Perms::integerToArray($perm_val));
         $this->_form->addVariable('', 'creator', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
     } else {
         $var = $this->_form->addVariable('', 'creator', $this->_type, false, false, null, $params);
         $var->setDefault($perm_val);
     }
     /* Users permissions. */
     $perm_val = $permission->getUserPermissions();
     $this->_form->setSection('users', Horde_Core_Translation::t("Individual Users"), Horde_Themes_Image::tag('user.png'), false);
     $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
     $user_list = array();
     if ($auth->hasCapability('list')) {
         /* The auth driver has list capabilities so set up an array which
          * the matrix field type will recognise to set up an enum box for
          * adding new users to the permissions matrix. */
         $new_users = array();
         try {
             $user_list = $auth->listNames();
             foreach ($user_list as $user => $name) {
                 if (!isset($perm_val[$user])) {
                     $new_users[$user] = $name;
                 }
             }
         } catch (Horde_Auth_Exception $e) {
             $new_users = true;
         }
     } else {
         /* No list capabilities, setting to true so that the matrix field
          * type will offer a text input box for adding new users. */
         $new_users = true;
     }
     if ($this->_type == 'matrix') {
         /* Set up the matrix array, breaking up each permission integer
          * into an array.  The keys of this array will be the row
          * headers. */
         $rows = array();
         $matrix = array();
         foreach ($perm_val as $u_id => $u_perms) {
             $rows[$u_id] = isset($user_list[$u_id]) ? $user_list[$u_id] : $u_id;
             $matrix[$u_id] = Horde_Perms::integerToArray($u_perms);
         }
         $this->_form->addVariable('', 'u', 'matrix', false, false, null, array($cols, $rows, $matrix, $new_users));
     } else {
         if ($new_users) {
             if (is_array($new_users)) {
                 $u_n = Horde_Util::getFormData('u_n');
                 $u_n = empty($u_n['u']) ? null : $u_n['u'];
                 $user_html = '<select name="u_n[u]"><option value="">' . Horde_Core_Translation::t("-- select --") . '</option>';
                 foreach ($new_users as $new_user => $name) {
                     $user_html .= '<option value="' . $new_user . '"';
                     $user_html .= $u_n == $new_user ? ' selected="selected"' : '';
                     $user_html .= '>' . htmlspecialchars($name) . '</option>';
                 }
                 $user_html .= '</select>';
//.........这里部分代码省略.........
开发者ID:horde,项目名称:horde,代码行数:101,代码来源:Ui.php


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