mise en place du routage

This commit is contained in:
Marien Fressinaud
2012-10-25 22:24:54 +02:00
parent 3ff51a59ba
commit b5916b6c04
9 changed files with 158 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
[general]
environment = "development"
use_url_rewriting = false
use_url_rewriting = true
sel_application = "flux rss lalala ~~~"
base_url = "/~marien/rss/public"

View File

@@ -1,5 +1,124 @@
<?php
return array (
// Index
array (
'route' => '/\?q=([\w\d\-_]+)&p=([\d+])',
'controller' => 'index',
'action' => 'index',
'params' => array ('get', 'page')
),
array (
'route' => '/\?q=([\w\d\-_]+)',
'controller' => 'index',
'action' => 'index',
'params' => array ('get')
),
array (
'route' => '/\?p=([\d]+)',
'controller' => 'index',
'action' => 'index',
'params' => array ('page')
),
array (
'route' => '/login.php',
'controller' => 'index',
'action' => 'login'
),
array (
'route' => '/logout.php',
'controller' => 'index',
'action' => 'logout'
),
array (
'route' => '/mode.php\?m=([\w_]+)',
'controller' => 'index',
'action' => 'changeMode',
'params' => array ('mode')
),
// Scripts
array (
'route' => '/scripts/main.js',
'controller' => 'javascript',
'action' => 'main'
),
// Entry
array (
'route' => '/articles/marquer.php\?lu=([\d]{1})',
'controller' => 'entry',
'action' => 'read',
'params' => array ('is_read')
),
array (
'route' => '/articles/marquer.php\?id=([\w\d\-_]{6})&favori=([\d]{1})',
'controller' => 'entry',
'action' => 'bookmark',
'params' => array ('id', 'is_favorite')
),
array (
'route' => '/articles/marquer.php\?id=([\w\d\-_]{6})&lu=([\d]{1})',
'controller' => 'entry',
'action' => 'read',
'params' => array ('id', 'is_read')
),
// Feed
array (
'route' => '/flux/ajouter.php',
'controller' => 'feed',
'action' => 'add'
),
array (
'route' => '/flux/actualiser.php',
'controller' => 'feed',
'action' => 'actualize'
),
array (
'route' => '/flux/supprimer.php\?id=([\w\d\-_]{6})',
'controller' => 'feed',
'action' => 'delete',
'params' => array ('id')
),
// Configure
array (
'route' => '/configuration/flux.php',
'controller' => 'configure',
'action' => 'feed'
),
array (
'route' => '/configuration/flux.php\?id=([\w\d\-_]{6})',
'controller' => 'configure',
'action' => 'feed',
'params' => array ('id')
),
array (
'route' => '/configuration/categories.php',
'controller' => 'configure',
'action' => 'categorize'
),
array (
'route' => '/configuration/global.php',
'controller' => 'configure',
'action' => 'display'
),
array (
'route' => '/configuration/import_export.php',
'controller' => 'configure',
'action' => 'importExport'
),
array (
'route' => '/configuration/import_export.php\?q=([\w]{6})',
'controller' => 'configure',
'action' => 'importExport',
'params' => array ('q')
),
array (
'route' => '/configuration/raccourcis.php',
'controller' => 'configure',
'action' => 'shortcut'
),
);

View File

@@ -46,7 +46,7 @@ class configureController extends ActionController {
$this->view->categories = $catDAO->listCategories ();
}
public function fluxAction () {
public function feedAction () {
$feedDAO = new FeedDAO ();
$this->view->feeds = $feedDAO->listFeeds ();

View File

@@ -156,7 +156,7 @@ class feedController extends ActionController {
$feedDAO = new FeedDAO ();
$feedDAO->deleteFeed ($id);
Request::forward (array ('c' => 'configure', 'a' => 'flux'));
Request::forward (array ('c' => 'configure', 'a' => 'feed'), true);
}
}
}

View File

@@ -21,7 +21,7 @@
</li>
<?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
<li <?php echo Request::controllerName () == 'configure' ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux')); ?>">Configurer</a>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'feed')); ?>">Configurer</a>
</li>
<?php } ?>
<li>
@@ -44,8 +44,8 @@
<div class="aside">
<ul id="menu">
<li><h2>Configuration</h2></li>
<li <?php echo Request::actionName () == 'flux' ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux')); ?>">Flux RSS</a>
<li <?php echo Request::actionName () == 'feed' ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'feed')); ?>">Flux RSS</a>
</li>
<li <?php echo Request::actionName () == 'categorize' ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'categorize')); ?>">Catégories</a>

View File

@@ -5,7 +5,7 @@
<?php if (!empty ($this->feeds)) { ?>
<?php foreach ($this->feeds as $feed) { ?>
<li <?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux', 'params' => array ('id' => $feed->id ()))); ?>"><?php echo $feed->name (); ?></a>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $feed->id ()))); ?>"><?php echo $feed->name (); ?></a>
</li>
<?php } ?>
<?php } else { ?>

View File

@@ -9,8 +9,9 @@
<form method="post" action="">
<h1>Gérer les raccourcis</h1>
<label for="mark_read">Marquer l'article comme lu</label>
<label for="mark_read">Marquer l'article comme lu / non lu</label>
<input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" />
<p>+ <code>shift</code> pour marquer tous les articles</p>
<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']; ?>" />
@@ -20,15 +21,19 @@
<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']; ?>" />
<p>+ <code>shift</code> pour passer au dernier article de la page</p>
<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']; ?>" />
<p>+ <code>shift</code> pour passer au premier article de la page</p>
<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']; ?>" />
<p>+ <code>shift</code> pour passer à la dernière page</p>
<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']; ?>" />
<p>+ <code>shift</code> pour passer à la première page</p>
<input type="submit" value="Valider" />
</form>

View File

@@ -146,6 +146,14 @@ $(document).ready (function () {
slide (last_active, old_active);
}
});
shortcut.add("shift+<?php echo $s['prev_entry']; ?>", function () {
old_active = $(".post.flux.active");
first = $(".post.flux:first");
if (first[0] instanceof HTMLDivElement) {
slide (first, old_active);
}
});
shortcut.add("<?php echo $s['next_entry']; ?>", function () {
old_active = $(".post.flux.active");
first_active = $(".post.flux:first");
@@ -157,20 +165,28 @@ $(document).ready (function () {
slide (first_active, old_active);
}
});
shortcut.add("shift+<?php echo $s['next_entry']; ?>", function () {
old_active = $(".post.flux.active");
last = $(".post.flux:last");
if (last[0] instanceof HTMLDivElement) {
slide (last, old_active);
}
});
shortcut.add("<?php echo $s['next_page']; ?>", function () {
url = $(".pager-next a").attr ("href");
if (url === undefined) {
url = $(".pager-first a").attr ("href");
}
redirect (url);
});
shortcut.add("shift+<?php echo $s['next_page']; ?>", function () {
url = $(".pager-last a").attr ("href");
redirect (url);
});
shortcut.add("<?php echo $s['prev_page']; ?>", function () {
url = $(".pager-previous a").attr ("href");
if (url === undefined) {
url = $(".pager-last a").attr ("href");
}
redirect (url);
});
shortcut.add("shift+<?php echo $s['prev_page']; ?>", function () {
url = $(".pager-first a").attr ("href");
redirect (url);
});
shortcut.add("<?php echo $s['go_website']; ?>", function () {

View File

@@ -239,6 +239,6 @@ class Router {
}
}
return $uri;
return str_replace ('&', '&amp;', $uri);
}
}