diff options
| author | 2012-10-21 18:47:57 +0200 | |
|---|---|---|
| committer | 2012-10-21 18:47:57 +0200 | |
| commit | fb57be5a5af3a2fb46b2dbf2b503ffe78eb5cf49 (patch) | |
| tree | 9440fc7846d8a56a7005b9ef029669c96ad959aa /app | |
First commit
Diffstat (limited to 'app')
| -rw-r--r-- | app/App_FrontController.php | 29 | ||||
| -rw-r--r-- | app/configuration/application.ini | 9 | ||||
| -rw-r--r-- | app/configuration/routes.php | 5 | ||||
| -rwxr-xr-x | app/controllers/configureController.php | 33 | ||||
| -rwxr-xr-x | app/controllers/entryController.php | 58 | ||||
| -rw-r--r-- | app/controllers/errorController.php | 26 | ||||
| -rwxr-xr-x | app/controllers/feedController.php | 89 | ||||
| -rwxr-xr-x | app/controllers/indexController.php | 34 | ||||
| -rw-r--r-- | app/layout/aside.phtml | 35 | ||||
| -rw-r--r-- | app/layout/layout.phtml | 17 | ||||
| -rwxr-xr-x | app/models/Entry.php | 178 | ||||
| -rw-r--r-- | app/models/Feed.php | 148 | ||||
| -rwxr-xr-x | app/models/RSSConfiguration.php | 76 | ||||
| -rw-r--r-- | app/views/configure/categorize.phtml | 3 | ||||
| -rw-r--r-- | app/views/configure/display.phtml | 28 | ||||
| -rw-r--r-- | app/views/configure/flux.phtml | 3 | ||||
| -rw-r--r-- | app/views/error/index.phtml | 13 | ||||
| -rwxr-xr-x | app/views/helpers/pagination.phtml | 34 | ||||
| -rw-r--r-- | app/views/index/index.phtml | 49 |
19 files changed, 867 insertions, 0 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php new file mode 100644 index 000000000..5a2b27eed --- /dev/null +++ b/app/App_FrontController.php @@ -0,0 +1,29 @@ +<?php +/** + * MINZ - Copyright 2011 Marien Fressinaud + * Sous licence AGPL3 <http://www.gnu.org/licenses/> +*/ +require ('FrontController.php'); + +class App_FrontController extends FrontController { + public function init () { + $this->loadLibs (); + $this->loadModels (); + + Session::init (); + + View::prependStyle (Url::display ('/theme/base.css')); + View::_param ('conf', Session::param ('conf', new RSSConfiguration ())); + } + + private function loadLibs () { + require (LIB_PATH . '/lib_rss.php'); + require (LIB_PATH . '/lib_simplepie.php'); + } + + private function loadModels () { + include (APP_PATH . '/models/RSSConfiguration.php'); + include (APP_PATH . '/models/Feed.php'); + include (APP_PATH . '/models/Entry.php'); + } +} diff --git a/app/configuration/application.ini b/app/configuration/application.ini new file mode 100644 index 000000000..75911aef5 --- /dev/null +++ b/app/configuration/application.ini @@ -0,0 +1,9 @@ +[general]
+environment = "development"
+use_url_rewriting = false
+sel_application = "flux rss lalala ~~~"
+
+base_url = "/~marien/rss/public"
+title = "Flux RSS"
+language = "fr"
+cache_enabled = false ; n'influe pas sur le cache de SimplePie
diff --git a/app/configuration/routes.php b/app/configuration/routes.php new file mode 100644 index 000000000..0efec7ba7 --- /dev/null +++ b/app/configuration/routes.php @@ -0,0 +1,5 @@ +<?php + +return array ( + +); diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php new file mode 100755 index 000000000..0f5d6b658 --- /dev/null +++ b/app/controllers/configureController.php @@ -0,0 +1,33 @@ +<?php + +class configureController extends ActionController { + public function categorizeAction () { + + } + + public function fluxAction () { + + } + + public function displayAction () { + if (Request::isPost ()) { + $nb = Request::param ('posts_per_page', 10); + $view = Request::param ('default_view', 'all'); + $display = Request::param ('display_posts', 'no'); + + $this->view->conf->_postsPerPage (intval ($nb)); + $this->view->conf->_defaultView ($view); + $this->view->conf->_displayPosts ($display); + + $values = array ( + 'posts_per_page' => $this->view->conf->postsPerPage (), + 'default_view' => $this->view->conf->defaultView (), + 'display_posts' => $this->view->conf->displayPosts () + ); + + $confDAO = new RSSConfigurationDAO (); + $confDAO->save ($values); + Session::_param ('conf', $this->view->conf); + } + } +} diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php new file mode 100755 index 000000000..e180cc7f1 --- /dev/null +++ b/app/controllers/entryController.php @@ -0,0 +1,58 @@ +<?php + +class entryController extends ActionController { + public function readAction () { + $id = Request::param ('id'); + $is_read = Request::param ('is_read'); + + if ($is_read) { + $is_read = true; + } else { + $is_read = false; + } + + $entryDAO = new EntryDAO (); + if ($id == false) { + $entries = $entryDAO->listNotReadEntries (); + } else { + $entry = $entryDAO->searchById ($id); + $entries = $entry !== false ? array ($entry) : array (); + } + + foreach ($entries as $entry) { + $values = array ( + 'is_read' => $is_read, + ); + + $entryDAO->updateEntry ($entry->id (), $values); + } + + Request::forward (array (), true); + } + + public function bookmarkAction () { + $id = Request::param ('id'); + $is_fav = Request::param ('is_favorite'); + + if ($is_fav) { + $is_fav = true; + } else { + $is_fav = false; + } + + $entryDAO = new EntryDAO (); + if ($id != false) { + $entry = $entryDAO->searchById ($id); + + if ($entry != false) { + $values = array ( + 'is_favorite' => $is_fav, + ); + + $entryDAO->updateEntry ($entry->id (), $values); + } + } + + Request::forward (array (), true); + } +} diff --git a/app/controllers/errorController.php b/app/controllers/errorController.php new file mode 100644 index 000000000..3b6f202ab --- /dev/null +++ b/app/controllers/errorController.php @@ -0,0 +1,26 @@ +<?php + +class ErrorController extends ActionController { + public function indexAction () { + View::prependTitle (Translate::t ('error') . ' - '); + + switch (Request::param ('code')) { + case 403: + $this->view->code = 'Error 403 - Forbidden'; + break; + case 404: + $this->view->code = 'Error 404 - Not found'; + break; + case 500: + $this->view->code = 'Error 500 - Internal Server Error'; + break; + case 503: + $this->view->code = 'Error 503 - Service Unavailable'; + break; + default: + $this->view->code = 'Error 404 - Not found'; + } + + $this->view->logs = Request::param ('logs'); + } +} diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php new file mode 100755 index 000000000..3b4a90b64 --- /dev/null +++ b/app/controllers/feedController.php @@ -0,0 +1,89 @@ +<?php + +class feedController extends ActionController { + public function addAction () { + if (Request::isPost ()) { + $url = Request::param ('url_rss'); + + try { + $feed = new Feed ($url); + $entries = $feed->loadEntries (); + $feed_entries = array (); + + if ($entries !== false) { + $entryDAO = new EntryDAO (); + + foreach ($entries as $entry) { + $values = array ( + 'id' => $entry->id (), + 'guid' => $entry->guid (), + 'title' => $entry->title (), + 'author' => $entry->author (), + 'content' => $entry->content (), + 'link' => $entry->link (), + 'date' => $entry->date (true), + 'is_read' => $entry->isRead (), + 'is_favorite' => $entry->isFavorite (), + ); + $entryDAO->addEntry ($values); + + $feed_entries[] = $entry->id (); + } + } + + $feedDAO = new FeedDAO (); + $values = array ( + 'id' => $feed->id (), + 'url' => $feed->url (), + 'categories' => $feed->categories (), + 'entries' => $feed_entries + ); + $feedDAO->addFeed ($values); + } catch (Exception $e) { + // TODO ajouter une erreur : url non valide + } + + Request::forward (array (), true); + } + } + + public function actualizeAction () { + $feedDAO = new FeedDAO (); + $entryDAO = new EntryDAO (); + + $feeds = $feedDAO->listFeeds (); + + foreach ($feeds as $feed) { + $entries = $feed->loadEntries (); + $feed_entries = $feed->entries (); + + if ($entries !== false) { + foreach ($entries as $entry) { + $values = array ( + 'id' => $entry->id (), + 'guid' => $entry->guid (), + 'title' => $entry->title (), + 'author' => $entry->author (), + 'content' => $entry->content (), + 'link' => $entry->link (), + 'date' => $entry->date (true), + 'is_read' => $entry->isRead (), + 'is_favorite' => $entry->isFavorite (), + ); + $entryDAO->addEntry ($values); + + if (!in_array ($entry->id (), $feed_entries)) { + $feed_entries[] = $entry->id (); + } + } + } + + $values = array ( + 'entries' => $feed_entries + ); + $feedDAO->updateFeed ($values); + } + + Request::forward (array (), true); + } +} diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php new file mode 100755 index 000000000..3fda234ca --- /dev/null +++ b/app/controllers/indexController.php @@ -0,0 +1,34 @@ +<?php + +class indexController extends ActionController { + public function indexAction () { + $entryDAO = new EntryDAO (); + + $mode = Session::param ('mode', $this->view->conf->defaultView ()); + if ($mode == 'not_read') { + $entries = $entryDAO->listNotReadEntries (); + } elseif ($mode == 'all') { + $entries = $entryDAO->listEntries (); + } + + usort ($entries, 'sortEntriesByDate'); + + //gestion pagination + $page = Request::param ('page', 1); + $this->view->entryPaginator = new Paginator ($entries); + $this->view->entryPaginator->_nbItemsPerPage ($this->view->conf->postsPerPage ()); + $this->view->entryPaginator->_currentPage ($page); + } + + public function changeModeAction () { + $mode = Request::param ('mode'); + + if ($mode == 'not_read') { + Session::_param ('mode', 'not_read'); + } else { + Session::_param ('mode', 'all'); + } + + Request::forward (array (), true); + } +} diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml new file mode 100644 index 000000000..6e2e4965d --- /dev/null +++ b/app/layout/aside.phtml @@ -0,0 +1,35 @@ +<div id="main_aside" class="aside"> + <form id="add_rss" method="post" action="<?php echo Url::display (array ('c' => 'feed', 'a' => 'add')); ?>"> + <input type="url" name="url_rss" placeholder="Ajouter un flux RSS" /> + <input type="submit" value="+" /> + </form> + + <ul id="menu"> + <li <?php echo Request::controllerName () == 'index' ? 'class="active"' : ''; ?>> + <a href="<?php echo Url::display (array ()); ?>">Flux RSS</a> + </li> + <li <?php echo Request::controllerName () == 'configure' ? 'class="active"' : ''; ?>> + <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'categorize')); ?>">Configurer</a> + </li> + <li> + <a href="<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize')); ?>">Mettre les flux à jour</a> + </li> + </ul> +</div> + +<?php if (Request::controllerName () == 'configure') { ?> +<div class="aside"> + <ul id="menu"> + <li><h2>Configuration</h2></li> + <li <?php echo Request::actionName () == 'categorize' ? 'class="active"' : ''; ?>> + <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'categorize')); ?>">Catégories</a> + </li> + <li <?php echo Request::actionName () == 'flux' ? 'class="active"' : ''; ?>> + <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux')); ?>">Flux RSS</a> + </li> + <li <?php echo Request::actionName () == 'display' ? 'class="active"' : ''; ?>> + <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'display')); ?>">Affichage</a> + </li> + </ul> +</div> +<?php } ?> diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml new file mode 100644 index 000000000..ad798c369 --- /dev/null +++ b/app/layout/layout.phtml @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<html lang="fr"> + <head> + <meta charset="utf-8"> + <?php echo self::headTitle(); ?> + <?php echo self::headStyle(); ?> + </head> + <body> +<div id="global"> + <?php $this->partial ('aside'); ?> + + <div id="main"> + <?php $this->render (); ?> + </div> +</div> + </body> +</html> diff --git a/app/models/Entry.php b/app/models/Entry.php new file mode 100755 index 000000000..85e04cb4e --- /dev/null +++ b/app/models/Entry.php @@ -0,0 +1,178 @@ +<?php + +class Entry extends Model { + private $guid; + private $title; + private $author; + private $content; + private $link; + private $date; + private $is_read; + private $is_favorite; + + public function __construct ($guid = '', $title = '', $author = '', $content = '', + $link = '', $pubdate = 0, $is_read = false, $is_favorite = false) { + $this->_guid ($guid); + $this->_title ($title); + $this->_author ($author); + $this->_content ($content); + $this->_link ($link); + $this->_date ($pubdate); + $this->_isRead ($is_read); + $this->_isFavorite ($is_favorite); + } + + public function id () { + return small_hash ($this->guid . Configuration::selApplication ()); + } + public function guid () { + return $this->guid; + } + public function title () { + return $this->title; + } + public function author () { + return $this->author; + } + public function content () { + return $this->content; + } + public function link () { + return $this->link; + } + public function date ($raw = false) { + if ($raw) { + return $this->date; + } else { + return timestamptodate ($this->date); + } + } + public function isRead () { + return $this->is_read; + } + public function isFavorite () { + return $this->is_favorite; + } + + public function _guid ($value) { + $this->guid = $value; + } + public function _title ($value) { + $this->title = $value; + } + public function _author ($value) { + $this->author = $value; + } + public function _content ($value) { + $this->content = $value; + } + public function _link ($value) { + $this->link = $value; + } + public function _date ($value) { + $this->date = $value; + } + public function _isRead ($value) { + $this->is_read = $value; + } + public function _isFavorite ($value) { + $this->is_favorite = $value; + } +} + +class EntryDAO extends Model_array { + public function __construct () { + parent::__construct (PUBLIC_PATH . '/data/db/Entries.array.php'); + } + + public function addEntry ($values) { + $id = $values['id']; + unset ($values['id']); + + if (!isset ($this->array[$id])) { + $this->array[$id] = array (); + + foreach ($values as $key => $value) { + $this->array[$id][$key] = $value; + } + + $this->writeFile ($this->array); + } else { + return false; + } + } + + public function updateEntry ($id, $values) { + foreach ($values as $key => $value) { + $this->array[$id][$key] = $value; + } + + $this->writeFile($this->array); + } + + public function searchById ($id) { + $list = HelperEntry::daoToEntry ($this->array); + + if (isset ($list[$id])) { + return $list[$id]; + } else { + return false; + } + } + + public function listEntries () { + $list = $this->array; + + if (!is_array ($list)) { + $list = array (); + } + + return HelperEntry::daoToEntry ($list); + } + + public function listNotReadEntries () { + $list = $this->array; + $list_not_read = array (); + + if (!is_array ($list)) { + $list = array (); + } + + foreach ($list as $key => $entry) { + if (!$entry['is_read']) { + $list_not_read[$key] = $entry; + } + } + + return HelperEntry::daoToEntry ($list_not_read); + } + + public function count () { + return count ($this->array); + } +} + +class HelperEntry { + public static function daoToEntry ($listDAO) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); + } + + foreach ($listDAO as $key => $dao) { + $list[$key] = new Entry ( + $dao['guid'], + $dao['title'], + $dao['author'], + $dao['content'], + $dao['link'], + $dao['date'], + $dao['is_read'], + $dao['is_favorite'] + ); + } + + return $list; + } +} diff --git a/app/models/Feed.php b/app/models/Feed.php new file mode 100644 index 000000000..583a7fef5 --- /dev/null +++ b/app/models/Feed.php @@ -0,0 +1,148 @@ +<?php + +class Feed extends Model { + private $url; + private $categories; + private $entries_list; + + public function __construct ($url = null) { + $this->_url ($url); + $this->_categories (array ()); + $this->_entries (array ()); + } + + public function id () { + return small_hash ($this->url . Configuration::selApplication ()); + } + public function url () { + return $this->url; + } + public function categories () { + return $this->categories; + } + public function entries () { + return $this->entries_list; + } + + public function _url ($value) { + if (!is_null ($value) && filter_var ($value, FILTER_VALIDATE_URL)) { + $this->url = $value; + } else { + throw new Exception (); + } + } + public function _categories ($value) { + if (!is_array ($value)) { + $value = array ($value); + } + + $this->categories = $value; + } + public function _entries ($value) { + if (!is_array ($value)) { + $value = array ($value); + } + + $this->entries_list = $value; + } + + public function loadEntries () { + if (!is_null ($this->url)) { + $feed = new SimplePie (); + $feed->set_feed_url ($this->url); + $feed->set_cache_location (CACHE_PATH); + $feed->init (); + + $entries = array (); + if ($feed->data) { + foreach ($feed->get_items () as $item) { + $title = $item->get_title (); + $author = $item->get_author (); + $content = $item->get_content (); + $link = $item->get_permalink (); + $date = strtotime ($item->get_date ()); + + $entry = new Entry ( + $item->get_id (), + !is_null ($title) ? $title : '', + !is_null ($author) ? $author->name : '', + !is_null ($content) ? $content : '', + !is_null ($link) ? $link : '', + $date ? $date : time () + ); + + $entries[$entry->id ()] = $entry; + } + + return $entries; + } else { + return false; + } + } else { + return false; + } + } +} + +class FeedDAO extends Model_array { + public function __construct () { + parent::__construct (PUBLIC_PATH . '/data/db/Feeds.array.php'); + } + + public function addFeed ($values) { + $id = $values['id']; + unset ($values['id']); + + if (!isset ($this->array[$id])) { + $this->array[$id] = array (); + + foreach ($values as $key => $value) { + $this->array[$id][$key] = $value; + } + + $this->writeFile ($this->array); + } else { + return false; + } + } + + public function updateFeed ($id, $values) { + foreach ($values as $key => $value) { + $this->array[$id][$key] = $value; + } + + $this->writeFile($this->array); + } + + public function listFeeds () { + $list = $this->array; + + if (!is_array ($list)) { + $list = array (); + } + + return HelperFeed::daoToFeed ($list); + } + + public function count () { + return count ($this->array); + } +} + +class HelperFeed { + public static function daoToFeed ($listDAO) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); + } + + foreach ($listDAO as $key => $dao) { + $list[$key] = new Feed ($dao['url']); + $list[$key]->_categories ($dao['categories']); + $list[$key]->_entries ($dao['entries']); + } + + return $list; + } +} diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php new file mode 100755 index 000000000..f42f1283c --- /dev/null +++ b/app/models/RSSConfiguration.php @@ -0,0 +1,76 @@ +<?php + +class RSSConfiguration extends Model { + private $posts_per_page; + private $default_view; + private $display_posts; + + public function __construct () { + $confDAO = new RSSConfigurationDAO (); + $this->_postsPerPage ($confDAO->posts_per_page); + $this->_defaultView ($confDAO->default_view); + $this->_displayPosts ($confDAO->display_posts); + } + + public function postsPerPage () { + return $this->posts_per_page; + } + public function defaultView () { + return $this->default_view; + } + public function displayPosts () { + return $this->display_posts; + } + + public function _postsPerPage ($value) { + if (is_int ($value)) { + $this->posts_per_page = $value; + } else { + $this->posts_per_page = 10; + } + } + public function _defaultView ($value) { + if ($value == 'not_read') { + $this->default_view = 'not_read'; + } else { + $this->default_view = 'all'; + } + } + public function _displayPosts ($value) { + if ($value == 'yes') { + $this->display_posts = 'yes'; + } else { + $this->display_posts = 'no'; + } + } +} + +class RSSConfigurationDAO extends Model_array { + public $posts_per_page = 10; + public $default_view = 'all'; + public $display_posts = 'no'; + + public function __construct () { + parent::__construct (PUBLIC_PATH . '/data/db/Configuration.array.php'); + + if (isset ($this->array['posts_per_page'])) { + $this->posts_per_page = $this->array['posts_per_page']; + } + if (isset ($this->array['default_view'])) { + $this->default_view = $this->array['default_view']; + } + if (isset ($this->array['display_posts'])) { + $this->display_posts = $this->array['display_posts']; + } + } + + public function save ($values) { + $this->array[0] = array (); + + foreach ($values as $key => $value) { + $this->array[0][$key] = $value; + } + + $this->writeFile($this->array); + } +} diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml new file mode 100644 index 000000000..126f6b48a --- /dev/null +++ b/app/views/configure/categorize.phtml @@ -0,0 +1,3 @@ +<div class="post"> + Fonctionnalité non implémentée (pour le moment) +</div> diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml new file mode 100644 index 000000000..23c41712b --- /dev/null +++ b/app/views/configure/display.phtml @@ -0,0 +1,28 @@ +<div class="post"> + <form method="post" action=""> + <h1>Configuration de l'affichage</h1> + + <label for="posts_per_page">Nombre d'articles par page</label> + <input type="number" id="posts_per_page" name="posts_per_page" value="<?php echo $this->conf->postsPerPage (); ?>" /> + + <label>Vue par défaut</label> + <div class="radio_group"> + <input type="radio" name="default_view" id="radio_all" value="all"<?php echo $this->conf->defaultView () == 'all' ? ' checked="checked"' : ''; ?> /> + <label for="radio_all">Tout afficher</label> + <br /> + <input type="radio" name="default_view" id="radio_not_read" value="not_read"<?php echo $this->conf->defaultView () == 'not_read' ? ' checked="checked"' : ''; ?> /> + <label for="radio_not_read">Afficher les non lus</label> + </div> + + <label>Afficher les articles dépliés par défaut</label> + <div class="radio_group"> + <input type="radio" name="display_posts" id="radio_yes" value="yes"<?php echo $this->conf->displayPosts () ? ' checked="checked"' : ''; ?> /> + <label for="radio_yes">Oui</label> + <br /> + <input type="radio" name="display_posts" id="radio_no" value="no"<?php echo !$this->conf->displayPosts () ? ' checked="checked"' : ''; ?> /> + <label for="radio_no">Non</label> + </div> + + <input type="submit" value="Valider" /> + </form> +</div> diff --git a/app/views/configure/flux.phtml b/app/views/configure/flux.phtml new file mode 100644 index 000000000..126f6b48a --- /dev/null +++ b/app/views/configure/flux.phtml @@ -0,0 +1,3 @@ +<div class="post"> + Fonctionnalité non implémentée (pour le moment) +</div> diff --git a/app/views/error/index.phtml b/app/views/error/index.phtml new file mode 100644 index 000000000..ffa156068 --- /dev/null +++ b/app/views/error/index.phtml @@ -0,0 +1,13 @@ +<h1><?php echo Translate::t ('an error occured'); ?></h1> + +<h2><?php echo $this->code; ?></h2> + +<?php if (!empty ($this->logs)) { ?> +<ul> + <?php foreach ($this->logs as $log) { ?> + <li><?php echo $log; ?></li> + <?php } ?> +</ul> +<?php } ?> + +<p><a href="<?php echo Url::display (); ?>"><?php echo Translate::t ('go back home'); ?></a></p> diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml new file mode 100755 index 000000000..fe9feb0e8 --- /dev/null +++ b/app/views/helpers/pagination.phtml @@ -0,0 +1,34 @@ +<?php + $c = Request::controllerName (); + $a = Request::actionName (); + $params = Request::params (); +?> + +<?php if ($this->nbPage > 1) { ?> +<ul class="pagination"> + <?php if ($this->currentPage > 1) { ?> + <?php $params[$getteur] = 1; ?> + <li class="pager-first"><a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">« Début</a></li> + <?php $params[$getteur] = $this->currentPage - 1; ?> + <li class="pager-previous"><a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">‹ Précédent</a></li> + <?php } ?> + + <?php for ($i = $this->currentPage - 2; $i <= $this->currentPage + 2; $i++) { ?> + <?php if($i > 0 && $i <= $this->nbPage) { ?> + <?php if ($i != $this->currentPage) { ?> + <?php $params[$getteur] = $i; ?> + <li class="pager-item"><a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>"><?php echo $i; ?></a></li> + <?php } else { ?> + <li class="pager-current"><?php echo $i; ?></li> + <?php } ?> + <?php } ?> + <?php } ?> + + <?php if ($this->currentPage < $this->nbPage) { ?> + <?php $params[$getteur] = $this->currentPage + 1; ?> + <li class="pager-next"><a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">Suivant ›</a></li> + <?php $params[$getteur] = $this->nbPage; ?> + <li class="pager-last"><a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">Fin »</a></li> + <?php } ?> +</ul> +<?php } ?> diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml new file mode 100644 index 000000000..2dfdb5064 --- /dev/null +++ b/app/views/index/index.phtml @@ -0,0 +1,49 @@ +<div id="top"> + <a class="read_all" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('is_read' => 1))); ?>">Tout marquer comme lu</a><!-- + <?php if (Session::param ('mode', 'all') == 'not_read') { ?> + --><a class="print_all" href="<?php echo Url::display (array ('a' => 'changeMode', 'params' => array ('mode' => 'all'))); ?>">Tout afficher</a> + <?php } else { ?> + --><a class="print_non_read" href="<?php echo Url::display (array ('a' => 'changeMode', 'params' => array ('mode' => 'not_read'))); ?>">Afficher les non lus</a> + <?php } ?> +</div> + +<div id="stream"> +<?php $items = $this->entryPaginator->items (); ?> +<?php if (!empty ($items)) { ?> + <?php $this->entryPaginator->render ('pagination.phtml', 'page'); ?> + + <?php foreach ($items as $item) { ?> + <div class="post flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>"> + <div class="before"><?php echo $item->author (); ?> a écrit le <?php echo $item->date (); ?>,</div> + + <h1><a target="_blank" href="<?php echo $item->link (); ?>"> <?php echo $item->title (); ?></a></h1> + <div class="content"><?php echo $item->content (); ?></div> + + <div class="after"> + <?php if (!$item->isRead ()) { ?> + <a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 1))); ?>">J'ai fini de lire l'article</a><!-- + <?php } else { ?> + <a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 0))); ?>">Marquer comme non lu</a><!-- + <?php } ?> + + <?php if (!$item->isFavorite ()) { ?> + --><a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 1))); ?>">Ajouter l'article à mes favoris</a> + <?php } else { ?> + --><a href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 0))); ?>">Retirer l'article de mes favoris</a> + <?php } ?> + </div> + </div> + <?php } ?> + + <?php $this->entryPaginator->render ('pagination.phtml', 'page'); ?> +<?php } else { ?> + <div class="post flux"> + <p> + Il n'y a aucun flux à afficher. + <?php if (Session::param ('mode', 'all') == 'not_read') { ?> + <a class="print_all" href="<?php echo Url::display (array ('a' => 'changeMode', 'params' => array ('mode' => 'all'))); ?>">Afficher tous les articles ?</a> + <?php } ?> + </p> + </div> +<?php } ?> +</div> |
