Exemplo n.º 1
0
 protected function displayComments()
 {
     if ($this->post->comment_status != SiteCommentStatus::CLOSED) {
         Blorg::displayAd($this->app, 'post_comments');
         $div_tag = new SwatHtmlTag('div');
         $div_tag->id = 'comments';
         $div_tag->class = 'entry-comments';
         $div_tag->open();
         $comments = $this->post->getVisibleComments();
         $view = SiteViewFactory::get($this->app, 'post-comment');
         $count = count($comments);
         if ($count > 0) {
             echo '<h3 class="comments-title">', Blorg::_('Comments'), '</h3>';
         }
         // display message for locked comments
         if ($this->post->comment_status == SiteCommentStatus::LOCKED) {
             $div_tag = new SwatHtmlTag('div');
             $div_tag->class = 'comments-locked-message';
             $div_tag->setContent(Blorg::_('Comments are locked. No additional comments may be ' . 'posted.'));
             $div_tag->display();
         }
         foreach ($comments as $i => $comment) {
             if ($i == $count - 1) {
                 $div_tag = new SwatHtmlTag('div');
                 $div_tag->id = 'last_comment';
                 $div_tag->open();
                 $view->display($comment);
                 $div_tag->close();
             } else {
                 $view->display($comment);
             }
         }
         $div_tag->close();
     }
 }
Exemplo n.º 2
0
 protected function buildNavBar()
 {
     parent::buildNavBar();
     if ($this->post->id !== null) {
         $entry = $this->layout->navbar->popEntry();
         $this->layout->navbar->createEntry($this->post->getTitle(), sprintf('Post/Details?id=%s', $this->post->id));
         $this->layout->navbar->addEntry($entry);
     }
 }
Exemplo n.º 3
0
 protected function initCommentStatuses()
 {
     $status = $this->ui->getWidget('blorg_default_comment_status');
     // open
     $option = new SwatOption(SiteCommentStatus::OPEN, BlorgPost::getCommentStatusTitle(SiteCommentStatus::OPEN));
     $status->addOption($option);
     $status->addContextNote($option, Blorg::_('Comments can be added by anyone and are immediately visible on ' . 'this post.'));
     // moderated
     $option = new SwatOption(SiteCommentStatus::MODERATED, BlorgPost::getCommentStatusTitle(SiteCommentStatus::MODERATED));
     $status->addOption($option);
     $status->addContextNote($option, Blorg::_('Comments can be added by anyone but must be approved by a site ' . 'author before being visible on this post.'));
     // locked
     $option = new SwatOption(SiteCommentStatus::LOCKED, BlorgPost::getCommentStatusTitle(SiteCommentStatus::LOCKED));
     $status->addOption($option);
     $status->addContextNote($option, Blorg::_('Comments can only be added by an author. Existing comments are ' . 'still visible on this post.'));
     // closed
     $option = new SwatOption(SiteCommentStatus::CLOSED, BlorgPost::getCommentStatusTitle(SiteCommentStatus::CLOSED));
     $status->addOption($option);
     $status->addContextNote($option, Blorg::_('Comments can only be added by an author. No comments are visible ' . 'on this post.'));
 }
Exemplo n.º 4
0
 protected function buildPost(XML_Atom_Feed $feed, BlorgPost $post)
 {
     $site_base_href = $this->app->getBaseHref();
     $blorg_base_href = $site_base_href . $this->app->config->blorg->path;
     $path = $blorg_base_href . 'archive';
     $date = clone $post->publish_date;
     $date->convertTZ($this->app->default_time_zone);
     $year = $date->getYear();
     $month_name = BlorgPageFactory::$month_names[$date->getMonth()];
     $post_uri = sprintf('%s/%s/%s/%s', $path, $year, $month_name, $post->shortname);
     $entry = new XML_Atom_Entry($post_uri, $post->getTitle(), $post->publish_date);
     if ($post->extended_bodytext != '') {
         $full_bodytext = $post->bodytext . $post->extended_bodytext;
         $entry->setSummary($post->bodytext, 'html');
         $entry->setContent($full_bodytext, 'html');
     } else {
         $entry->setContent($post->bodytext, 'html');
     }
     foreach ($post->getTags() as $tag) {
         $entry->addCategory($tag->shortname, $blorg_base_href, $tag->title);
     }
     $entry->addLink($post_uri, 'alternate', 'text/html');
     foreach ($post->getVisibleFiles() as $file) {
         $link = new XML_Atom_Link($site_base_href . $file->getRelativeUri($this->app->config->blorg->path), 'enclosure', $file->mime_type);
         $link->setTitle($file->getDescription());
         $link->setLength($file->filesize);
         $entry->addLink($link);
     }
     if ($post->author->visible) {
         $author_uri = $blorg_base_href . 'author/' . $post->author->shortname;
     } else {
         $author_uri = '';
     }
     $entry->addAuthor($post->author->name, $author_uri, $post->author->email);
     $visible_comment_count = $post->getVisibleCommentCount();
     if ($post->comment_status == SiteCommentStatus::OPEN || $post->comment_status == SiteCommentStatus::MODERATED || $post->comment_status == SiteCommentStatus::LOCKED && $visible_comment_count > 0) {
         $entry->addLink($post_uri . '#comments', 'comments', 'text/html');
     }
     $feed->addEntry($entry);
 }
