protected function getParams($slot, $settings) { $pages_ids = array(); $q = sfPlopPageQuery::create()->filterByTreeLevel($slot->getPage()->getLevel() + 1); $pages = $slot->getPage()->getBranch($q); foreach ($pages as $page) { $pages_ids[] = $page->getId(); } $slotConfigs = sfPlopSlotConfigQuery::create()->innerJoinsfPlopSlot()->filterByPageId($pages_ids)->usesfPlopPageQuery()->orderByTreeLeft()->endUse()->find(); foreach ($slotConfigs as $i => $slotConfig) { if (!$slotConfig->getTemplate() != 'AssetGallery' && !$slotConfig->getSlot()->ispublished()) { unset($slotConfigs[$i]); } } return array('slotConfigs' => $slotConfigs); }
/** * Retrieve a slot config by his page, his slot and his culture. * @param sfPlopPage $page * @param sfPlopSlot $slot * @param String $culture * @param Boolean $createIfEmpty * @return BaseObject */ public static function getOneByPageSlotAndCulture(sfPlopPage $page, sfPlopSlot $slot, $culture = null, $createIfEmpty = false) { $obj = sfPlopSlotConfigQuery::create()->joinWithsfPlopSlot()->filterBysfPlopSlot($slot)->filterBysfPlopPage($page)->findOne(); if ($obj) { $obj->setCulture($culture); } elseif (!$obj && $createIfEmpty) { $obj = new sfPlopSlotConfig(); $obj->setPageId($page->getId()); $obj->setSlotId($slot->getId()); $obj->setCulture($culture); $obj->setValue($slot->getValue($culture)); $obj->setOptions($slot->getOptions($culture)); $obj->save(); } return $obj; }
public function getChoices() { $page_filters_ids = array(); $page = sfPlopPagePeer::retrieveByPK($this->getOption('page_id)')); $q = sfPlopPageQuery::create()->filterByTreeLevel($page->getLevel() + 1); $page_filters = $page->getBranch($q); foreach ($page_filters as $page_filter) { $page_filters_ids[] = $page_filter->getId(); } $filters = sfPlopSlotConfigQuery::create()->innerJoinsfPlopSlot()->filterByPageId($page_filters_ids)->find(); foreach ($filters as $i => $filter) { if (!$filter->getTemplate() != 'GoogleMapsFilter' && !$filter->getSlot()->ispublished()) { unset($filters[$i]); } } $options_for_filter = array('' => ''); foreach ($filters as $filter_object) { $options_for_filter[$filter_object->getValue($this->getOption('page_culture)'))] = $filter_object->getValue($this->getOption('page_culture)')); } $this->setOption('choices', array_keys($options_for_filter)); return parent::getChoices(); }
/** * Delete all the unused template slot configs * @param Integer $tpl_id The template page to retrieve slots */ public function deleteUnusedInheritedSlotConfigs($tpl_id) { if (!$tpl_id) { return; } $slot_ids = array(); $slots = sfPlopSlotQuery::create()->filterByPageId($tpl_id)->filterByTemplate('Area', Criteria::NOT_EQUAL)->find(); foreach ($slots as $slot) { $slot_ids[] = $slot->getId(); } $page_ids = array($this->getId()); $pages = sfPlopPageQuery::create()->filterByTemplateId($this->getId())->find(); foreach ($pages as $page) { $page_ids[] = $page->getId(); } $slot_configs = sfPlopSlotConfigQuery::create()->filterByPageId($page_ids)->filterBySlotId($slot_ids)->find(); foreach ($slot_configs as $sc) { $sc->delete(); } }
/** * Returns the I18N options of the slot config. * @param String $culture * @param PropelPDO $con * @return String */ public function getOptions($culture = null, PropelPDO $con = null) { if (!$this->hasConfig(null, $con)) { return $this->getTemplateObject()->getDefaultOptions(); } $config = sfPlopSlotConfigQuery::create()->joinWithI18n($culture)->filterByPageId($this->getPageId())->filterBySlotId($this->getId())->findOne(); if ($config) { return $config->getOptions(); } }