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');
// 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)
define('DATA_DIRECTORY', __DIR__.'/data');

View File

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

View File

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

View File

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

View File

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