2015-06-11 16:44:52 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Global functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-09-25 13:41:12 -04:00
|
|
|
// End of functions.php
|