public function executeCreateRootPage()
 {
     if (!$this->getRequestParameter('slug')) {
         throw new Exception('Attempting to create a page with no slug. Please make sure you enter a slug in the form before submitting it.');
     }
     $page = new sfSimpleCMSPage();
     $page->makeRoot();
     $page->setSlug($this->getRequestParameter('slug'));
     $page->setTemplate($this->getRequestParameter('template'));
     $page->save();
     $this->redirect('sfSimpleCMSAdmin/list?page=' . $this->getRequestParameter('page', 1));
 }
Example #2
0
 public function addsfSimpleCMSPageRelatedByTreeParent(sfSimpleCMSPage $l)
 {
     $this->collsfSimpleCMSPagesRelatedByTreeParent[] = $l;
     $l->setsfSimpleCMSPageRelatedByTreeParent($this);
 }
 public function executeCreate()
 {
     $this->forward404Unless($this->getRequest()->getMethod() == sfRequest::POST);
     $this->checkEditorCredential();
     $culture = $this->getCulture();
     $page = new sfSimpleCMSPage();
     if ($this->positionType == 'under') {
         $page->insertAsFirstChildOf($this->relative_page);
     } else {
         $page->insertAsNextSiblingOf($this->relative_page);
     }
     $page->setSlug($this->getRequestParameter('create_slug'));
     $page->setTemplate($this->getRequestParameter('template'));
     $page->save();
     $this->redirect(sfSimpleCMSTools::urlForPage($page->getSlug(), 'edit=true', $culture));
 }
Example #4
0
 public static function doSelectWithTitle(Criteria $c, $culture = null, $include_unpublished_pages = false, $con = null)
 {
     $dbMap = Propel::getDatabaseMap($c->getDbName());
     if ($con === null) {
         $con = Propel::getConnection($c->getDbName());
     }
     if ($culture === null) {
         $culture = sfContext::getInstance()->getUser()->getCulture();
     }
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     self::addSelectColumns($c);
     $startcol = self::NUM_COLUMNS - self::NUM_LAZY_LOAD_COLUMNS + 1;
     $c->addSelectColumn(sfSimpleCMSSlotPeer::VALUE);
     if (!$include_unpublished_pages) {
         $c->add(self::IS_PUBLISHED, true);
     }
     // Start of the complicated stuff
     // ------------------------------
     // big hack to have the join operate on three conditions
     $c->addJoin(sfSimpleCMSSlotPeer::PAGE_ID, sfSimpleCMSPagePeer::ID . ' AND ' . sfSimpleCMSSlotPeer::CULTURE . ' = ? AND ' . sfSimpleCMSSlotPeer::NAME . ' = \'title\'', Criteria::RIGHT_JOIN);
     // but now we need to populate the statement by hand
     $params = array();
     $sql = BasePeer::createSelectSql($c, $params);
     array_unshift($params, array('column' => sfSimpleCMSSlotPeer::CULTURE, 'table' => sfSimpleCMSSlotPeer::TABLE_NAME, 'value' => $culture));
     $stmt = $con->prepareStatement($sql);
     $stmt->setLimit($c->getLimit());
     $stmt->setOffset($c->getOffset());
     $i = 1;
     foreach ($params as $param) {
         $tableName = $param['table'];
         $columnName = $param['column'];
         $value = $param['value'];
         if ($value === null) {
             $stmt->setNull($i++);
         } else {
             $cMap = $dbMap->getTable($tableName)->getColumn($columnName);
             $setter = 'set' . CreoleTypes::getAffix($cMap->getCreoleType());
             $stmt->{$setter}($i++, $value);
         }
     }
     $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
     // ----------------------------
     // End of the complicated stuff
     /*
     // The complicated code above is there just to add a join on the three conditions 
     // It could be achieved in a simpler way with these lines
     $c->addJoin(sfSimpleCMSSlotPeer::PAGE_ID, sfSimpleCMSPagePeer::ID, Criteria::RIGHT_JOIN);
     $c->add(sfSimpleCMSSlotPeer::CULTURE, $culture);
     $c->add(sfSimpleCMSSlotPeer::NAME, 'title');
     // But then pages with no title would not be visible in menus
     // So we do it with more code and it's both safe and functional
     */
     $results = array();
     while ($rs->next()) {
         $page = new sfSimpleCMSPage();
         $page->hydrate($rs);
         //$page->setCulture($culture);
         $page->setTitle($rs->getString($startcol));
         $results[] = $page;
     }
     return $results;
 }