コード例 #1
0
 /**
  * @param type                                          $contentHandlerId
  * @param type                                          $state
  * @param \NyroDev\NyroCmsBundle\Repository\Orm\Content $specificContent
  * @param array                                         $where
  * @param array                                         $order
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getQbForHandler($contentHandlerId, $state = ContentSpec::STATE_ACTIVE, Content $specificContent = null, array $where = array(), array $order = array())
 {
     $qb = $this->createQueryBuilder('cs')->andWhere('cs.contentHandler = :chid')->setParameter('chid', $contentHandlerId);
     if ($specificContent && $specificContent->getId()) {
         $qb->andWhere('(:cid MEMBER OF cs.contents OR SIZE(cs.contents) = 0)')->setParameter('cid', $specificContent->getId());
     }
     $qb->andWhere('(cs.validStart IS NULL OR cs.validStart <= :now)')->andWhere('(cs.validEnd IS NULL OR cs.validEnd >= :now)')->setParameter('now', new \DateTime());
     if ($state) {
         $qb->andWhere('cs.state = :state')->setParameter('state', $state);
     }
     if (count($where)) {
         foreach ($where as $k => $v) {
             $operator = '=';
             if ($k[0] == '!') {
                 $operator = '<>';
                 $k = substr($k, 1);
             }
             $qb->andWhere('cs.' . $k . ' ' . $operator . ' :' . $k . '_wh')->setParameter($k . '_wh', $v);
         }
     }
     if (count($order)) {
         foreach ($order as $k => $v) {
             $qb->addOrderBy('cs.' . $k, $v);
         }
     }
     return $qb;
 }
コード例 #2
0
 public function canHaveSub(Content $content)
 {
     return $content ? $content->getLevel() < $this->getParameter('nyroCms.content.maxlevel') : true;
 }
コード例 #3
0
ファイル: Sitemap.php プロジェクト: nyroDev/NyroCmsBundle
 protected function _prepareView(Content $content, ContentSpec $handlerContent = null, $handlerAction = null)
 {
     $root = $this->getContentById($content->getRoot());
     return array('view' => 'NyroDevNyroCmsBundle:Handler:sitemap.html.php', 'vars' => array('content' => $content, 'contents' => $this->getHierarchy($root), 'isRoot' => true));
 }
コード例 #4
0
 protected function getQueryMenuOption($menuOption, \NyroDev\NyroCmsBundle\Model\Content $root = null)
 {
     $qb = $this->createQueryBuilder('c')->andWhere('c.menuOption LIKE :menuOption')->setParameter('menuOption', $menuOption);
     if ($root) {
         $qb->andWhere('c.root = :root')->setParameter('root', $root->getId());
     }
     $q = $qb->getQuery();
     $q->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     return $q;
 }
コード例 #5
0
 protected function getAllowedParams(Content $content)
 {
     $ret = array();
     if ($content->getContentHandler()) {
         $handler = $this->get('nyrocms')->getHandler($content->getContentHandler());
         $ret = $handler->getAllowedParams();
     }
     return $ret;
 }