2015-06-11 16:44:52 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Global functions
|
|
|
|
*/
|
|
|
|
|
2015-06-24 16:01:35 -04:00
|
|
|
/**
|
|
|
|
* Check if the user is currently logged in
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function is_logged_in()
|
|
|
|
{
|
|
|
|
return array_key_exists('hummingbird_anime_token', $_SESSION);
|
|
|
|
}
|
|
|
|
|
2015-06-11 16:44:52 -04:00
|
|
|
/**
|
|
|
|
* HTML selection helper function
|
|
|
|
*
|
|
|
|
* @param string $a - First item to compare
|
|
|
|
* @param string $b - Second item to compare
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function is_selected($a, $b)
|
|
|
|
{
|
|
|
|
return ($a === $b) ? 'selected' : '';
|
|
|
|
}
|
|
|
|
|
2015-06-16 11:11:35 -04:00
|
|
|
/**
|
|
|
|
* Inverse of selected helper function
|
|
|
|
*
|
|
|
|
* @param string $a - First item to compare
|
|
|
|
* @param string $b - Second item to compare
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function is_not_selected($a, $b)
|
|
|
|
{
|
|
|
|
return ($a !== $b) ? 'selected' : '';
|
|
|
|
}
|
|
|
|
|
2015-06-24 16:01:35 -04:00
|
|
|
/**
|
2015-07-02 14:04:04 -04:00
|
|
|
* Get the last segment of the current url
|
2015-06-24 16:01:35 -04:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-07-02 14:04:04 -04:00
|
|
|
function last_segment()
|
2015-06-24 16:01:35 -04:00
|
|
|
{
|
2015-07-02 14:04:04 -04:00
|
|
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
|
|
$segments = explode('/', $path);
|
|
|
|
return end($segments);
|
2015-06-24 16:01:35 -04:00
|
|
|
}
|
|
|
|
|
2015-06-11 16:44:52 -04:00
|
|
|
/**
|
2015-07-02 14:04:04 -04:00
|
|
|
* Determine whether to show the sub-menu
|
2015-06-11 16:44:52 -04:00
|
|
|
*
|
2015-07-02 14:04:04 -04:00
|
|
|
* @return bool
|
2015-06-11 16:44:52 -04:00
|
|
|
*/
|
2015-07-02 14:04:04 -04:00
|
|
|
function is_view_page()
|
2015-06-11 16:44:52 -04:00
|
|
|
{
|
2015-07-02 14:04:04 -04:00
|
|
|
$blacklist = ['edit', 'add', 'update', 'login', 'logout'];
|
|
|
|
$page_segments = explode("/", $_SERVER['REQUEST_URI']);
|
2015-06-16 11:11:35 -04:00
|
|
|
|
2015-07-02 14:04:04 -04:00
|
|
|
$intersect = array_intersect($page_segments, $blacklist);
|
2015-06-24 16:01:35 -04:00
|
|
|
|
2015-07-02 14:04:04 -04:00
|
|
|
return empty($intersect);
|
2015-06-16 11:11:35 -04:00
|
|
|
}
|
|
|
|
|
2015-06-11 16:44:52 -04:00
|
|
|
// End of functions.php
|