コード例 #1
0
 public function execute()
 {
     $tag_name = waRequest::get('tag');
     $tag_name = urldecode($tag_name);
     $tag_model = new photosTagModel();
     $tag = $tag_model->getByName($tag_name);
     $title = _w('Tag not found');
     $photos = array();
     $config = $this->getConfig();
     if ($tag) {
         $hash = '/tag/' . $tag_name;
         $collection = new photosCollection($hash);
         $count = $config->getOption('photos_per_page');
         $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, $count);
         $photos = photosCollection::extendPhotos($photos);
         $title = $collection->getTitle();
         $this->view->assign('frontend_link', photosCollection::getFrontendLink($hash));
         $this->view->assign('total_count', $collection->count());
     }
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
     $this->view->assign('title', $title);
     $this->view->assign('photos', $photos);
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('sort_method', 'upload_datetime');
     $this->template = 'templates/actions/photo/PhotoList.html';
 }
コード例 #2
0
 protected function tagPrepareIntersection($tag_names)
 {
     $tag_model = new photosTagModel();
     $in = array();
     $title = array();
     foreach (explode(',', $tag_names) as $tag_name) {
         $tag = $tag_model->getByName($tag_name);
         if ($tag) {
             $in[] = (int) $tag['id'];
             $title[] = $tag['name'];
         }
     }
     if (!$in) {
         $this->where[] = "0";
     } else {
         $sql = "SELECT photo_id, COUNT(tag_id) cnt FROM `photos_photo_tags` \n                WHERE tag_id IN (" . implode(',', $in) . ")\n                GROUP BY photo_id\n                HAVING cnt = " . count($in);
         $photo_id = array_keys($tag_model->query($sql)->fetchAll('photo_id'));
         if ($photo_id) {
             $this->where[] = "p.id IN (" . implode(',', $photo_id) . ")";
             $this->addTitle(sprintf(_w('Tagged “%s”'), implode(',', $title)));
         } else {
             $this->where[] = "0";
         }
     }
 }
コード例 #3
0
 protected function tagPrepare($id, $auto_title = true)
 {
     $tag_model = new photosTagModel();
     $tag = false;
     if (is_numeric($id)) {
         $tag = $tag_model->getById($id);
     }
     if (!$tag) {
         $tag = $tag_model->getByName($id);
         $id = $tag['id'];
     }
     $this->joins['tags'] = array('table' => 'photos_photo_tags', 'alias' => 'pt');
     $this->where[] = "pt.tag_id = " . (int) $id;
     $this->addTitle(sprintf(_w('Tagged “%s”'), $tag['name']));
 }