Example #1
0
 /**
  * Displays the title and meta information for a weblog post
  *
  * @param BlorgPost $post
  */
 protected function displaySubHeader(BlorgPost $post)
 {
     ob_start();
     $this->displayAuthor($post);
     $author = ob_get_clean();
     ob_start();
     $this->displayPermalink($post);
     $permalink = ob_get_clean();
     ob_start();
     $this->displayCommentCount($post);
     $comment_count = ob_get_clean();
     echo '<div class="entry-subtitle">';
     /*
      * Comment count is shown if and only if comment_count element is shown
      * AND the following:
      * - comments are locked AND there is one or more visible comment OR
      * - comments are open OR
      * - comments are moderated.
      */
     $show_comment_count = strlen($comment_count) > 0 && ($post->comment_status == SiteCommentStatus::LOCKED && $post->getVisibleCommentCount() > 0 || $post->comment_status == SiteCommentStatus::OPEN || $post->comment_status == SiteCommentStatus::MODERATED);
     if (strlen($author) > 0) {
         if ($show_comment_count) {
             printf(Blorg::_('Posted by %s on %s | %s'), $author, $permalink, $comment_count);
         } else {
             printf(Blorg::_('Posted by %s on %s'), $author, $permalink);
         }
     } else {
         if ($show_comment_count) {
             printf('%s  %s', $permalink, $comment_count);
         } else {
             echo $permalink;
         }
     }
     echo '</div>';
 }
Example #2
0
 protected function buildHeader(XML_Atom_Feed $feed)
 {
     BlorgAbstractAtomPage::buildHeader($feed);
     $tag_href = $this->getBlorgBaseHref() . 'tag/' . $this->tag->shortname;
     $feed->addLink($tag_href, 'alternate', 'text/html');
     $feed->setSubTitle(sprintf(Blorg::_('Posts Tagged: %s'), $this->tag->title));
 }
Example #3
0
    /**
     * Creates a new tag
     *
     * @throws SwatException if no database connection is set on this tag
     *                        entry control.
     */
    protected function insertTag($title, $index)
    {
        if ($this->app === null) {
            throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
        }
        // check to see if the tag already exists
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from
			BlorgTag where lower(title) = lower(%s) and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgTagWrapper'));
        // only insert if no tag already exists (prevents creating two tags on
        // reloading)
        if (count($tags) > 0) {
            $tag = $tags->getFirst();
        } else {
            $tag = new BlorgTag();
            $tag->setDatabase($this->app->db);
            $tag->instance = $instance_id;
            $tag->title = $title;
            $tag->save();
            if (isset($this->app->memcache)) {
                $this->app->memcache->flushNs('tags');
            }
            $message = new SwatMessage(sprintf(Blorg::_('The tag “%s” has been added.'), $tag->title));
            $this->app->messages->add($message);
        }
        $this->tag_array[$tag->shortname] = $tag->title;
        $this->selected_tag_array[$tag->shortname] = $tag->title;
    }
Example #4
0
    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $num = count($view->getSelection());
        $message = null;
        $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer');
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->getSelection());
                break;
            case 'enable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been shown on site.', '%s authors have been shown on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been hidden on site.', '%s authors have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
Example #5
0
    protected function buildInternal()
    {
        parent::buildInternal();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        $dep = new AdminListDependency();
        $dep->setTitle(Blorg::_('post'), Blorg::_('posts'));
        $sql = sprintf('select id, title, bodytext from BlorgPost
			where instance %s %s and id in (%s)
			order by publish_date desc, title', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $posts = SwatDB::query($this->app->db, $sql, 'BlorgPostWrapper');
        $entries = array();
        foreach ($posts as $post) {
            $entry = new AdminDependencyEntry();
            $entry->id = $post->id;
            $entry->title = $post->getTitle();
            $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();
        }
    }
 /**
  * Gets translatable string resources for the JavaScript object for
  * this widget
  *
  * @return string translatable JavaScript string resources for this widget.
  */
 protected function getInlineJavaScriptTranslations()
 {
     $attach_text = SwatString::quoteJavaScriptString(Blorg::_('Attach'));
     $detach_text = SwatString::quoteJavaScriptString(Blorg::_('Detach'));
     $attached_text = SwatString::quoteJavaScriptString(Blorg::_('(attached)'));
     $detached_text = SwatString::quoteJavaScriptString(Blorg::_('(not attached)'));
     return "BlorgFileAttachControl.attach_text = {$attach_text};\n" . "BlorgFileAttachControl.detach_text = {$detach_text};\n" . "BlorgFileAttachControl.attached_text = {$attached_text};\n" . "BlorgFileAttachControl.detached_text = {$detached_text};\n";
 }
Example #7
0
 protected function buildTitle()
 {
     if ($this->hasSearchDataValue('type') && $this->getSearchDataValue('type') === 'article') {
         $this->layout->data->title = Blorg::_('Article Search Results');
     } else {
         parent::buildTitle();
     }
 }
 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));
 }
