protected function displayContent()
 {
     $comments = $this->getComments();
     if (count($comments) == 0) {
         echo Pinhole::_('No comments have been made.');
     } else {
         $locale = SwatI18NLocale::get();
         echo '<ul>';
         foreach ($comments as $comment) {
             echo '<li>';
             $date = new SwatDate($comment->createdate);
             $date->convertTZById($this->app->config->date->time_zone);
             $date_diff = $date->getHumanReadableDateDiff();
             $author = $comment->photographer === null ? $comment->fullname : $comment->photographer->fullname;
             $a_tag = new SwatHtmlTag('a');
             $a_tag->href = sprintf('photo/%s#comment%s', $comment->getInternalValue('photo'), $comment->id);
             $a_tag->setContent(sprintf('%s ago by %s', $date_diff, $author));
             $a_tag->display();
             $div_tag = new SwatHtmlTag('div');
             $div_tag->setContent(SwatString::ellipsizeRight(SwatString::condense($comment->bodytext), 100));
             $div_tag->display();
             echo '</li>';
         }
         echo '</ul>';
     }
 }
 protected function buildTitle()
 {
     $this->layout->data->html_title = Blorg::_('Authors');
     $authors = array();
     foreach ($this->authors as $author) {
         $authors[] = sprintf(Blorg::_('%s - %s'), $author->name, SwatString::ellipsizeRight(SwatString::condense($author->description), 200));
     }
     $this->layout->data->meta_description = SwatString::minimizeEntities(implode('; ', $authors));
 }
Exemple #3
0
 protected function getFileFilename(BlorgFile $file)
 {
     $extension_position = strrpos($file->filename, '.');
     if ($extension_position !== false) {
         $base = substr($file->filename, 0, $extension_position);
         $extension = substr($file->filename, $extension_position + 1);
     } else {
         $base = $file->filename;
         $extension = '';
     }
     if (strlen($base) > 18) {
         $filename = SwatString::ellipsizeRight($base, 18);
         if ($extension != '') {
             $filename .= '&nbsp;' . $extension;
         }
     } else {
         $filename = $file->filename;
     }
     return $filename;
 }
Exemple #4
0
 protected function buildMetaDescription()
 {
     $this->layout->data->meta_description = SwatString::minimizeEntities(SwatString::ellipsizeRight(SwatString::condense($this->post->bodytext), 300));
 }
Exemple #5
0
 protected function displayBodytext(BlorgPost $post)
 {
     switch ($this->getMode('bodytext')) {
         case SiteView::MODE_ALL:
             $div_tag = new SwatHtmlTag('div');
             $div_tag->class = 'entry-content';
             $div_tag->setContent($post->bodytext, 'text/xml');
             $div_tag->display();
             if ($this->getMode('extended_bodytext') == SiteView::MODE_ALL && ($post->extended_bodytext != '' || $this->app->config->blorg->ad_post_comments == '')) {
                 Blorg::displayAd($this->app, 'post_content');
             }
             break;
         case SiteView::MODE_SUMMARY:
             $bodytext = null;
             $link = $this->getLink('bodytext');
             // don't summarize microblogs
             if ($post->title == '') {
                 $stripped_bodytext = strip_tags($post->bodytext);
                 $stripped_bodytext = html_entity_decode($stripped_bodytext, ENT_COMPAT, 'UTF-8');
                 if (strlen($stripped_bodytext) <= $this->microblog_length) {
                     $bodytext = $post->bodytext;
                 }
             }
             if ($bodytext === null) {
                 $flag = false;
                 $bodytext = SwatString::ellipsizeRight(SwatString::condense($post->bodytext), $this->bodytext_summary_length, ' …', $flag);
                 if ($flag && $link !== false) {
                     $anchor_tag = new SwatHtmlTag('a');
                     if (is_string($link)) {
                         $anchor_tag->href = $link;
                     } else {
                         $anchor_tag->href = $this->getRelativeUri($post);
                     }
                     $anchor_tag->setContent(Blorg::_('read more »'));
                     $bodytext .= ' ' . $anchor_tag;
                 }
             }
             $div_tag = new SwatHtmlTag('div');
             $div_tag->class = 'entry-content';
             $div_tag->setContent($bodytext, 'text/xml');
             $div_tag->display();
             break;
     }
 }
Exemple #6
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;
    }
Exemple #7
0
 protected function buildTitle()
 {
     $this->layout->data->html_title = $this->author->name;
     $this->layout->data->meta_description = SwatString::minimizeEntities(SwatString::ellipsizeRight(SwatString::condense($this->author->bodytext), 300));
 }
Exemple #8
0
 protected function displayBodytext(BlorgAuthor $author)
 {
     switch ($this->getMode('bodytext')) {
         case SiteView::MODE_ALL:
             $div_tag = new SwatHtmlTag('div');
             $div_tag->class = 'author-content';
             $div_tag->setContent($author->bodytext, 'text/xml');
             $div_tag->display();
             break;
         case SiteView::MODE_SUMMARY:
             $bodytext = SwatString::ellipsizeRight(SwatString::condense($author->bodytext), $this->bodytext_summary_length);
             $div_tag = new SwatHtmlTag('div');
             $div_tag->class = 'author-content';
             $div_tag->setContent($bodytext, 'text/xml');
             $div_tag->display();
             break;
     }
 }
Exemple #9
0
 /**
  * Part of the {@link SiteCommentable} interface
  *
  * @return string the title of this post.
  */
 public function getTitle()
 {
     if ($this->title == '') {
         return SwatString::ellipsizeRight(SwatString::condense(SwatString::toXHTML($this->bodytext)), 50, Blorg::_(' …'));
     } else {
         return $this->title;
     }
 }
Exemple #10
0
    protected function buildInternal()
    {
        parent::buildInternal();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        $dep = new AdminListDependency();
        $dep->setTitle(Blorg::_('comment'), Blorg::_('comments'));
        $sql = sprintf('select BlorgComment.id, BlorgComment.bodytext from BlorgComment
				inner join BlorgPost on BlorgPost.id = BlorgComment.post
			where instance %s %s and BlorgComment.id in (%s)
			order by BlorgComment.createdate desc, BlorgComment.id', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $comments = SwatDB::query($this->app->db, $sql);
        $entries = array();
        foreach ($comments as $comment) {
            $entry = new AdminDependencyEntry();
            $entry->id = $comment->id;
            $entry->title = SwatString::ellipsizeRight(SwatString::condense(SiteCommentFilter::toXhtml($comment->bodytext)), 100);
            $entry->status_level = AdminDependency::DELETE;
            $entry->parent = null;
            $entries[] = $entry;
        }
        $dep->entries = $entries;
        $message = $this->ui->getWidget('confirmation_message');
        $message->content = $dep->getMessage();
        $message->content_type = 'text/xml';
        if ($dep->getStatusLevelCount(AdminDependency::DELETE) == 0) {
            $this->switchToCancelButton();
        }
    }
 protected function getCustomGoogleCampaign()
 {
     $utm_campaign = $this->google_campaign;
     // If no campaign exists, use a shortened version of the subject line.
     if ($utm_campaign == '') {
         $utm_campaign = SwatString::ellipsizeRight($this->subject, 10, '');
     }
     return sprintf($this->app->config->deliverance->analytics_utm_campaign, rawurlencode($utm_campaign), $this->shortname);
 }
Exemple #12
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;
    }