diff options
Diffstat (limited to 'app')
25 files changed, 515 insertions, 184 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php index 0ff7bf182..5a66ae1dd 100644 --- a/app/App_FrontController.php +++ b/app/App_FrontController.php @@ -9,42 +9,47 @@ class App_FrontController extends FrontController { public function init () { $this->loadLibs (); $this->loadModels (); - + Session::init (); // lancement de la session doit se faire après chargement des modèles sinon bug (pourquoi ?) $this->loadParamsView (); $this->loadStylesAndScripts (); $this->loadNotifications (); } - + private function loadLibs () { require (LIB_PATH . '/lib_phpQuery.php'); require (LIB_PATH . '/lib_rss.php'); - require (LIB_PATH . '/lib_simplepie.php'); + require (LIB_PATH . '/SimplePie_autoloader.php'); require (LIB_PATH . '/lib_text.php'); } - + private function loadModels () { + include (APP_PATH . '/models/Exception/FeedException.php'); include (APP_PATH . '/models/RSSConfiguration.php'); include (APP_PATH . '/models/Days.php'); include (APP_PATH . '/models/Category.php'); include (APP_PATH . '/models/Feed.php'); include (APP_PATH . '/models/Entry.php'); } - - private function loadStylesAndScripts () { - View::prependStyle (Url::display ('/theme/base.css')); - View::appendScript ('https://login.persona.org/include.js'); - View::appendScript (Url::display ('/scripts/jquery.js')); - View::appendScript (Url::display ('/scripts/notification.js')); - } - + private function loadParamsView () { - View::_param ('conf', Session::param ('conf', new RSSConfiguration ())); - + $this->conf = Session::param ('conf', new RSSConfiguration ()); + View::_param ('conf', $this->conf); + $entryDAO = new EntryDAO (); View::_param ('nb_not_read', $entryDAO->countNotRead ()); } - + + private function loadStylesAndScripts () { + View::appendStyle (Url::display ('/theme/global.css')); + View::appendStyle (Url::display ('/theme/freshrss.css')); + if (login_is_conf ($this->conf)) { + View::appendScript ('https://login.persona.org/include.js'); + } + View::appendScript (Url::display ('/scripts/jquery.js')); + View::appendScript (Url::display ('/scripts/notification.js')); + } + private function loadNotifications () { $notif = Session::param ('notification'); if ($notif) { diff --git a/app/configuration/.gitignore b/app/configuration/.gitignore new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/app/configuration/.gitignore @@ -0,0 +1 @@ +* diff --git a/app/configuration/application.ini b/app/configuration/application.ini deleted file mode 100644 index 2beb60324..000000000 --- a/app/configuration/application.ini +++ /dev/null @@ -1,13 +0,0 @@ -[general]
-environment = "development"
-use_url_rewriting = false
-sel_application = "flux rss lalala ~~~"
-
-base_url = "/~marien/rss/public" ; pas de slash à la fin /!\
-title = "FreshRSS"
-
-[db]
-host = "localhost"
-user = "bd"
-password = "bede"
-base = "marienfr_rss"
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 243c155f9..18a56c066 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -56,6 +56,7 @@ class configureController extends ActionController { } $this->view->categories = $catDAO->listCategories (); + $this->view->defaultCategory = $catDAO->getDefault (); View::prependTitle ('Gestion des catégories - '); } @@ -88,10 +89,12 @@ class configureController extends ActionController { if (Request::isPost () && $this->view->flux) { $cat = Request::param ('category', 0); $path = Request::param ('path_entries', ''); + $priority = Request::param ('priority', 0); $values = array ( 'category' => $cat, - 'pathEntries' => $path + 'pathEntries' => $path, + 'priority' => $priority ); if ($feedDAO->updateFeed ($id, $values)) { @@ -130,6 +133,7 @@ class configureController extends ActionController { $openArticle = Request::param ('mark_open_article', 'no'); $openSite = Request::param ('mark_open_site', 'no'); $openPage = Request::param ('mark_open_page', 'no'); + $urlShaarli = Request::param ('shaarli', ''); $this->view->conf->_postsPerPage (intval ($nb)); $this->view->conf->_defaultView ($view); @@ -142,6 +146,7 @@ class configureController extends ActionController { 'site' => $openSite, 'page' => $openPage, )); + $this->view->conf->_urlShaarli ($urlShaarli); $values = array ( 'posts_per_page' => $this->view->conf->postsPerPage (), @@ -151,6 +156,7 @@ class configureController extends ActionController { 'old_entries' => $this->view->conf->oldEntries (), 'mail_login' => $this->view->conf->mailLogin (), 'mark_when' => $this->view->conf->markWhen (), + 'url_shaarli' => $this->view->conf->urlShaarli (), ); $confDAO = new RSSConfigurationDAO (); @@ -178,7 +184,8 @@ class configureController extends ActionController { View::_title ('feeds_opml.xml'); $this->view->_useLayout (false); - header('Content-type: text/xml'); + header('Content-Type: text/xml; charset=utf-8'); + header('Content-disposition: attachment; filename=feeds_opml.xml'); $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index e16161842..c67609d57 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -33,9 +33,17 @@ class feedController extends ActionController { 'description' => $feed->description (), 'lastUpdate' => time () ); - if ($feedDAO->addFeed ($values)) { + + if ($feedDAO->searchByUrl ($values['url'])) { + $notif = array ( + 'type' => 'bad', + 'content' => 'Vous êtes déjà abonné à <em>' . $feed->name () . '</em>' + ); + Session::_param ('notification', $notif); + } elseif ($feedDAO->addFeed ($values)) { $entryDAO = new EntryDAO (); $entries = $feed->entries (); + foreach ($entries as $entry) { $values = $entry->toArray (); $entryDAO->addEntry ($values); @@ -56,6 +64,13 @@ class feedController extends ActionController { ); Session::_param ('notification', $notif); } + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + $notif = array ( + 'type' => 'bad', + 'content' => 'Un problème interne a été rencontré, le flux n\'a pas pu être ajouté' + ); + Session::_param ('notification', $notif); } catch (FileNotExistException $e) { Log::record ($e->getMessage (), Log::ERROR); // notif @@ -82,7 +97,16 @@ class feedController extends ActionController { $feedDAO = new FeedDAO (); $entryDAO = new EntryDAO (); - $feeds = $feedDAO->listFeedsOrderUpdate (); + $id = Request::param ('id'); + $feeds = array (); + if ($id) { + $feed = $feedDAO->searchById ($id); + if ($feed) { + $feeds = array ($feed); + } + } else { + $feeds = $feedDAO->listFeedsOrderUpdate (); + } // pour ne pas ajouter des entrées trop anciennes $nb_month_old = $this->view->conf->oldEntries (); @@ -90,17 +114,21 @@ class feedController extends ActionController { $i = 0; foreach ($feeds as $feed) { - $feed->load (); - $entries = $feed->entries (); + try { + $feed->load (); + $entries = $feed->entries (); - foreach ($entries as $entry) { - if ($entry->date (true) >= $date_min) { - $values = $entry->toArray (); - $entryDAO->addEntry ($values); + foreach ($entries as $entry) { + if ($entry->date (true) >= $date_min) { + $values = $entry->toArray (); + $entryDAO->addEntry ($values); + } } - } - $feedDAO->updateLastUpdate ($feed->id ()); + $feedDAO->updateLastUpdate ($feed->id ()); + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + } $i++; if ($i >= 10) { @@ -111,13 +139,37 @@ class feedController extends ActionController { $entryDAO->cleanOldEntries ($nb_month_old); // notif - $notif = array ( - 'type' => 'good', - 'content' => '10 flux ont été mis à jour' - ); - Session::_param ('notification', $notif); + $url = array (); + if ($i == 1) { + $feed = reset ($feeds); + $notif = array ( + 'type' => 'good', + 'content' => '<em>' . $feed->name () . '</em> a été mis à jour' + ); + $url['params'] = array ('get' => 'f_' . $feed->id ()); + } elseif ($i > 0) { + $notif = array ( + 'type' => 'good', + 'content' => $i . ' flux ont été mis à jour' + ); + } else { + $notif = array ( + 'type' => 'bad', + 'content' => 'Aucun flux n\'a pu être mis à jour' + ); + } - Request::forward (array (), true); + if (Request::param ('ajax', 0) == 0) { + Session::_param ('notification', $notif); + Request::forward ($url, true); + } else { + $notif = array ( + 'type' => 'good', + 'content' => 'Les flux ont été mis à jour' + ); + Session::_param ('notification', $notif); + $this->view->_useLayout (false); + } } public function massiveImportAction () { @@ -138,28 +190,49 @@ class feedController extends ActionController { $nb_month_old = $this->view->conf->oldEntries (); $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old); + $error = false; $i = 0; foreach ($feeds as $feed) { - $feed->load (); + try { + $feed->load (); - // Enregistrement du flux - $values = array ( - 'id' => $feed->id (), - 'url' => $feed->url (), - 'category' => $feed->category (), - 'name' => $feed->name (), - 'website' => $feed->website (), - 'description' => $feed->description (), - 'lastUpdate' => 0 - ); + // Enregistrement du flux + $values = array ( + 'id' => $feed->id (), + 'url' => $feed->url (), + 'category' => $feed->category (), + 'name' => $feed->name (), + 'website' => $feed->website (), + 'description' => $feed->description (), + 'lastUpdate' => 0 + ); - $feedDAO->addFeed ($values); + if (!$feedDAO->searchByUrl ($values['url'])) { + if (!$feedDAO->addFeed ($values)) { + $error = true; + } + } + } catch (FeedException $e) { + $error = true; + Log::record ($e->getMessage (), Log::ERROR); + } } + if ($error) { + $res = 'Les flux ont été importés mais des erreurs sont survenus'; + } else { + $res = 'Les flux ont été importés'; + } + $notif = array ( + 'type' => 'good', + 'content' => $res + ); + Session::_param ('notification', $notif); + Request::forward (array ( - 'c' => 'feed', - 'a' => 'actualize' - )); + 'c' => 'configure', + 'a' => 'importExport' + ), true); } } @@ -170,19 +243,43 @@ class feedController extends ActionController { array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) ); } else { + $type = Request::param ('type', 'feed'); $id = Request::param ('id'); $feedDAO = new FeedDAO (); - $feedDAO->deleteFeed ($id); + if ($type == 'category') { + if ($feedDAO->deleteFeedByCategory ($id)) { + $notif = array ( + 'type' => 'good', + 'content' => 'La catégorie a été vidée' + ); + } else { + $notif = array ( + 'type' => 'bad', + 'content' => 'Un problème est survenu' + ); + } + } else { + if ($feedDAO->deleteFeed ($id)) { + $notif = array ( + 'type' => 'good', + 'content' => 'Le flux a été supprimé' + ); + } else { + $notif = array ( + 'type' => 'bad', + 'content' => 'Un problème est survenu' + ); + } + } - // notif - $notif = array ( - 'type' => 'good', - 'content' => 'Le flux a été supprimé' - ); Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + if ($type == 'category') { + Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); + } else { + Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + } } } @@ -190,7 +287,7 @@ class feedController extends ActionController { $catDAO = new CategoryDAO (); foreach ($categories as $cat) { - if (!$catDAO->searchByName ()) { + if (!$catDAO->searchByName ($cat->name ())) { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index c83f7f1d2..8fa911631 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -8,6 +8,7 @@ class indexController extends ActionController { public function indexAction () { View::appendScript (Url::display ('/scripts/shortcut.js')); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); + View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); $entryDAO = new EntryDAO (); $feedDAO = new FeedDAO (); @@ -38,6 +39,9 @@ class indexController extends ActionController { } elseif ($this->get['type'] == 'favoris') { $entries = $entryDAO->listFavorites ($this->mode, $search, $order); View::prependTitle ('Vos favoris - '); + } elseif ($this->get['type'] == 'public') { + $entries = $entryDAO->listPublic ($this->mode, $search, $order); + View::prependTitle ('Public - '); } elseif ($this->get != false) { if ($this->get['type'] == 'c') { $cat = $catDAO->searchById ($this->get['filter']); @@ -76,13 +80,15 @@ class indexController extends ActionController { try { $this->view->entryPaginator = $entryDAO->getPaginator ($entries); - } catch (CurrentPagePaginationException $e) { - - } + } catch (CurrentPagePaginationException $e) { } $this->view->cat_aside = $catDAO->listCategories (); $this->view->nb_favorites = $entryDAO->countFavorites (); $this->view->nb_total = $entryDAO->count (); + + if (Request::param ('output', '') == 'rss') { + $this->view->_useLayout (false); + } } } @@ -163,6 +169,13 @@ class indexController extends ActionController { 'type' => $get, 'filter' => $get ); + } elseif ($get == 'public') { + $this->view->get_c = $get; + + $this->get = array ( + 'type' => $get, + 'filter' => $get + ); } elseif ($get == false) { $this->get = array ( 'type' => 'all', diff --git a/app/controllers/javascriptController.php b/app/controllers/javascriptController.php index 8060f560c..071cf65a4 100755 --- a/app/controllers/javascriptController.php +++ b/app/controllers/javascriptController.php @@ -5,8 +5,11 @@ class javascriptController extends ActionController { $this->view->_useLayout (false); header('Content-type: text/javascript'); } - - public function mainAction () { - + + public function mainAction () {} + + public function actualizeAction () { + $feedDAO = new FeedDAO (); + $this->view->feeds = $feedDAO->listFeeds (); } } diff --git a/app/controllers/rssController.php b/app/controllers/rssController.php deleted file mode 100755 index 1f66f4517..000000000 --- a/app/controllers/rssController.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -class rssController extends ActionController { - public function firstAction() { - header('Content-Type: text/xml'); - header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - - $this->view->_useLayout (false); - } - - public function publicAction () { - $entryDAO = new EntryDAO (); - $entryDAO->_nbItemsPerPage (-1); - - $items = $entryDAO->listPublic ('low_to_high'); - - try { - $page = Request::param('page', 1); - $nb = Request::param('nb', 15); - $this->view->itemPaginator = new Paginator($items); - $this->view->itemPaginator->_nbItemsPerPage($nb); - $this->view->itemPaginator->_currentPage($page); - } catch(CurrentPagePaginationException $e) { - Error::error( - 404, - array('error' => array('La page que vous cherchez n\'existe pas')) - ); - } - } - - public function getNbNotReadAction() { - } -} diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index aaeb225eb..bd92b3393 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -35,7 +35,7 @@ <?php foreach ($this->feeds as $feed) { ?> <li class="item<?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?>"> <a href="<?php echo _url ('configure', 'feed', 'id', $feed->id ()); ?>"> - <img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="favicon <?php echo $feed->name (); ?>" /> + <img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="" /> <?php echo $feed->name (); ?> </a> </li> diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 1d1700170..3a6ecb304 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -1,7 +1,31 @@ -<div class="aside aside_flux"> +<div class="aside aside_flux" id="aside_flux"> + <a class="toggle_aside" href="#close"><i class="icon i_close"></i></a> + <ul class="categories"> + <?php + $get = Request::param ('get', ''); + $search = Request::param ('search', ''); + $url = array ( + 'c' => 'index', + 'a' => 'index', + 'params' => array ( + 'output' => 'rss' + ) + ); + if ($get != '') { + $url['params']['get'] = $get; + } + if ($search != '') { + $url['params']['search'] = $search; + } + ?> <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> - <li><a class="btn btn-important" href="<?php echo _url ('configure', 'feed'); ?>">Gestion des abonnements</a></li> + <li> + <div class="stick"> + <a class="btn btn-important" href="<?php echo _url ('configure', 'feed'); ?>">Gestion des abonnements</a> + <a class="btn btn-important" href="<?php echo Url::display ($url); ?>"><i class="icon i_rss"></i></a> + </div> + </li> <?php } ?> <li> @@ -50,17 +74,20 @@ <ul class="dropdown-menu"> <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> <li class="item"><a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>">Filtrer</a></li> - <li class="separator"></li> + <li class="item"><a target="_blank" href="<?php echo $feed->website (); ?>">Voir le site</a></li> <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> + <li class="separator"></li> + <li class="item"><a href="<?php echo _url ('configure', 'feed', 'id', $feed->id ()); ?>">Gestion</a></li> + <li class="item"><a href="<?php echo _url ('feed', 'actualize', 'id', $feed->id ()); ?>">Actualiser</a></li> + <li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', 'f_' . $feed->id ()); ?>">Marquer comme lu</a></li> <?php } ?> - <li class="item"><a href="<?php echo $feed->website (); ?>">Voir le site</a></li> </ul> </div> <?php $not_read = $feed->nbNotRead (); ?> - <img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="favicon <?php echo $feed->name (); ?>" /> + <img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="" /> <?php echo $not_read > 0 ? '<b>' : ''; ?> <a class="feed" href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"> <?php echo $not_read > 0 ? '(' . $not_read . ') ' : ''; ?> diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 4962c3aa5..5d7dd3091 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -1,5 +1,7 @@ <div class="nav_menu"> - <a class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a> + <a class="btn toggle_aside" href="#aside_flux"><i class="icon i_category"></i></a> + + <a id="actualize" class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a> <?php $get = false; diff --git a/app/models/Category.php b/app/models/Category.php index d7db8ee65..7ce572e71 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -77,6 +77,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -94,6 +96,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -107,6 +111,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -152,6 +158,20 @@ class CategoryDAO extends Model_pdo { return HelperCategory::daoToCategory ($stm->fetchAll (PDO::FETCH_ASSOC)); } + public function getDefault () { + $sql = 'SELECT * FROM category WHERE id="000000"'; + $stm = $this->bd->prepare ($sql); + + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $cat = HelperCategory::daoToCategory ($res); + + if (isset ($cat[0])) { + return $cat[0]; + } else { + return false; + } + } public function checkDefault () { $def_cat = $this->searchById ('000000'); diff --git a/app/models/Entry.php b/app/models/Entry.php index 3e90db289..230b457bf 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -49,7 +49,11 @@ class Entry extends Model { return $this->title; } public function author () { - return $this->author; + if (is_null ($this->author)) { + return ''; + } else { + return $this->author; + } } public function content () { return $this->content; @@ -212,7 +216,7 @@ class Entry extends Model { class EntryDAO extends Model_pdo { public function addEntry ($valuesTmp) { - $sql = 'INSERT INTO entry(id, guid, title, author, content, link, date, is_read, is_favorite, is_public, id_feed, annotation, tags, lastUpdate) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + $sql = 'INSERT INTO entry(id, guid, title, author, content, link, date, is_read, is_favorite, is_public, id_feed, lastUpdate) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -227,14 +231,14 @@ class EntryDAO extends Model_pdo { $valuesTmp['is_favorite'], $valuesTmp['is_public'], $valuesTmp['id_feed'], - $valuesTmp['annotation'], - $valuesTmp['tags'], $valuesTmp['lastUpdate'], ); if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -261,12 +265,14 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } public function markReadEntries ($read, $dateMax) { - $sql = 'UPDATE entry SET is_read = ? WHERE date < ?'; + $sql = 'UPDATE entry e INNER JOIN feed f ON e.id_feed = f.id SET is_read = ? WHERE date < ? AND priority > 0'; $stm = $this->bd->prepare ($sql); $values = array ($read, $dateMax); @@ -274,6 +280,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -286,6 +294,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -298,6 +308,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -323,13 +335,15 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } public function cleanOldEntries ($nb_month) { $date = 60 * 60 * 24 * 30 * $nb_month; - $sql = 'DELETE FROM entry WHERE date <= ? AND is_favorite = 0 AND notes != ""'; + $sql = 'DELETE FROM entry WHERE date <= ? AND is_favorite = 0 AND annotation = ""'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -339,6 +353,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -361,19 +377,15 @@ class EntryDAO extends Model_pdo { } public function listEntries ($mode, $search = false, $order = 'high_to_low') { - $where = ''; + $where = ' WHERE priority > 0'; if ($mode == 'not_read') { - $where = ' WHERE is_read=0'; + $where .= ' AND is_read=0'; } $values = array(); if ($search) { $values[] = '%'.$search.'%'; - if ($mode == 'not_read') { - $where = ' AND title LIKE ?'; - } else { - $where = ' WHERE title LIKE ?'; - } + $where .= ' AND title LIKE ?'; } if ($order == 'low_to_high') { @@ -382,7 +394,7 @@ class EntryDAO extends Model_pdo { $order = ''; } - $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where; $stm = $this->bd->prepare ($sql); $stm->execute ($values); $res = $stm->fetchAll (PDO::FETCH_ASSOC); @@ -391,7 +403,8 @@ class EntryDAO extends Model_pdo { $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; $fin = $this->nbItemsPerPage; - $sql = 'SELECT * FROM entry' . $where + $sql = 'SELECT e.* FROM entry e' + . ' INNER JOIN feed f ON e.id_feed = f.id' . $where . ' ORDER BY date' . $order . ' LIMIT ' . $deb . ', ' . $fin; $stm = $this->bd->prepare ($sql); @@ -409,7 +422,7 @@ class EntryDAO extends Model_pdo { $values = array(); if ($search) { $values[] = '%'.$search.'%'; - $where = ' AND title LIKE ?'; + $where .= ' AND title LIKE ?'; } if ($order == 'low_to_high') { @@ -442,8 +455,17 @@ class EntryDAO extends Model_pdo { return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); } - public function listPublic ($order = 'high_to_low') { + public function listPublic ($mode, $search = false, $order = 'high_to_low') { $where = ' WHERE is_public=1'; + if ($mode == 'not_read') { + $where .= ' AND is_read=0'; + } + + $values = array(); + if ($search) { + $values[] = '%'.$search.'%'; + $where .= ' AND title LIKE ?'; + } if ($order == 'low_to_high') { $order = ' DESC'; @@ -451,10 +473,26 @@ class EntryDAO extends Model_pdo { $order = ''; } - $sql = 'SELECT * FROM entry' . $where . ' ORDER BY date' . $order; + $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; + $stm = $this->bd->prepare ($sql); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $this->nbItems = $res[0]['count']; + + if($this->nbItemsPerPage < 0) { + $sql = 'SELECT * FROM entry' . $where + . ' ORDER BY date' . $order; + } else { + $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; + $fin = $this->nbItemsPerPage; + $sql = 'SELECT * FROM entry' . $where + . ' ORDER BY date' . $order + . ' LIMIT ' . $deb . ', ' . $fin; + } $stm = $this->bd->prepare ($sql); - $stm->execute (); + + $stm->execute ($values); return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); } @@ -468,7 +506,7 @@ class EntryDAO extends Model_pdo { $values = array ($cat); if ($search) { $values[] = '%'.$search.'%'; - $where = ' AND title LIKE ?'; + $where .= ' AND title LIKE ?'; } if ($order == 'low_to_high') { @@ -502,10 +540,10 @@ class EntryDAO extends Model_pdo { $where .= ' AND is_read=0'; } - $values = array(); + $values = array($feed); if ($search) { $values[] = '%'.$search.'%'; - $where = ' AND title LIKE ?'; + $where .= ' AND title LIKE ?'; } if ($order == 'low_to_high') { @@ -516,7 +554,6 @@ class EntryDAO extends Model_pdo { $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; $stm = $this->bd->prepare ($sql); - $values = array ($feed); $stm->execute ($values); $res = $stm->fetchAll (PDO::FETCH_ASSOC); $this->nbItems = $res[0]['count']; @@ -529,15 +566,13 @@ class EntryDAO extends Model_pdo { $stm = $this->bd->prepare ($sql); - $values = array ($feed); - $stm->execute ($values); return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); } public function count () { - $sql = 'SELECT COUNT(*) AS count FROM entry'; + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE priority > 0'; $stm = $this->bd->prepare ($sql); $stm->execute (); $res = $stm->fetchAll (PDO::FETCH_ASSOC); @@ -546,7 +581,7 @@ class EntryDAO extends Model_pdo { } public function countNotRead () { - $sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_read=0'; + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE is_read=0 AND priority > 0'; $stm = $this->bd->prepare ($sql); $stm->execute (); $res = $stm->fetchAll (PDO::FETCH_ASSOC); diff --git a/app/models/Exception/FeedException.php b/app/models/Exception/FeedException.php new file mode 100644 index 000000000..3fe0f4ea0 --- /dev/null +++ b/app/models/Exception/FeedException.php @@ -0,0 +1,7 @@ +<?php + +class FeedException extends Exception { + public function __construct ($message) { + parent::__construct ($message); + } +} diff --git a/app/models/Feed.php b/app/models/Feed.php index 91c8d8022..222e22256 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -9,6 +9,7 @@ class Feed extends Model { private $website = ''; private $description = ''; private $lastUpdate = 0; + private $priority = 10; private $pathEntries = ''; private $httpAuth = ''; @@ -48,6 +49,9 @@ class Feed extends Model { public function lastUpdate () { return $this->lastUpdate; } + public function priority () { + return $this->priority; + } public function pathEntries () { return $this->pathEntries; } @@ -108,6 +112,12 @@ class Feed extends Model { public function _lastUpdate ($value) { $this->lastUpdate = $value; } + public function _priority ($value) { + if (!is_int (intval ($value))) { + $value = 10; + } + $this->priority = $value; + } public function _pathEntries ($value) { $this->pathEntries = $value; } @@ -124,10 +134,14 @@ class Feed extends Model { ); } else { $feed = new SimplePie (); - $feed->set_feed_url ($this->url); + $feed->set_feed_url (preg_replace ('/&/', '&', $this->url)); $feed->set_cache_location (CACHE_PATH); $feed->init (); + if ($feed->error()) { + throw new FeedException ($feed->error); + } + $subscribe_url = $feed->subscribe_url (); if (!is_null ($subscribe_url) && $subscribe_url != $this->url) { $this->_url ($subscribe_url); @@ -191,7 +205,7 @@ class Feed extends Model { class FeedDAO extends Model_pdo { public function addFeed ($valuesTmp) { - $sql = 'INSERT INTO feed (id, url, category, name, website, description, lastUpdate) VALUES(?, ?, ?, ?, ?, ?, ?)'; + $sql = 'INSERT INTO feed (id, url, category, name, website, description, lastUpdate, priority, error) VALUES(?, ?, ?, ?, ?, ?, ?, 10, 0)'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -207,6 +221,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -229,6 +245,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -245,6 +263,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -258,6 +278,22 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function deleteFeedByCategory ($id) { + $sql = 'DELETE FROM feed WHERE category=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -278,6 +314,22 @@ class FeedDAO extends Model_pdo { return false; } } + public function searchByUrl ($url) { + $sql = 'SELECT * FROM feed WHERE url=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($url); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $feed = current (HelperFeed::daoToFeed ($res)); + + if (isset ($feed)) { + return $feed; + } else { + return false; + } + } public function listFeeds () { $sql = 'SELECT * FROM feed ORDER BY name'; @@ -354,6 +406,7 @@ class HelperFeed { $list[$key]->_website ($dao['website']); $list[$key]->_description ($dao['description']); $list[$key]->_lastUpdate ($dao['lastUpdate']); + $list[$key]->_priority ($dao['priority']); $list[$key]->_pathEntries ($dao['pathEntries']); $list[$key]->_httpAuth ($dao['httpAuth']); diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index 270ec2ce1..ca56ec3a8 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -9,6 +9,7 @@ class RSSConfiguration extends Model { private $shortcuts = array (); private $mail_login = ''; private $mark_when = array (); + private $url_shaarli = ''; public function __construct () { $confDAO = new RSSConfigurationDAO (); @@ -20,6 +21,7 @@ class RSSConfiguration extends Model { $this->_shortcuts ($confDAO->shortcuts); $this->_mailLogin ($confDAO->mail_login); $this->_markWhen ($confDAO->mark_when); + $this->_urlShaarli ($confDAO->url_shaarli); } public function postsPerPage () { @@ -55,6 +57,9 @@ class RSSConfiguration extends Model { public function markWhenPage () { return $this->mark_when['page']; } + public function urlShaarli () { + return $this->url_shaarli; + } public function _postsPerPage ($value) { if (is_int (intval ($value))) { @@ -108,11 +113,17 @@ class RSSConfiguration extends Model { $this->mark_when['site'] = $values['site']; $this->mark_when['page'] = $values['page']; } + public function _urlShaarli ($value) { + $this->url_shaarli = ''; + if (filter_var ($value, FILTER_VALIDATE_URL)) { + $this->url_shaarli = $value; + } + } } class RSSConfigurationDAO extends Model_array { - public $posts_per_page = 10; - public $default_view = 'all'; + public $posts_per_page = 20; + public $default_view = 'not_read'; public $display_posts = 'no'; public $sort_order = 'low_to_high'; public $old_entries = 3; @@ -131,6 +142,7 @@ class RSSConfigurationDAO extends Model_array { 'site' => 'yes', 'page' => 'no' ); + public $url_shaarli = ''; public function __construct () { parent::__construct (PUBLIC_PATH . '/data/Configuration.array.php'); @@ -159,6 +171,9 @@ class RSSConfigurationDAO extends Model_array { if (isset ($this->array['mark_when'])) { $this->mark_when = $this->array['mark_when']; } + if (isset ($this->array['url_shaarli'])) { + $this->url_shaarli = $this->array['url_shaarli']; + } } public function update ($values) { diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 943dd489e..660ddef20 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -6,13 +6,18 @@ <form method="post" action="<?php echo _url ('configure', 'categorize'); ?>"> <legend>Gestion des catégories - <a href="<?php echo _url ('configure', 'feed'); ?>">gestion des flux</a></legend> + <p class="alert alert-warn">Lors de la suppression d'une catégorie, ses flux seront automatiquement classés dans <em><?php echo $this->defaultCategory->name (); ?></em>.</p> + <?php $i = 0; foreach ($this->categories as $cat) { $i++; ?> <div class="form-group"> - <label class="group-name" for="cat_<?php echo $cat->id (); ?>">Catégorie n°<?php echo $i; ?></label> + <label class="group-name" for="cat_<?php echo $cat->id (); ?>"> + Catégorie n°<?php echo $i; ?> + </label> <div class="group-controls"> <input type="text" id="cat_<?php echo $cat->id (); ?>" name="categories[]" value="<?php echo $cat->name (); ?>" /> - <?php if ($cat->id () == '000000') { ?> - <i class="icon i_help"></i> ne peut pas être supprimé + <a href="<?php echo _url ('feed', 'delete', 'id', $cat->id (), 'type', 'category'); ?>">Vider ?</a> (<?php echo $cat->nbFeed (); ?> flux) + <?php if ($cat->id () == $this->defaultCategory->id ()) { ?> + <i class="icon i_help"></i> ne peut pas être supprimée <?php } ?> <input type="hidden" name="ids[]" value="<?php echo $cat->id (); ?>" /> </div> diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 240428493..79fa4b43c 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -87,6 +87,14 @@ </div> </div> + <legend>Partage</legend> + <div class="form-group"> + <label class="group-name" for="shaarli">Votre Shaarli</label> + <div class="group-controls"> + <input type="text" id="shaarli" name="shaarli" value="<?php echo $this->conf->urlShaarli (); ?>" placeholder="Laissez vide pour désactiver"/> + </div> + </div> + <div class="form-group form-actions"> <div class="group-controls"> <button type="submit" class="btn btn-important">Valider</button> diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 2ac601e3d..adea27e52 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -9,28 +9,25 @@ <form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>"> <legend>Informations</legend> - <div class="form-group"> <label class="group-name">URL du site</label> <div class="group-controls"> <span class="control"><a target="_blank" href="<?php echo $this->flux->website (); ?>"><?php echo $this->flux->website (); ?></a></span> </div> </div> - <div class="form-group"> <label class="group-name">URL du flux</label> <div class="group-controls"> <span class="control"><a target="_blank" href="<?php echo $this->flux->url (); ?>"><?php echo $this->flux->url (); ?></a></span> </div> </div> - <div class="form-group"> <label class="group-name">Nombre d'articles</label> <div class="group-controls"> <span class="control"><?php echo $this->flux->nbEntries (); ?></span> </div> </div> - + <legend>Catégorie - <a href="<?php echo _url ('configure', 'categorize'); ?>">gestion</a></legend> <div class="form-group"> <label class="group-name">Ranger dans une catégorie</label> @@ -46,13 +43,22 @@ <legend>Avancé</legend> <div class="form-group"> + <label class="group-name" for="priority">Afficher dans le flux principal</label> + <div class="group-controls"> + <label class="checkbox" for="priority"> + <input type="checkbox" name="priority" id="priority" value="10"<?php echo $this->flux->priority () > 0 ? ' checked="checked"' : ''; ?> /> + Oui + </label> + </div> + </div> + <div class="form-group"> <label class="group-name" for="path_entries">Chemin CSS des articles sur le site d'origine</label> <div class="group-controls"> <input type="text" name="path_entries" id="path_entries" value="<?php echo $this->flux->pathEntries (); ?>" placeholder="Laissez vide pour désactiver" /> <i class="icon i_help"></i> Permet de récupérer les flux tronqués (attention, demande plus de temps !) </div> </div> - +<!-- <div class="form-group"> <label class="group-name" for="http_user">Username HTTP</label> <div class="group-controls"> @@ -65,6 +71,7 @@ <input type="text" name="http_pass" id="http_pass" value="Pas encore implémenté" /> </div> </div> +--> <div class="form-group form-actions"> <div class="group-controls"> diff --git a/app/views/configure/importExport.phtml b/app/views/configure/importExport.phtml index cd677c1eb..34bee4a07 100644 --- a/app/views/configure/importExport.phtml +++ b/app/views/configure/importExport.phtml @@ -29,7 +29,7 @@ <div class="group-controls"> <button type="submit" class="btn btn-important">Importer</button> ou - <button type="submit" class="btn btn-important" formaction="<?php echo Url::display (array ('c' => 'configure', 'a' => 'importExport', 'params' => array ('q' => 'export'))); ?>">Exporter</button> + <a target="_blank" class="btn btn-important" href="<?php echo _url ('configure', 'importExport', 'q', 'export'); ?>">Exporter</a> </div> </div> </form> diff --git a/app/views/rss/public.phtml b/app/views/helpers/rss.phtml index 04a035699..1aa0ac44a 100755 --- a/app/views/rss/public.phtml +++ b/app/views/helpers/rss.phtml @@ -3,13 +3,12 @@ <channel> <title><?php echo View::title(); ?></title> <link><?php echo Url::display(); ?></link> - <description>Flux public de <?php echo View::title(); ?></description> - <language>fr</language> + <description>Flux RSS de <?php echo View::title(); ?></description> <pubDate><?php echo date('D, d M Y H:i:s O'); ?></pubDate> <lastBuildDate><?php echo gmdate('D, d M Y H:i:s'); ?> GMT</lastBuildDate> - <atom:link href="<?php echo Url::display(array('a' => 'rss')); ?>" rel="self" type="application/rss+xml" /> + <atom:link href="<?php echo _url ('index', 'index', 'output', 'rss'); ?>" rel="self" type="application/rss+xml" /> <?php -$items = $this->itemPaginator->items (); +$items = $this->entryPaginator->items (); foreach ($items as $item) { ?> <item> @@ -20,10 +19,10 @@ foreach ($items as $item) { <dc:creator><?php echo $author; ?></dc:creator> <?php } ?> <description><![CDATA[<?php - echo html_entity_decode($item->notes (false, false)); + echo $item->content (); ?>]]></description> <pubDate><?php echo date('D, d M Y H:i:s O', $item->date (true)); ?></pubDate> - <guid><?php echo $item->guid (); ?></guid> + <guid isPermaLink="false"><?php echo $item->id (); ?></guid> </item> <?php } ?> diff --git a/app/views/index/about.phtml b/app/views/index/about.phtml index ad3eb6cc6..73f5f4001 100644 --- a/app/views/index/about.phtml +++ b/app/views/index/about.phtml @@ -20,5 +20,5 @@ <p>FreshRSS est un agrégateur de flux RSS à auto-héberger à l'image de <a href="http://rsslounge.aditu.de/">RSSLounge</a>, <a href="http://tt-rss.org/redmine/projects/tt-rss/wiki">TinyTinyRSS</a> ou <a href="http://projet.idleman.fr/leed/">Leed</a>. Il se veut léger et facile à prendre en main tout en étant un outil puissant et paramétrable. L'objectif étant d'offrir une alternative sérieuse au futur feu-Google Reader.</p> <h1>Crédits</h1> - Les <a href="https://git.gnome.org/browse/gnome-icon-theme-symbolic">icônes</a> sont issus du <a href="https://www.gnome.org/">projet GNOME</a>. La police <em>Open Sans</em> utilisée a été créée par <a href="https://www.google.com/webfonts/specimen/Open+Sans">Steve Matteson</a>. Les favicons sont récupérés grâce au site <a href="https://getfavicon.appspot.com/">getFavicon</a>. FreshRSS repose sur <a href="https://github.com/marienfressinaud/MINZ">Minz</a>, un framework PHP. + Des éléments de design sont issus du <a href="http://twitter.github.io/bootstrap/">projet Bootstrap</a> bien que FreshRSS n'utilise pas ce framework. Les <a href="https://git.gnome.org/browse/gnome-icon-theme-symbolic">icônes</a> sont issues du <a href="https://www.gnome.org/">projet GNOME</a>. La police <em>Open Sans</em> utilisée a été créée par <a href="https://www.google.com/webfonts/specimen/Open+Sans">Steve Matteson</a>. Les favicons sont récupérés grâce au site <a href="https://getfavicon.appspot.com/">getFavicon</a>. FreshRSS repose sur <a href="https://github.com/marienfressinaud/MINZ">Minz</a>, un framework PHP. </div> diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 53d7a2412..6889a8b51 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,3 +1,10 @@ +<?php +if (Request::param ('output', '') == 'rss') { + $this->renderHelper ('rss'); + return; +} +?> + <?php $this->partial ('aside_flux'); ?> <?php $this->partial ('nav_menu'); ?> @@ -25,7 +32,7 @@ if (isset ($this->entryPaginator)) { <?php $display_others = false; } ?> <div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>"> - <ul class="flux_header"> + <ul class="horizontal-list flux_header"> <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> <li class="item manage"> <?php if (!$item->isRead ()) { ?> @@ -39,27 +46,50 @@ if (isset ($this->entryPaginator)) { <?php } else { ?> <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 0); ?>"> </a> <?php } ?> - - <a class="note" href="<?php echo _url ('entry', 'note', 'id', $item->id ()); ?>"> - <?php if ($item->notes () != '') { ?> - <i class="icon i_note"></i> - <?php } else { ?> - <i class="icon i_note_empty"></i> - <?php } ?> - </a> </li> <?php } ?> <?php $feed = $item->feed (true); ?> - <li class="item website"><a target="_blank" href="<?php echo $feed->website (); ?>"><img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="favicon <?php echo $feed->name (); ?>" /> <span><?php echo $feed->name (); ?></span></a></li> - <li class="item title"><h1><?php echo $item->title (); ?></h1></li> + <li class="item website"><a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"><img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="" /> <span><?php echo $feed->name (); ?></span></a></li> + <li class="item title"><?php echo $item->title (); ?></li> <li class="item date">le <?php echo $item->date (); ?></li> <li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"> </a></li> </ul> - - <div class="content"> - <?php $author = $item->author (); ?> - <?php echo $author != '' ? '<div class="author">Par <em>' . $author . '</em></div>' : ''; ?> - <?php echo $item->content (); ?> + + <div class="flux_content"> + <div class="content"> + <h1 class="title"><?php echo $item->title (); ?></h1> + <?php $author = $item->author (); ?> + <?php echo $author != '' ? '<div class="author">Par <em>' . $author . '</em></div>' : ''; ?> + <?php echo $item->content (); ?> + </div> + + <ul class="horizontal-list bottom"> + <li class="item"> + <?php if ($item->notes () != '') { ?> + <i class="icon i_note"></i> <a class="note" href="<?php echo _url ('entry', 'note', 'id', $item->id ()); ?>">Modifier votre note</a> + <?php } else { ?> + <i class="icon i_note_empty"></i> <a class="note" href="<?php echo _url ('entry', 'note', 'id', $item->id ()); ?>">Ajouter une note</a> + <?php } ?> + </li> + <li class="item"> + <div class="dropdown"> + <div id="dropdown-share-<?php echo $item->id ();?>" class="dropdown-target"></div> + <i class="icon i_share"></i> <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id ();?>">Partager</a> + + <ul class="dropdown-menu"> + <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> + + <li class="item"><a href="mailto:?subject=<?php echo $item->title (); ?>&body=J'ai trouvé cet article intéressant, tu peux le lire à cette adresse : <?php echo urlencode($item->link ()); ?>">Par mail</a></li> + <?php + $shaarli = $this->conf->urlShaarli (); + if ($shaarli) { + ?> + <li class="item"><a target="_blank" href="<?php echo $shaarli . '?post=' . urlencode($item->link ()) . '&title=' . urlencode ($item->title ()) . '&source=bookmarklet'; ?>">Shaarli</a></li> + <?php } ?> + </ul> + </div> + </li> + </ul> </div> </div> <?php } ?> diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml new file mode 100644 index 000000000..16188422a --- /dev/null +++ b/app/views/javascript/actualize.phtml @@ -0,0 +1,45 @@ +var feeds = new Array (); +<?php foreach ($this->feeds as $feed) { ?> +feeds.push ("<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>"); +<?php } ?> + +function initProgressBar (init) { + if (init) { + $("body").after ("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\ + Actualisation <span class=\"progress\">0 / " + feeds.length + "</span><br />\ + <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\ + </div>"); + } else { + window.location.reload (); + } +} +function updateProgressBar (i) { + $("#actualizeProgressBar").val(i); + $("#actualizeProgress .progress").html (i + " / " + feeds.length); +} + +function updateFeeds () { + initProgressBar (true); + + var i = 0; + for (var f in feeds) { + $.ajax ({ + type: 'POST', + url: feeds[f], + }).done (function (data) { + i++; + updateProgressBar (i); + + if (i == feeds.length) { + initProgressBar (false); + } + }); + } +} + +$(document).ready (function () { + $("#actualize").click (function () { + updateFeeds (); + return false; + }); +}); diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index 4f049e11d..e6c882333 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -26,10 +26,10 @@ function toggleContent (new_active, old_active) { } if (hide_posts) { - old_active.children (".content").toggle (0); + old_active.children (".flux_content").toggle (0); if (old_active[0] != new_active[0]) { - new_active.children (".content").toggle (0, function () { + new_active.children (".flux_content").toggle (0, function () { $("html,body").scrollTop (new_active.position ().top); }); } @@ -110,7 +110,7 @@ function mark_favorite (active) { function init_img () { $(".flux .content img").each (function () { - if ($(this).width () > ($("#stream").width()) / 2) { + if ($(this).width () > ($("#stream .content").width()) / 2) { $(this).addClass("big"); } }); @@ -127,7 +127,7 @@ function init_posts () { init_img (); if (hide_posts) { - $(".flux:not(.active) .content").hide (); + $(".flux:not(.active) .flux_content").hide (); } $(".flux_header .item.title, .flux_header .item.date").click (function () { |
