コード例 #1
0
 protected function getParams($slot, $settings)
 {
     $page = $settings['page'];
     $relative_slug = $slot->getOption('relative_page', null, $settings['culture']);
     if ($relative_slug === null) {
         $relative_page = $page->isRoot() ? $page : sfPlopPageQuery::create()->findRoot();
     } elseif ($page->getSlug() == $relative_slug) {
         $relative_page = $page;
     } else {
         $relative_page = sfPlopPagePeer::retrieveBySlug($relative_slug);
     }
     if (!$relative_page) {
         $relative_page = $page->isRoot() ? $page : sfPlopPageQuery::create()->findRoot();
     }
     $level_depth = $slot->getOption('level_depth', null, $settings['culture']);
     if (isset($level_depth)) {
         $q = sfPlopPageQuery::create()->addCond('cond1', sfPlopPagePeer::TREE_LEVEL, $relative_page->getLevel() + $level_depth, Criteria::LESS_EQUAL)->addCond('cond2', sfPlopPagePeer::TREE_LEVEL, null, Criteria::ISNULL)->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR);
     } else {
         $q = sfPlopPageQuery::create();
     }
     $level1_nodes = $relative_page->getDescendants($q);
     $useAjax = sfPlop::get('sf_plop_use_ajax') === true ? true : false;
     $displays = $slot->getOption('displays', array(), $settings['culture']);
     $use_icon = in_array('icon', $displays) ? true : false;
     $use_subtitle = in_array('subtitle', $displays) ? true : false;
     $use_title = in_array('title', $displays) || !$use_icon && !$use_subtitle ? true : false;
     return array('relative_level' => $relative_page->getLevel() + 1, 'relative_page' => $relative_page, 'level_depth' => $level_depth, 'show_hidden_parent' => false, 'level1_nodes' => $level1_nodes, 'useAjax' => $useAjax, 'displays' => $displays, 'use_icon' => $use_icon, 'use_subtitle' => $use_subtitle, 'use_title' => $use_title, 'menu_class' => 'w-menu');
 }
コード例 #2
0
 public function getChoices()
 {
     $slugs = sfPlopPagePeer::getPageSlugsWithLevel();
     if (isset($this->options['add_empty'])) {
         $slugs = array('' => '') + $slugs;
     }
     return $slugs;
 }
コード例 #3
0
 public function configure()
 {
     parent::configure();
     unset($this['layout'], $this['template'], $this['is_editable'], $this['sortable_rank'], $this['created_at'], $this['updated_at']);
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('plopAdmin');
     $this->widgetSchema['page_id'] = new sfWidgetFormChoice(array('choices' => sfPlopPagePeer::getPagesWithLevel(true)));
     $this->validatorSchema['page_id'] = new sfValidatorChoice(array('choices' => array_keys(sfPlopPagePeer::getPagesWithLevel(true)), 'required' => false));
     if ($this->getOption('page_id')) {
         $this->widgetSchema['page_id']->setDefault($this->getOption('page_id'));
     }
     $this->widgetSchema['is_published']->setLabel('Is published ?');
 }
コード例 #4
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $slug The slug to find
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveBySlug($slug = null, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(sfPlopPagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $obj = null;
     if ($slug) {
         $criteria = new Criteria(sfPlopPagePeer::DATABASE_NAME);
         $criteria->add(sfPlopPagePeer::SLUG, $slug);
         $obj = sfPlopPagePeer::doSelectOne($criteria, $con);
     }
     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();
 }
コード例 #6
0
ファイル: sfPlopPage.php プロジェクト: noreiller/sfPlopPlugin
 /**
  * Override the doSave function to do some custom tweaks.
  * @param PropelPDO $con
  */
 protected function doSave(PropelPDO $con)
 {
     if ($this->isColumnModified(sfPlopPagePeer::TEMPLATE_ID)) {
         $tpl = sfPlopPagePeer::retrieveByPK($this->getTemplateId());
         if ($tpl && $tpl->getTemplateId()) {
             $tplTpl = sfPlopPagePeer::retrieveByPK($tpl->getTemplateId());
             if ($tplTpl && $tplTpl->hasSlotArea()) {
                 $this->setTemplateId($tpl->getId());
             }
         } elseif (!$tpl) {
             $this->setTemplateId(null);
         }
         if (!$this->isSlotable()) {
             $this->deleteOwnSlots();
         }
         $this->getPeer()->removeInstanceFromPool($this);
         $oldTemplate = $this->getPeer()->retrieveByPK($this->getId());
         if ($oldTemplate) {
             $oldTemplateId = $oldTemplate->getTemplateId();
         }
         if ($oldTemplateId != $this->getTemplateId()) {
             $this->deleteUnusedInheritedSlotConfigs($oldTemplateId);
         }
     }
     return parent::doSave($con);
 }
コード例 #7
0
 protected function doSave($con = null)
 {
     $values = $this->values;
     if (isset($values['position']) && $values['position'] != '') {
         $relative_page = sfPlopPagePeer::retrieveByPk($values['position_relative']);
         if (in_array($values['position'], array('first_child', 'last_child'))) {
             if ($this->getObject()->isNew() && $values['position'] == 'first_child') {
                 $this->getObject()->insertAsFirstChildOf($relative_page);
             } elseif ($values['position'] == 'first_child') {
                 $this->getObject()->moveToFirstChildOf($relative_page);
             } elseif ($this->getObject()->isNew()) {
                 $this->getObject()->insertAsLastChildOf($relative_page);
             } else {
                 $this->getObject()->moveToLastChildOf($relative_page);
             }
         } elseif (in_array($values['position'], array('previous_sibling', 'next_sibling')) && ($relative_page && !$relative_page->isRoot())) {
             if ($this->getObject()->isNew() && $values['position'] == 'previous_sibling') {
                 $this->getObject()->insertAsPrevSiblingOf($relative_page);
             } elseif ($values['position'] == 'previous_sibling') {
                 $this->getObject()->moveToPrevSiblingOf($relative_page);
             } elseif ($this->getObject()->isNew()) {
                 $this->getObject()->insertAsNextSiblingOf($relative_page);
             } else {
                 $this->getObject()->moveToNextSiblingOf($relative_page);
             }
         }
     } elseif ($this->getObject()->isNew()) {
         if ($this->getOption('page_ref') && $this->getOption('page_ref') instanceof sfPlopPage) {
             $this->getObject()->insertAsNextSiblingOf($this->getOption('page_ref'));
         } else {
             $this->getObject()->insertAsLastChildOf(sfPlopPagePeer::retrieveRoot());
         }
     }
     parent::doSave($con);
     if ($this->getOption('page_ref') instanceof sfPlopPage) {
         $this->getObject()->copySlotsFrom($this->getOption('page_ref'));
     }
     if (isset($values[$this->getObject()->getCulture()]) && $values[$this->getObject()->getCulture()]['title'] == '') {
         $this->getObject()->setCulture($values[$this->getObject()->getCulture()]['locale']);
         $this->getObject()->setTitle('Page');
         $this->getObject()->save();
     }
 }
コード例 #8
0
 public function getValidators($slot)
 {
     return array('hide_root' => new sfValidatorBoolean(), 'displays' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys(sfPlop::get('sf_plop_menu_items')), 'multiple' => true)), 'level_depth' => new sfValidatorInteger(array('required' => false, 'min' => 1, 'max' => sfPlopPagePeer::getMaxLevel())));
 }