Переглянути джерело

défini un flux par défaut lorsqu'aucun sélectionné dans ?c=configure&a=feed

Marien Fressinaud 13 роки тому
батько
коміт
87e07e66c9
1 змінених файлів з 44 додано та 41 видалено
  1. 44 41
      app/controllers/configureController.php

+ 44 - 41
app/controllers/configureController.php

@@ -9,17 +9,17 @@ class configureController extends ActionController {
 			);
 			);
 		}
 		}
 	}
 	}
-	
+
 	public function indexAction () { }
 	public function indexAction () { }
 
 
 	public function categorizeAction () {
 	public function categorizeAction () {
 		$catDAO = new CategoryDAO ();
 		$catDAO = new CategoryDAO ();
-		
+
 		if (Request::isPost ()) {
 		if (Request::isPost ()) {
 			$cats = Request::param ('categories', array ());
 			$cats = Request::param ('categories', array ());
 			$ids = Request::param ('ids', array ());
 			$ids = Request::param ('ids', array ());
 			$newCat = Request::param ('new_category');
 			$newCat = Request::param ('new_category');
-			
+
 			foreach ($cats as $key => $name) {
 			foreach ($cats as $key => $name) {
 				if (strlen ($name) > 0) {
 				if (strlen ($name) > 0) {
 					$cat = new Category ($name);
 					$cat = new Category ($name);
@@ -32,7 +32,7 @@ class configureController extends ActionController {
 					$catDAO->deleteCategory ($ids[$key]);
 					$catDAO->deleteCategory ($ids[$key]);
 				}
 				}
 			}
 			}
-			
+
 			if ($newCat != false) {
 			if ($newCat != false) {
 				$cat = new Category ($newCat);
 				$cat = new Category ($newCat);
 				$values = array (
 				$values = array (
@@ -42,32 +42,35 @@ class configureController extends ActionController {
 				);
 				);
 				$catDAO->addCategory ($values);
 				$catDAO->addCategory ($values);
 			}
 			}
-			
+
 			// notif
 			// notif
 			$notif = array (
 			$notif = array (
 				'type' => 'good',
 				'type' => 'good',
 				'content' => 'Les catégories ont été mises à jour'
 				'content' => 'Les catégories ont été mises à jour'
 			);
 			);
 			Session::_param ('notification', $notif);
 			Session::_param ('notification', $notif);
-			
+
 			Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true);
 			Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true);
 		}
 		}
-		
+
 		$this->view->categories = $catDAO->listCategories ();
 		$this->view->categories = $catDAO->listCategories ();
-		
+
 		View::prependTitle ('Gestion des catégories - ');
 		View::prependTitle ('Gestion des catégories - ');
 	}
 	}
