/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset) { $output = ''; if ($fieldset->has('Groups')) { $groups = $fieldset->get('Groups'); if ($groups->count()) { $output = "<div>\n"; foreach ($groups as $element) { if ($element instanceof \Zend\Form\Element\Radio) { $label = $view->htmlElement('a', $view->escapeHtml($element->getLabel()), array('href' => $view->consoleUrl('group', 'general', array('name' => $element->getLabel())))); $output .= $view->htmlElement('fieldset', "<legend>{$label}</legend>\n" . $view->formRadio($element)); } } $output .= $view->formRow($fieldset->get('Submit')); $output .= "\n</div>\n"; } } return $output; }
/** {@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; }
/** {@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; }
/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset) { $headers = array('Id' => 'ID', 'Name' => $view->translate('Name'), 'NetworkInterface.MacAddress' => $view->translate('MAC address'), 'Serial' => $view->translate('Serial number'), 'AssetTag' => $view->translate('Asset tag'), 'LastContactDate' => $view->translate('Last contact')); $renderCriteria = function ($view, $client, $property) { $value = $client[$property]; if ($value === null) { // NULL values are never considered for duplicates and cannot be blacklisted. return; } if ($property == 'NetworkInterface.MacAddress') { $property = 'MacAddress'; } // Hyperlink to blacklist form return $view->htmlElement('a', $view->escapeHtml($value), array('href' => $view->consoleUrl('duplicates', 'allow', array('criteria' => $property, 'value' => $value))), true); }; $renderCallbacks = array('Id' => function ($view, $client) { // Display ID and a checkbox. Render checkbox manually because // ZF's MultiCheckbox element does not handle duplicate values. // $_POST['clients'] will become an array of selected // (possibly duplicate) IDs. return sprintf('<input type="checkbox" name="clients[]" value="%d">%d', $client['Id'], $client['Id']); }, 'Name' => function ($view, $client) { // Hyperlink to "customfields" page of given client. // This allows for easy review of the information about to be merged. return $view->htmlElement('a', $view->escapeHtml($client['Name']), array('href' => $view->consoleUrl('client', 'customfields', array('id' => $client['Id']))), true); }, 'NetworkInterface.MacAddress' => $renderCriteria, 'Serial' => $renderCriteria, 'AssetTag' => $renderCriteria); $formContent = $view->table($this->getOption('clients'), $headers, array('order' => $this->getOption('order'), 'direction' => $this->getOption('direction')), $renderCallbacks); $formContent .= "<div>\n"; foreach ($this as $element) { $formContent .= $view->formRow($element, 'append') . "\n"; } $formContent .= "</div>\n"; return $formContent; }
/** * Render all elements from a fieldset * * This method iterates over all elements from the given fieldset and * renders them in a way appropriate for each element type. Subclasses with * more specialized rendering may extend or replace this method. * * @param \Zend\View\Renderer\PhpRenderer $view * @param \Zend\Form\Fieldset $fieldset * @return string HTML code */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset) { $output = '<div class="table">'; foreach ($fieldset as $element) { $row = ''; if ($element instanceof \Zend\Form\Element\Submit) { $row .= "<span class='cell'></span>\n"; $row .= $view->formSubmit($element); } elseif ($element instanceof \Zend\Form\Fieldset) { $row .= $view->htmlElement('span', $view->translate($element->getLabel()), array('class' => 'label'), true) . "\n"; $row .= $view->htmlElement('fieldset', "<legend></legend>\n" . $this->renderFieldset($view, $element)); } elseif (!$element instanceof \Zend\Form\Element\Csrf) { $row .= $view->formRow($element, 'prepend', false); if ((string) $element->getLabel() == '') { $row = "<div class='row'>\n<span class='label'></span>\n{$row}\n</div>"; } if ($element->getMessages()) { $row .= "\n<span class='cell'></span>\n"; $row .= $view->formElementErrors($element, array('class' => 'errors')); } if ($element->hasAttribute('id')) { // The FormRow helper renders the label differently: It // precedes the element instead of encapsulating it. // Add a div wrapper to achieve the same appearance. $row = "<div class='row'>\n{$row}\n</div>"; } } $output .= $row . "\n"; } $output .= "</div>\n"; return $output; }
/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset = null) { $output = "<div class='table'>\n"; $types = $this->get('Types'); foreach ($this->_definedTypes as $name => $count) { $element = $types->get($name); if ($element->getMessages()) { $element->setAttribute('class', 'input-error'); } $row = $view->formText($element); if ($count == 0) { $row .= $view->htmlElement('a', $view->translate('Delete'), array('href' => $view->consoleUrl('preferences', 'deletedevicetype', array('name' => $name))), true); } $output .= $view->htmlElement('div', $row); $output .= $view->formElementErrors($element, array('class' => 'error')); $output .= "\n"; } $add = $this->get('Add'); $output .= $view->formRow($add, null, false); $output .= $view->formElementErrors($add, array('class' => 'error')); $output .= $view->formRow($this->get('Submit')); $output .= "\n</div>\n"; return $output; }
/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset) { $output = $view->htmlElement('div', $view->formRow($fieldset->get('DeleteInterfaces'), 'append')); $output .= $view->htmlElement('div', $view->formRow($fieldset->get('yes')) . $view->formRow($fieldset->get('no'))); return $output; }
/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset = null) { $output = "<div class='table'>\n"; $fields = $this->get('Fields'); foreach ($this->_definedFields as $name => $type) { $element = $fields->get($name); if ($element->getMessages()) { $element->setAttribute('class', 'input-error'); } $row = $view->formText($element) . "\n"; $row .= $view->htmlElement('span', $view->translate($type), array('class' => 'cell')); $row .= $view->htmlElement('span', $view->htmlElement('a', $view->translate('Delete'), array('href' => $view->consoleUrl('preferences', 'deletefield', array('name' => $name))), true), array('class' => 'cell')); $output .= $view->htmlElement('div', $row, array('class' => 'row')); $output .= $view->formElementErrors($element, array('class' => 'error')); $output .= "\n"; } $newName = $this->get('NewName'); $output .= $view->htmlElement('div', $view->formRow($newName, null, false) . $view->formRow($this->get('NewType')), array('class' => 'row')); $output .= $view->formElementErrors($newName, array('class' => 'error')); $output .= $view->formRow($this->get('Submit')); $output .= "\n</div>\n"; return $output; }