Exemplo n.º 1
1
 /** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     if ($fieldset->getName()) {
         return parent::renderFieldset($view, $fieldset);
     }
     // Reimplement form renderer to align submit button with elements from Preferences fieldset.
     $output = "<div class='table'>\n";
     foreach ($this->get('Preferences') as $element) {
         if ($element instanceof \Zend\Form\Fieldset) {
             $output .= $view->htmlElement('span', $view->translate($element->getLabel()), array('class' => 'label'), true) . "\n";
             $output .= $view->htmlElement('fieldset', "<legend></legend>\n" . $this->renderFieldset($view, $element));
         } else {
             $output .= $view->formRow($element, 'prepend', false);
             if ($element->getMessages()) {
                 $output .= "\n<div class='row'>\n<span class='cell'></span>\n";
                 $output .= $view->formElementErrors($element, array('class' => 'errors'));
                 $output .= "\n</div>";
             }
         }
         $output .= "\n";
     }
     $output .= "<div class='row'>\n";
     $output .= "<span class='cell'></span>\n";
     $output .= $view->formRow($this->get('Submit'));
     $output .= "\n</div>\n</div>\n";
     return $output;
 }
Exemplo n.º 2
0
 /** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     $output = '';
     if ($fieldset->getName() == 'Deploy') {
         foreach ($fieldset as $element) {
             // Default renderer would prepend
             $output .= $view->formRow($element, 'append') . "\n";
         }
     } else {
         $output .= parent::renderFieldset($view, $fieldset);
     }
     return $output;
 }
Exemplo n.º 3
0
 /**
  * Render a Fieldset
  *
  * @param  \Zend\Form\Fieldset $fieldset
  * @return string
  */
 public function renderFieldset(Fieldset $fieldset)
 {
     $id = $fieldset->getAttribute('id') ?: $fieldset->getName();
     $class = $fieldset->getAttribute('class');
     $label = $fieldset->getLabel();
     if (!empty($label)) {
         $label = "<legend>{$label}</legend>";
     }
     return '<fieldset id="fieldset-' . $id . '" class="' . $class . '">' . $label . $this->render($fieldset) . '</fieldset>';
 }
