Exemplo n.º 1
0
    protected function getTableModel(SwatView $view)
    {
        $sql = sprintf('select Newsletter.*, Instance.title as instance_title
			from Newsletter
			left outer join Instance on Instance.id = Newsletter.instance
			where %s order by instance_title nulls first, %s', $this->getWhereClause(), $this->getOrderByClause($view, 'send_date desc nulls first, Newsletter.createdate desc'));
        $pager = $this->ui->getWidget('pager');
        $this->app->db->setLimit($pager->page_size, $pager->current_record);
        $newsletters = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('DeliveranceNewsletterWrapper'));
        $store = new SwatTableStore();
        foreach ($newsletters as $newsletter) {
            $ds = new SwatDetailsStore($newsletter);
            $ds->title = $newsletter->getCampaignTitle();
            $ds->status = $newsletter->getCampaignStatus($this->app);
            $store->add($ds);
        }
        return $store;
    }
Exemplo n.º 2
0
 protected function displayByDateAdded(PinholeTagList $tag_list)
 {
     $now = new SwatDate();
     $now->convertTZById($this->app->config->date->time_zone);
     $store = new SwatTableStore();
     foreach ($tag_list as $tag) {
         $ds = new SwatDetailsStore();
         $ds->tag = $tag;
         $tag_date = $tag->getDataObject()->first_modified;
         $tag_date->convertTZById($this->app->config->date->time_zone);
         $days_past = $now->diff($tag_date)->days;
         if ($days_past <= 1) {
             $ds->date_part = Pinhole::_('Today');
         } elseif ($days_past <= $now->getDayOfWeek() + 1) {
             $ds->date_part = Pinhole::_('This Week');
         } elseif ($days_past <= $now->getDay()) {
             $ds->date_part = Pinhole::_('This Month');
         } elseif ($days_past <= $now->getDayOfYear()) {
             $ds->date_part = Pinhole::_('This Year');
         } else {
             $ds->date_part = sprintf(Pinhole::_('%s'), $tag_date->getYear());
         }
         $store->add($ds);
     }
     $ul_tag = new SwatHtmlTag('ul');
     $li_tag = new SwatHtmlTag('li');
     $ul_tag->open();
     $part = null;
     foreach ($store as $ds) {
         if ($part !== $ds->date_part) {
             if ($part !== null) {
                 $li_tag->close();
             }
             $li_tag->open();
             $h2_tag = new SwatHtmlTag('h2');
             $h2_tag->class = 'pinhole-tag-entity';
             $h2_tag->setContent($ds->date_part);
             $h2_tag->display();
         } elseif ($part !== null) {
             echo ', ';
         }
         $this->displayTag($ds->tag);
         $part = $ds->date_part;
     }
     $li_tag->close();
     $ul_tag->close();
 }
Exemplo n.º 3
0
    /**
     * Gets the metadata for display
     *
     * @return SwatTableModel with metadata information.
     */
    protected function getTableModel(SwatView $view)
    {
        $sql = 'select * from PinholeMetaData
			where PinholeMetaData.instance %s %s
			order by %s';
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf($sql, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->getOrderByClause($view, 'visible desc, displayorder, title'));
        $metadata = SwatDB::query($this->app->db, $sql);
        $store = new SwatTableStore();
        foreach ($metadata as $data) {
            $ds = new SwatDetailsView();
            $ds->title = $data->title;
            $ds->shortname = $data->shortname;
            $ds->id = $data->id;
            $ds->visible = $data->visible;
            $ds->machine_tag = $data->machine_tag;
            if ($ds->visible) {
                $ds->group_title = 'Shown';
            } else {
                $ds->group_title = 'Not Shown';
            }
            $store->add($ds);
        }
        return $store;
    }
Exemplo n.º 4
0
    protected function getPostsTableModel()
    {
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select id, title, publish_date, bodytext
			from BlorgPost
			where instance %s %s and enabled = %s
			order by publish_date desc, title', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->app->db->quote(true, 'boolean'));
        $this->app->db->setLimit(self::MAX_POSTS);
        $posts = SwatDB::query($this->app->db, $sql, 'BlorgPostWrapper');
        $store = new SwatTableStore();
        foreach ($posts as $post) {
            $ds = new SwatDetailsStore($post);
            $ds->title = $post->getTitle();
            $store->add($ds);
        }
        return $store;
    }
