yf_site_nav_bar user module

Fileplugins/site_nav_bar/modules/yf_site_nav_bar.class.php
Usemodule('site_nav_bar'), URL ?object=site_nav_bar

Public properties

A site sets them in its config with $PROJECT_CONF['site_nav_bar']['NAME'] = ...;

PropertyDefaultDescription
$AUTO_TRANSLATE
bool
true
$HOME_LOCATION
string
'./'
$HOOK_NAME
string
'_nav_bar_items'
$SHOW_NAV_BAR
bool
true
$_nav_item_as_array null

Public methods 7

None without a leading underscore.

Methods starting with _ hooks and helpers; not routable as page actions

__call

public 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 _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));
    }

_show

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);
    }
public function _show_dropdown_menu()
    public function _show_dropdown_menu()
    {
        $items = _class('graphics')->_show_menu([
            'name' => 'user_main_menu',
            'force_stpl_name' => 'site_nav_bar/dropdown_menu',
            'return_array' => 1,
        ]);
        if ( ! $items) {
            return false;
        }
        foreach ((array) $items as $id => $item) {
            $item['need_clear'] = 0;
            if ($item['type_id'] != 1/* $item['type_id'] == 1 && !module('admin_home')->_url_allowed($item['link'])*/) {
                unset($items[$id]);
                continue;
            }
            $items[$id] = tpl()->parse('site_nav_bar/dropdown_menu_item', $item);
        }
        return tpl()->parse('site_nav_bar/dropdown_menu', [
            'items' => implode('', (array) $items),
        ]);
    }