diff options
| author | 2012-10-25 17:08:17 +0200 | |
|---|---|---|
| committer | 2012-10-25 17:08:17 +0200 | |
| commit | 48a1aa7d52e712d5f64a33a003b31f23a00b99f5 (patch) | |
| tree | ab6e6de44c007836edda8f0b2ded29c8d28ca1a1 /app | |
| parent | 32ee8feccfb28aa3141469581cd04d4813fd6835 (diff) | |
ajout de la fonctionnalité pour paramétrer les raccourcis
Diffstat (limited to 'app')
| -rwxr-xr-x | app/controllers/configureController.php | 37 | ||||
| -rwxr-xr-x | app/controllers/feedController.php | 9 | ||||
| -rw-r--r-- | app/layout/aside.phtml | 3 | ||||
| -rw-r--r-- | app/models/Feed.php | 13 | ||||
| -rwxr-xr-x | app/models/RSSConfiguration.php | 26 | ||||
| -rw-r--r-- | app/views/configure/flux.phtml | 2 | ||||
| -rw-r--r-- | app/views/configure/shortcut.phtml | 34 | ||||
| -rw-r--r-- | app/views/index/index.phtml | 2 | ||||
| -rw-r--r-- | app/views/javascript/main.phtml | 27 |
9 files changed, 140 insertions, 13 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index daabfd3bb..849066ad7 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -85,7 +85,7 @@ class configureController extends ActionController { ); $confDAO = new RSSConfigurationDAO (); - $confDAO->save ($values); + $confDAO->update ($values); Session::_param ('conf', $this->view->conf); } } @@ -120,4 +120,39 @@ class configureController extends ActionController { } } } + + public function shortcutAction () { + $list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter', + 'escape', 'f', 'g', 'h', 'i', 'insert', 'j', 'k', 'l', 'left', + 'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right', + 's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y', + 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', + 'f10', 'f11', 'f12'); + $this->view->list_keys = $list_keys; + $list_names = array ('mark_read', 'mark_favorite', 'go_website', 'next_entry', + 'prev_entry', 'next_page', 'prev_page'); + + if (Request::isPost ()) { + $shortcuts = Request::param ('shortcuts'); + $shortcuts_ok = array (); + + foreach ($shortcuts as $key => $value) { + if (in_array ($key, $list_names) + && in_array ($value, $list_keys)) { + $shortcuts_ok[$key] = $value; + } + } + + $this->view->conf->_shortcuts ($shortcuts_ok); + + $values = array ( + 'shortcuts' => $this->view->conf->shortcuts () + ); + + $confDAO = new RSSConfigurationDAO (); + $confDAO->update ($values); + Session::_param ('conf', $this->view->conf); + } + } } diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index f597c872f..4ef4039f6 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -129,4 +129,13 @@ class feedController extends ActionController { Request::forward (array ('c' => 'configure', 'a' => 'importExport')); } + + public function deleteAction () { + $id = Request::param ('id'); + + $feedDAO = new FeedDAO (); + $feedDAO->deleteFeed ($id); + + Request::forward (array ('c' => 'configure', 'a' => 'flux')); + } } diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml index 525357ea5..f88f6cc0f 100644 --- a/app/layout/aside.phtml +++ b/app/layout/aside.phtml @@ -44,6 +44,9 @@ <li <?php echo Request::actionName () == 'importExport' ? 'class="active"' : ''; ?>> <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'importExport')); ?>">Import / Export OPML</a> </li> + <li <?php echo Request::actionName () == 'shortcut' ? 'class="active"' : ''; ?>> + <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'shortcut')); ?>">Raccourcis</a> + </li> </ul> </div> <?php } ?> diff --git a/app/models/Feed.php b/app/models/Feed.php index 399c34d18..e28657612 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -146,6 +146,19 @@ class FeedDAO extends Model_pdo { } } + public function deleteFeed ($id) { + $sql = 'DELETE FROM feed WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + return false; + } + } + public function searchById ($id) { $sql = 'SELECT * FROM feed WHERE id=?'; $stm = $this->bd->prepare ($sql); diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index 8ee1717b3..f3e7f9d4a 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -6,6 +6,7 @@ class RSSConfiguration extends Model { private $display_posts; private $sort_order; private $old_entries; + private $shortcuts = array (); public function __construct () { $confDAO = new RSSConfigurationDAO (); @@ -14,6 +15,7 @@ class RSSConfiguration extends Model { $this->_displayPosts ($confDAO->display_posts); $this->_sortOrder ($confDAO->sort_order); $this->_oldEntries ($confDAO->old_entries); + $this->_shortcuts ($confDAO->shortcuts); } public function postsPerPage () { @@ -31,6 +33,9 @@ class RSSConfiguration extends Model { public function oldEntries () { return $this->old_entries; } + public function shortcuts () { + return $this->shortcuts; + } public function _postsPerPage ($value) { if (is_int ($value)) { @@ -67,6 +72,11 @@ class RSSConfiguration extends Model { $this->old_entries = 3; } } + public function _shortcuts ($values) { + foreach ($values as $key => $value) { + $this->shortcuts[$key] = $value; + } + } } class RSSConfigurationDAO extends Model_array { @@ -75,6 +85,15 @@ class RSSConfigurationDAO extends Model_array { public $display_posts = 'no'; public $sort_order = 'low_to_high'; public $old_entries = 3; + public $shortcuts = array ( + 'mark_read' => 'r', + 'mark_favorite' => 'f', + 'go_website' => 'enter', + 'next_entry' => 'page_down', + 'prev_entry' => 'page_up', + 'next_page' => 'right', + 'prev_page' => 'left', + ); public function __construct () { parent::__construct (PUBLIC_PATH . '/data/db/Configuration.array.php'); @@ -94,11 +113,12 @@ class RSSConfigurationDAO extends Model_array { if (isset ($this->array['old_entries'])) { $this->old_entries = $this->array['old_entries']; } + if (isset ($this->array['shortcuts'])) { + $this->shortcuts = $this->array['shortcuts']; + } } - public function save ($values) { - $this->array[0] = array (); - + public function update ($values) { foreach ($values as $key => $value) { $this->array[0][$key] = $value; } diff --git a/app/views/configure/flux.phtml b/app/views/configure/flux.phtml index fe1ddc644..1aa26c634 100644 --- a/app/views/configure/flux.phtml +++ b/app/views/configure/flux.phtml @@ -36,6 +36,8 @@ </div> <input type="submit" value="Valider" /> + + <button formaction="<?php echo Url::display (array ('c' => 'feed', 'a' => 'delete', 'params' => array ('id' => $this->flux->id ()))); ?>">Supprimer</button> <?php } ?> </form> <?php } else { ?> diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml new file mode 100644 index 000000000..6fc253dd5 --- /dev/null +++ b/app/views/configure/shortcut.phtml @@ -0,0 +1,34 @@ +<datalist id="keys"> + <?php foreach ($this->list_keys as $key) { ?> + <option value="<?php echo $key; ?>"> + <?php } ?> +</datalist> + +<?php $s = $this->conf->shortcuts (); ?> + +<form method="post" action=""> + <h1>Gérer les raccourcis</h1> + + <label for="mark_read">Marquer l'article comme lu</label> + <input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" /> + + <label for="mark_favorite">Mettre l'article en favori</label> + <input type="text" id="mark_favorite" name="shortcuts[mark_favorite]" list="keys" value="<?php echo $s['mark_favorite']; ?>" /> + + <label for="go_website">Afficher l'article sur le site d'origine</label> + <input type="text" id="go_website" name="shortcuts[go_website]" list="keys" value="<?php echo $s['go_website']; ?>" /> + + <label for="next_entry">Passer à l'article suivant</label> + <input type="text" id="next_entry" name="shortcuts[next_entry]" list="keys" value="<?php echo $s['next_entry']; ?>" /> + + <label for="prev_entry">Passer à l'article précédent</label> + <input type="text" id="prev_entry" name="shortcuts[prev_entry]" list="keys" value="<?php echo $s['prev_entry']; ?>" /> + + <label for="next_page">Passer à la page suivant</label> + <input type="text" id="next_page" name="shortcuts[next_page]" list="keys" value="<?php echo $s['next_page']; ?>" /> + + <label for="prev_page">Passer à la page précédente</label> + <input type="text" id="prev_page" name="shortcuts[prev_page]" list="keys" value="<?php echo $s['prev_page']; ?>" /> + + <input type="submit" value="Valider" /> +</form> diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index c3f4242c4..27a6f9fe2 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -22,7 +22,7 @@ sur <a target="_blank" href="<?php echo $feed->website (); ?>"><?php echo $feed->name (); ?> <img src="http://www.google.com/s2/favicons?domain=<?php echo get_domain ($feed->website ()); ?>" alt="" /></a>, </div> - <h1><a target="_blank" href="<?php echo $item->link (); ?>"> <?php echo $item->title (); ?></a></h1> + <h1 class="title"><a target="_blank" href="<?php echo $item->link (); ?>"> <?php echo $item->title (); ?></a></h1> <div class="content"><?php echo $item->content (); ?></div> <div class="after"> diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index c801ba7d0..beae6c12b 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -4,9 +4,15 @@ var hide_posts = true; var hide_posts = false; <?php } ?> -function redirect (url) { +<?php $s = $this->conf->shortcuts (); ?> + +function redirect (url, new_tab = false) { if (url) { - location.href = url; + if (new_tab) { + window.open (url); + } else { + location.href = url; + } } } @@ -98,19 +104,19 @@ $(document).ready (function () { }); // Touches de manipulation - shortcut.add("m", function () { + shortcut.add("<?php echo $s['mark_read']; ?>", function () { // on marque comme lu ou non lu active = $(".post.flux.active"); mark_read (active); }); - shortcut.add("f", function () { + shortcut.add("<?php echo $s['mark_favorite']; ?>", function () { // on marque comme favori ou non favori active = $(".post.flux.active"); mark_favorite (active); }); // Touches de navigation - shortcut.add("page_up", function () { + shortcut.add("<?php echo $s['prev_entry']; ?>", function () { old_active = $(".post.flux.active"); last_active = $(".post.flux:last"); new_active = old_active.prev (); @@ -121,7 +127,7 @@ $(document).ready (function () { slide (last_active, old_active); } }); - shortcut.add("page_down", function () { + shortcut.add("<?php echo $s['next_entry']; ?>", function () { old_active = $(".post.flux.active"); first_active = $(".post.flux:first"); new_active = old_active.next (); @@ -132,7 +138,7 @@ $(document).ready (function () { slide (first_active, old_active); } }); - shortcut.add("right", function () { + shortcut.add("<?php echo $s['next_page']; ?>", function () { url = $(".pager-next a").attr ("href"); if (url === undefined) { url = $(".pager-first a").attr ("href"); @@ -140,7 +146,7 @@ $(document).ready (function () { redirect (url); }); - shortcut.add("left", function () { + shortcut.add("<?php echo $s['prev_page']; ?>", function () { url = $(".pager-previous a").attr ("href"); if (url === undefined) { url = $(".pager-last a").attr ("href"); @@ -148,4 +154,9 @@ $(document).ready (function () { redirect (url); }); + shortcut.add("<?php echo $s['go_website']; ?>", function () { + url = $(".post.flux.active h1.title a").attr ("href"); + + redirect (url, true); + }); }); |
