Example #1
0
    protected function loadData()
    {
        $tag_list = new PinholeTagList($this->app, $this->tag->name, true);
        $photos = $tag_list->getPhotos();
        $order_array = array();
        $class_name = SwatDBClassMap::get('PinholeImageSet');
        $set = new $class_name();
        $set->setDatabase($this->app->db);
        $set->instance = $this->app->getInstance();
        $set->loadByShortname('photos');
        $thumb = $set->getDimensionByShortname('thumb');
        foreach ($photos as $photo) {
            $image = new SwatImageDisplay();
            $image->image = $photo->getUri('thumb', '../');
            $image->width = $photo->getWidth('thumb');
            $image->height = $photo->getHeight('thumb');
            $image->occupy_width = $thumb->max_width;
            $image->occupy_height = $thumb->max_height;
            ob_start();
            $image->display();
            $order_array[$photo->id] = ob_get_clean();
        }
        $order_widget = $this->ui->getWidget('order');
        $order_widget->width = '580px';
        $order_widget->height = '400px';
        $order_widget->addOptionsByArray($order_array, 'text/xml');
        $sql = sprintf('select sum(displayorder) from PinholePhotoTagBinding
			where tag = %s', $this->app->db->quote($this->tag->id, 'integer'));
        $sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
        $options_list = $this->ui->getWidget('options');
        $options_list->value = $sum == 0 ? 'auto' : 'custom';
    }
Example #2
0
 protected function displayContent()
 {
     $cache_module = isset($this->app->memcache) ? $this->app->memcache : null;
     $tag_list = new PinholeTagList($this->app, null, $this->app->session->isLoggedIn());
     if ($tag_list->getGeoTaggedPhotoCount() == 0) {
         echo Pinhole::_('There are no tags with geo-tagged data.');
     } else {
         $locale = SwatI18NLocale::get();
         echo sprintf(Pinhole::_('%s photos can be %sviewed on a map%s.'), $locale->formatNumber($tag_list->getGeoTaggedPhotoCount()), '<a href="' . $this->app->config->pinhole->path . 'map' . '">', '</a>');
         $map = new PinholeStaticMapView();
         $map->setTagList($tag_list);
         $map->api_key = $this->app->config->pinhole->google_maps_api_key;
         $map->width = 250;
         $map->height = 150;
         $map->base = $this->app->config->pinhole->path . 'map';
         $map->display();
     }
 }
 /**
  * Displays date.date tags for all the photos in the site instance of
  * this date tag browser's tag list
  *
  * The <i>$start_date</i> and <i>$end_date</i> are used to tell which
  * day, month and year are currently selected.
  *
  * @param SwatDate $start_date the start date of the photos in this date
  *                              tag browser's tag list.
  * @param SwatDate $end_date the end date of the photos in this date
  *                              tag browser's tag list.
  */
 protected function displayDays(SwatDate $start_date, SwatDate $end_date)
 {
     $date = new SwatDate();
     /*
      * Setting the month and year to the $start_date month and year makes
      * sense because the day list is only displayed if the start year and
      * month are the same as the end year and month.
      */
     $date->setMonth($start_date->getMonth());
     $date->setYear($start_date->getYear());
     // get selected day if it exists
     if ($start_date->getDay() == $end_date->getDay()) {
         $selected_day = $start_date->getDay();
     } else {
         $selected_day = null;
     }
     // create base tag list that new date.month tags will be added to
     $tag_list = $this->tag_list->filter(array('PinholeDateTag'));
     $tag_list->add(sprintf('date.year=%s', $date->formatLikeIntl('yyyy')));
     $tag_list->add(sprintf('date.month=%s', $date->formatLikeIntl('MM')));
     $photos = $tag_list->getPhotoCountByDate('day');
     // Filter again since the day list uses date.date tags instead of
     // combined date.year, date.month and date.day tags.
     $tag_list = $this->tag_list->filter(array('PinholeDateTag'));
     // display date.date tags for each day
     $div_tag = new SwatHtmlTag('div');
     $div_tag->class = 'days clearfix';
     $div_tag->open();
     $days_in_month = $date->getDaysInMonth();
     for ($i = 1; $i <= $days_in_month; $i++) {
         $date->setDay($i);
         $key = $date->formatLikeIntl('yyyy-MM-dd');
         $tag_string = sprintf('date.date=%s', $date->formatLikeIntl('yyyy-MM-dd'));
         $tag_list->add($tag_string);
         if ($selected_day === $i) {
             $span_tag = new SwatHtmlTag('span');
             $span_tag->setContent($date->formatLikeIntl('dd'));
             $span_tag->class = 'selected';
             $span_tag->display();
         } elseif (array_key_exists($key, $photos)) {
             $a_tag = new SwatHtmlTag('a');
             $a_tag->href = $this->base . '?' . $tag_list->__toString();
             $a_tag->title = sprintf(Pinhole::ngettext('1 photo', '%s photos', $photos[$key]), SwatString::numberFormat($photos[$key]));
             $a_tag->setContent($date->formatLikeIntl('dd'));
             $a_tag->display();
         } else {
             $span_tag = new SwatHtmlTag('span');
             $span_tag->setContent($date->formatLikeIntl('dd'));
             $span_tag->display();
         }
         $tag_list->remove($tag_string);
     }
     $div_tag->close();
 }
 protected function displayContent()
 {
     $range = new SwatDBRange($this->getValue('limit'));
     $cache_module = isset($this->app->memcache) ? $this->app->memcache : null;
     $tag_list = new PinholeTagList($this->app, null, $this->app->session->isLoggedIn());
     $sub_tag_list = $tag_list->getSubTags($range);
     $sub_tag_count = $tag_list->getSubTagCount();
     $this->tag_list_view = new PinholeSubTagListView();
     $base_path = $this->app->config->pinhole->path;
     $this->tag_list_view->base = $base_path . 'tag';
     $this->tag_list_view->setTagList($tag_list);
     $this->tag_list_view->setSubTagList($sub_tag_list);
     $this->tag_list_view->display();
     if ($sub_tag_count > count($sub_tag_list)) {
         $div_tag = new SwatHtmlTag('div');
         $div_tag->class = 'pinhole-sub-tag-more-link';
         $div_tag->open();
         $a_tag = new SwatHtmlTag('a');
         $a_tag->href = $base_path . 'tags/date';
         $a_tag->setContent(sprintf(Pinhole::_('View All %s Tags'), $sub_tag_count));
         $a_tag->display();
         $div_tag->close();
     }
 }
Example #5
0
 /**
  * Gets a new tag list that is the intersection of this tag list with
  * another tag list
  *
  * @param PinholeTagList $tag_list the tag list to intersect with this tag
  *                                  list.
  *
  * @return PinholeTagList a new tag list that is the intersection of this
  *                         tag list with the tag list specified in
  *                         <i>$tag_list</i>.
  */
 public function intersect(PinholeTagList $tag_list)
 {
     $new_tag_list = $this->getEmptyCopy();
     foreach ($this->tags as $tag) {
         if ($tag_list->contains($tag)) {
             $new_tag_list->add($tag);
         }
     }
     return $new_tag_list;
 }
Example #6
0
 public function getTagsAsTagList(SiteApplication $app)
 {
     // require statements are here to prevent circular dependency issues
     require_once 'Pinhole/tags/PinholeTag.php';
     require_once 'Pinhole/PinholeTagList.php';
     $tag_list = new PinholeTagList($this->app);
     foreach ($this->tags as $tag) {
         $tag_list->add(new PinholeTag($this->image_set->instance, $tag));
     }
     return $tag_list;
 }
Example #7
0
 protected function getTableModel(SwatView $view)
 {
     $tag_list = new PinholeTagList($this->app, $this->tag->name, true);
     $photos = $tag_list->getPhotos();
     $store = new SwatTableStore();
     foreach ($photos as $photo) {
         $ds = new SwatDetailsStore();
         $ds->photo = $photo;
         $ds->class_name = $this->getTileClasses($photo);
         $store->add($ds);
     }
     return $store;
 }