|
From: <al...@us...> - 2008-09-23 22:36:03
|
Revision: 691
http://sciret.svn.sourceforge.net/sciret/?rev=691&view=rev
Author: alpeb
Date: 2008-09-23 22:35:56 +0000 (Tue, 23 Sep 2008)
Log Message:
-----------
[#16] added RSS for categories
Modified Paths:
--------------
trunk/flowMap.php
trunk/templates/MainView.tpl
trunk/views/MainView.php
Added Paths:
-----------
trunk/templates/Rss.tpl
trunk/views/Rss.php
Modified: trunk/flowMap.php
===================================================================
--- trunk/flowMap.php 2008-09-23 20:41:51 UTC (rev 690)
+++ trunk/flowMap.php 2008-09-23 22:35:56 UTC (rev 691)
@@ -18,6 +18,7 @@
'InstallOk' => array(User::ROLE_ANONYMOUS, true, true, false, false),
'Login' => array(User::ROLE_ANONYMOUS, true, true, true, false),
'MainView' => array(User::ROLE_ANONYMOUS, true, true, true, true),
+ 'Rss' => array(User::ROLE_ANONYMOUS, true, false, false, true),
'EditArticle' => array(User::ROLE_REGISTERED, true, true, true),
'EditBookmark' => array(User::ROLE_REGISTERED, true, true, true),
'ViewArticle' => array(User::ROLE_ANONYMOUS, true, true, true, true),
Modified: trunk/templates/MainView.tpl
===================================================================
--- trunk/templates/MainView.tpl 2008-09-23 20:41:51 UTC (rev 690)
+++ trunk/templates/MainView.tpl 2008-09-23 22:35:56 UTC (rev 691)
@@ -48,11 +48,13 @@
</div>
<div>
<div class="title_view">
- <div class="title_content">
+ <div class="title_content" style="position:relative">
<span>
{navigationTitle}
<a href="javascript:void(0)" onclick="addFavorite('location')"><img id="favoriteStarImg" src="images/star.png" alt="[l]Add location to favorites[/l]" title="[l]Add location to favorites[/l]" style="display:{favoriteLocationStarImgDisplay}" /><img id="unFavoriteStarImg" src="images/star_crossed.png" alt="[l]Remove location from favorites[/l]" title="[l]Remove location from favorites[/l]" style="display:{unFavoriteLocationStarImgDisplay}" /><img id="favoriteProgressImg" src="images/progress.gif" style="display:none" /></a>
</span>
+ <span style="position:absolute; right:0; top:7px">
+ <a href="{rssLink}"><img src="images/rss.gif" /></a></span>
</div>
<p class="view_left">
<!-- BEGIN viewAllLink_block -->
Added: trunk/templates/Rss.tpl
===================================================================
--- trunk/templates/Rss.tpl (rev 0)
+++ trunk/templates/Rss.tpl 2008-09-23 22:35:56 UTC (rev 691)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0">
+ <channel>
+ <title>
+ [l]Knowledge Base Articles[/l] {category}
+ </title>
+ <link>{link}</link>
+ <description>
+ [l]Knowledge Base Articles[/l]{category}
+ </description>
+ <generator>Sciret version {version}</generator>
+ <!-- BEGIN articles_block -->
+ <item>
+ <title>{art_title} [l]by[/l] {art_author}</title>
+ <link>{art_link}</link>
+ <description>{art_excerpt}</description>
+ <pubDate>{art_date}</pubDate>
+ </item>
+ <!-- END articles_block -->
+ </channel>
+</rss>
Modified: trunk/views/MainView.php
===================================================================
--- trunk/views/MainView.php 2008-09-23 20:41:51 UTC (rev 690)
+++ trunk/views/MainView.php 2008-09-23 22:35:56 UTC (rev 691)
@@ -71,6 +71,7 @@
'viewBookmarksLink' => Library::getLink(array('view' => 'MainView', 'set' => 'bookmarks')),
'sortByDateLink' => Library::getLink(array('view' => 'MainView', 'sort' => 'created_'.($order == 'created' && $direction == 'desc'? 'asc' : 'desc'))),
'sortByViewsLink' => Library::getLink(array('view' => 'MainView', 'sort' => 'views_'.($order == 'views' && $direction == 'desc'? 'asc' : 'desc'))),
+ 'rssLink' => Library::getLink(array('view' => 'Rss', 'catId' => $catId, 'items' => 10)),
));
if ($catId != 0) {
Added: trunk/views/Rss.php
===================================================================
--- trunk/views/Rss.php (rev 0)
+++ trunk/views/Rss.php 2008-09-23 22:35:56 UTC (rev 691)
@@ -0,0 +1,72 @@
+<?php
+
+/*
+* @copyright Copyright (C) 2005-2008 Keyboard Monkeys Ltd http://www.kb-m.com
+* @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
+* @author Alejandro Pedraza
+* @since Sciret 1.0
+* @package Sciret
+* @packager Keyboard Monkeys
+*/
+
+require_once 'views/View.php';
+require_once 'models/ArticleGateway.php';
+
+class Rss extends View
+{
+ const DEFAULT_NUM_ITEMS = 10;
+ private $_allowedNumItems = array(3, 5, 10, 20);
+
+ public function dispatch()
+ {
+ $this->tpl->set_file('main', 'Rss.tpl');
+ $this->tpl->set_block('main', 'articles_block', 'articles');
+
+ if (isset($_GET['catId']) && $_GET['catId'] > 0) {
+ $catId = (int)$_GET['catId'];
+ $category = new Category($catId);
+ $this->tpl->set_var('category', ' - ' . $this->user->lang('Category %s', $category->getLabel()));
+ } else {
+ $catId = 0;
+ $this->tpl->set_var('category', '');
+ }
+
+ if (!isset($_GET['items']) || !in_array($_GET['items'], $this->_allowedNumItems)) {
+ $_GET['items'] = self::DEFAULT_NUM_ITEMS;
+ }
+
+ $config = new Configuration();
+
+ $this->tpl->set_var(array(
+ 'link' => htmlspecialchars(Library::getLink()),
+ 'version' => $config->getConfigValue('version'),
+ ));
+
+ $articleGateway = new ArticleGateway;
+ $articles = $articleGateway->getArticles( $catId,
+ $this->user->getPreference('navigationType') == 'catAndSubCats',
+ false,
+ false,
+ false,
+ 0,
+ $_GET['items'],
+ isset($_GET['set'])? $_GET['set'] : 'all',
+ isset($_GET['sort'])? $_GET['sort'] : false);
+ $firstIteration = true;
+ while ($article = $articles->fetch()) {
+ unset($this->tPath);
+ $this->tpl->set_var(array(
+ 'art_link' => htmlspecialchars($article->isBookmark()? $article->getURL(true) : Library::getLink(array('view' => 'ViewArticle', 'id' => $article->getId()))),
+ 'art_title' => htmlspecialchars($article->getTitle()),
+ 'art_date' => date('r', strtotime($article->getModifiedByUserId() > 0? $article->getModificationDate() : $article->getCreationDate())),
+ 'art_excerpt' => strip_tags($article->getExcerpt()).($article->isBookmark()? '' : '...'),
+ 'art_author' => htmlspecialchars($article->getCreatedBy()),
+ ));
+
+ $this->tpl->parse('articles', 'articles_block', !$firstIteration);
+ $firstIteration = false;
+ }
+
+ $this->tpl->pparse('out', 'main');
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|