diff options
| author | 2013-03-17 15:13:19 +0100 | |
|---|---|---|
| committer | 2013-03-17 15:13:19 +0100 | |
| commit | fd171e8f9517dd5a046d4f7f159cde3002e7706a (patch) | |
| tree | b236935155c0da7e61ddd9f73bce6474fc581f4b | |
| 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)
| -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 | ||||
| -rw-r--r-- | freshrss.sql | 16 | ||||
| -rw-r--r-- | lib/lib_rss.php | 14 | ||||
| -rw-r--r-- | public/data/Sites.array.php | 7 | ||||
| -rw-r--r-- | public/theme/base.css | 28 | ||||
| -rw-r--r-- | public/theme/icons/help.svg | 32 |
11 files changed, 121 insertions, 70 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> diff --git a/freshrss.sql b/freshrss.sql index 34ef29aa4..3fa334333 100644 --- a/freshrss.sql +++ b/freshrss.sql @@ -1,11 +1,11 @@ -- phpMyAdmin SQL Dump --- version 3.5.5 +-- version 3.5.7 -- http://www.phpmyadmin.net -- -- Client: localhost --- Généré le: Sam 02 Mars 2013 à 00:09 --- Version du serveur: 5.1.68-cll --- Version de PHP: 5.3.17 +-- Généré le: Dim 17 Mars 2013 à 14:08 +-- Version du serveur: 5.5.30 +-- Version de PHP: 5.4.12 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; @@ -17,7 +17,7 @@ SET time_zone = "+00:00"; /*!40101 SET NAMES utf8 */; -- --- Base de données: `flux_rss` +-- Base de données: `freshrss` -- -- -------------------------------------------------------- @@ -50,6 +50,8 @@ CREATE TABLE IF NOT EXISTS `entry` ( `is_read` int(11) NOT NULL, `is_favorite` int(11) NOT NULL, `id_feed` varchar(6) NOT NULL, + `annotation` text NOT NULL, + `tags` text NOT NULL, PRIMARY KEY (`id`), KEY `id_feed` (`id_feed`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -63,11 +65,13 @@ CREATE TABLE IF NOT EXISTS `entry` ( CREATE TABLE IF NOT EXISTS `feed` ( `id` varchar(6) NOT NULL, `url` text NOT NULL, - `category` varchar(6) DEFAULT NULL, + `category` varchar(6) DEFAULT '000000', `name` varchar(255) NOT NULL, `website` text NOT NULL, `description` text NOT NULL, `lastUpdate` int(11) NOT NULL, + `pathEntries` varchar(500) DEFAULT NULL, + `httpAuth` varchar(500) DEFAULT NULL, PRIMARY KEY (`id`), KEY `category` (`category`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/lib/lib_rss.php b/lib/lib_rss.php index e957a11fb..a412ca7b1 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -166,20 +166,6 @@ function getFeed ($outline, $cat_id) { return $feed; } -/* - * Vérifie pour un site donné s'il faut aller parser directement sur le site - * Renvoie le path (id et class html) pour récupérer le contenu, false si pas besoin - * On se base sur une base connue de sites - */ -function get_path ($url) { - $list_sites_parse = include (PUBLIC_PATH . '/data/Sites.array.php'); - if (isset ($list_sites_parse[$url])) { - return $list_sites_parse[$url]; - } else { - return false; - } -} - /* permet de récupérer le contenu d'un article pour un flux qui n'est pas complet */ function get_content_by_parsing ($url, $path) { diff --git a/public/data/Sites.array.php b/public/data/Sites.array.php deleted file mode 100644 index 57cc9b22c..000000000 --- a/public/data/Sites.array.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -return array ( - 'http://www.numerama.com/' => '#newstext', - 'http://www.rue89.com/' => '#article .content', // buggué lorsqu'il y a des mises à jour :-/ - 'http://www.explosm.net/' => '#maincontent div div div img' -); diff --git a/public/theme/base.css b/public/theme/base.css index 4d7e80a90..6f9ebfb06 100644 --- a/public/theme/base.css +++ b/public/theme/base.css @@ -395,42 +395,46 @@ input, select { height: 14px; vertical-align: middle; line-height: 14px; + background: center center no-repeat; } .icon.i_refresh { - background: url("icons/refresh.svg") center center no-repeat; + background-image: url("icons/refresh.svg"); } .icon.i_bookmark { - background: url("icons/starred.svg") center center no-repeat; + background-image: url("icons/starred.svg"); } .icon.i_all { - background: url("icons/all.svg") center center no-repeat; + background-image: url("icons/all.svg"); } .icon.i_close { - background: url("icons/close.svg") center center no-repeat; + background-image: url("icons/close.svg"); } .icon.i_search { - background: url("icons/search.svg") center center no-repeat; + background-image: url("icons/search.svg"); } .icon.i_configure { - background: url("icons/configure.svg") center center no-repeat; + background-image: url("icons/configure.svg"); } .icon.i_login { - background: url("icons/login.svg") center center no-repeat; + background-image: url("icons/login.svg"); } .icon.i_logout { - background: url("icons/logout.svg") center center no-repeat; + background-image: url("icons/logout.svg"); } .icon.i_add { - background: url("icons/add.svg") center center no-repeat; + background-image: url("icons/add.svg"); } .icon.i_link { - background: url("icons/link.svg") center center no-repeat; + background-image: url("icons/link.svg"); } .icon.i_down { - background: url("icons/down.svg") center center no-repeat; + background-image: url("icons/down.svg"); } .icon.i_up { - background: url("icons/up.svg") center center no-repeat; + background-image: url("icons/up.svg"); + } + .icon.i_help { + background-image: url("icons/help.svg"); } /* STRUCTURE */ diff --git a/public/theme/icons/help.svg b/public/theme/icons/help.svg new file mode 100644 index 000000000..b103ec46d --- /dev/null +++ b/public/theme/icons/help.svg @@ -0,0 +1,32 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg xmlns:cc='http://creativecommons.org/ns#' xmlns:svg='http://www.w3.org/2000/svg' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' id='svg7384' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' version='1.1' inkscape:version='0.47 r22583' height='16' sodipodi:docname='help-browser-symbolic.svg' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns='http://www.w3.org/2000/svg' width='16'> + <metadata id='metadata90'> + <rdf:RDF> + <cc:Work rdf:about=''> + <dc:format>image/svg+xml</dc:format> + <dc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/> + <dc:title>Gnome Symbolic Icon Theme</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview inkscape:object-paths='true' inkscape:cy='-218.16054' inkscape:current-layer='layer11' inkscape:window-width='1920' pagecolor='#555753' showborder='false' showguides='true' inkscape:snap-nodes='false' objecttolerance='10' showgrid='true' inkscape:object-nodes='true' inkscape:pageshadow='2' inkscape:guide-bbox='true' inkscape:window-x='0' inkscape:snap-bbox='true' bordercolor='#666666' id='namedview88' inkscape:window-maximized='1' inkscape:snap-global='true' inkscape:window-y='26' gridtolerance='10' inkscape:zoom='1' inkscape:window-height='1021' borderopacity='1' guidetolerance='10' inkscape:snap-bbox-midpoints='false' inkscape:cx='-124.56688' inkscape:bbox-paths='false' inkscape:snap-grids='true' inkscape:pageopacity='1' inkscape:snap-to-guides='true'> + <inkscape:grid visible='true' spacingx='1px' type='xygrid' spacingy='1px' id='grid4866' empspacing='2' enabled='true' snapvisiblegridlinesonly='true'/> + </sodipodi:namedview> + <title id='title9167'>Gnome Symbolic Icon Theme</title> + <defs id='defs7386'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer9' inkscape:label='status' style='display:inline'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer10' inkscape:label='devices'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer11' inkscape:label='apps'> + <path d='m 190,490 c -4.4147,0 -8,3.5853 -8,8 0,4.4147 3.5853,8 8,8 4.4147,0 8,-3.5853 8,-8 0,-4.4147 -3.5853,-8 -8,-8 z m 0,2 c 3.3413,0 6,2.6587 6,6 0,3.3413 -2.6587,6 -6,6 -3.3413,0 -6,-2.6587 -6,-6 0,-3.3413 2.6587,-6 6,-6 z' id='rect11749-5-0-3' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans'/> + + <path d='M 189.34375,495 C 188.05763,495 187,496.05763 187,497.34375 l 0,1.3125 c 0,1.28612 1.05763,2.34375 2.34375,2.34375 l 1.3125,0 C 191.94237,501 193,499.94237 193,498.65625 l 0,-1.3125 C 193,496.05763 191.94237,495 190.65625,495 l -1.3125,0 z m 0,1 1.3125,0 c 0.74942,0 1.34375,0.59433 1.34375,1.34375 l 0,1.3125 C 192,499.40567 191.40567,500 190.65625,500 l -1.3125,0 C 188.59433,500 188,499.40567 188,498.65625 l 0,-1.3125 C 188,496.59433 188.59433,496 189.34375,496 z' id='rect11749-5-0-3-3' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999994;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans'/> + <path inkscape:connector-curvature='0' d='m 186.71875,491.4375 c -1.51031,0.6073 -2.6811,1.7985 -3.28125,3.3125 l 3.75,1.875 c 0.25196,-0.64029 0.74249,-1.17056 1.375,-1.4375 l -1.84375,-3.75 z m 6.5625,0 -1.84375,3.75 c 0.63251,0.26694 1.12304,0.79721 1.375,1.4375 l 3.75,-1.875 c -0.60015,-1.514 -1.77094,-2.7052 -3.28125,-3.3125 z m -6.09375,8 -3.75,1.875 c 0.60709,1.48862 1.78896,2.64995 3.28125,3.25 l 1.875,-3.75 c -0.62682,-0.25556 -1.14334,-0.75203 -1.40625,-1.375 z m 5.625,0 c -0.26291,0.62297 -0.77943,1.11944 -1.40625,1.375 l 1.875,3.75 c 1.49229,-0.60005 2.67416,-1.76138 3.28125,-3.25 l -3.75,-1.875 z' id='path4624' style='fill:#bebebe;fill-opacity:1;stroke:none'/> + </g> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer12' inkscape:label='actions'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer13' inkscape:label='places'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer14' inkscape:label='mimetypes'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='layer15' inkscape:label='emblems' style='display:inline'/> + <g transform='translate(-182,-490)' inkscape:groupmode='layer' id='g4953' inkscape:label='categories' style='display:inline'/> +</svg> |
