summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-01 11:27:41 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-01 11:27:41 +0200
commit1eef7893068655f8d145a3e06061a9e6296ac1f3 (patch)
treeec9cc77f2dc39baedf92a155da124bb6bd800984 /app
parentfdb63fbbe695b6a6bc32f0e93f2ff702ca42329c (diff)
Reorganize subscription management code
There is still a lot of work to do. Some links are broken. See https://github.com/marienfressinaud/FreshRSS/issues/646
Diffstat (limited to 'app')
-rwxr-xr-xapp/Controllers/configureController.php116
-rw-r--r--app/Controllers/subscriptionController.php130
-rw-r--r--app/Models/Themes.php1
-rw-r--r--app/layout/aside_feed.phtml60
-rw-r--r--app/layout/aside_flux.phtml4
-rw-r--r--app/layout/aside_subscription.phtml17
-rw-r--r--app/views/importExport/index.phtml2
-rw-r--r--app/views/subscription/feed.phtml (renamed from app/views/configure/feed.phtml)4
-rw-r--r--app/views/subscription/index.phtml (renamed from app/views/configure/categorize.phtml)48
9 files changed, 198 insertions, 184 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 3fd1d5149..b7b88b3ba 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -8,9 +8,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
* This action is called before every other action in that class. It is
* the common boiler plate for every action. It is triggered by the
* underlying framework.
- *
- * @todo see if the category default configuration is needed here or if
- * we can move it to the categorize action
*/
public function firstAction() {
if (!$this->view->loginOk) {
@@ -19,119 +16,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
array('error' => array(_t('access_denied')))
);
}
-
- $catDAO = new FreshRSS_CategoryDAO();
- $catDAO->checkDefault();
- }
-
- /**
- * This action handles the category configuration page
- *
- * It displays the category configuration page.
- */
- public function categorizeAction() {
- $catDAO = new FreshRSS_CategoryDAO();
-
- $this->view->categories = $catDAO->listCategories(false);
- $this->view->default_category = $catDAO->getDefault();
-
- Minz_View::prependTitle(_t('categories_management') . ' · ');
- }
-
- /**
- * This action handles the feed configuration page.
- *
- * It displays the feed configuration page.
- * If this action is reached through a POST request, it stores all new
- * configuraiton values then sends a notification to the user.
- *
- * The options available on the page are:
- * - name
- * - description
- * - website URL
- * - feed URL
- * - category id (default: default category id)
- * - CSS path to article on website
- * - display in main stream (default: 0)
- * - HTTP authentication
- * - number of article to retain (default: -2)
- * - refresh frequency (default: -2)
- * Default values are empty strings unless specified.
- */
- public function feedAction() {
- if (Minz_Request::param('ajax')) {
- $this->view->_useLayout(false);
- }
-
- $catDAO = new FreshRSS_CategoryDAO();
- $this->view->categories = $catDAO->listCategories(false);
-
- $feedDAO = FreshRSS_Factory::createFeedDao();
- $this->view->feeds = $feedDAO->listFeeds();
-
- $id = Minz_Request::param('id');
- if ($id == false && !empty($this->view->feeds)) {
- $id = current($this->view->feeds)->id();
- }
-
- $this->view->flux = false;
- if ($id != false) {
- $this->view->flux = $this->view->feeds[$id];
-
- if (!$this->view->flux) {
- Minz_Error::error(
- 404,
- array('error' => array(_t('page_not_found')))
- );
- } else {
- if (Minz_Request::isPost() && $this->view->flux) {
- $user = Minz_Request::param('http_user', '');
- $pass = Minz_Request::param('http_pass', '');
-
- $httpAuth = '';
- if ($user != '' || $pass != '') {
- $httpAuth = $user . ':' . $pass;
- }
-
- $cat = intval(Minz_Request::param('category', 0));
-
- $values = array(
- 'name' => Minz_Request::param('name', ''),
- 'description' => sanitizeHTML(Minz_Request::param('description', '', true)),
- 'website' => Minz_Request::param('website', ''),
- 'url' => Minz_Request::param('url', ''),
- 'category' => $cat,
- 'pathEntries' => Minz_Request::param('path_entries', ''),
- 'priority' => intval(Minz_Request::param('priority', 0)),
- 'httpAuth' => $httpAuth,
- 'keep_history' => intval(Minz_Request::param('keep_history', -2)),
- 'ttl' => intval(Minz_Request::param('ttl', -2)),
- );
-
- if ($feedDAO->updateFeed($id, $values)) {
- $this->view->flux->_category($cat);
- $this->view->flux->faviconPrepare();
- $notif = array(
- 'type' => 'good',
- 'content' => _t('feed_updated')
- );
- } else {
- $notif = array(
- 'type' => 'bad',
- 'content' => _t('error_occurred_update')
- );
- }
- invalidateHttpCache();
-
- Minz_Session::_param('notification', $notif);
- Minz_Request::forward(array('c' => 'configure', 'a' => 'feed', 'params' => array('id' => $id)), true);
- }
-
- Minz_View::prependTitle(_t('rss_feed_management') . ' — ' . $this->view->flux->name() . ' · ');
- }
- } else {
- Minz_View::prependTitle(_t('rss_feed_management') . ' · ');
- }
}
/**
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
new file mode 100644
index 000000000..ab00f3e6a
--- /dev/null
+++ b/app/Controllers/subscriptionController.php
@@ -0,0 +1,130 @@
+<?php
+
+/**
+ * Controller to handle subscription actions.
+ */
+class FreshRSS_subscription_Controller extends Minz_ActionController {
+ /**
+ * This action is called before every other action in that class. It is
+ * the common boiler plate for every action. It is triggered by the
+ * underlying framework.
+ */
+ public function firstAction() {
+ if (!$this->view->loginOk) {
+ Minz_Error::error(
+ 403,
+ array('error' => array(_t('access_denied')))
+ );
+ }
+ }
+
+ /**
+ * This action handles the main subscription page
+ *
+ * It displays categories and associated feeds.
+ */
+ public function indexAction() {
+ $catDAO = new FreshRSS_CategoryDAO();
+
+ $this->view->categories = $catDAO->listCategories(false);
+ $this->view->default_category = $catDAO->getDefault();
+
+ Minz_View::prependTitle(_t('subscription_management') . ' · ');
+ }
+
+ /**
+ * This action handles the feed configuration page.
+ *
+ * It displays the feed configuration page.
+ * If this action is reached through a POST request, it stores all new
+ * configuraiton values then sends a notification to the user.
+ *
+ * The options available on the page are:
+ * - name
+ * - description
+ * - website URL
+ * - feed URL
+ * - category id (default: default category id)
+ * - CSS path to article on website
+ * - display in main stream (default: 0)
+ * - HTTP authentication
+ * - number of article to retain (default: -2)
+ * - refresh frequency (default: -2)
+ * Default values are empty strings unless specified.
+ */
+ public function feedAction() {
+ if (Minz_Request::param('ajax')) {
+ $this->view->_useLayout(false);
+ }
+
+ $catDAO = new FreshRSS_CategoryDAO();
+ $this->view->categories = $catDAO->listCategories(false);
+
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ $this->view->feeds = $feedDAO->listFeeds();
+
+ $id = Minz_Request::param('id');
+ if ($id == false && !empty($this->view->feeds)) {
+ $id = current($this->view->feeds)->id();
+ }
+
+ $this->view->flux = false;
+ if ($id != false) {
+ $this->view->flux = $this->view->feeds[$id];
+
+ if (!$this->view->flux) {
+ Minz_Error::error(
+ 404,
+ array('error' => array(_t('page_not_found')))
+ );
+ } else {
+ if (Minz_Request::isPost() && $this->view->flux) {
+ $user = Minz_Request::param('http_user', '');
+ $pass = Minz_Request::param('http_pass', '');
+
+ $httpAuth = '';
+ if ($user != '' || $pass != '') {
+ $httpAuth = $user . ':' . $pass;
+ }
+
+ $cat = intval(Minz_Request::param('category', 0));
+
+ $values = array(
+ 'name' => Minz_Request::param('name', ''),
+ 'description' => sanitizeHTML(Minz_Request::param('description', '', true)),
+ 'website' => Minz_Request::param('website', ''),
+ 'url' => Minz_Request::param('url', ''),
+ 'category' => $cat,
+ 'pathEntries' => Minz_Request::param('path_entries', ''),
+ 'priority' => intval(Minz_Request::param('priority', 0)),
+ 'httpAuth' => $httpAuth,
+ 'keep_history' => intval(Minz_Request::param('keep_history', -2)),
+ 'ttl' => intval(Minz_Request::param('ttl', -2)),
+ );
+
+ if ($feedDAO->updateFeed($id, $values)) {
+ $this->view->flux->_category($cat);
+ $this->view->flux->faviconPrepare();
+ $notif = array(
+ 'type' => 'good',
+ 'content' => _t('feed_updated')
+ );
+ } else {
+ $notif = array(
+ 'type' => 'bad',
+ 'content' => _t('error_occurred_update')
+ );
+ }
+ invalidateHttpCache();
+
+ Minz_Session::_param('notification', $notif);
+ Minz_Request::forward(array('c' => 'subscription'), true);
+ }
+
+ Minz_View::prependTitle(_t('rss_feed_management') . ' · ' . $this->view->flux->name() . ' · ');
+ }
+ } else {
+ Minz_View::prependTitle(_t('rss_feed_management') . ' · ');
+ }
+ }
+}
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index 68fc17a2b..e3b260261 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -82,6 +82,7 @@ class FreshRSS_Themes extends Minz_Model {
'favorite' => '★',
'help' => 'ⓘ',
'icon' => '⊚',
+ 'import' => '⤓',
'key' => '⚿',
'link' => '↗',
'login' => '🔒',
diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml
deleted file mode 100644
index c028c4918..000000000
--- a/app/layout/aside_feed.phtml
+++ /dev/null
@@ -1,60 +0,0 @@
-<ul class="nav nav-list aside aside_feed">
- <li class="nav-header"><?php echo _t('your_rss_feeds'); ?></li>
-
- <li class="nav-form">
- <form id="add_rss" method="post" action="<?php echo _url('feed', 'add'); ?>" autocomplete="off">
- <div class="stick">
- <input type="url" name="url_rss" placeholder="<?php echo _t('add_rss_feed'); ?>" />
- <div class="dropdown">
- <div id="dropdown-cat" class="dropdown-target"></div>
-
- <a class="dropdown-toggle btn" href="#dropdown-cat"><?php echo _i('down'); ?></a>
- <ul class="dropdown-menu">
- <li class="dropdown-close"><a href="#close">❌</a></li>
-
- <li class="dropdown-header"><?php echo _t('category'); ?></li>
-
- <li class="input">
- <select name="category" id="category">
- <?php foreach ($this->categories as $cat) { ?>
- <option value="<?php echo $cat->id(); ?>"<?php echo $cat->id() == 1 ? ' selected="selected"' : ''; ?>>
- <?php echo $cat->name(); ?>
- </option>
- <?php } ?>
- <option value="nc"><?php echo _t('new_category'); ?></option>
- </select>
- </li>
-
- <li class="input" style="display:none">
- <input type="text" name="new_category[name]" id="new_category_name" autocomplete="off" placeholder="<?php echo _t('new_category'); ?>" />
- </li>
-
- <li class="separator"></li>
-
- <li class="dropdown-header"><?php echo _t('http_authentication'); ?></li>
- <li class="input">
- <input type="text" name="http_user" id="http_user_add" autocomplete="off" placeholder="<?php echo _t('username'); ?>" />
- </li>
- <li class="input">
- <input type="password" name="http_pass" id="http_pass_add" autocomplete="off" placeholder="<?php echo _t('password'); ?>" />
- </li>
- </ul>
- </div>
- <button class="btn" type="submit"><?php echo _i('add'); ?></button>
- </div>
- </form></li>
-
- <li class="item">
- <a onclick="return false;" href="javascript:(function(){var%20url%20=%20location.href;window.open('<?php echo Minz_Url::display(array('c' => 'feed', 'a' => 'add'), 'html', true); ?>&amp;url_rss='+encodeURIComponent(url), '_blank');})();">
- <?php echo _t('bookmark'); ?>
- </a>
- </li>
-
- <li class="item<?php echo Minz_Request::controllerName() == 'importExport' ? ' active' : ''; ?>">
- <a href="<?php echo _url('importExport', 'index'); ?>"><?php echo _t('import_export'); ?></a>
- </li>
-
- <li class="item<?php echo Minz_Request::actionName() == 'categorize' ? ' active' : ''; ?>">
- <a href="<?php echo _url('configure', 'categorize'); ?>"><?php echo _t('categories_management'); ?></a>
- </li>
-</ul>
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml
index aac3c0896..341697103 100644
--- a/app/layout/aside_flux.phtml
+++ b/app/layout/aside_flux.phtml
@@ -7,8 +7,8 @@
<li>
<div class="stick configure-feeds">
- <a class="btn btn-important" href="<?php echo _url('configure', 'feed'); ?>"><?php echo _t('subscription_management'); ?></a>
- <a class="btn btn-important" href="<?php echo _url('configure', 'categorize'); ?>" title="<?php echo _t('categories_management'); ?>"><?php echo _i('category-white'); ?></a>
+ <a class="btn btn-important" href="<?php echo _url('subscription', 'index'); ?>"><?php echo _t('subscription_management'); ?></a>
+ <a class="btn btn-important" href="<?php echo _url('importExport', 'index'); ?>"><?php echo _i('import'); ?></a>
</div>
</li>
<?php } elseif (Minz_Configuration::needsLogin()) { ?>
diff --git a/app/layout/aside_subscription.phtml b/app/layout/aside_subscription.phtml
new file mode 100644
index 000000000..9a95763c3
--- /dev/null
+++ b/app/layout/aside_subscription.phtml
@@ -0,0 +1,17 @@
+<ul class="nav nav-list aside aside_feed">
+ <li class="nav-header"><?php echo _t('subscription_management'); ?></li>
+
+ <li class="item<?php echo Minz_Request::controllerName() == 'subscription' ? ' active' : ''; ?>">
+ <a href="<?php echo _url('subscription', 'index'); ?>"><?php echo _t('subscription_management'); ?></a>
+ </li>
+
+ <li class="item<?php echo Minz_Request::controllerName() == 'importExport' ? ' active' : ''; ?>">
+ <a href="<?php echo _url('importExport', 'index'); ?>"><?php echo _t('import_export'); ?></a>
+ </li>
+
+ <li class="item">
+ <a onclick="return false;" href="javascript:(function(){var%20url%20=%20location.href;window.open('<?php echo Minz_Url::display(array('c' => 'feed', 'a' => 'add'), 'html', true); ?>&amp;url_rss='+encodeURIComponent(url), '_blank');})();">
+ <?php echo _t('bookmark'); ?>
+ </a>
+ </li>
+</ul>
diff --git a/app/views/importExport/index.phtml b/app/views/importExport/index.phtml
index 35371faca..36c0eab4e 100644
--- a/app/views/importExport/index.phtml
+++ b/app/views/importExport/index.phtml
@@ -1,4 +1,4 @@
-<?php $this->partial('aside_feed'); ?>
+<?php $this->partial('aside_subscription'); ?>
<div class="post ">
<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('back_to_rss_feeds'); ?></a>
diff --git a/app/views/configure/feed.phtml b/app/views/subscription/feed.phtml
index f58ac65af..e047741a1 100644
--- a/app/views/configure/feed.phtml
+++ b/app/views/subscription/feed.phtml
@@ -1,6 +1,6 @@
<?php
if (!Minz_Request::param('ajax')) {
- $this->partial('aside_feed');
+ $this->partial('aside_subscription');
}
?>
@@ -19,7 +19,7 @@
<p class="alert alert-warn"><?php echo Minz_Translate::t ('feed_empty'); ?></p>
<?php } ?>
- <form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>" autocomplete="off">
+ <form method="post" action="<?php echo _url ('subscription', 'feed', 'id', $this->flux->id ()); ?>" autocomplete="off">
<legend><?php echo Minz_Translate::t ('informations'); ?></legend>
<div class="form-group">
<label class="group-name" for="name"><?php echo Minz_Translate::t ('title'); ?></label>
diff --git a/app/views/configure/categorize.phtml b/app/views/subscription/index.phtml
index f5030ef2c..444dc9d9b 100644
--- a/app/views/configure/categorize.phtml
+++ b/app/views/subscription/index.phtml
@@ -1,9 +1,51 @@
-<?php $this->partial('aside_feed'); ?>
+<?php $this->partial('aside_subscription'); ?>
<div class="post">
<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('back_to_rss_feeds'); ?></a>
- <h2><?php echo _t('categories_management'); ?></h2>
+ <h2><?php echo _t('subscription_management'); ?></h2>
+
+ <form id="add_rss" method="post" action="<?php echo _url('feed', 'add'); ?>" autocomplete="off">
+ <div class="stick">
+ <input type="url" name="url_rss" class="extend" placeholder="<?php echo _t('add_rss_feed'); ?>" />
+ <div class="dropdown">
+ <div id="dropdown-cat" class="dropdown-target"></div>
+
+ <a class="dropdown-toggle btn" href="#dropdown-cat"><?php echo _i('down'); ?></a>
+ <ul class="dropdown-menu">
+ <li class="dropdown-close"><a href="#close">❌</a></li>
+
+ <li class="dropdown-header"><?php echo _t('category'); ?></li>
+
+ <li class="input">
+ <select name="category" id="category">
+ <?php foreach ($this->categories as $cat) { ?>
+ <option value="<?php echo $cat->id(); ?>"<?php echo $cat->id() == 1 ? ' selected="selected"' : ''; ?>>
+ <?php echo $cat->name(); ?>
+ </option>
+ <?php } ?>
+ <option value="nc"><?php echo _t('new_category'); ?></option>
+ </select>
+ </li>
+
+ <li class="input" style="display:none">
+ <input type="text" name="new_category[name]" id="new_category_name" autocomplete="off" placeholder="<?php echo _t('new_category'); ?>" />
+ </li>
+
+ <li class="separator"></li>
+
+ <li class="dropdown-header"><?php echo _t('http_authentication'); ?></li>
+ <li class="input">
+ <input type="text" name="http_user" id="http_user_add" autocomplete="off" placeholder="<?php echo _t('username'); ?>" />
+ </li>
+ <li class="input">
+ <input type="password" name="http_pass" id="http_pass_add" autocomplete="off" placeholder="<?php echo _t('password'); ?>" />
+ </li>
+ </ul>
+ </div>
+ <button class="btn" type="submit"><?php echo _i('add'); ?></button>
+ </div>
+ </form>
<p class="alert alert-warn">
<?php echo _t('feeds_moved_category_deleted', $this->default_category->name()); ?>
@@ -73,7 +115,7 @@
$empty = $feed->nbEntries() == 0 ? ' empty' : '';
?>
<li class="item<?php echo $error, $empty; ?>">
- <a class="configure open-slider" href="<?php echo _url('configure', 'feed', 'id', $feed->id()); ?>"><?php echo _i('configure'); ?></a>
+ <a class="configure open-slider" href="<?php echo _url('subscription', 'feed', 'id', $feed->id()); ?>"><?php echo _i('configure'); ?></a>
<img class="favicon" src="<?php echo $feed->favicon(); ?>" alt="✇" /> <?php echo $feed->name(); ?>
</li>
<?php }