/**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 function render(Zikula_Form_View $view)
 {
     $result = parent::render($view);
     if ($this->editLink && !empty($this->category) && SecurityUtil::checkPermission('Categories::', "{$this->category['id']}::", ACCESS_EDIT)) {
         $url = DataUtil::formatForDisplay(ModUtil::url('Categories', 'user', 'edit', array('dr' => $this->category['id'])));
         $result .= "<a class=\"z-formnote\" href=\"{$url}\">" . __('Edit') . '</a>';
     }
     return $result;
 }
Exemple #2
0
 /**
  * Alias to Zikula_Form_Plugin_CheckboxList constructor.
  *
  * @deprecated
  * @see Zikula_Form_Plugin_CheckboxList::__construct()
  */
 public function __construct(&$render, &$params)
 {
     parent::__construct($render, $params);
     LogUtil::log(__f('Warning! Class %1$s is deprecated. Please use %2$s instead.', array(__CLASS__, 'Zikula_Form_Plugin_CheckboxList')), E_USER_DEPRECATED);
 }
 /**
  * Load values.
  *
  * Called internally by the plugin itself to load values from the render.
  * Can also by called when some one is calling the render object's Zikula_Form_View::setValues.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View render object.
  * @param array            &$values Values to load.
  *
  * @return void
  */
 public function loadValue(Zikula_Form_View $view, &$values)
 {
     if ($this->enableDBUtil && $this->dataBased) {
         $items = null;
         $value = null;
         if ($this->group == null) {
             if ($this->dataField != null && isset($values['__CATEGORIES__'][$this->dataField])) {
                 $value = $values['__CATEGORIES__'][$this->dataField];
             }
             if ($this->itemsDataField != null && isset($values[$this->itemsDataField])) {
                 $items = $values[$this->itemsDataField];
             }
         } else {
             if (isset($values[$this->group])) {
                 $data = $values[$this->group];
                 if (isset($data['__CATEGORIES__'][$this->dataField])) {
                     $value = $data['__CATEGORIES__'][$this->dataField];
                     if ($this->itemsDataField != null && isset($data[$this->itemsDataField])) {
                         $items = $data[$this->itemsDataField];
                     }
                 }
             }
         }
         if ($items != null) {
             $this->setItems($items);
         }
         $this->setSelectedValue($value);
     } elseif ($this->enableDoctrine && $this->dataBased) {
         $items = null;
         $value = null;
         if ($this->group == null) {
             if ($this->dataField != null && isset($values['Categories'][$this->dataField])) {
                 $value = $values['Categories'][$this->dataField]['category_id'];
             }
             if ($this->itemsDataField != null && isset($values[$this->itemsDataField])) {
                 $items = $values[$this->itemsDataField];
             }
         } else {
             if (isset($values[$this->group])) {
                 $data = $values[$this->group];
                 if (isset($data['Categories'][$this->dataField])) {
                     $value = $data['Categories'][$this->dataField]['category_id'];
                     if ($this->itemsDataField != null && isset($data[$this->itemsDataField])) {
                         $items = $data[$this->itemsDataField];
                     }
                 }
             }
         }
         if ($items != null) {
             $this->setItems($items);
         }
         $this->setSelectedValue($value);
     } elseif ($this->doctrine2) {
         if (isset($values[$this->group])) {
             $entity = $values[$this->group];
             if (isset($entity[$this->dataField])) {
                 $collection = $entity[$this->dataField];
                 $selectedValues = array();
                 foreach ($collection as $c) {
                     $categoryId = $c->getCategoryRegistryId();
                     if ($categoryId == $this->registryId) {
                         $selectedValues[$c->getCategory()->getId()] = $c->getCategory()->getId();
                     }
                 }
                 $this->setSelectedValue($selectedValues);
             }
         }
     } else {
         parent::loadValue($view, $values);
     }
 }