/**
  * Output for viewing rols
  *
  * @param array $privileges
  * @return \MUtil_Html_ListElement
  */
 public function formatPrivileges(array $privileges)
 {
     if (count($privileges)) {
         $output = \MUtil_Html_ListElement::ul();
         $privileges = array_combine($privileges, $privileges);
         $output->class = 'allowed';
         foreach ($this->getUsedPrivileges() as $privilege => $description) {
             if (isset($privileges[$privilege])) {
                 $output->li()->raw($description);
             }
         }
         if (count($output)) {
             return $output;
         }
     }
     return \MUtil_Html::create('em', $this->_('No privileges found.'));
 }
예제 #2
0
 /**
  * Apply this element to the form as the output decorator.
  *
  * @param \Zend_Form $form
  * @param mixed $width The style.width content for the labels
  * @param array $order The display order of the elements
  * @param string $errorClass Class name to display all errors in
  * @return \MUtil_Html_DlElement
  */
 public function setAsFormLayout(\Zend_Form $form, $width = null, $order = array('label', 'element', 'description'), $errorClass = 'errors')
 {
     $this->_repeatTags = true;
     $prependErrors = $errorClass;
     // Make a Lazy repeater for the form elements and set it as the element repeater
     $formrep = new \MUtil_Lazy_RepeatableFormElements($form);
     $formrep->setSplitHidden(true);
     // These are treated separately
     $this->setRepeater($formrep);
     if (null === $width) {
         $attr = array();
     } else {
         $attr['style'] = array('display' => 'inline-block', 'width' => $width);
     }
     // Place the choosen renderers
     foreach ($order as $renderer) {
         switch ($renderer) {
             case 'label':
                 $this->label($formrep->element, $attr);
                 // Set label with optional width
                 break;
             case 'error':
                 $prependErrors = false;
                 // Intentional fall through
             // Intentional fall through
             default:
                 $this->append($formrep->{$renderer});
         }
     }
     // Set this element as the form decorator
     $decorator = new \MUtil_Html_ElementDecorator();
     $decorator->setHtmlElement($this);
     $decorator->setPrologue($formrep);
     // Renders hidden elements before this element
     if ($prependErrors) {
         $decorator->setPrependErrors(\MUtil_Html_ListElement::ul(array('class' => $errorClass, 'style' => array('margin-left' => $width))));
     }
     $form->setDecorators(array($decorator, 'AutoFocus', 'Form'));
     return $this;
 }
 public function toUl($actionController = null)
 {
     if ($this->isVisible() && $this->hasChildren()) {
         $parameterSources = func_get_args();
         $ul = \MUtil_Html_ListElement::ul();
         foreach ($this->getChildren() as $menuItem) {
             if ($li = $menuItem->_toLi(new \Gems_Menu_ParameterCollector($parameterSources))) {
                 $ul->append($li);
             }
         }
         if (count($ul)) {
             return $ul;
         }
     }
 }