Exemplo n.º 4
0
 /** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     $name = $fieldset->getName();
     if ($name) {
         $default = $view->translate('Default');
         $effective = $view->translate('Effective');
         $yes = $view->translate('Yes');
         $no = $view->translate('No');
         switch ($name) {
             case 'Agent':
                 $legend = $view->translate('Agent');
                 break;
             case 'Download':
                 $legend = $view->translate('Download');
                 break;
             case 'Scan':
                 $legend = $view->translate('Network scanning');
                 break;
         }
         $output = "<div class='table'>\n";
         foreach ($fieldset as $element) {
             if ($element->getAttribute('disabled')) {
                 continue;
             }
             preg_match('/.*\\[(.*)\\]$/', $element->getName(), $matches);
             $option = $matches[1];
             if ($option == 'scanThisNetwork') {
                 $row = '';
             } else {
                 $defaultValue = $this->_object->getDefaultConfig($option);
                 if ($element instanceof Element\Checkbox) {
                     $defaultValue = $defaultValue ? $yes : $no;
                 }
                 $row = sprintf('%s: %s', $default, $defaultValue);
                 if ($this->_object instanceof \Model\Client\Client) {
                     $effectiveValue = $this->_object->getEffectiveConfig($option);
                     if ($element instanceof Element\Checkbox) {
                         $effectiveValue = $effectiveValue ? $yes : $no;
                     }
                     $row .= sprintf(', %s: %s', $effective, $effectiveValue);
                 }
                 $row = $view->escapeHtml("({$row})");
             }
             if ($element->getMessages()) {
                 $element->setAttribute('class', 'input-error');
             }
             $row = $view->htmlElement('span', $view->formElement($element) . $row, array('class' => 'values'));
             $row = $view->htmlElement('span', $view->translate($element->getLabel()), array('class' => 'label')) . $row;
             $output .= $view->htmlElement('label', $row);
             if ($element->getMessages()) {
                 $output .= $view->htmlElement('span', null, array('class' => 'cell'));
                 $output .= $view->formElementErrors($element, array('class' => 'error'));
             }
         }
         $output .= "</div>\n";
         $output = $view->htmlElement('fieldset', $view->htmlElement('legend', $legend) . $output);
     } else {
         $output = "<div class='table'>\n";
         foreach ($fieldset as $element) {
             if ($element instanceof \Zend\Form\Fieldset) {
                 $output .= $this->renderFieldset($view, $element);
             }
         }
         $output .= $view->formRow($fieldset->get('Submit'));
         $output .= "</div>\n";
     }
     return $output;
 }
Exemplo n.º 5
0
 /** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset = null)
 {
     $output = '';
     $name = $fieldset->getName();
     switch ($name) {
         case 'inspect':
             $output .= "<div class='textcenter'>\n";
             $output .= $view->formRow($fieldset->get('inspect'), 'append') . "\n";
             $output .= "</div>\n";
             break;
         case 'existing':
             $table = '';
             foreach ($this->_definedValues as $value) {
                 $id = $value['Id'];
                 $element = $fieldset->get("value_{$id}_name");
                 $row = $view->htmlElement('td', $view->formElement($element) . $view->formElementErrors($element, array('class' => 'errors')));
                 $row .= $view->htmlElement('td', $view->escapeHtml($element->getLabel()));
                 $row .= $view->htmlElement('td', $view->htmlElement('a', $view->translate('Delete'), array('href' => $view->consoleUrl('preferences', 'deleteregistryvalue', array('name' => $value['Name'])))));
                 $table .= $view->htmlElement('tr', $row);
             }
             $output .= $view->htmlElement('table', $table);
             break;
         case 'new_value':
             $output .= parent::renderFieldset($view, $fieldset);
             break;
         default:
             if ($fieldset == $this) {
                 $output .= $this->renderFieldset($view, $fieldset->get('inspect'));
                 if (count($this->_definedValues)) {
                     $output .= $view->htmlElement('h2', $view->translate('Values'));
                     $output .= $this->renderFieldset($view, $fieldset->get('existing'));
                 }
                 $output .= $view->htmlElement('h2', $view->translate('Add'));
                 $output .= $this->renderFieldset($view, $fieldset->get('new_value'));
             }
             break;
     }
     return $output;
 }
Exemplo n.º 6
0
 /** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     if ($fieldset->getName() == 'Fields') {
         // Labels (except "Category") are user defined and must not be translated.
         $fieldset->get('TAG')->setLabel($view->translate('Category'));
         $formRow = $view->plugin('FormRow');
         $translatorEnabled = $formRow->isTranslatorEnabled();
         $formRow->setTranslatorEnabled(false);
         $output = parent::renderFieldset($view, $fieldset);
         $formRow->setTranslatorEnabled($translatorEnabled);
     } else {
         $output = $this->renderFieldset($view, $this->get('Fields'));
         $output .= "<div class='table'>\n";
         $output .= "<span class='cell'></span>\n";
         $output .= $view->formSubmit($fieldset->get('Submit')) . "\n";
         $output .= "</div>\n";
     }
     return $output;
 }
Exemplo n.º 7
0
 /**
  * Render a Fieldset
  *
  * @param Zend\Form\Fieldset $fieldset
  * @return void
  */
 public function renderFieldset(Fieldset $fieldset)
 {
     $id = $fieldset->getAttribute('id') ?: $fieldset->getName();
     return '<fieldset id="fieldset-' . $id . '">' . $this->render($fieldset) . '</fieldset>';
 }
Exemplo n.º 8
0
 /**
  * @param Fieldset $fieldset
  * @param boolean  $groupActions
  *
  * @return HtmlElement
  */
 protected function renderFieldset(Fieldset $fieldset, $groupActions = false)
 {
     $fieldsetElement = new HtmlElement('fieldset');
     $id = $fieldset->getAttribute('id') ?: $fieldset->getName();
     $parent = $this->getElement();
     $fieldsetElement->addAttribute('id', $id);
     /**
      * This changes the scope of the current element,
      * so that the child elements (the ones that are about to be rendered),
      * will be set on the fieldset.
      * Then change it back again so that the fieldset will be added to the form.
      */
     $this->setElement($fieldsetElement)->renderElements($fieldset, $groupActions)->setElement($parent);
     return $fieldsetElement;
 }