コード例 #1
0
 public function getQuery()
 {
     // Explicit select() mandatory with orderByList
     $q = Doctrine::getTable($this->modelClass)->createQuery()->leftJoin($this->modelClass . '.Author a')->leftJoin($this->modelClass . '.Categories c')->select($this->modelClass . '.*, a.*, c.*');
     Doctrine::getTable($this->modelClass)->addPublished($q);
     if (isset($this->values['title_or_tag']) && $this->values['title_or_tag'] === 'title') {
         $this->handSelected = true;
         if (isset($this->values['blog_posts']) && count($this->values['blog_posts'])) {
             $q->andWhereIn('id', $this->values['blog_posts']);
             $q = aDoctrine::orderByList($q, $this->values['blog_posts']);
         } else {
             $q->andWhere('0 <> 0');
         }
         // Works way better when you actually return it!
         return $q;
     } else {
         if (isset($this->values['categories_list']) && count($this->values['categories_list']) > 0) {
             $q->andWhereIn('c.id', $this->values['categories_list']);
         }
         if (isset($this->values['tags_list']) && strlen($this->values['tags_list']) > 0) {
             PluginTagTable::getObjectTaggedWithQuery($q->getRootAlias(), $this->values['tags_list'], $q, array('nb_common_tags' => 1));
         }
         if (!isset($this->values['count'])) {
             $this->values['count'] = 3;
         }
         $q->limit($this->values['count']);
         $q->orderBy('published_at desc');
         return $q;
     }
 }
コード例 #2
0
 public function executeTag(sfWebRequest $request)
 {
     $p = PluginTagTable::getObjectTaggedWithQuery('peanutPosts', $request->getParameter('tag'));
     $p->andWhere('peanutPosts.status = ?', 'publish');
     $p->orderBy('peanutPosts.created_at DESC');
     $this->entries = $p->execute();
     $this->forward404Unless($this->entries);
 }
コード例 #3
0
 public function getQuery()
 {
     // Explicit select() mandatory with orderByList
     $q = Doctrine::getTable($this->modelClass)->createQuery()->leftJoin($this->modelClass . '.Author a')->leftJoin($this->modelClass . '.Categories c')->select($this->modelClass . '.*, a.*, c.*');
     Doctrine::getTable($this->modelClass)->addPublished($q);
     if (isset($this->values['title_or_tag']) && $this->values['title_or_tag'] === 'title') {
         $this->handSelected = true;
         if (isset($this->values['blog_posts']) && count($this->values['blog_posts'])) {
             $q->andWhereIn('id', $this->values['blog_posts']);
             $q = aDoctrine::orderByList($q, $this->values['blog_posts']);
         } else {
             $q->andWhere('0 <> 0');
         }
         // Works way better when you actually return it!
         return $q;
     } else {
         if (isset($this->values['categories_list']) && count($this->values['categories_list']) > 0) {
             // This doesn't cut it because we wind up not knowing about the
             // other categories of each post, which breaks our "link to best page
             // for this post" algorithm
             // $q->andWhereIn('c.id', $this->values['categories_list']);
             // This would be nice but Doctrine croaks parsing it
             // $q->andWhere($this->modelClass . '.id IN (SELECT iblog.id FROM ' . $this->modelClass . ' iblog INNER JOIN iblog.Categories ic WITH ic.id IN ?)', array($this->values['categories_list']));
             // Let's cheat and use aMysql to pull the blog item IDs that have the relevant categories in a lightweight way,
             // then do a whereIn clause. It's not ideal, but it works well in practice
             $sql = new aMysql();
             $blogItemsForCategories = $sql->queryScalar('SELECT i.id FROM a_blog_item i INNER JOIN a_blog_item_to_category ic ON i.id = ic.blog_item_id AND ic.category_id IN :category_ids', array('category_ids' => $this->values['categories_list']));
             // So we use this after all, but we'll fetch all the categories for the posts in a second pass, sigh
             $q->andWhereIn($this->modelClass . '.id', $blogItemsForCategories);
         }
         if (isset($this->values['tags_list']) && strlen($this->values['tags_list']) > 0) {
             PluginTagTable::getObjectTaggedWithQuery($q->getRootAlias(), $this->values['tags_list'], $q, array('nb_common_tags' => 1));
         }
         if (!isset($this->values['count'])) {
             $this->values['count'] = 3;
         }
         $q->limit($this->values['count']);
         $q->orderBy('published_at desc');
         return $q;
     }
 }
コード例 #4
0
 public function executeNormalView()
 {
     $this->setup();
     $this->values = $this->slot->getArrayValue();
     $q = Doctrine::getTable($this->modelClass)->createQuery()->leftJoin($this->modelClass . '.Author a')->leftJoin($this->modelClass . '.Categories c');
     Doctrine::getTable($this->modelClass)->addPublished($q);
     if (isset($this->values['categories_list']) && count($this->values['categories_list']) > 0) {
         $q->andWhereIn('c.id', $this->values['categories_list']);
     }
     if (isset($this->values['tags_list']) && strlen($this->values['tags_list']) > 0) {
         PluginTagTable::getObjectTaggedWithQuery($q->getRootAlias(), $this->values['tags_list'], $q, array('nb_common_tags' => 1));
     }
     $limit = isset($this->values['count']) ? $this->values['count'] : 5;
     $this->options['slideshowOptions']['width'] = isset($this->options['slideshowOptions']['width']) ? $this->options['slideshowOptions']['width'] : 100;
     $this->options['slideshowOptions']['height'] = isset($this->options['slideshowOptions']['height']) ? $this->options['slideshowOptions']['height'] : 100;
     $this->options['slideshowOptions']['resizeType'] = isset($this->options['slideshowOptions']['resizeType']) ? $this->options['slideshowOptions']['resizeType'] : 'c';
     $this->options['excerptLength'] = $this->getOption('excerptLength', 100);
     $this->options['maxImages'] = $this->getOption('maxImages', 1);
     aEventTable::getInstance()->addUpcoming($q, $limit);
     $this->aEvents = $q->execute();
     aBlogItemTable::populatePages($this->aEvents);
 }
コード例 #5
0
 public function filterByTag($tag, Doctrine_Query $q)
 {
     PluginTagTable::getObjectTaggedWithQuery($q->getRootAlias(), $tag, $q, array('nb_common_tag' => 1));
 }
コード例 #6
0
 public function filterByTag(Doctrine_Query $q, sfWebRequest $request)
 {
     PluginTagTable::getObjectTaggedWithQuery($q->getRootAlias(), $request->getParameter('tag'), $q, array('nb_common_tag' => 1));
 }