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


PHP Web\Form类代码示例

本文整理汇总了PHP中Icinga\Web\Form的典型用法代码示例。如果您正苦于以下问题:PHP Form类的具体用法?PHP Form怎么用?PHP Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: showAction

 /**
  * Show a user
  */
 public function showAction()
 {
     $this->assertPermission('config/authentication/users/show');
     $userName = $this->params->getRequired('user');
     $backend = $this->getUserBackend($this->params->getRequired('backend'));
     $user = $backend->select(array('user_name', 'is_active', 'created_at', 'last_modified'))->where('user_name', $userName)->fetchRow();
     if ($user === false) {
         $this->httpNotFound(sprintf($this->translate('User "%s" not found'), $userName));
     }
     $memberships = $this->loadMemberships(new User($userName))->select();
     $filterEditor = Widget::create('filterEditor')->setQuery($memberships)->setSearchColumns(array('group_name'))->preserveParams('limit', 'sort', 'dir', 'view', 'backend', 'user')->ignoreParams('page')->handleRequest($this->getRequest());
     $memberships->applyFilter($filterEditor->getFilter());
     $this->setupFilterControl($filterEditor);
     $this->setupPaginationControl($memberships);
     $this->setupLimitControl();
     $this->setupSortControl(array('group_name' => $this->translate('Group')), $memberships);
     if ($this->hasPermission('config/authentication/groups/edit')) {
         $extensibleBackends = $this->loadUserGroupBackends('Icinga\\Data\\Extensible');
         $this->view->showCreateMembershipLink = !empty($extensibleBackends);
     } else {
         $this->view->showCreateMembershipLink = false;
     }
     $this->view->user = $user;
     $this->view->backend = $backend;
     $this->view->memberships = $memberships;
     $this->createShowTabs($backend->getName(), $userName)->activate('user/show');
     if ($this->hasPermission('config/authentication/groups/edit')) {
         $removeForm = new Form();
         $removeForm->setUidDisabled();
         $removeForm->addElement('hidden', 'user_name', array('isArray' => true, 'value' => $userName, 'decorators' => array('ViewHelper')));
         $removeForm->addElement('hidden', 'redirect', array('value' => Url::fromPath('user/show', array('backend' => $backend->getName(), 'user' => $userName)), 'decorators' => array('ViewHelper')));
         $removeForm->addElement('button', 'btn_submit', array('escape' => false, 'type' => 'submit', 'class' => 'link-like', 'value' => 'btn_submit', 'decorators' => array('ViewHelper'), 'label' => $this->view->icon('trash'), 'title' => $this->translate('Cancel this membership')));
         $this->view->removeForm = $removeForm;
     }
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:38,代码来源:UserController.php

示例2: recurseForm

 /**
  * Recurse the given form and return the descriptions for it and all of its subforms
  *
  * @param   Form    $form   The form to recurse
  *
  * @return  array
  */
 protected function recurseForm(Form $form)
 {
     $descriptions = array($form->getDescriptions());
     foreach ($form->getSubForms() as $subForm) {
         $descriptions[] = $this->recurseForm($subForm);
     }
     return call_user_func_array('array_merge', $descriptions);
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:15,代码来源:FormDescriptions.php

示例3: recurseForm

 /**
  * Recurse the given form and return the notifications for it and all of its subforms
  *
  * @param   Form    $form       The form to recurse
  *
  * @return array
  */
 protected function recurseForm(Form $form)
 {
     $notifications = $form->getNotifications();
     foreach ($form->getSubForms() as $subForm) {
         $notifications = $notifications + $this->recurseForm($subForm);
     }
     return $notifications;
 }
开发者ID:xert,项目名称:icingaweb2,代码行数:15,代码来源:FormNotifications.php

示例4: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     $result = ResourceFactory::createResource(new ConfigObject($form->getValues()))->inspect();
     if ($result->hasError()) {
         $form->addError(sprintf('%s (%s)', $form->translate('Connectivity validation failed, connection to the given resource not possible.'), $result->getError()));
     }
     // TODO: display diagnostics in $result->toArray() to the user
     return !$result->hasError();
 }
开发者ID:bebehei,项目名称:icingaweb2,代码行数:16,代码来源:LdapResourceForm.php

示例5: isValidUserBackend

 /**
  * Validate the configuration by creating a backend and requesting the user count
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidUserBackend(Form $form)
 {
     $backend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig()));
     $result = $backend->inspect();
     if ($result->hasError()) {
         $form->addError(sprintf($form->translate('Using the specified backend failed: %s'), $result->getError()));
     }
     // TODO: display diagnostics in $result->toArray() to the user
     return !$result->hasError();
 }
开发者ID:bebehei,项目名称:icingaweb2,代码行数:17,代码来源:DbBackendForm.php

示例6: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     try {
         $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
         $resource->getConnection()->getConnection();
     } catch (Exception $e) {
         $form->addError($form->translate('Connectivity validation failed, connection to the given resource not possible.'));
         return false;
     }
     return true;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:18,代码来源:DbResourceForm.php

示例7: recurseForm

 /**
  * Recurse the given form and return the notifications for it and all of its subforms
  *
  * @param   Form    $form   The form to recurse
  *
  * @return  array
  */
 protected function recurseForm(Form $form)
 {
     $notifications = $form->getNotifications();
     foreach ($form->getSubForms() as $subForm) {
         foreach ($this->recurseForm($subForm) as $type => $messages) {
             foreach ($messages as $message) {
                 $notifications[$type][] = $message;
             }
         }
     }
     return $notifications;
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:19,代码来源:FormNotifications.php

示例8: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     try {
         $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
         $resource->bind();
     } catch (Exception $e) {
         $msg = $form->translate('Connectivity validation failed, connection to the given resource not possible.');
         if ($error = $e->getMessage()) {
             $msg .= ' (' . $error . ')';
         }
         $form->addError($msg);
         return false;
     }
     return true;
 }
开发者ID:kain64,项目名称:icingaweb2,代码行数:22,代码来源:LdapResourceForm.php

示例9: setupPage

 /**
  * Setup the given page that is either going to be displayed or validated
  *
  * @param   Form        $page       The page to setup
  * @param   Request     $request    The current request
  */
 public function setupPage(Form $page, Request $request)
 {
     if ($page->getName() === 'setup_requirements') {
         $page->setRequirements($this->getRequirements());
     } elseif ($page->getName() === 'setup_monitoring_summary') {
         $page->setSummary($this->getSetup()->getSummary());
         $page->setSubjectTitle(mt('monitoring', 'the monitoring module', 'setup.summary.subject'));
     } elseif ($this->getDirection() === static::FORWARD && ($page->getName() === 'setup_monitoring_ido' || $page->getName() === 'setup_monitoring_livestatus')) {
         if (($authDbResourceData = $this->getPageData('setup_auth_db_resource')) !== null && $authDbResourceData['name'] === $request->getPost('name') || ($configDbResourceData = $this->getPageData('setup_config_db_resource')) !== null && $configDbResourceData['name'] === $request->getPost('name') || ($ldapResourceData = $this->getPageData('setup_ldap_resource')) !== null && $ldapResourceData['name'] === $request->getPost('name')) {
             $page->error(mt('monitoring', 'The given resource name is already in use.'));
         }
     }
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:19,代码来源:MonitoringWizard.php

示例10: isValidUserBackend

 /**
  * Validate the configuration by creating a backend and requesting the user count
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidUserBackend(Form $form)
 {
     try {
         $ldapUserBackend = UserBackend::create(null, new ConfigObject($form->getValues()));
         $ldapUserBackend->assertAuthenticationPossible();
     } catch (AuthenticationException $e) {
         if (($previous = $e->getPrevious()) !== null) {
             $form->addError($previous->getMessage());
         } else {
             $form->addError($e->getMessage());
         }
         return false;
     } catch (Exception $e) {
         $form->addError(sprintf($form->translate('Unable to validate authentication: %s'), $e->getMessage()));
         return false;
     }
     return true;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:25,代码来源:LdapBackendForm.php

示例11: getRedirectUrl

 /**
  * {@inheritdoc}
  */
 public function getRedirectUrl()
 {
     $redirectUrl = parent::getRedirectUrl();
     // TODO(el): Forms should provide event handling. This is quite hackish
     $formData = $this->getRequestData();
     if ($this->wasSent($formData) && (!$this->getSubmitLabel() || $this->isSubmitted()) && $this->isValid($formData)) {
         $this->getResponse()->setAutoRefreshInterval(1);
     }
     return $redirectUrl;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:13,代码来源:CommandForm.php

示例12: getValues

 /**
  * {@inheritdoc}
  *
  * Values from subforms are directly added to the returned values array instead of being grouped by the subforms'
  * names.
  */
 public function getValues($suppressArrayNotation = false)
 {
     $values = parent::getValues($suppressArrayNotation);
     foreach (array_keys($this->_subForms) as $name) {
         // Zend returns values from subforms grouped by their names, but we want them flat
         $values = array_merge($values, $values[$name]);
         unset($values[$name]);
     }
     return $values;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:16,代码来源:ConfigForm.php

示例13: isValidUserBackend

 /**
  * Validate the configuration by creating a backend and requesting the user count
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidUserBackend(Form $form)
 {
     /**
      * @var $result Inspection
      */
     $result = UserBackend::create(null, new ConfigObject($form->getValues()))->inspect();
     if ($result->hasError()) {
         $form->addError($result->getError());
     }
     // TODO: display diagnostics in $result->toArray() to the user
     return !$result->hasError();
 }
开发者ID:bebehei,项目名称:icingaweb2,代码行数:19,代码来源:LdapBackendForm.php

示例14: recurseForm

 /**
  * Recurse the given form and return the descriptions for it and all of its subforms
  *
  * @param   Form    $form               The form to recurse
  * @param   mixed   $entirelyRequired   Set by reference, true means all elements in the hierarchy are
  *                                       required, false only a partial subset and null none at all
  * @param   bool    $elementsPassed     Whether there were any elements passed during the recursion until now
  *
  * @return  array
  */
 protected function recurseForm(Form $form, &$entirelyRequired = null, $elementsPassed = false)
 {
     $requiredLabels = array();
     if ($form->getRequiredCue() !== null) {
         $partiallyRequired = $partiallyOptional = false;
         foreach ($form->getElements() as $element) {
             if (!in_array($element->getType(), $this->blacklist)) {
                 if (!$element->isRequired()) {
                     $partiallyOptional = true;
                     if ($entirelyRequired) {
                         $entirelyRequired = false;
                     }
                 } else {
                     $partiallyRequired = true;
                     if (($label = $element->getDecorator('label')) !== false) {
                         $requiredLabels[] = $label;
                     }
                 }
             }
         }
         if (!$elementsPassed) {
             $elementsPassed = $partiallyRequired || $partiallyOptional;
             if ($entirelyRequired === null && $partiallyRequired) {
                 $entirelyRequired = !$partiallyOptional;
             }
         } elseif ($entirelyRequired === null && $partiallyRequired) {
             $entirelyRequired = false;
         }
     }
     $descriptions = array($form->getDescriptions());
     foreach ($form->getSubForms() as $subForm) {
         $descriptions[] = $this->recurseForm($subForm, $entirelyRequired, $elementsPassed);
     }
     if ($entirelyRequired) {
         foreach ($requiredLabels as $label) {
             $label->setRequiredSuffix('');
         }
     }
     return call_user_func_array('array_merge', $descriptions);
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:50,代码来源:FormDescriptions.php

示例15: isValid

 /**
  * Validate the given form data and check whether a BIND-request is successful
  *
  * @param   array   $data   The data to validate
  *
  * @return  bool
  */
 public function isValid($data)
 {
     if (false === parent::isValid($data)) {
         return false;
     }
     return true;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:14,代码来源:LdapDiscoveryConfirmPage.php


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