展示链接列表导航

@param Nav $nav
773736
public function displayLink(Nav $nav)
    {
        $links = $nav->getLinks();
        $this->view->display('@nav/navs/link.php', ['links' => $links]);
    }
658486
protected function initSidenav($sidenavId)
    {
        $this->sidenavToggleButtonOptions = ArrayHelper::merge([
            'label' => false,
            'icon' => [
                'name' => 'menu'
            ],
            'type' => Button::TYPE_FLAT,
        ], $this->sidenavToggleButtonOptions);

        if (!isset($this->sidenavToggleButtonOptions['options']['data-target'])) {
            $this->sidenavToggleButtonOptions['options']['data-target'] = $sidenavId;
        }

        Html::addCssClass($this->sidenavToggleButtonOptions['options'], ['trigger' => 'sidenav-trigger']);
    }
583062
public function handle($request, Closure $next)
    {
        if (auth()->check() && $request->is(admin_prefix() . '*')) {
            Menu::make('admin', function (Builder $menu) {
                $menu->add('Dashboard', route('administrator.index'))->icon('home');

                $navs = app('navigation')->getPublished();
                if ($navs->count()) {
                    $nav = $menu->add('Navigation', '#')->icon('sitemap')
                                ->data('permission', 'navigation.view');
                    $nav->add('Manage', route('administrator.navigation.index'))
                        ->icon('cogs')
                        ->data([
                            'permission' => 'navigation.view',
                            'append'     => route('administrator.navigation.create'),
                        ]);
                    $navs->each(function ($item) use ($nav) {
                        $nav->add($item->title, route('administrator.navigation.menu.index', $item->id))
                            ->icon('link')
                            ->data([
                                'permission' => 'navigation.view',
                                'append'     => route('administrator.navigation.menu.create', $item->id),
                            ]);
                    });
                } else {
                    $menu->add('Navigation', route('administrator.navigation.index'))->icon('link')
                         ->data(['permission' => 'navigation.view']);
                }
                event('admin.menu.nav', $navs);

                $contents = $menu->add('Contents', '#')->icon('files-o');
                $contents->add('Articles', route('administrator.articles.index'))
                         ->icon('files-o')
                         ->data([
                             'permission' => 'article.view',
                             'append'     => route('administrator.articles.create'),
                         ]);
                $contents->add('Categories', route('administrator.categories.index'))
                         ->icon('folder-open-o')
                         ->data([
                             'permission' => 'category.view',
                             'append'     => route('administrator.categories.create'),
                         ]);
                $contents->add('Widgets', route('administrator.widgets.index'))->icon('plug')
                         ->data([
                             'permission' => 'widget.view',
                             'append'     => route('administrator.widgets.create'),
                         ]);
                $contents->add('Media', route('administrator.media.index'))->icon('image')
                         ->data('permission', 'media.view');
                event('admin.menu.contents', $contents);

                $modules = $menu->add('Modules', '#')->icon('cubes')->data('permission', 'module.view');
                $modules->add('Manage', route('administrator.modules.index'))->icon('cogs')->data('permission', 'module.view');
                event('admin.menu.modules', $modules);

                $users = $menu->add('Users', '#')->icon('key')
                              ->data([
                                  'permission' => ['user.view', 'role.view', 'permission.view']
                              ]);
                $users->add('Manage', route('administrator.users.index'))->icon('users')
                      ->data([
                          'permission' => 'user.view',
                          'append'     => route('administrator.users.create'),
                      ]);
                $users->add('Roles', route('administrator.roles.index'))->icon('shield')
                      ->data([
                          'permission' => 'role.view',
                          'append'     => route('administrator.roles.create'),
                      ]);
                $users->add('Permissions', route('administrator.permissions.index'))->icon('tag')
                      ->data([
                          'permission' => 'permission.view',
                          'append'     => route('administrator.permissions.create'),
                      ]);
                event('admin.menu.users', $users);

                $config = $menu->add('Configurations', '#')->icon('gears')
                               ->data([
                                   'permission' => ['extension.view', 'utilities.config', 'theme.view']
                               ]);
                $config->add('Global', route('administrator.configuration.index'))->icon('globe')
                       ->data('permission', 'utilities.config');
                $config->add('Extensions', route('administrator.extension.index'))->icon('plug')
                       ->data('permission', 'extension.view');
                $config->add('Themes', route('administrator.themes.index'))
                     ->icon('windows')
                     ->data(['permission' => 'theme.view']);

                event('admin.menu.config', $config);

                $menu->add('Utilities', route('administrator.utilities.index'))->icon('wrench')
                     ->data('permission', 'utilities.view');

                $menu->divide(['class' => 'header text-uppercase', 'text' => 'Add-ons Menu']);
                event('admin.menu.add-ons', $menu);

                $menu->add('Logout', route('administrator.logout'))->icon('power-off')->attribute(['name' => 'logout']);
            })->filter(function ($item) {
                $permissions = (array) $item->data('permission');
                if (! $permissions) {
                    return true;
                }

                return current_user()->canAtLeast($permissions);
            });
        }

        $response = $next($request);

        return $response;
    }
