Explorar el Código

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
Marien Fressinaud hace 11 años
padre
commit
1eef789306

+ 0 - 116
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') . ' · ');
-		}
 	}
 
 	/**

+ 130 - 0
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') . ' · ');
+		}
+	}
+}

+ 1 - 0
app/Models/Themes.php

@@ -82,6 +82,7 @@ class FreshRSS_Themes extends Minz_Model {
 			'favorite' => '★',
 			'help' => 'ⓘ',
 			'icon' => '⊚',
+			'import' => '⤓',
 			'key' => '⚿',
 			'link' => '↗',
 			'login' => '🔒',

+ 0 - 60
app/layout/aside_feed.phtml

@@ -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>

+ 2 - 2
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()) { ?>

+ 17 - 0
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>

+ 1 - 1
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>

+ 2 - 2
app/views/configure/feed.phtml → 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>

+ 45 - 3
app/views/configure/categorize.phtml → 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 	}

+ 9 - 0
p/themes/icons/import.svg

@@ -0,0 +1,9 @@
+<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
+<g transform="translate(-80,-648)" fill="#ffffff">
+<path style="baseline-shift:baseline;block-progression:tb;color:#ffffff;direction:ltr;text-indent:0;text-align:start;enable-background:accumulate;text-transform:none;" d="m84.406,657a0.50005,0.50005,0,0,0,-0.3125,0.21875l-1,1.5a0.50005,0.50005,0,1,0,0.8125,0.5625l1-1.5a0.50005,0.50005,0,0,0,-0.5,-0.78zm7,0a0.50005,0.50005,0,0,0,-0.3125,0.78125l1,1.5a0.50005,0.50005,0,1,0,0.8125,-0.5625l-1-1.5a0.50005,0.50005,0,0,0,-0.5,-0.22z"/>
+<g transform="translate(-80,110)">
+<path style="block-progression:tb;color:#000000;direction:ltr;text-indent:0;text-align:start;enable-background:accumulate;text-transform:none;" d="m167,539,0,5.5625-1.2812-1.2812c-0.19-0.19-0.45-0.28-0.72-0.28h-1v1c0.00001,0.2653,0.0931,0.53058,0.28125,0.71875l3,3,0.28125,0.28125h0.875l0.28125-0.28125,3-3c0.19-0.19,0.28-0.45,0.28-0.72v-1h-1c-0.2653,0.00001-0.53059,0.0931-0.71875,0.28125l-1.28,1.28v-5.56z"/>
+<path style="enable-background:accumulate;color:#000000;" d="m163,549,0,4,10,0,0-4zm3.3438,1.4375c0.0208-0.001,0.0417-0.001,0.0625,0,0.29096-0.0556,0.59898,0.20383,0.59375,0.5v0.0625h2v-0.0625c-0.004-0.26416,0.23582-0.50712,0.5-0.50712s0.50373,0.24296,0.5,0.50712l-9.99,0.06c0,0.54535-0.45465,1-1,1h-2c-0.54535,0-1-0.45465-1-1v-0.0625c-0.0108-0.21706,0.13723-0.43234,0.34375-0.5z" fill-rule="evenodd"/>
+</g>
+</g>
+</svg>