Remove some code duplication and fix some minor issues

This commit is contained in:
Frederic Guillot 2015-08-14 22:08:04 -04:00
parent 4f7ea89925
commit 33a4bf2202
6 changed files with 9 additions and 22 deletions

View File

@ -4,7 +4,7 @@
define('HTTP_TIMEOUT', '20'); define('HTTP_TIMEOUT', '20');
// HTTP_MAX_RESPONSE_SIZE => Maximum accepted size of the response body in MB (default 2MB) // HTTP_MAX_RESPONSE_SIZE => Maximum accepted size of the response body in MB (default 2MB)
defined('HTTP_MAX_RESPONSE_SIZE') or define('HTTP_MAX_RESPONSE_SIZE', 2097152); define('HTTP_MAX_RESPONSE_SIZE', 2097152);
// DATA_DIRECTORY => default is data (writable directory) // DATA_DIRECTORY => default is data (writable directory)
define('DATA_DIRECTORY', __DIR__.'/data'); define('DATA_DIRECTORY', __DIR__.'/data');

View File

@ -17,7 +17,7 @@ Router\get_action('unread', function() {
$group_id = Request\int_param('group_id', null); $group_id = Request\int_param('group_id', null);
$feed_ids = array(); $feed_ids = array();
if (!is_null($group_id)) { if (! is_null($group_id)) {
$feed_ids = Model\Group\get_feeds_by_group($group_id); $feed_ids = Model\Group\get_feeds_by_group($group_id);
} }

View File

@ -74,25 +74,13 @@ function escape($value)
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false);
} }
function flash($html) function flash($type, $html)
{ {
$data = ''; $data = '';
if (isset($_SESSION['flash_message'])) { if (isset($_SESSION[$type])) {
$data = sprintf($html, escape($_SESSION['flash_message'])); $data = sprintf($html, escape($_SESSION[$type]));
unset($_SESSION['flash_message']); unset($_SESSION[$type]);
}
return $data;
}
function flash_error($html)
{
$data = '';
if (isset($_SESSION['flash_error_message'])) {
$data = sprintf($html, escape($_SESSION['flash_error_message']));
unset($_SESSION['flash_error_message']);
} }
return $data; return $data;

View File

@ -79,7 +79,7 @@ function get_group_id($title)
/** /**
* Get all feed ids assigned to a group * Get all feed ids assigned to a group
* *
* @param array $group_id * @param integer $group_id
* @return array * @return array
*/ */
function get_feeds_by_group($group_id) function get_feeds_by_group($group_id)

View File

@ -103,7 +103,6 @@ function refresh()
* Remove the current RememberMe session and the cookie * Remove the current RememberMe session and the cookie
* *
* @access public * @access public
* @param integer $user_id User id
*/ */
function destroy() function destroy()
{ {

View File

@ -51,8 +51,8 @@
</nav> </nav>
</header> </header>
<section class="page" data-item-page="<?= $menu ?>"> <section class="page" data-item-page="<?= $menu ?>">
<?= Helper\flash('<div class="alert alert-success">%s</div>') ?> <?= Helper\flash('flash_message', '<div class="alert alert-success">%s</div>') ?>
<?= Helper\flash_error('<div class="alert alert-error">%s</div>') ?> <?= Helper\flash('flash_error_message', '<div class="alert alert-error">%s</div>') ?>
<?= $content_for_layout ?> <?= $content_for_layout ?>
</section> </section>
</body> </body>