527627
public function eventBeforeInsert()
    {
        $item = self::find()->where([
            'nav_container_id' => $this->nav_container_id,
            'parent_nav_id' => $this->parent_nav_id
        ])->orderBy('sort_index DESC')->limit(1)->asArray()->one();
        if (!$item) {
            $this->sort_index = 1;
        } else {
            $this->sort_index = $item['sort_index'] + 1;
        }
    }
464766
public static function _load_nav_menus() {
		add_action( 'admin_enqueue_scripts', array( __CLASS__, '_enqueue_assets' ), 99 );

		/**
		 * Allow settings meta box to be disabled.
		 *
		 * @since 0.4.0
		 *
		 * @param bool $disabled Defaults to FALSE.
		 */
		$settings_disabled = apply_filters( 'menu_icons_disable_settings', false );
		if ( true === $settings_disabled ) {
			return;
		}

		self::_maybe_update_settings();
		self::_add_settings_meta_box();

		add_action( 'admin_notices', array( __CLASS__, '_admin_notices' ) );
	}
946530
private function skip( $nav )
	{
		if ( $this->excludeComments && $nav->getNodeType() == XML_COMMENT_NODE )
		{
			$this->commentsSkipped++;
		}
		return	( $this->excludeComments && $nav->getNodeType() == XML_COMMENT_NODE ) ||
				( $this->excludeWhitespace && $nav->IsWhitespaceNode() );
	}
76081
public static function init($module = '')
    {
        // 定位模块目录
        $module = $module ? $module . DS : '';

        // 加载第三方拓展包
        require_once VENDOR_PATH . 'autoload' . EXT;

        // 加载助手函数
        include HOPE_PATH . 'helper' . EXT;

        // 初始化系统配置
        self::$config = Config::init();

        $path = APP_PATH . $module;

        // 加载公共文件
        if (is_file($path . 'common' . EXT)) {
            require $path . 'common' . EXT;
        }

        // 如果有自定义配置则加载
        if (is_file($path . 'config' . EXT)) {
            require $path . 'config' . EXT;
        }

    }
1141751
public function nack($multiple = null, $requeue = null)
    {
        $this->checkChannel();

        $outputFrame = BasicNackFrame::create($this->tag, $multiple, $requeue);
        $outputFrame->frameChannelId = $this->channel->getId();
        $this->channel->getConnection()->command($outputFrame);
    }
1020686
private function startCommon(): void
    {
        if (self::$app !== null) {
            return;
        }
        self::$app = $this;
        // 加载框架配置文件
        $config = DataMap::loadFromPhpFile($this->mvcSourcePath . '/../config.inc.php');
        // 应用配置
        if ($this->config === null) {
            $appConfigFile = APP_CONFIG_PATH . '/./config.inc.php';
            if (is_file($appConfigFile)) {
                $appConfig = DataMap::loadFromPhpFile($appConfigFile);
                $config->mergeData($appConfig);
            }
        } else {
            $config->mergeData($this->config);
        }
        $this->config = $config;
        $this->loadContainer();
    }
462765
public function removeNavigation(Navigation $navigation)
    {
        if ($this->navigations->contains($navigation)) {
            $this->navigations->removeElement($navigation);
            $navigation->setSiteroot(null);
        }

        return $this;
    }
