diff options
| author | 2013-03-17 15:13:19 +0100 | |
|---|---|---|
| committer | 2013-03-17 15:13:19 +0100 | |
| commit | fd171e8f9517dd5a046d4f7f159cde3002e7706a (patch) | |
| tree | b236935155c0da7e61ddd9f73bce6474fc581f4b /app | |
| parent | 001c425acd3345e363fe36c014f776069dd587dc (diff) | |
Fix bug #31 : catégorie par défaut ne peut plus être supprimée mais peut être renommée. Ajout gestion flux tronqués directement dans l'interface (+ intégré en base de données). Attention, la BDD a changé (+ 4 champs : 2 pour feed, 2 pour entry)
Diffstat (limited to 'app')
| -rwxr-xr-x | app/controllers/configureController.php | 31 | ||||
| -rwxr-xr-x | app/controllers/feedController.php | 13 | ||||
| -rwxr-xr-x | app/models/Category.php | 11 | ||||
| -rw-r--r-- | app/models/Feed.php | 20 | ||||
| -rw-r--r-- | app/views/configure/categorize.phtml | 3 | ||||
| -rw-r--r-- | app/views/configure/feed.phtml | 16 |
6 files changed, 63 insertions, 31 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 9e1c7b2cb..cfc295ba6 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -12,6 +12,7 @@ class configureController extends ActionController { public function categorizeAction () { $catDAO = new CategoryDAO (); + $catDAO->checkDefault (); if (Request::isPost ()) { $cats = Request::param ('categories', array ()); @@ -26,7 +27,7 @@ class configureController extends ActionController { 'color' => $cat->color () ); $catDAO->updateCategory ($ids[$key], $values); - } else { + } elseif ($ids[$key] != '000000') { $catDAO->deleteCategory ($ids[$key]); } } @@ -79,21 +80,29 @@ class configureController extends ActionController { $this->view->categories = $catDAO->listCategories (); if (Request::isPost () && $this->view->flux) { - $cat = Request::param ('category'); + $cat = Request::param ('category', 0); + $path = Request::param ('path_entries', ''); + $values = array ( - 'category' => $cat + 'category' => $cat, + 'pathEntries' => $path ); - $feedDAO->updateFeed ($id, $values); - $this->view->flux->_category ($cat); + if ($feedDAO->updateFeed ($id, $values)) { + $this->view->flux->_category ($cat); - // notif - $notif = array ( - 'type' => 'good', - 'content' => 'Le flux a été mis à jour' - ); - Session::_param ('notification', $notif); + $notif = array ( + 'type' => 'good', + 'content' => 'Le flux a été mis à jour' + ); + } else { + $notif = array ( + 'type' => 'bad', + 'content' => 'Une erreur est survenue lors de la mise à jour' + ); + } + Session::_param ('notification', $notif); Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true); } diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index fd3abbcf2..e77347bf9 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -1,6 +1,11 @@ <?php class feedController extends ActionController { + public function firstAction () { + $catDAO = new CategoryDAO (); + $catDAO->checkDefault (); + } + public function addAction () { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( @@ -16,17 +21,11 @@ class feedController extends ActionController { $feed = new Feed ($url); $feed->load (); - $catDAO = new CategoryDAO (); - $cat = $feed->category (); - if ($cat == '') { - $cat = $catDAO->getDefault ()->id (); - } - $feedDAO = new FeedDAO (); $values = array ( 'id' => $feed->id (), 'url' => $feed->url (), - 'category' => $cat, + 'category' => $feed->category (), 'name' => $feed->name (), 'website' => $feed->website (), 'description' => $feed->description (), diff --git a/app/models/Category.php b/app/models/Category.php index a7f900880..d7db8ee65 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -13,7 +13,7 @@ class Category extends Model { public function id () { if (!$this->id) { - return small_hash ($this->name . Configuration::selApplication ()); + return small_hash ($this->name . time () . Configuration::selApplication ()); } else { return $this->id; } @@ -152,11 +152,12 @@ class CategoryDAO extends Model_pdo { return HelperCategory::daoToCategory ($stm->fetchAll (PDO::FETCH_ASSOC)); } - public function getDefault () { - $def_cat = $this->searchByName ('Sans catégorie'); + public function checkDefault () { + $def_cat = $this->searchById ('000000'); if (!$def_cat) { $cat = new Category ('Sans catégorie'); + $cat->_id ('000000'); $values = array ( 'id' => $cat->id (), @@ -165,11 +166,7 @@ class CategoryDAO extends Model_pdo { ); $this->addCategory ($values); - - $def_cat = $cat; } - - return $def_cat; } public function count () { diff --git a/app/models/Feed.php b/app/models/Feed.php index 046e5af92..2f471f0a4 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -3,12 +3,14 @@ class Feed extends Model { private $id = null; private $url; - private $category = ''; + private $category = '000000'; private $entries = null; private $name = ''; private $website = ''; private $description = ''; private $lastUpdate = 0; + private $pathEntries = ''; + private $httpAuth = ''; public function __construct ($url) { $this->_url ($url); @@ -46,6 +48,12 @@ class Feed extends Model { public function lastUpdate () { return $this->lastUpdate; } + public function pathEntries () { + return $this->pathEntries; + } + public function httpAuth () { + return $this->httpAuth; + } public function nbEntries () { $feedDAO = new FeedDAO (); return $feedDAO->countEntries ($this->id ()); @@ -89,6 +97,12 @@ class Feed extends Model { public function _lastUpdate ($value) { $this->lastUpdate = $value; } + public function _pathEntries ($value) { + $this->pathEntries = $value; + } + public function _httpAuth ($value) { + $this->httpAuth = $value; + } public function load () { if (!is_null ($this->url)) { @@ -122,7 +136,7 @@ class Feed extends Model { // Gestion du contenu // On cherche à récupérer les articles en entier... même si le flux ne le propose pas - $path = get_path ($this->website ()); + $path = $this->pathEntries (); if ($path) { try { $content = get_content_by_parsing ($item->get_permalink (), $path); @@ -306,6 +320,8 @@ class HelperFeed { $list[$key]->_website ($dao['website']); $list[$key]->_description ($dao['description']); $list[$key]->_lastUpdate ($dao['lastUpdate']); + $list[$key]->_pathEntries ($dao['pathEntries']); + $list[$key]->_httpAuth ($dao['httpAuth']); if (isset ($dao['id'])) { $list[$key]->_id ($dao['id']); diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 5d649a93a..aa87129aa 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -9,6 +9,9 @@ <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é + <?php } ?> <input type="hidden" name="ids[]" value="<?php echo $cat->id (); ?>" /> </div> </div> diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 11a194071..145d79348 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -23,6 +23,7 @@ </div> <?php if (!empty ($this->categories)) { ?> + <legend>Catégorie</legend> <div class="form-group"> <label class="group-name">Ranger dans une catégorie</label> <div class="group-controls"> @@ -35,13 +36,20 @@ </div> </div> + <?php } ?> + + <legend>Avancé</legend> + <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 form-actions"> <div class="group-controls"> <button class="btn btn-important">Valider</button> - <?php } else { ?> - <div class="form-group"> - <div class="group-controls"> - <?php } ?> <button class="btn btn-attention" formaction="<?php echo Url::display (array ('c' => 'feed', 'a' => 'delete', 'params' => array ('id' => $this->flux->id ()))); ?>">Supprimer</button> </div> </div> |