Example #9
0
 protected function define()
 {
     $this->defineDefaultTitle(Blorg::_('Flickr Photos'));
     $this->defineSetting('uri', Blorg::_('JSON Photo Feed'), 'string');
     $this->defineSetting('limit', Blorg::_('Limit'), 'integer', 10);
     $this->defineSetting('size', Blorg::_('Display Size'), 'string', 'square');
     $this->defineDescription(Blorg::_('Displays photos from Flickr'));
     $this->addJavaScript('packages/blorg/javascript/blorg-flickr-json-gadget.js', Blorg::PACKAGE_ID);
     $this->id = uniqid('flickr');
 }
Example #10
0
 protected function displayHeader()
 {
     $header_div = new SwatHtmlTag('div');
     $header_div->class = 'site-comment-display-header';
     $header_div->open();
     $anchor_tag = new SwatHtmlTag('a');
     $anchor_tag->href = sprintf('Post/Details?id=%s', $this->comment->post->id);
     $anchor_tag->setContent($this->comment->post->getTitle());
     printf(Blorg::_('Comment on %s'), $anchor_tag);
     $this->displayStatusSpan();
     $header_div->close();
 }
Example #11
0
 protected function processDBData()
 {
     parent::processDBData();
     $item_list = $this->getItemList('integer');
     $sql = sprintf('delete from BlorgTag where id in (%s)', $item_list);
     $num = SwatDB::exec($this->app->db, $sql);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('tags');
         $this->app->memcache->flushNs('posts');
     }
     $message = new SwatMessage(sprintf(Blorg::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
 }
Example #12
0
 protected function buildInternal()
 {
     parent::buildInternal();
     $this->buildMessages();
     $ds = new SwatDetailsStore($this->tag);
     $ds->post_count = $this->tag->getPostCount();
     $details_view = $this->ui->getWidget('details_view');
     $details_view->data = $ds;
     $details_frame = $this->ui->getWidget('details_frame');
     $details_frame->title = Blorg::_('Tag');
     $details_frame->subtitle = $this->tag->title;
     $this->buildToolbar();
 }
Example #13
0
 protected function define()
 {
     $this->defineDefaultTitle(Blorg::_('Recently Listened'));
     $this->defineSetting('username', Blorg::_('User Name'), 'string');
     $this->defineSetting('limit', Blorg::_('Limit'), 'integer', 10);
     $this->defineSetting('invert', Blorg::_('Invert Loading Image'), 'boolean', false);
     $this->defineSetting('date_format', Blorg::_('Date Format (“short” 2:36pm, Jan 5 — or — ' . '“long” 2:36 pm, January 5)'), 'string', 'long');
     $this->defineDescription(Blorg::_('Lists recently listened songs for a user on Last.fm.'));
     $this->defineAjaxProxyMapping('^last\\.fm/([^/]+)$', 'http://ws.audioscrobbler.com/1.0/user/\\1/recenttracks.xml');
     $yui = new SwatYUI(array('dom', 'connection', 'animation'));
     $this->html_head_entry_set->addEntrySet($yui->getHtmlHeadEntrySet());
     $this->addJavaScript('packages/blorg/javascript/blorg-last-fm-gadget.js', Blorg::PACKAGE_ID);
     $this->id = uniqid();
 }
Example #14
0
 protected function displayContent()
 {
     $comment = $this->data_object;
     $div_tag = new SwatHtmlTag('div');
     $div_tag->setContent($this->data_object->post->getTitle());
     $div_tag->display();
     $h2_tag = new SwatHtmlTag('h2');
     $h2_tag->setContent($this->data_object->fullname);
     $h2_tag->display();
     $abbr_tag = new SwatHtmlTag('abbr');
     $date = clone $comment->createdate;
     $date->convertTZ($this->app->default_time_zone);
     $abbr_tag->setContent(sprintf(Blorg::_('Posted: %s'), $date->formatLikeIntl(SwatDate::DF_DATE)));
     $abbr_tag->display();
     echo SwatString::toXHTML($comment->bodytext);
 }
Example #15
0
    protected function getTableModel(SwatView $view)
    {
        $sql = sprintf('select count(id) from BlorgTag where %s', $this->getWhereClause());
        $pager = $this->ui->getWidget('pager');
        $pager->total_records = SwatDB::queryOne($this->app->db, $sql);
        $sql = sprintf('select id, title, shortname
			from BlorgTag
			where %s
			order by %s', $this->getWhereClause(), $this->getOrderByClause($view, 'title'));
        $tags = SwatDB::query($this->app->db, $sql, 'BlorgTagWrapper');
        if (count($tags) > 0) {
            $this->ui->getWidget('results_frame')->visible = true;
            $this->ui->getWidget('results_message')->content = $pager->getResultsMessage(Blorg::_('result'), Blorg::_('results'));
        }
        return $tags;
    }
Example #16
0
 protected function buildInternal()
 {
     parent::buildInternal();
     $item_list = $this->getItemList('integer');
     $instance_id = $this->app->getInstanceId();
     $where_clause = sprintf('id in (%s) and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
     $dep = new AdminListDependency();
     $dep->setTitle('author', 'authors');
     $dep->entries = AdminListDependency::queryEntries($this->app->db, 'BlorgAuthor', 'integer:id', null, 'text:name', 'id', $where_clause, AdminDependency::DELETE);
     $dep_posts = new AdminSummaryDependency();
     $dep_posts->setTitle(Blorg::_('post'), Blorg::_('posts'));
     $dep_posts->summaries = AdminSummaryDependency::querySummaries($this->app->db, 'BlorgPost', 'integer:id', 'integer:author', 'author in (' . $item_list . ')', AdminDependency::NODELETE);
     $dep->addDependency($dep_posts);
     $message = $this->ui->getWidget('confirmation_message');
     $message->content = $dep->getMessage();
     $message->content_type = 'text/xml';
     if ($dep->getStatusLevelCount(AdminDependency::DELETE) == 0) {
         $this->switchToCancelButton();
     }
 }
Example #17
0
 protected function initBlorgDefaultCommentStatus()
 {
     $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.'));
 }
Example #18
0
 /**
  * Displays this embed markup view
  */
 public function display()
 {
     if (!$this->visible) {
         return;
     }
     parent::display();
     $div_tag = new SwatHtmlTag('div');
     $div_tag->id = $this->id;
     $div_tag->open();
     $label_tag = new SwatHtmlTag('label');
     $label_tag->for = $this->id . '_textarea';
     $label_tag->class = 'blorg-markup-view-label';
     $label_tag->open();
     $span_tag = new SwatHtmlTag('span');
     $span_tag->setContent(Blorg::_('Embed:'));
     $span_tag->display();
     $label_tag->close();
     $first_option = reset($this->getOptions());
     $textarea = $this->getCompositeWidget('textarea');
     $textarea->value = $first_option->value;
     $textarea->display();
     $div_tag->close();
     Swat::displayInlineJavaScript($this->getInlineJavaScript());
 }
Example #19
0
 protected function getAuthorRelativeUri(BlorgAuthor $author)
 {
     return Blorg::getAuthorRelativeUri($this->app, $author);
 }
 protected function buildComment(XML_Atom_Feed $feed, BlorgComment $comment)
 {
     $post = $comment->post;
     $path = $this->getBlorgBaseHref() . '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);
     $comment_uri = $post_uri . '#comment' . $comment->id;
     if ($comment->author !== null) {
         $author_name = $comment->author->name;
         if ($comment->author->visible) {
             $author_uri = $this->getBlorgBaseHref() . 'author/' . $comment->author->shortname;
             $author_email = $comment->author->email;
         } else {
             $author_uri = '';
             $author_email = '';
         }
     } else {
         $author_name = $comment->fullname;
         $author_uri = $comment->link;
         // don't show anonymous author email
         $author_email = '';
     }
     $entry = new XML_Atom_Entry($comment_uri, sprintf(Blorg::_('%s on “%s”'), $author_name, $post->getTitle()), $comment->createdate);
     $entry->setContent(SiteCommentFilter::toXhtml($comment->bodytext), 'html');
     $entry->addAuthor($author_name, $author_uri, $author_email);
     $entry->addLink($comment_uri, 'alternate', 'text/html');
     $feed->addEntry($entry);
 }
Example #21
0
 public static function getCommentRelativeUri(SiteApplication $app, SiteComment $comment)
 {
     return Blorg::getPostRelativeUri($app, $comment->post) . '#comment' . $comment->id;
 }
Example #22
0
 protected function getPermalink(SiteComment $comment)
 {
     return $this->app->getFrontendBaseHref() . Blorg::getPostRelativeUri($this->app, $comment->post);
 }
Example #23
0
 protected function getFileMarkupOptions(BlorgFile $file)
 {
     $options = array();
     $uri = $file->getRelativeUri($this->app->config->blorg->path);
     if ($file->image === null) {
         $description = $file->description === null ? $file->filename : $file->description;
         $markup = sprintf('<a class="file" href="%s">%s</a>', $uri, $description);
         $options[] = new SwatOption($markup, 'Link');
     } else {
         // thumbnail
         $img_tag = $file->image->getImgTag('thumb');
         $img_tag->title = $file->description;
         $thumb_markup = sprintf('<a class="file" href="%s">%s</a>', $uri, $img_tag);
         $options[] = new SwatOption($thumb_markup, Blorg::_('Thumbnail'));
         // small
         $img_tag = $file->image->getImgTag('small');
         $img_tag->title = $file->description;
         $small_markup = sprintf('<a class="file" href="%s">%s</a>', $uri, $img_tag);
         $options[] = new SwatOption($small_markup, Blorg::_('Medium'));
         // original
         $img_tag = $file->image->getImgTag('original');
         $img_tag->title = $file->description;
         $original_markup = sprintf('<a class="file" href="%s">%s</a>', $uri, $img_tag);
         $options[] = new SwatOption($original_markup, Blorg::_('Original'));
         // link to file
         $description = $file->description === null ? $file->filename : $file->description;
         $link_markup = sprintf('<a class="file" href="%s">%s</a>', $uri, $description);
         $options[] = new SwatOption($link_markup, Blorg::_('Link Only'));
     }
     return $options;
 }
Example #24
0
 public function getPageTitle()
 {
     return Blorg::_('Spam');
 }
Example #25
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();
     }
 }
Example #26
0
 protected function define()
 {
     $this->defineDefaultTitle(Blorg::_('Search'));
     $this->defineSetting('label', Blorg::_('Label'), 'string', Blorg::_('Keywords …'));
     $this->defineDescription(Blorg::_('Displays a search form, allowing searching from any page that ' . 'displays the sidebar.'));
 }
 public function getPageTitle()
 {
     return Blorg::_('Analytics');
 }
Example #28
0
 protected function displayFooter()
 {
     echo '<div class="footer">';
     $path = $this->app->config->blorg->path;
     $post_count = $this->loader->getPostCount();
     $this->pager = new SwatPagination();
     $this->pager->display_parts ^= SwatPagination::POSITION;
     $this->pager->total_records = $post_count;
     $this->pager->page_size = self::MAX_POSTS;
     $this->pager->setCurrentPage($this->getArgument('page'));
     /* These strings include a non-breaking space */
     $this->pager->previous_label = Blorg::_('« Newer');
     $this->pager->next_label = Blorg::_('Older »');
     $this->pager->link = $path . 'page%s';
     $this->pager->display();
     echo '<div class="results-message">';
     echo $this->pager->getResultsMessage(Blorg::_('post'), Blorg::_('posts'));
     echo '</div>';
     echo '<div class="archive-link">';
     $anchor_tag = new SwatHtmlTag('a');
     $anchor_tag->href = $path . 'archive';
     $anchor_tag->setContent(Blorg::_('Archive'));
     $anchor_tag->display();
     echo '</div>';
     echo '</div>';
 }
Example #29
0
 protected function buildHeader(XML_Atom_Feed $feed)
 {
     parent::buildHeader($feed);
     $feed->setSubTitle(Blorg::_('Recent Posts'));
     $feed->addLink($this->getBlorgBaseHref(), 'alternate', 'text/html');
 }
Example #30
0
 protected function loadBlorgFeedLogo()
 {
     $value = $this->app->config->blorg->feed_logo;
     if ($value == '') {
         $this->ui->getWidget('logo_container')->visible = false;
     } else {
         $change_image = $this->ui->getWidget('change_logo');
         $change_image->title = Blorg::_('Replace Feed Logo');
         $change_image->open = false;
     }
 }