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


PHP Zikula_Form_View::get_template_vars方法代码示例

本文整理汇总了PHP中Zikula_Form_View::get_template_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_Form_View::get_template_vars方法的具体用法?PHP Zikula_Form_View::get_template_vars怎么用?PHP Zikula_Form_View::get_template_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zikula_Form_View的用法示例。


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

示例1: saveValue

 /**
  * Saves value in data object.
  *
  * Called by the render when doing $render->getValues()
  * Uses the group parameter to decide where to store data.
  *
  * @param Zikula_Form_View $view  Reference to Form render object.
  * @param array            &$data Data object.
  *
  * @return void
  */
 public function saveValue(Zikula_Form_View $view, &$data)
 {
     if ($this->enableDBUtil && $this->dataBased) {
         if ($this->group == null) {
             $data['__CATEGORIES__'][$this->dataField] = $this->getSelectedValue();
         } else {
             if (!array_key_exists($this->group, $data)) {
                 $data[$this->group] = array();
             }
             $data[$this->group]['__CATEGORIES__'][$this->dataField] = $this->getSelectedValue();
         }
     } else {
         if ($this->enableDoctrine && $this->dataBased) {
             if ($this->group == null) {
                 $data['Categories'][$this->dataField] = array('category_id' => $this->getSelectedValue(), 'reg_property' => $this->dataField);
             } else {
                 if (!array_key_exists($this->group, $data)) {
                     $data[$this->group] = array();
                 }
                 $data[$this->group]['Categories'][$this->dataField] = array('category_id' => $this->getSelectedValue(), 'reg_property' => $this->dataField);
             }
         } else {
             if ($this->doctrine2) {
                 $entity = $view->get_template_vars($this->group);
                 // load category from db
                 $em = ServiceUtil::getService('doctrine.entitymanager');
                 $collection = $em->getClassMetadata(get_class($entity))->getFieldValue($entity, $this->dataField);
                 if (!$collection) {
                     $collection = new \Doctrine\Common\Collections\ArrayCollection();
                     $em->getClassMetadata(get_class($entity))->setFieldValue($entity, $this->dataField, $collection);
                 }
                 if (is_array($this->getSelectedValue())) {
                     $selectedValues = $this->getSelectedValue();
                 } else {
                     $selectedValues[] = $this->getSelectedValue();
                 }
                 $selectedValues = array_combine($selectedValues, $selectedValues);
                 foreach ($collection->getKeys() as $key) {
                     $entityCategory = $collection->get($key);
                     if ($entityCategory->getCategoryRegistryId() == $this->registryId) {
                         $categoryId = $entityCategory->getCategory()->getId();
                         if (isset($selectedValues[$categoryId])) {
                             unset($selectedValues[$categoryId]);
                         } else {
                             $collection->remove($key);
                         }
                     }
                 }
                 // we do NOT flush here, as the calling module is responsible for that (Guite)
                 //$em->flush();
                 foreach ($selectedValues as $selectedValue) {
                     $category = $em->find('Zikula_Doctrine2_Entity_Category', $selectedValue);
                     $class = $em->getClassMetadata(get_class($entity))->getAssociationTargetClass($this->dataField);
                     $collection->add(new $class($this->registryId, $category, $entity));
                 }
             } else {
                 parent::saveValue($view, $data);
             }
         }
     }
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:72,代码来源:CategorySelector.php

示例2: saveValue

 /**
  * Saves value in data object.
  *
  * Called by the render when doing $render->getValues()
  * Uses the group parameter to decide where to store data.
  *
  * @param Zikula_Form_View $view  Reference to Form render object.
  * @param array            &$data Data object.
  *
  * @return void
  */
 function saveValue(Zikula_Form_View $view, &$data)
 {
     if ($this->enableDBUtil && $this->dataBased) {
         if ($this->group == null) {
             $data['__CATEGORIES__'][$this->dataField] = $this->getSelectedValue();
         } else {
             if (!array_key_exists($this->group, $data)) {
                 $data[$this->group] = array();
             }
             $data[$this->group]['__CATEGORIES__'][$this->dataField] = $this->getSelectedValue();
         }
     } else {
         if ($this->enableDoctrine && $this->dataBased) {
             if ($this->group == null) {
                 $data['Categories'][$this->dataField] = array('category_id' => $this->getSelectedValue(), 'reg_property' => $this->dataField);
             } else {
                 if (!array_key_exists($this->group, $data)) {
                     $data[$this->group] = array();
                 }
                 $data[$this->group]['Categories'][$this->dataField] = array('category_id' => $this->getSelectedValue(), 'reg_property' => $this->dataField);
             }
         } else {
             if ($this->doctrine2) {
                 $entity = $view->get_template_vars($this->group);
                 // load category from db
                 $em = ServiceUtil::get('doctrine')->getEntityManager();
                 $category = $em->find('Zikula_Doctrine2_Entity_Category', $this->getSelectedValue());
                 $collection = $em->getClassMetadata(get_class($entity))->getFieldValue($entity, $this->dataField);
                 if (!$collection) {
                     $collection = new \Doctrine\Common\Collections\ArrayCollection();
                     $em->getClassMetadata(get_class($entity))->setFieldValue($entity, $this->dataField, $collection);
                 }
                 if ($collection->containsKey($this->registryId)) {
                     $collection->get($this->registryId)->setCategory($category);
                 } else {
                     $class = $em->getClassMetadata(get_class($entity))->getAssociationTargetClass($this->dataField);
                     $collection->set($this->registryId, new $class($this->registryId, $category, $entity));
                 }
             } else {
                 parent::saveValue($view, $data);
             }
         }
     }
 }
开发者ID:planetenkiller,项目名称:core,代码行数:55,代码来源:CategorySelector.php

示例3: preprocessIdentifiers

 /**
  * Pre-process relationship identifiers.
  *
  * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
  * @param array            &$params Parameters passed from the Smarty plugin function.
  *
  * @return void
  */
 protected function preprocessIdentifiers(Zikula_Form_View $view, &$params)
 {
     $entityData = isset($params['linkingItem']) ? $params['linkingItem'] : $view->get_template_vars('linkingItem');
     $alias = $this->id;
     $itemIds = array();
     $many = $this->selectionMode == 'multiple';
     if (isset($entityData[$alias])) {
         $relatedItems = $entityData[$alias];
         if (is_array($relatedItems) || is_object($relatedItems)) {
             if ($many) {
                 foreach ($relatedItems as $relatedItem) {
                     $itemIds[] = $this->createItemIdentifier($relatedItem);
                 }
             } else {
                 $itemIds[] = $this->createItemIdentifier($relatedItems);
             }
         }
         $this->preselectedItems = $relatedItems;
     }
     if (count($itemIds) > 0) {
         if ($this->selectionMode != 'multiple') {
             $entityData[$alias] = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $alias, 'id' => $itemIds[0]));
         } else {
             $entityData[$alias] = ModUtil::apiFunc($this->name, 'selection', 'getEntities', array('ot' => $alias, 'idList' => $itemIds));
         }
     }
     $view->assign('linkingItem', $entityData);
 }
开发者ID:robbrandt,项目名称:MUVideo,代码行数:36,代码来源:AbstractObjectSelector.php


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