本文整理汇总了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>';
//.........这里部分代码省略.........