本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}