aboutsummaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-07-04 19:38:29 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-07-04 19:38:29 +0200
commiteb5f05304c253df90873b94ba52d7093115f3850 (patch)
tree1152ab618aa5cf884a1f2f2e2d1926da4167a6be /app/controllers
parent8dd5fd51f74a47e5c80052f27a74cdcd5dd044b9 (diff)
parentb5f233f6d524ca9f74e9d33bf5692a1a678d7fec (diff)
Merge branch 'dev'0.4.0
Diffstat (limited to 'app/controllers')
-rwxr-xr-xapp/controllers/apiController.php46
-rwxr-xr-xapp/controllers/configureController.php48
-rwxr-xr-xapp/controllers/entryController.php86
-rwxr-xr-xapp/controllers/feedController.php7
-rwxr-xr-xapp/controllers/indexController.php35
5 files changed, 92 insertions, 130 deletions
diff --git a/app/controllers/apiController.php b/app/controllers/apiController.php
deleted file mode 100755
index 025908f3e..000000000
--- a/app/controllers/apiController.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-class apiController extends ActionController {
- public function firstAction() {
- header('Content-type: application/json');
-
- $this->view->_useLayout (false);
- }
-
- public function getPublicFeedAction () {
- $entryDAO = new EntryDAO ();
- $entryDAO->_nbItemsPerPage (-1);
-
- $entries_tmp = $entryDAO->listPublic ('low_to_high');
-
- $entries = array ();
- foreach ($entries_tmp as $e) {
- $author = $e->author ();
-
- $notes = $e->notes ();
- if ($notes == '') {
- $feed = $e->feed (true);
- if($author != '') {
- $notes = Translate::t ('article_published_on_author', $feed->website (), $feed->name (), $author);
- } else {
- $notes = Translate::t ('article_published_on', $feed->website (), $feed->name ());
- }
- }
-
- $id = $e->id ();
- $entries[$id] = array ();
- $entries[$id]['title'] = $e->title ();
- $entries[$id]['content'] = $notes;
- $entries[$id]['date'] = $e->date (true);
- $entries[$id]['lastUpdate'] = $e->lastUpdate (true);
- $entries[$id]['tags'] = $e->tags ();
- $entries[$id]['url'] = $e->link ();
- $entries[$id]['type'] = 'url';
- }
-
- $this->view->entries = $entries;
- }
-
- public function getNbNotReadAction() {
- }
-}
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php
index 2f56da177..ce53e1040 100755
--- a/app/controllers/configureController.php
+++ b/app/controllers/configureController.php
@@ -91,6 +91,7 @@ class configureController extends ActionController {
$this->view->categories = $catDAO->listCategories ();
if (Request::isPost () && $this->view->flux) {
+ $name = Request::param ('name', '');
$cat = Request::param ('category', 0);
$path = Request::param ('path_entries', '');
$priority = Request::param ('priority', 0);
@@ -103,6 +104,7 @@ class configureController extends ActionController {
}
$values = array (
+ 'name' => $name,
'category' => $cat,
'pathEntries' => $path,
'priority' => $priority,
@@ -138,35 +140,41 @@ class configureController extends ActionController {
if (Request::isPost ()) {
$language = Request::param ('language', 'en');
$nb = Request::param ('posts_per_page', 10);
+ $mode = Request::param ('view_mode', 'normal');
$view = Request::param ('default_view', 'all');
$display = Request::param ('display_posts', 'no');
+ $lazyload = Request::param ('lazyload', 'yes');
$sort = Request::param ('sort_order', 'low_to_high');
$old = Request::param ('old_entries', 3);
$mail = Request::param ('mail_login', false);
$openArticle = Request::param ('mark_open_article', 'no');
$openSite = Request::param ('mark_open_site', 'no');
- $openPage = Request::param ('mark_open_page', 'no');
+ $scroll = Request::param ('mark_scroll', 'no');
$urlShaarli = Request::param ('shaarli', '');
$this->view->conf->_language ($language);
$this->view->conf->_postsPerPage (intval ($nb));
+ $this->view->conf->_viewMode ($mode);
$this->view->conf->_defaultView ($view);
$this->view->conf->_displayPosts ($display);
+ $this->view->conf->_lazyload ($lazyload);
$this->view->conf->_sortOrder ($sort);
$this->view->conf->_oldEntries ($old);
$this->view->conf->_mailLogin ($mail);
$this->view->conf->_markWhen (array (
'article' => $openArticle,
'site' => $openSite,
- 'page' => $openPage,
+ 'scroll' => $scroll,
));
$this->view->conf->_urlShaarli ($urlShaarli);
$values = array (
'language' => $this->view->conf->language (),
'posts_per_page' => $this->view->conf->postsPerPage (),
+ 'view_mode' => $this->view->conf->viewMode (),
'default_view' => $this->view->conf->defaultView (),
'display_posts' => $this->view->conf->displayPosts (),
+ 'lazyload' => $this->view->conf->lazyload (),
'sort_order' => $this->view->conf->sortOrder (),
'old_entries' => $this->view->conf->oldEntries (),
'mail_login' => $this->view->conf->mailLogin (),
@@ -196,6 +204,9 @@ class configureController extends ActionController {
}
public function importExportAction () {
+ $catDAO = new CategoryDAO ();
+ $this->view->categories = $catDAO->listCategories ();
+
$this->view->req = Request::param ('q');
if ($this->view->req == 'export') {
@@ -218,14 +229,31 @@ class configureController extends ActionController {
} elseif ($this->view->req == 'import' && Request::isPost ()) {
if ($_FILES['file']['error'] == 0) {
// on parse le fichier OPML pour récupérer les catégories et les flux associés
- list ($categories, $feeds) = opml_import (file_get_contents ($_FILES['file']['tmp_name']));
-
- // On redirige vers le controller feed qui va se charger d'insérer les flux en BDD
- // les flux sont mis au préalable dans des variables de Request
- Request::_param ('q', 'null');
- Request::_param ('categories', $categories);
- Request::_param ('feeds', $feeds);
- Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
+ try {
+ list ($categories, $feeds) = opml_import (
+ file_get_contents ($_FILES['file']['tmp_name'])
+ );
+
+ // On redirige vers le controller feed qui va se charger d'insérer les flux en BDD
+ // les flux sont mis au préalable dans des variables de Request
+ Request::_param ('q', 'null');
+ Request::_param ('categories', $categories);
+ Request::_param ('feeds', $feeds);
+ Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
+ } catch (OpmlException $e) {
+ Log::record ($e->getMessage (), Log::ERROR);
+
+ $notif = array (
+ 'type' => 'bad',
+ 'content' => Translate::t ('bad_opml_file')
+ );
+ Session::_param ('notification', $notif);
+
+ Request::forward (array (
+ 'c' => 'configure',
+ 'a' => 'importExport'
+ ), true);
+ }
}
}
diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php
index 35f3150ea..c7e13f471 100755
--- a/app/controllers/entryController.php
+++ b/app/controllers/entryController.php
@@ -98,74 +98,22 @@ class entryController extends ActionController {
}
}
- public function noteAction () {
- View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main')));
-
- $not_found = false;
- $entryDAO = new EntryDAO ();
- $catDAO = new CategoryDAO ();
-
- $id = Request::param ('id');
- if ($id) {
- $entry = $entryDAO->searchById ($id);
-
- if ($entry) {
- $feed = $entry->feed (true);
-
- if (Request::isPost ()) {
- $note = htmlspecialchars (Request::param ('note', ''));
- $public = Request::param ('public', 'no');
- if ($public == 'yes') {
- $public = true;
- } else {
- $public = false;
- }
-
- $values = array (
- 'annotation' => $note,
- 'is_public' => $public,
- 'lastUpdate' => time ()
- );
-
- if ($entryDAO->updateEntry ($id, $values)) {
- $notif = array (
- 'type' => 'good',
- 'content' => Translate::t ('updated')
- );
- } else {
- $notif = array (
- 'type' => 'bad',
- 'content' => Translate::t ('error_occured')
- );
- }
- Session::_param ('notification', $notif);
- Request::forward (array (
- 'c' => 'entry',
- 'a' => 'note',
- 'params' => array (
- 'id' => $id
- )
- ), true);
- }
- } else {
- $not_found = true;
- }
- } else {
- $not_found = true;
- }
-
- if ($not_found) {
- Error::error (
- 404,
- array ('error' => array (Translate::t ('page_not_found')))
- );
- } else {
- $this->view->entry = $entry;
- $this->view->cat_aside = $catDAO->listCategories ();
- $this->view->nb_favorites = $entryDAO->countFavorites ();
- $this->view->nb_total = $entryDAO->count ();
- $this->view->get_c = $feed->category ();
- $this->view->get_f = $feed->id ();
- }
+ public function optimizeAction() {
+ // La table des entrées a tendance à grossir énormément
+ // Cette action permet d'optimiser cette table permettant de grapiller un peu de place
+ // Cette fonctionnalité n'est à appeler qu'occasionnellement
+ $entryDAO = new EntryDAO();
+ $entryDAO->optimizeTable();
+
+ $notif = array (
+ 'type' => 'good',
+ 'content' => Translate::t ('optimization_complete')
+ );
+ Session::_param ('notification', $notif);
+
+ Request::forward(array(
+ 'c' => 'configure',
+ 'a' => 'display'
+ ), true);
}
}
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 77f1787d0..76da41c58 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -159,8 +159,7 @@ class feedController extends ActionController {
$feedDAO->updateLastUpdate ($feed->id ());
} catch (FeedException $e) {
Log::record ($e->getMessage (), Log::ERROR);
- // TODO si on a une erreur ici, il faut mettre
- // le flux à jour en BDD (error = 1) (issue #70)
+ $feedDAO->isInError ($feed->id ());
}
// On arrête à 10 flux pour ne pas surcharger le serveur
@@ -220,8 +219,8 @@ class feedController extends ActionController {
$entryDAO = new EntryDAO ();
$feedDAO = new FeedDAO ();
- $categories = Request::param ('categories', array ());
- $feeds = Request::param ('feeds', array ());
+ $categories = Request::param ('categories', array (), true);
+ $feeds = Request::param ('feeds', array (), true);
// on ajoute les catégories en masse dans une fonction à part
$this->addCategories ($categories);
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php
index f4f0b98b3..594d379fb 100755
--- a/app/controllers/indexController.php
+++ b/app/controllers/indexController.php
@@ -6,12 +6,19 @@ class indexController extends ActionController {
private $mode = 'all';
public function indexAction () {
- if (Request::param ('output') == 'rss') {
+ $output = Request::param ('output');
+
+ if ($output == 'rss') {
$this->view->_useLayout (false);
} else {
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')));
+ View::appendScript (Url::display ('/scripts/endless_mode.js'));
+
+ if(!$output) {
+ Request::_param ('output', $this->view->conf->viewMode());
+ }
}
$entryDAO = new EntryDAO ();
@@ -138,6 +145,32 @@ class indexController extends ActionController {
View::prependTitle (Translate::t ('about') . ' - ');
}
+ public function logsAction () {
+ if (login_is_conf ($this->view->conf) && !is_logged ()) {
+ Error::error (
+ 403,
+ array ('error' => array (Translate::t ('access_denied')))
+ );
+ }
+
+ View::prependTitle (Translate::t ('logs') . ' - ');
+
+ $logs = array();
+ try {
+ $logDAO = new LogDAO ();
+ $logs = $logDAO->lister ();
+ $logs = array_reverse ($logs);
+ } catch(FileNotExistException $e) {
+
+ }
+
+ //gestion pagination
+ $page = Request::param ('page', 1);
+ $this->view->logsPaginator = new Paginator ($logs);
+ $this->view->logsPaginator->_nbItemsPerPage (50);
+ $this->view->logsPaginator->_currentPage ($page);
+ }
+
public function loginAction () {
$this->view->_useLayout (false);