yf_site_nav_bar user module| File | plugins/site_nav_bar/modules/yf_site_nav_bar.class.php |
|---|---|
| Use | module('site_nav_bar'), URL ?object=site_nav_bar |
A site sets them in its config with $PROJECT_CONF['site_nav_bar']['NAME'] = ...;
| Property | Default | Description |
|---|---|---|
$AUTO_TRANSLATEbool |
true |
|
$HOME_LOCATIONstring |
'./' |
|
$HOOK_NAMEstring |
'_nav_bar_items' |
|
$SHOW_NAV_BARbool |
true |
|
$_nav_item_as_array |
null |
None without a leading underscore.
_ hooks and helpers; not routable as page actionspublic function __call($name, $arguments)
Catch missing method call.
public function __call($name, $arguments)
{
trigger_error(__CLASS__ . ': No method ' . $name, E_USER_WARNING);
return false;
}
public function _breadcrumbs()
public function _decode_from_url($text = '')
public function _decode_from_url($text = '')
{
return ucwords(str_replace('_', ' ', $text));
}
public function _encode_for_url($text = '')
public function _encode_for_url($text = '')
{
return strtolower(str_replace(' ', '_', $text));
}
public function _show($return_array = false)
public function _show($return_array = false)
{
$bookmark_page_code = null;
if ($return_array) {
$this->_nav_item_as_array = true;
}
$items = [];
// Switch between specific actions
if (in_array(($_GET['object'] ?? null), ['', 'home_page'])) {
// Empty
} else {
if ( ! in_array(($_GET['action'] ?? null), ['', 'show'])) {
$items[] = $this->_nav_item($this->_decode_from_url(($_GET['object'] ?? null)), './?object=' . ($_GET['object'] ?? null));
$items[] = $this->_nav_item($this->_decode_from_url(($_GET['action'] ?? null)));
} else {
$items[] = $this->_nav_item($this->_decode_from_url(($_GET['object'] ?? null)));
}
}
// Try to get items from hook '_nav_bar_items'
if ( ! empty($this->HOOK_NAME)) {
$CUR_OBJ = module(($_GET['object'] ?? null));
if (is_object($CUR_OBJ) && method_exists($CUR_OBJ, $this->HOOK_NAME)) {
$hook_params = [
'nav_bar_obj' => $this,
'items' => $items,
];
$func = $this->HOOK_NAME;
$hooked_items = $CUR_OBJ->$func($hook_params);
}
}
// Do not show nav bar if hooked code set that
if ( ! $this->SHOW_NAV_BAR) {
return false;
}
// Stop here if gathered nothing
if (count((array) $items) < 1) {
return false;
}
// Hook have max priority
if ( ! empty($hooked_items)) {
$items = $hooked_items;
}
// Add first item to all valid items
array_unshift($items, $this->_nav_item('Home', $this->HOME_LOCATION, 'icon-home fa fa-home'));
if ($return_array) {
$this->_nav_item_as_array = false;
return $items;
}
$replace = [
'items' => implode(tpl()->parse(__CLASS__ . '/div'), $items),
'is_logged_in' => (int) ((bool) (isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0)),
'bookmark_page' => '',
];
return tpl()->parse(__CLASS__ . '/main', $replace);
}