Exemplo n.º 5
0
 /**
  * Gets the metadata for display
  *
  * @return SwatTableModel with metadata information.
  */
 protected function getTableModel(SwatView $view)
 {
     $metadata = $this->getMetaData();
     $store = new SwatTableStore();
     foreach ($metadata as $data) {
         $ds = new SwatDetailsView();
         $ds->title = $data->title;
         $ds->value = $data->value;
         $ds->id = $data->id;
         $ds->visible = $data->visible;
         $ds->machine_tag = $data->machine_tag;
         if ($ds->visible) {
             $ds->group_title = Pinhole::_('Shown');
         } else {
             $ds->group_title = Pinhole::_('Not Shown');
         }
         $store->add($ds);
     }
     return $store;
 }
Exemplo n.º 6
0
 protected function buildInternal()
 {
     parent::buildInternal();
     if ($this->extended_selected) {
         // note the only page with an extended-selection that accesses this
         // is the pending photos page - so the message can be more
         // specific.
         $message = $this->ui->getWidget('confirmation_message');
         $message->content_type = 'text/xml';
         $message->content = Pinhole::_('<strong>Are you sure ' . 'you want to delete all pending photos?</strong>');
     } else {
         $container = $this->ui->getWidget('confirmation_container');
         $delete_view = $this->ui->getWidget('delete_view');
         $store = new SwatTableStore();
         foreach ($this->getPhotos() as $photo) {
             $ds = new SwatDetailsStore();
             $ds->photo = $photo;
             $store->add($ds);
         }
         $delete_view->model = $store;
         $message = $this->ui->getWidget('confirmation_message');
         $message->content_type = 'text/xml';
         $message->content = sprintf(Pinhole::_('<strong>Are you sure ' . 'you want to delete the following %s?</strong>'), Pinhole::ngettext('photo', 'photos', count($store)));
     }
 }