573592
function navTouchEvt(e) {
            var $cur = $(e.currentTarget),
                type;

            if ($cur.hasClass('screen-nav')) {
                //筛选
                $screen.toggleClass('hide');
                $prevFocusNav.toggleClass('focus');
                $cur.toggleClass('focus');
            } else {
                if ($cur.hasClass('focus')) {
                    if ($cur.hasClass('price-nav')) {
                        toggleSort($cur);
                    }
                    return;
                }

                $prevFocusNav = $cur;

                $navItem.removeClass('focus');
                $cur.addClass('focus');

                type = getFocusNavType(); //当前focus项(new/sale/price)

                $goodList.addClass('hide');
                switch (type) {
                    case 'newest':
                        $npc.removeClass('hide');
                        break;
                    case 'sale':
                        $svc.removeClass('hide');
                        break;
                    case 'price':
                        $pc.removeClass('hide');
                        break;
                }

                if (navInfo[type].reload) {
                    search();
                }
            }
        }
993028
public function handle()
    {
        $topicName = trim($this->argument('topic'));

        $prefix = trim($this->option('prefix'));
        $max = trim($this->option('max'));
        $next = trim($this->option('next'));

        /**
         * @var Client
         */
        $client = $this->mns;
        if (!$client) {
            $this->error('请先配置阿里云MSN服务，并在DI里面注册');

            return;
        }

        try {
            $data = [];
            $topic = $client->getTopicRef($topicName);
            $res = $topic->listSubscription($max, $prefix, $next);
            if ($res->isSucceed()) {
                foreach ($res->getSubscriptionNames() as $subscriptionName) {
                    $subscription['name'] = $subscriptionName;

                    $attr = $topic->getSubscriptionAttribute($subscriptionName)->getSubscriptionAttributes();

                    $subscription['endpoint'] = $attr->getEndpoint();
                    $subscription['filterTag'] = $attr->getFilterTag();
                    $subscription['strategy'] = $attr->getStrategy();
                    $subscription['contentFormat'] = $attr->getContentFormat();
                    $subscription['createTime'] = date('Y-m-d H:i:s', $attr->getCreateTime());
                    $subscription['updateTime'] = date('Y-m-d H:i:s', $attr->getLastModifyTime());
                    $data[] = $subscription;
                }
            }


            $subscriptionHeaders = ['Name', 'Endpoint', 'FilterTag', 'Strategy', 'ContentFormat', 'CreateTime', 'UpdateTime'];
            $this->line("List of Subscriptions for Topic: $topicName");
            $this->table($subscriptionHeaders, $data);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
    }
1077570
protected function MoveToFirst( $nav )
	{
		$result = $nav->MoveToFirstAttribute();

		if ( $result && $this->skip( $nav ) )
		{
			return $this->MoveToNext( $nav );
		}

		return $result;
	}
475954
private function buildExtensionsNavigation(&$nav)
    {
        // Loop over all the installed extensions to add in other navigation items
        $extensions = Symphony::ExtensionManager()->listInstalledHandles();

        foreach ($extensions as $e) {
            $extension = Symphony::ExtensionManager()->getInstance($e);
            $extension_navigation = $extension->fetchNavigation();

            if (is_array($extension_navigation) && !empty($extension_navigation)) {
                foreach ($extension_navigation as $item) {
                    $type = isset($item['children']) ? Extension::NAV_GROUP : Extension::NAV_CHILD;

                    switch ($type) {
                        case Extension::NAV_GROUP:
                            $index = General::array_find_available_index($nav, $item['location']);

                            // Actual group
                            $nav[$index] = self::createParentNavItem($index, $item);

                            // Render its children
                            foreach ($item['children'] as $child) {
                                $nav[$index]['children'][] = self::createChildNavItem($child, $e);
                            }

                            break;

                        case Extension::NAV_CHILD:
                            if (!is_numeric($item['location'])) {
                                // is a navigation group
                                $group_name = $item['location'];
                                $group_index = self::__navigationFindGroupIndex($nav, $item['location']);
                            } else {
                                // is a legacy numeric index
                                $group_index = $item['location'];
                            }

                            $child = self::createChildNavItem($item, $e);

                            if ($group_index === false) {
                                $group_index = General::array_find_available_index($nav, 0);

                                $nav_parent = self::createParentNavItem($group_index, $item);
                                $nav_parent['name'] = $group_name;
                                $nav_parent['children'] = array($child);

                                // add new navigation group
                                $nav[$group_index] = $nav_parent;
                            } else {
                                // add new location by index
                                $nav[$group_index]['children'][] = $child;
                            }

                            break;
                    }
                }
            }
        }
    }
151528
private function buildSectionNavigation(&$nav)
    {
        // Build the section navigation, grouped by their navigation groups
        $sections = SectionManager::fetch(null, 'asc', 'sortorder');

        if (is_array($sections) && !empty($sections)) {
            foreach ($sections as $s) {
                $group_index = self::__navigationFindGroupIndex($nav, $s->get('navigation_group'));

                if ($group_index === false) {
                    $group_index = General::array_find_available_index($nav, 0);

                    $nav[$group_index] = array(
                        'name' => $s->get('navigation_group'),
                        'type' => 'content',
                        'index' => $group_index,
                        'children' => array()
                    );
                }

                $hasAccess = true;
                $url = '/publish/' . $s->get('handle') . '/';
                /**
                 * Immediately after the core access rules allowed access to this page
                 * (i.e. not called if the core rules denied it).
                 * Extension developers must only further restrict access to it.
                 * Extension developers must also take care of checking the current value
                 * of the allowed parameter in order to prevent conflicts with other extensions.
                 * `$context['allowed'] = $context['allowed'] && customLogic();`
                 *
                 * @delegate CanAccessPage
                 * @since Symphony 2.7.0
                 * @see doesAuthorHaveAccess()
                 * @param string $context
                 *  '/backend/'
                 * @param bool $allowed
                 *  A flag to further restrict access to the page, passed by reference
                 * @param string $page_limit
                 *  The computed page limit for the current page
                 * @param string $page_url
                 *  The computed page url for the current page
                 * @param int $section.id
                 *  The id of the section for this url
                 * @param string $section.handle
                 *  The handle of the section for this url
                 */
                Symphony::ExtensionManager()->notifyMembers('CanAccessPage', '/backend/', array(
                    'allowed' => &$hasAccess,
                    'page_limit' => 'author',
                    'page_url' => $url,
                    'section' => array(
                        'id' => $s->get('id'),
                        'handle' => $s->get('handle')
                    ),
                ));

                if ($hasAccess) {
                    $nav[$group_index]['children'][] = array(
                        'link' => $url,
                        'name' => $s->get('name'),
                        'type' => 'section',
                        'section' => array(
                            'id' => $s->get('id'),
                            'handle' => $s->get('handle')
                        ),
                        'visible' => ($s->get('hidden') == 'no' ? 'yes' : 'no')
                    );
                }
            }
        }
    }
449951
protected function MoveToFirst( $nav )
	{
		$result = $nav->MoveToFirstChild();

		if ( $result )
		{
			if ( $this->skip( $nav ) )
			{
				return $this->MoveToNext( $nav );
			}
		}

		return $result;
	}
1073229
public function bootstrap($app)
    {
        if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
            //监听用户活动时间
            /** @var \yii\web\UserEvent $event */
            $app->on(Application::EVENT_AFTER_REQUEST, function ($event) use ($app) {
                if (!$app->user->isGuest && Yii::$app->has('queue')) {
                    $user = UserExtra::findOne(['user_id' => $app->user->id]);
                    $user->updateAttributesAsync(['last_visit' => time()]);
                }
            });

            //监听用户登录事件
            /** @var \yii\web\UserEvent $event */
            $app->user->on(User::EVENT_AFTER_LOGIN, function ($event) use ($app) {
                //记录最后登录时间记录最后登录IP记录登录次数
                $user = UserExtra::findOne(['user_id' => $app->user->id]);
                $user->updateAttributesAsync(['login_at' => time(), 'login_ip' => Yii::$app->request->userIP]);
                $user->updateCountersAsync(['login_num' => 1]);
            });
        }
    }