Example #1
0
 public function __construct()
 {
     parent::__construct();
     $this->head->link->append(url::current_site('feed'));
     if (config::get('blog.enable_tagcloud') === 'yes') {
         $tags = ORM::factory('blog_post')->tags();
         if (!empty($tags)) {
             Sidebar::instance()->add('Tagcloud', array('tags' => $tags));
         }
     }
 }
Example #2
0
 public function comments()
 {
     header('Content-Type: text/xml; charset=UTF-8', TRUE);
     if ($cache = $this->cache->get('s7n_blog_feed_comments')) {
         echo $cache;
         return;
     }
     $comments = ORM::factory('blog_comment')->orderby('id', 'desc')->find_all(20);
     $info = array('title' => config::get('s7n.site_title') . ' (Latest Comments)', 'link' => url::current_site(), 'generator' => 'S7Ncms - http://www.s7n.de/');
     $items = array();
     foreach ($comments as $comment) {
         $items[] = array('author' => html::specialchars($comment->author), 'pubDate' => date('r', strtotime($comment->date)), 'title' => 'New comment for "' . $comment->blog_post->title . '"', 'description' => html::specialchars($comment->content), 'link' => $comment->blog_post->url(), 'guid' => $comment->blog_post->url());
     }
     $feed = feed::create($info, $items);
     $this->cache->set('s7n_blog_feed_comments', $feed);
     echo $feed;
 }
Example #3
0
 public function tags()
 {
     $tags = array();
     $query = Database::instance()->select('tags')->get('blog_posts');
     foreach ($query as $result) {
         $exploded = explode(',', $result->tags);
         foreach ($exploded as $tag) {
             $tag = trim($tag);
             if (empty($tag)) {
                 continue;
             }
             if (array_key_exists($tag, $tags)) {
                 $tags[$tag]++;
             } else {
                 $tags[$tag] = 1;
             }
         }
     }
     $result = array();
     foreach ($tags as $title => $count) {
         $result[] = array('title' => $title, 'count' => $count, 'link' => url::current_site('tag/' . $title));
     }
     return $result;
 }