Exemplo n.º 7
0
    protected function getCommentsTableModel(SwatTableView $view)
    {
        $sql = sprintf('select count(id) from BlorgComment
			where post = %s and spam = %s', $this->app->db->quote($this->post->id, 'integer'), $this->app->db->quote(false, 'boolean'));
        $pager = $this->ui->getWidget('pager');
        $pager->total_records = SwatDB::queryOne($this->app->db, $sql);
        $sql = sprintf('select id, fullname, author, bodytext, createdate, status
			from BlorgComment
			where post = %s and spam = %s
			order by %s', $this->app->db->quote($this->post->id, 'integer'), $this->app->db->quote(false, 'boolean'), $this->getOrderByClause($view, 'createdate'));
        $this->app->db->setLimit($pager->page_size, $pager->current_record);
        $comments = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgCommentWrapper'));
        $store = new SwatTableStore();
        foreach ($comments as $comment) {
            $ds = new SwatDetailsStore($comment);
            //TODO: distinguish authors somehow
            if ($comment->author !== null) {
                $ds->fullname = $comment->author->name;
            }
            $ds->bodytext = SwatString::condense(SwatString::ellipsizeRight($comment->bodytext, 500));
            $ds->post_id = $this->post->id;
            $store->add($ds);
        }
        return $store;
    }
Exemplo n.º 8
0
 protected function getTile(PinholePhoto $photo)
 {
     $ui = new AdminUI();
     $ui->loadFromXML($this->ui_xml);
     $store = new SwatTableStore();
     $ds = new SwatDetailsStore();
     $ds->photo = $photo;
     $ds->class_name = $this->getTileClasses($photo);
     $store->add($ds);
     $ui->getWidget('index_view')->model = $store;
     ob_start();
     $ui->getWidget('index_view')->display();
     $string = ob_get_clean();
     // only pass back the tile element, not the whole view
     $dom = new DomDocument();
     $dom->loadXML('<xml>' . $string . '</xml>');
     $divs = $dom->getElementsByTagName('div');
     foreach ($divs as $div) {
         $classes = explode(' ', $div->getAttribute('class'));
         if (in_array('swat-tile', $classes)) {
             return $dom->saveXML($div);
         }
     }
 }
Exemplo n.º 9
0
    protected function getTableModel(SwatView $view)
    {
        $this->searchPosts();
        $sql = sprintf('select count(id) from BlorgPost %s where %s', $this->getJoinClause(), $this->getWhereClause());
        $pager = $this->ui->getWidget('pager');
        $pager->total_records = SwatDB::queryOne($this->app->db, $sql);
        $sql = sprintf('select * from BlorgPost
			%s
			where %s
			order by %s', $this->getJoinClause(), $this->getWhereClause(), $this->getOrderByClause($view, 'publish_date desc, title'));
        $this->app->db->setLimit($pager->page_size, $pager->current_record);
        $posts = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgPostWrapper'));
        $current_date = null;
        $store = new SwatTableStore();
        foreach ($posts as $post) {
            if ($current_date === null || $post->publish_date->getMonth() != $current_date->getMonth() || $post->publish_date->getYear() != $current_date->getYear()) {
                $current_date = clone $post->publish_date;
                $current_date->setDay(1);
                $current_date->setHour(0);
                $current_date->setMinute(0);
                $current_date->setSecond(0);
            }
            $ds = new SwatDetailsStore($post);
            $ds->title = $post->getTitle();
            $ds->publish_date_month = $current_date;
            $store->add($ds);
        }
        return $store;
    }
Exemplo n.º 10
0
    protected function getTableModel(SwatView $view)
    {
        $sql = sprintf('select count(PinholePhoto.id) from PinholePhoto
			inner join ImageSet on PinholePhoto.image_set = ImageSet.id
			where %s', $this->getWhereClause());
        $pager = $this->ui->getWidget('pager');
        $pager->total_records = SwatDB::queryOne($this->app->db, $sql);
        $sql = sprintf('select PinholePhoto.* from PinholePhoto
			inner join ImageSet on PinholePhoto.image_set = ImageSet.id
			where %s
			order by PinholePhoto.upload_date desc, PinholePhoto.id', $this->getWhereClause());
        $this->app->db->setLimit($pager->page_size, $pager->current_record);
        $wrapper_class = SwatDBClassMap::get('PinholePhotoWrapper');
        $photos = SwatDB::query($this->app->db, $sql, $wrapper_class);
        $tile_view = $this->ui->getWidget('index_view');
        $tile_view->check_all_unit = Pinhole::_('Pending Photos');
        $store = new SwatTableStore();
        if (count($photos) > 0) {
            $tile_view->check_all_extended_count = $pager->total_records;
            $tile_view->check_all_visible_count = count($photos);
            foreach ($photos as $photo) {
                $ds = new SwatDetailsStore();
                $ds->photo = $photo;
                $ds->class_name = $this->getTileClasses($photo);
                $store->add($ds);
            }
        }
        return $store;
    }
Exemplo n.º 11
0
    protected function getTableModel(SwatView $view)
    {
        $sql = sprintf('select id, fullname, photographer, bodytext, createdate, status
			from PinholeComment
			where photo = %s and spam = %s
			order by %s', $this->app->db->quote($this->photo->id, 'integer'), $this->app->db->quote(false, 'boolean'), $this->getOrderByClause($view, 'createdate'));
        $comments = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeCommentWrapper'));
        $store = new SwatTableStore();
        foreach ($comments as $comment) {
            $ds = new SwatDetailsStore($comment);
            if ($comment->photographer !== null) {
                $ds->fullname = $comment->photographer->fullname;
            }
            $ds->bodytext = SwatString::condense(SwatString::ellipsizeRight($comment->bodytext, 500));
            $ds->photo_id = $this->photo->id;
            $store->add($ds);
        }
        return $store;
    }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
0
 private function displayPhotoGrid(PinholePhotoWrapper $photos, $tag_list, array $box)
 {
     $ui = new SwatUI();
     $ui->loadFromXml(dirname(__FILE__) . '/map-tile.xml');
     $store = new SwatTableStore();
     foreach ($photos as $photo) {
         $ds = new SwatDetailsStore();
         $ds->photo = $photo;
         $ds->root_path = $this->app->config->pinhole->path;
         $ds->path = 'photo/' . $photo->id;
         if ($tag_list !== null) {
             $ds->path .= '?' . $tag_list;
         }
         $ds->display_title = $this->app->config->pinhole->browser_index_titles;
         $store->add($ds);
     }
     $ui->getWidget('photo_view')->model = $store;
     $locale = SwatI18NLocale::get();
     $h3_tag = new SwatHtmlTag('h3');
     $h3_tag->setContent(sprintf(Pinhole::_('%s Photos, Displaying %s to %s'), $locale->formatNumber($this->photo_count), $locale->formatNumber(1), $locale->formatNumber(count($photos))));
     $h3_tag->display();
     if (count($photos) > 3) {
         echo '<div class="fixed-width-marker">';
         $ui->display();
         echo '</div>';
     } else {
         $ui->display();
     }
     if (count($photos) < $this->photo_count) {
         $a_tag = new SwatHtmlTag('a');
         $a_tag->class = 'more-photos-link';
         $a_tag->setContent(sprintf(Pinhole::_('View All %s Photos'), $locale->formatNumber($this->photo_count)));
         if ($box['min_latitude'] == $box['max_latitude'] && $box['min_longitude'] == $box['max_longitude']) {
             $a_tag->href = sprintf('tag?gps.latitude=%s/gps.longitude=%s', $box['min_latitude'], $box['min_longitude']);
         } else {
             $a_tag->href = sprintf('tag?gps.box=%sx%s|%sx%s', $box['max_latitude'], $box['min_longitude'], $box['min_latitude'], $box['max_longitude']);
         }
         if ($tag_list !== null) {
             $a_tag->href .= '/' . $tag_list;
         }
         $a_tag->display();
     }
 }
Exemplo n.º 14
0
 protected function getTableModel(SwatView $view)
 {
     $now = new SwatDate();
     $now->setTimezone($this->app->default_time_zone);
     $year = $this->start_date->getYear();
     $start_date = new SwatDate();
     $start_date->setTime(0, 0, 0);
     $start_date->setDate($year, 1, 1);
     $start_date->setTZ($this->app->default_time_zone);
     $end_date = clone $start_date;
     $end_date->addMonths(3);
     $display_end_date = clone $end_date;
     $display_end_date->subtractMonths(1);
     $store = new SwatTableStore();
     while ($end_date->before($now)) {
         for ($i = 1; $i <= 4; $i++) {
             // Only add the quarter to the table model if the start date
             // is within or prior to that quarter.
             if ($this->start_date->before($end_date)) {
                 $ds = new SwatDetailsStore();
                 $quarter = $start_date->formatLikeIntl('yyyy-qq');
                 $ds->date = clone $start_date;
                 $ds->year = $year;
                 $ds->quarter = $quarter;
                 $ds->quarter_title = sprintf(CME::_('Q%s - %s to %s'), $i, $start_date->formatLikeIntl('MMMM yyyy'), $display_end_date->formatLikeIntl('MMMM yyyy'));
                 foreach ($this->providers as $provider) {
                     $shortname = $provider->shortname;
                     $sensitive = isset($this->reports_by_quarter[$quarter][$shortname]);
                     $ds->{'is_' . $shortname . '_sensitive'} = $sensitive;
                 }
                 $store->add($ds);
             }
             $start_date->addMonths(3);
             $end_date->addMonths(3);
             $display_end_date->addMonths(3);
         }
         $year++;
     }
     return $store;
 }
Exemplo n.º 15
0
 protected function getTableModel(SwatView $view)
 {
     $store = new SwatTableStore();
     $sql = 'select count(id) from PinholeTag';
     $where_clause = $this->getWhereClause();
     if ($where_clause != '') {
         $sql .= ' where ' . $this->getWhereClause();
     }
     $pager = $this->ui->getWidget('pager');
     $pager->total_records = SwatDB::queryOne($this->app->db, $sql);
     $sql = 'select PinholeTag.* from PinholeTag';
     $where_clause = $this->getWhereClause();
     if ($where_clause != '') {
         $sql .= ' where ' . $this->getWhereClause();
     }
     $sql .= ' order by ' . $this->getOrderByClause($view, 'PinholeTag.title');
     $this->app->db->setLimit($pager->page_size, $pager->current_record);
     $wrapper_class = SwatDBClassMap::get('PinholeTagDataObjectWrapper');
     $data_objects = SwatDB::query($this->app->db, $sql, $wrapper_class);
     if (count($data_objects) > 0) {
         $this->ui->getWidget('results_frame')->visible = true;
         $this->ui->getWidget('results_message')->content = $pager->getResultsMessage(Pinhole::_('result'), Pinhole::_('results'));
         $class_name = SwatDBClassMap::get('PinholeTag');
         foreach ($data_objects as $data_object) {
             $tag = new $class_name($this->app->getInstance(), $data_object);
             $store->add($tag);
         }
     }
     $index_view = $this->ui->getWidget('index_view');
     $checkbox_column = $index_view->getColumn('checkbox');
     $checkbox_column->check_all_visible_count = count($data_objects);
     $checkbox_column->check_all_extended_count = $pager->total_records;
     $checkbox_column->check_all_unit = Pinhole::_('tags');
     return $store;
 }
Exemplo n.º 16
0
    protected function getTableModel(SwatView $view)
    {
        $this->searchPhotos();
        $sql = sprintf('select count(PinholePhoto.id)
			from PinholePhoto
			inner join ImageSet on PinholePhoto.image_set = ImageSet.id
			%s where %s', $this->join_clause, $this->getWhereClause());
        $pager = $this->ui->getWidget('pager');
        $pager->total_records = SwatDB::queryOne($this->app->db, $sql);
        $sql = sprintf('select PinholePhoto.* from PinholePhoto
			inner join ImageSet on PinholePhoto.image_set = ImageSet.id
			%s where %s order by %s', $this->join_clause, $this->getWhereClause(), $this->order_by_clause);
        $this->app->db->setLimit($pager->page_size, $pager->current_record);
        $wrapper_class = SwatDBClassMap::get('PinholePhotoWrapper');
        $photos = SwatDB::query($this->app->db, $sql, $wrapper_class);
        $store = new SwatTableStore();
        if (count($photos) != 0) {
            $this->ui->getWidget('results_message')->content = $pager->getResultsMessage(Pinhole::_('result'), Pinhole::_('results'));
            foreach ($photos as $photo) {
                $ds = new SwatDetailsStore();
                $ds->photo = $photo;
                $ds->class_name = $this->getTileClasses($photo);
                $store->add($ds);
            }
        }
        return $store;
    }
Exemplo n.º 17
0
 protected function buildInternal()
 {
     parent::buildInternal();
     if ($this->extended_selected) {
         // note the only page with an extended-selection that accesses this
         // is the pending photos page - so the message can be more
         // specific.
         $message = $this->ui->getWidget('confirmation_message');
         $message->content_type = 'text/xml';
         $message->content = Pinhole::_('<strong>Update the date/time/' . 'time-zone of all pending photos.</strong>');
     } else {
         $this->ui->getWidget('confirmation_frame')->classes[] = 'two-column';
         $container = $this->ui->getWidget('confirmation_container');
         $photo_view = $this->ui->getWidget('photo_view');
         $store = new SwatTableStore();
         foreach ($this->getPhotos() as $photo) {
             $ds = new SwatDetailsStore();
             $ds->photo = $photo;
             $store->add($ds);
         }
         $photo_view->model = $store;
         $message = $this->ui->getWidget('confirmation_message');
         $message->content_type = 'text/xml';
         $message->content = sprintf(Pinhole::_('<strong>Update the ' . 'date/time/time-zone of the following %s:</strong>'), Pinhole::ngettext('photo', 'photos', count($store)));
     }
 }
Exemplo n.º 18
0
 protected function getPhotoTableStore()
 {
     if (count($this->tag_list) == 0) {
         $tag_path = '';
     } else {
         $tag_path = '?' . $this->tag_list->__toString();
     }
     $photos = $this->tag_list->getPhotos('thumbnail');
     // throw exception or else tags that have only private photos would be
     // exposed.
     if (count($this->tag_list->getByType('PinholeTag')) > 0 && count($photos) == 0) {
         throw new SiteNotFoundException(sprintf('There are no photos in the current tag intersection: %s.', (string) $this->tag_list));
     }
     $store = new SwatTableStore();
     foreach ($photos as $photo) {
         $ds = new SwatDetailsStore();
         $ds->root_path = $this->app->config->pinhole->path;
         $ds->path = $photo->id . $tag_path;
         $ds->photo = $photo;
         $ds->display_title = $this->app->config->pinhole->browser_index_titles;
         $now = new SwatDate();
         $now->convertTZById($this->app->config->date->time_zone);
         $now->setTime(0, 0, 0);
         if (count($this->tag_list) == 0) {
             $publish_date = $photo->publish_date;
             $publish_date->convertTZbyID($this->app->config->date->time_zone);
             $days_past = $now->diff($publish_date)->days;
             if ($days_past <= 1) {
                 $period = Pinhole::_('Today');
             } elseif ($days_past <= 2) {
                 $period = Pinhole::_('Yesterday');
             } elseif ($days_past <= 7) {
                 $period = sprintf(Pinhole::_('%d Days Ago'), floor($days_past));
             } else {
                 $period = $publish_date->formatLikeIntl(SwatDate::DF_DATE_LONG);
             }
             $ds->publish_period = sprintf(Pinhole::_('Added %s'), $period);
         } else {
             $ds->publish_period = null;
         }
         $store->add($ds);
     }
     return $store;
 }