-	
+
 	public function feedAction () {
 	public function feedAction () {
 		$feedDAO = new FeedDAO ();
 		$feedDAO = new FeedDAO ();
 		$this->view->feeds = $feedDAO->listFeeds ();
 		$this->view->feeds = $feedDAO->listFeeds ();
-		
+
 		$id = Request::param ('id');
 		$id = Request::param ('id');
-		
+		if ($id == false && !empty ($this->view->feeds)) {
+			$id = current ($this->view->feeds)->id ();
+		}
+
 		$this->view->flux = false;
 		$this->view->flux = false;
 		if ($id != false) {
 		if ($id != false) {
 			$this->view->flux = $feedDAO->searchById ($id);
 			$this->view->flux = $feedDAO->searchById ($id);
-			
+
 			if (!$this->view->flux) {
 			if (!$this->view->flux) {
 				Error::error (
 				Error::error (
 					404,
 					404,
@@ -76,33 +79,33 @@ class configureController extends ActionController {
 			} else {
 			} else {
 				$catDAO = new CategoryDAO ();
 				$catDAO = new CategoryDAO ();
 				$this->view->categories = $catDAO->listCategories ();
 				$this->view->categories = $catDAO->listCategories ();
-			
+
 				if (Request::isPost () && $this->view->flux) {
 				if (Request::isPost () && $this->view->flux) {
 					$cat = Request::param ('category');
 					$cat = Request::param ('category');
 					$values = array (
 					$values = array (
 						'category' => $cat
 						'category' => $cat
 					);
 					);
 					$feedDAO->updateFeed ($id, $values);
 					$feedDAO->updateFeed ($id, $values);
-				
+
 					$this->view->flux->_category ($cat);
 					$this->view->flux->_category ($cat);
-					
+
 					// notif
 					// notif
 					$notif = array (
 					$notif = array (
 						'type' => 'good',
 						'type' => 'good',
 						'content' => 'Le flux a été mis à jour'
 						'content' => 'Le flux a été mis à jour'
 					);
 					);
 					Session::_param ('notification', $notif);
 					Session::_param ('notification', $notif);
-					
+
 					Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true);
 					Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true);
 				}
 				}
-			
+
 				View::prependTitle ('Gestion des flux RSS - ' . $this->view->flux->name () . ' - ');
 				View::prependTitle ('Gestion des flux RSS - ' . $this->view->flux->name () . ' - ');
 			}
 			}
 		} else {
 		} else {
 			View::prependTitle ('Gestion des flux RSS - ');
 			View::prependTitle ('Gestion des flux RSS - ');
 		}
 		}
 	}
 	}
-	
+
 	public function displayAction () {
 	public function displayAction () {
 		if (Request::isPost ()) {
 		if (Request::isPost ()) {
 			$nb = Request::param ('posts_per_page', 10);
 			$nb = Request::param ('posts_per_page', 10);
@@ -111,14 +114,14 @@ class configureController extends ActionController {
 			$sort = Request::param ('sort_order', 'low_to_high');
 			$sort = Request::param ('sort_order', 'low_to_high');
 			$old = Request::param ('old_entries', 3);
 			$old = Request::param ('old_entries', 3);
 			$mail = Request::param ('mail_login', false);
 			$mail = Request::param ('mail_login', false);
-		
+
 			$this->view->conf->_postsPerPage (intval ($nb));
 			$this->view->conf->_postsPerPage (intval ($nb));
 			$this->view->conf->_defaultView ($view);
 			$this->view->conf->_defaultView ($view);
 			$this->view->conf->_displayPosts ($display);
 			$this->view->conf->_displayPosts ($display);
 			$this->view->conf->_sortOrder ($sort);
 			$this->view->conf->_sortOrder ($sort);
 			$this->view->conf->_oldEntries ($old);
 			$this->view->conf->_oldEntries ($old);
 			$this->view->conf->_mailLogin ($mail);
 			$this->view->conf->_mailLogin ($mail);
-		
+
 			$values = array (
 			$values = array (
 				'posts_per_page' => $this->view->conf->postsPerPage (),
 				'posts_per_page' => $this->view->conf->postsPerPage (),
 				'default_view' => $this->view->conf->defaultView (),
 				'default_view' => $this->view->conf->defaultView (),
@@ -127,58 +130,58 @@ class configureController extends ActionController {
 				'old_entries' => $this->view->conf->oldEntries (),
 				'old_entries' => $this->view->conf->oldEntries (),
 				'mail_login' => $this->view->conf->mailLogin (),
 				'mail_login' => $this->view->conf->mailLogin (),
 			);
 			);
-		
+
 			$confDAO = new RSSConfigurationDAO ();
 			$confDAO = new RSSConfigurationDAO ();
 			$confDAO->update ($values);
 			$confDAO->update ($values);
 			Session::_param ('conf', $this->view->conf);
 			Session::_param ('conf', $this->view->conf);
 			Session::_param ('mail', $this->view->conf->mailLogin ());
 			Session::_param ('mail', $this->view->conf->mailLogin ());
-			
+
 			// notif
 			// notif
 			$notif = array (
 			$notif = array (
 				'type' => 'good',
 				'type' => 'good',
 				'content' => 'La configuration a été mise à jour'
 				'content' => 'La configuration a été mise à jour'
 			);
 			);
 			Session::_param ('notification', $notif);
 			Session::_param ('notification', $notif);
-			
+
 			Request::forward (array ('c' => 'configure', 'a' => 'display'), true);
 			Request::forward (array ('c' => 'configure', 'a' => 'display'), true);
 		}
 		}
-		
+
 		View::prependTitle ('Gestion générale et affichage - ');
 		View::prependTitle ('Gestion générale et affichage - ');
 	}
 	}
-	
+
 	public function importExportAction () {
 	public function importExportAction () {
 		$this->view->req = Request::param ('q');
 		$this->view->req = Request::param ('q');
-		
+
 		if ($this->view->req == 'export') {
 		if ($this->view->req == 'export') {
 			View::_title ('feeds_opml.xml');
 			View::_title ('feeds_opml.xml');
-			
+
 			$this->view->_useLayout (false);
 			$this->view->_useLayout (false);
 			header('Content-type: text/xml');
 			header('Content-type: text/xml');
-			
+
 			$feedDAO = new FeedDAO ();
 			$feedDAO = new FeedDAO ();
 			$catDAO = new CategoryDAO ();
 			$catDAO = new CategoryDAO ();
-			
+
 			$list = array ();
 			$list = array ();
 			foreach ($catDAO->listCategories () as $key => $cat) {
 			foreach ($catDAO->listCategories () as $key => $cat) {
 				$list[$key]['name'] = $cat->name ();
 				$list[$key]['name'] = $cat->name ();
 				$list[$key]['feeds'] = $feedDAO->listByCategory ($cat->id ());
 				$list[$key]['feeds'] = $feedDAO->listByCategory ($cat->id ());
 			}
 			}
-			
+
 			$this->view->categories = $list;
 			$this->view->categories = $list;
 		} elseif ($this->view->req == 'import' && Request::isPost ()) {
 		} elseif ($this->view->req == 'import' && Request::isPost ()) {
 			if ($_FILES['file']['error'] == 0) {
 			if ($_FILES['file']['error'] == 0) {
 				list ($categories, $feeds) = opml_import (file_get_contents ($_FILES['file']['tmp_name']));
 				list ($categories, $feeds) = opml_import (file_get_contents ($_FILES['file']['tmp_name']));
-				
+
 				Request::_param ('q', 'null');
 				Request::_param ('q', 'null');
 				Request::_param ('categories', $categories);
 				Request::_param ('categories', $categories);
 				Request::_param ('feeds', $feeds);
 				Request::_param ('feeds', $feeds);
 				Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
 				Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
 			}
 			}
 		}
 		}
-		
+
 		View::prependTitle ('Importation et exportation OPML - ');
 		View::prependTitle ('Importation et exportation OPML - ');
 	}
 	}
-	
+
 	public function shortcutAction () {
 	public function shortcutAction () {
 		$list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter',
 		$list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter',
 		                    'escape', 'f', 'g', 'h', 'i', 'insert', 'j', 'k', 'l', 'left',
 		                    'escape', 'f', 'g', 'h', 'i', 'insert', 'j', 'k', 'l', 'left',
@@ -190,38 +193,38 @@ class configureController extends ActionController {
 		$this->view->list_keys = $list_keys;
 		$this->view->list_keys = $list_keys;
 		$list_names = array ('mark_read', 'mark_favorite', 'go_website', 'next_entry',
 		$list_names = array ('mark_read', 'mark_favorite', 'go_website', 'next_entry',
 		                     'prev_entry', 'next_page', 'prev_page');
 		                     'prev_entry', 'next_page', 'prev_page');
-		
+
 		if (Request::isPost ()) {
 		if (Request::isPost ()) {
 			$shortcuts = Request::param ('shortcuts');
 			$shortcuts = Request::param ('shortcuts');
 			$shortcuts_ok = array ();
 			$shortcuts_ok = array ();
-			
+
 			foreach ($shortcuts as $key => $value) {
 			foreach ($shortcuts as $key => $value) {
 				if (in_array ($key, $list_names)
 				if (in_array ($key, $list_names)
 				 && in_array ($value, $list_keys)) {
 				 && in_array ($value, $list_keys)) {
 					$shortcuts_ok[$key] = $value;
 					$shortcuts_ok[$key] = $value;
 				}
 				}
 			}
 			}
-			
+
 			$this->view->conf->_shortcuts ($shortcuts_ok);
 			$this->view->conf->_shortcuts ($shortcuts_ok);
-			
+
 			$values = array (
 			$values = array (
 				'shortcuts' => $this->view->conf->shortcuts ()
 				'shortcuts' => $this->view->conf->shortcuts ()
 			);
 			);
-			
+
 			$confDAO = new RSSConfigurationDAO ();
 			$confDAO = new RSSConfigurationDAO ();
 			$confDAO->update ($values);
 			$confDAO->update ($values);
 			Session::_param ('conf', $this->view->conf);
 			Session::_param ('conf', $this->view->conf);
-			
+
 			// notif
 			// notif
 			$notif = array (
 			$notif = array (
 				'type' => 'good',
 				'type' => 'good',
 				'content' => 'Les raccourcis ont été mis à jour'
 				'content' => 'Les raccourcis ont été mis à jour'
 			);
 			);
 			Session::_param ('notification', $notif);
 			Session::_param ('notification', $notif);
-			
+
 			Request::forward (array ('c' => 'configure', 'a' => 'shortcut'), true);
 			Request::forward (array ('c' => 'configure', 'a' => 'shortcut'), true);
 		}
 		}
-		
+
 		View::prependTitle ('Gestion des raccourcis - ');
 		View::prependTitle ('Gestion des raccourcis - ');
 	}
 	}
 }
 }