Exemplo n.º 5
0
 protected function buildDetailsBlorgDefaultCommentStatus(SwatDetailsStore $ds)
 {
     switch ($this->app->config->blorg->default_comment_status) {
         case 'open':
             $value = SiteCommentStatus::OPEN;
             break;
         case 'moderated':
             $value = SiteCommentStatus::MODERATED;
             break;
         case 'locked':
             $value = SiteCommentStatus::LOCKED;
             break;
         case 'closed':
         default:
             $value = SiteCommentStatus::CLOSED;
             break;
     }
     $title = BlorgPost::getCommentStatusTitle($value);
     $ds->blorg_default_comment_status = $title;
 }
Exemplo n.º 6
0
 protected function displayFiles(BlorgPost $post)
 {
     if ($this->getMode('files') > SiteView::MODE_NONE) {
         $files = $post->getVisibleFiles();
         if (count($files) > 0) {
             $link = $this->getLink('files');
             echo '<ul class="attachments">';
             foreach ($files as $file) {
                 $li_tag = new SwatHtmlTag('li');
                 $li_tag->class = 'type-' . $file->mime_type;
                 $li_tag->open();
                 if ($link === false) {
                     $span_tag = new SwatHtmlTag('span');
                     $span_tag->setContent($file->getDescription());
                     $span_tag->display();
                 } else {
                     $a_tag = new SwatHtmlTag('a');
                     $a_tag->href = $file->getRelativeUri($this->app->config->blorg->path, $this->path_prefix);
                     $a_tag->setContent($file->getDescription());
                     $a_tag->display();
                 }
                 echo ' ' . SwatString::byteFormat($file->filesize);
                 $li_tag->close();
             }
             echo '</ul>';
         }
     }
 }
Exemplo n.º 7
0
 protected function getPostDetailsStore()
 {
     $store = new SwatDetailsStore($this->post);
     $store->has_modified_date = $this->post->modified_date !== null;
     $store->comment_status_title = BlorgPost::getCommentStatusTitle($this->post->comment_status);
     ob_start();
     $this->displayTags();
     $store->tags_summary = ob_get_clean();
     return $store;
 }
Exemplo n.º 8
0
 protected function isShortnameValid(BlorgPost $post, $shortname)
 {
     $post = clone $post;
     $post->shortname = $shortname;
     return BlorgPost::isShortnameValid($this->app, $post);
 }
Exemplo n.º 9
0
 protected function buildHeader(XML_Atom_Feed $feed)
 {
     parent::buildHeader($feed);
     $feed->addLink($this->getPostUri($this->post), 'alternate', 'text/html');
     $feed->setSubTitle(sprintf(Blorg::_('Comments on “%s”'), $this->post->getTitle()));
 }
Exemplo n.º 10
0
 private function relocateReallyOldPost($id)
 {
     $post = new BlorgPost();
     $post->setDatabase($this->app->db);
     $post->load($id, $this->app->getInstance());
     if ($post->id === null) {
         return;
     }
     $path = $this->app->config->blorg->path . 'archive';
     $date = clone $post->publish_date;
     $date->convertTZ($this->app->default_time_zone);
     $year = $date->getYear();
     $month_name = BlorgPageFactory::$month_names[$date->getMonth()];
     $url = sprintf('%s/%s/%s/%s', $path, $year, $month_name, $post->shortname);
     $this->relocate($url);
 }