/**
  * Show the page within the current culture.
  * @param sfWebRequest $request
  */
 function executeShow(sfWebRequest $request)
 {
     if (sfPlop::get('sf_plop_private_access') == true && !$this->getUser()->isAuthenticated()) {
         $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action'));
     }
     $this->page = $this->getRoute()->getObject();
     $this->forward404If(!$this->isUserAdmin && !$this->page->isPublished());
     $this->page->setCulture($this->culture);
     $this->forward404Unless($this->page);
     if ($this->page->isCategory() && !$this->isUserAdmin) {
         $this->redirect('@sf_plop_page_show?slug=' . $this->page->getFirstChild()->getSlug());
     }
     if ($this->page->isTemplate()) {
         $tplId = $this->page->getId();
         $this->pageTemplate = null;
         $this->subSlots = array();
     } else {
         if (!$this->page->getTemplate()->isTemplate() && $this->page->getTemplate()->getTemplate()->hasSlotArea()) {
             $tplId = $this->page->getTemplate()->getTemplateId();
         } else {
             $tplId = $this->page->getTemplateId();
         }
         $this->pageTemplate = sfPlopPageQuery::create()->joinWithI18n($this->culture)->findOneById($tplId);
         $this->subSlots = sfPlopSlotQuery::create()->filterByPageId($tplId != $this->page->getTemplateId() ? $this->page->getTemplateId() : $this->page->getId())->filterByIsPublished(true, $this->isUserAdmin ? Criteria::LESS_EQUAL : null)->orderByRank('asc')->groupById()->find();
     }
     $this->slots = sfPlopSlotQuery::create()->filterByPageId($tplId)->filterByIsPublished(true, $this->isUserAdmin ? Criteria::LESS_EQUAL : null)->orderByRank('asc')->groupById()->find();
     if (!$this->slots && $this->page->hasChildren()) {
         $this->redirect('@sf_plop_page_show?slug=' . $this->page->getFirstChild()->getSlug());
     } elseif (!$this->slots) {
         $this->redirect('@sf_plop_homepage');
     }
     if ($this->page->getSeoDescription()) {
         $seo_desc = $this->page->getSeoDescription();
     } else {
         $seo_desc = sfPlop::get('sf_plop_website_description');
     }
     if (sfPlop::get('sf_plop_use_title_in_seo_description') === true) {
         $this->getResponse()->addMeta('description', $seo_desc . ', ' . $this->page->getTitle(), true);
     } else {
         $this->getResponse()->addMeta('description', $seo_desc, true);
     }
     if ($this->page->getSeoKeywords()) {
         $this->getResponse()->addMeta('keywords', $this->page->getSeoKeywords(), true);
     } else {
         $this->getResponse()->addMeta('keywords', sfPlop::get('sf_plop_website_keywords'), true);
     }
     if ($this->page->getSeoTitle()) {
         $this->getResponse()->setTitle($this->page->getSeoTitle(), true);
     } elseif ($this->page->getTitle()) {
         $this->getResponse()->setTitle(sfPlop::setMetaTitle($this->page->getTitle()), true);
     }
     $this->decorate();
 }
Esempio n. 2
0
 /**
  * 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();
     }
 }
Esempio n. 3
0
 /**
  * Move the slot to another page
  * @param Integer $page_id
  */
 public function swapPage($page_id, PropelPDO $con = null)
 {
     if (!$con) {
         $con = Propel::getConnection(sfPlopSlotPeer::DATABASE_NAME);
     }
     try {
         $con->beginTransaction();
         $this->setPageId($page_id);
         $this->setRank(sfPlopSlotQuery::create()->getMaxRank($page_id, $con) + 1);
         $this->save();
         foreach ($this->getsfPlopSlotConfigs() as $config) {
             if (!$config->isDeleted()) {
                 $config->setPageId($page_id);
                 $config->save();
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
     return $this;
 }