Build and add the Dashboard's side navigation menu.

@since 2.0.0
@access public

@param string $CurrentUrl Used to highlight correct route in menu.
554452
public function AddSideMenu($CurrentUrl = FALSE) {
		if(!$CurrentUrl)
			$CurrentUrl = strtolower($this->SelfUrl);
		
      // Only add to the assets if this is not a view-only request
      if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
         // Configure SideMenu module
         $SideMenu = new SideMenuModule($this);
         $SideMenu->EventName = 'GetAppSettingsMenuItems';
         $SideMenu->HtmlId = '';
         $SideMenu->HighlightRoute($CurrentUrl);
			$SideMenu->Sort = C('Garden.DashboardMenu.Sort');
         
         // Hook for adding to menu
//         $this->EventArguments['SideMenu'] = &$SideMenu;
//         $this->FireEvent('GetAppSettingsMenuItems');
         
         // Add the module
         $this->AddModule($SideMenu, 'Panel');
      }
   }
58787
public function isActive($currentUrl)
    {
        $activeUrls = $this->getActiveUrls();

        return
            $currentUrl == $this->url ||
            (
                is_array($activeUrls) &&
                in_array($currentUrl, $this->getActiveUrls())
            );
    }
707886
function currentRedirectionURI()
    {
        $module = $this;
        $viewName = self::currentView();
        $parameters = $this->OriginalViewParameters;
        $unorderedParameters = $this->OriginalUnorderedParameters;
        $userParameters = $this->UserParameters;
        return $this->redirectionURIForModule( $module, $viewName, $parameters,
                                               $unorderedParameters, $userParameters );
    }
1247979
public function actionToolbar($tag = null, $currentTag = null)
    {
        // get manifest and calculate tag if needed
        $manifest = $this->getManifest(true);
        if (!$tag) {
            $first = reset($manifest);
            $tag = $first["tag"];
        }

        // use manifest to build urls array for dropdown
        $i = 0;
        $count = 0;
        $urls = [];
        $homeUrl = rtrim(Url::to(["/"], true), "/");
        foreach ($manifest as $rowTag => $row) {

            // keep count of number of requests to get to current request
            $i++;

            // replace $homeUrl with empty and truncate
            $numCharsToTrim = 50;
            $route = str_replace($homeUrl, "", $row["url"]);
            if (strlen($route) > $numCharsToTrim) {
                $route = substr($route, 0, $numCharsToTrim) . " ...";
            }

            // add method and ajax to select option label
            $method = "[{$row["method"]}]";
            $ajax = $row["ajax"] ? "[ajax]" : "";
            $urls[$rowTag] = "$method $ajax $route";

            // set current tag if not explicitly set
            if (!$currentTag && !$row["ajax"]) {
                $currentTag = $rowTag;
            }

            // check for the current request tag
            if ($currentTag && $currentTag == $rowTag) {
                $count = $i;
                $urls[0] = $this->module->currentRequestSeparator;
            }
        }

        // add count to labels
        $count = $count ?: count($manifest);
        if ($count > 1) {
            foreach ($urls as $k => $url) {
                if ($count > 0) {
                    $urls[$k] = "[$count] $url";
                }
                $count--;
            }
        }

        // load data and render
        $this->loadData($tag, 5);
        return $this->renderPartial('toolbar', [
            'urls' => $urls,
            'tag' => $tag,
            'currentTag' => $currentTag,
            'panels' => $this->module->panels,
            'position' => 'bottom',
            'defaultHeight' => $this->module->defaultHeight,
        ]);
    }
436177
def mark_current_menus(menus, path_info):
    
    for menu in menus:
        if menu.get_absolute_url() == "/":
            menu.is_current = menu.get_absolute_url() == path_info
        else:
            menu.is_current = path_info.find(menu.get_absolute_url()) == 0
133602
public function action_addAdminMenus()
    {
        // Default to the model's likely controller.
        $defaultController = Controller::generateClassName($this->model->getShortName());
        $parentSlug = 'edit.php?post_type=' . $this->model->getWordpressKey();

        foreach ($this->getConfiguration() as $func => $config) {
            $config += array(
                'title'         => ucfirst($func),
                'menu-title'    => ucfirst($func),
                'capability'    => "manage_options",
                'icon'          => null,
                'route'         => array($defaultController, $func),
                'position'      => null,
            );

            // This is to circumvent how Wordpress doesn't let you pass arguments to
            // callbacks so we can send the controller and function to the router.
            // We dont want people to have to specify that odd function name.
            // Allow them to send the controller string name and take care of the rest.
            if (is_string($config['route'])) {
                $route = Router::callback($config['route'], $func);
            } else {
                $route = Router::callback($config['route'][0], $config['route'][1]);
            }

            $uniquePage = $this->model->getWordpressKey() . "_" . $func;
            add_submenu_page($parentSlug, $config['title'], $config['menu-title'], $config['capability'], $uniquePage, $route, $config['icon'], $config['position']);
        }
    }
545490
public function addRoute($url, $schemaUrl)
    {
        $this->addedRoutes[] = [
            '$ref' => $this->normalizeRelativeUrl($url),
            'profile' => $this->normalizeRelativeUrl($schemaUrl)
        ];
    }
689608
public function createBreadcrumb()
    {
        if (null === $this->breadcrumb) {
            $this->createBreadcrumbRoot();

            // Retrieve the current page.
            $currentPage = $this->pageHelper->getCurrent();

            // If not found look for a parent
            if (null === $currentPage && null !== $request = $this->pageHelper->getRequest()) {
                // TODO create a route finder ? (same in AdminBundle ResourceHelper)
                $routeName = $request->attributes->get('_route');
                $i18nRouterClass = 'JMS\I18nRoutingBundle\Router\I18nRouterInterface';
                if (interface_exists($i18nRouterClass) && $this->router instanceof $i18nRouterClass) {
                    $route = $this->router->getOriginalRouteCollection()->get($routeName);
                } else {
                    $route = $this->router->getRouteCollection()->get($routeName);
                }
                if (null !== $route) {
                    $cmsOptions = $route->getOption('_cms');
                    if (null !== $cmsOptions
                        && array_key_exists('parent', $cmsOptions)
                        && 0 < strlen($cmsOptions['parent'])
                    ) {
                        $currentPage = $this->pageHelper->findByRoute($cmsOptions['parent']);
                    }
                }
            }

            // If found, build the breadcrumb
            if (null !== $currentPage) {
                $repository = $this->pageHelper->getPageRepository();
                $pages = $repository->findParentsForBreadcrumb($currentPage);

                // Fill the menu
                foreach ($pages as $page) {
                    if ($page['dynamicPath']) {
                        $params = ['uri' => null];
                    } else {
                        $params = ['route' => $page['route']];
                    }
                    $this->breadcrumb
                        ->addChild('page-' . $page['id'], $params)
                        ->setLabel($page['breadcrumb']);
                    $this->tagManager->addTags(sprintf('%s[id:%s]', $repository->getCachePrefix(), $page['id']));
                }
            }
        }

        return $this->breadcrumb;
    }
409284
public function externalUrl($url)
    {
        $this->link_type = self::LINK_EXTERNAL_URL;
        $this->link_value = [$url];
        $this->setOpenNewWindowOption();
        $this->setActive(false);

        return $this;
    }
601704
private function setCurrentPageUrl()
    {
        $controller = Url::segment(1);
        $method = '';
        $method = (Url::segment(2) == '') ? 'index' : Url::segment(2);

        $this->currentPageUrl = Url::getBase().$controller.'/'.$method;
    }
1120692
public function victoireLink($parameters, $label, $attr = [], $currentClass = 'active', $url = '#')
    {
        $referenceLink = UrlGeneratorInterface::ABSOLUTE_PATH;
        /** @var Widget $attachedWidget */
        $attachedWidget = isset($parameters[Link::TYPE_WIDGET]) ? $parameters[Link::TYPE_WIDGET] : null;

        if ($parameters['linkType'] == Link::TYPE_WIDGET && $attachedWidget && method_exists($attachedWidget->getWidgetMap()->getView(), 'getUrl')) {
            $viewUrl = $this->router->generate('victoire_core_page_show', ['_locale' => $attachedWidget->getWidgetMap()->getView()->getCurrentLocale(), 'url' => $attachedWidget->getWidgetMap()->getView()->getUrl()], $referenceLink);
            if ($this->request && (rtrim($this->request->getRequestUri(), '/') == rtrim($viewUrl, '/'))) {
                $attr['data-scroll'] = 'smooth';
            }
        }

        //Avoid to refresh page if not needed
        if ($this->request && ($this->request->getRequestUri() == $this->victoireLinkUrl($parameters, false))) {
            $this->addAttr('class', $currentClass, $attr);
        }

        //Build the target attribute
        if ($parameters['target'] == Link::TARGET_MODAL) {
            $attr['data-toggle'] = 'viclink-modal';
        } elseif ($parameters['target'] == '') {
            $attr['target'] = '_parent';
        } else {
            $attr['target'] = $parameters['target'];
        }

        //Add the analytics tracking code attribute
        if (isset($parameters['analyticsTrackCode'])) {
            $this->addAttr('onclick', $parameters['analyticsTrackCode'], $attr);
        }

        $url = $this->victoireLinkUrl($parameters, true, $url);
        // if modalLayout is set, we add it as GET parameter
        if ($parameters['target'] == Link::TARGET_MODAL && !empty($parameters['modalLayout'])) {
            $url .= !preg_match('/\?/', $url) ? '?' : '&';
            $url .= 'modalLayout='.$parameters['modalLayout'];
        }
        //Creates a new twig environment
        $twig = new \Twig_Environment(new \Twig_Loader_Array(['linkTemplate' => '{{ link|raw }}']));

        return $twig->render('linkTemplate', ['link' => '<a href="'.$url.'" '.$this->formatAttributes($attr).'>'.$label.'</a>']);
    }
251794
public function setUrl($url)
    {
        $this->url = $url;

        if ($this->url) {
            $this->updatedAt = new \DateTime('now');
        }

        return $this;
    }
1300442
public function buildMenu()
    {
        $sessionClass = ReporticoSession();

        if (!$this->static_menu && !is_array($this->static_menu)) {
            $this->static_menu = ReporticoApp::get("static_menu");
        }

        // In admin mode static_menu shows all reports
        if ($sessionClass::issetReporticoSessionParam('admin_password')) {
            // .. unless an admin menu has been specified
            if (ReporticoApp::get("admin_menu")) {
                $this->static_menu = ReporticoApp::get("admin_menu");
            } else {
                $this->static_menu = array(array("report" => ".*\.xml", "title" => "<AUTO>"));
            }

        }

        $p = new DesignPanel($this, "MENU");
        $this->initializePanels("MENU");
        $this->setAttribute("ReportTitle", ReporticoApp::getConfig("project_title", "Report Suite"));

        if ($this->static_menu && is_array($this->static_menu)) {
            $ct = 0;
            foreach ($this->static_menu as $menuitem) {
                if ($menuitem["title"] == "<AUTO>") {
                    // Generate Menu from XML files
                    if (is_dir(ReporticoApp::get("projpath"))) {
                        if ($dh = opendir(ReporticoApp::get("projpath"))) {
                            while (($file = readdir($dh)) !== false) {
                                $mtch = "/^" . $menuitem["report"] . "/";
                                if (preg_match($mtch, $file)) {
                                    $repxml = new XmlReader($this, $file, false, "ReportTitle");
                                    $this->panels["MENU"]->setMenuItem($file, ReporticoLang::translate($repxml->search_response));
                                }
                            }
                            closedir($dh);
                        }
                    }
                } else {
                    $this->panels["MENU"]->setMenuItem($menuitem["report"], ReporticoLang::translate($menuitem["title"]));
                }

                $ct++;
            }

            if ($ct == 0) {
                ReporticoApp::handleError("No Menu Items Available - Check Language - " . ReporticoApp::get("language"));
            }

        }
    }
707928
protected function setCurrentController()
    {
        $action = substr(basename(Route::currentRouteAction()), 0, strpos(basename(Route::currentRouteAction()), '@'));

        $this->currentController = Str::snake(Str::replaceLast('Controller', '', $action));
    }
1351041
public function setCurrent($current) {
        if(!$this->routeKeyPrefix)
            $current = str_replace($this->routeKeyPrefix,'',$current);
        if(!is_numeric($current)) return;
        if($current <= $this->getMax()) $this->current_page = $current;
        else $this->current_page = $this->getMax();
    }
465900
public function visit($url)
    {
        // First, if the URL is an object it means we are actually dealing with a page
        // and we need to create this page then get the URL from the page object as
        // it contains the URL. Once that is done, we will be ready to format it.
        if (is_object($url)) {
            $page = $url;

            $url = $page->url();
        }

        // If the URL does not start with http or https, then we will prepend the base
        // URL onto the URL and navigate to the URL. This will actually navigate to
        // the URL in the browser. Then we will be ready to make assertions, etc.
        if (! Str::startsWith($url, ['http://', 'https://'])) {
            $url = static::$baseUrl.'/'.ltrim($url, '/');
        }

        $this->driver->navigate()->to($url);

        // If the page variable was set, we will call the "on" method which will set a
        // page instance variable and call an assert method on the page so that the
        // page can have the chance to verify that we are within the right pages.
        if (isset($page)) {
            $this->on($page);
        }

        return $this;
    }
565084
public function runMvc($currentRoute) {
        if ($_SERVER['REQUEST_METHOD'] != 'OPTIONS') {
            $controllerPath = MODULES_DIR . '/' . $currentRoute['module'] . '/Controllers/' . $currentRoute['controller'] . '.php';

            if (!file_exists($controllerPath)) {
                throw new RouteException(_message(ExceptionMessages::CONTROLLER_NOT_FOUND, $currentRoute['controller']));
            }

            require_once $controllerPath;

            $controllerClass = '\\Modules\\' . $currentRoute['module'] . '\\Controllers\\' . $currentRoute['controller'];

            if (!class_exists($controllerClass, FALSE)) {
                throw new RouteException(_message(ExceptionMessages::CONTROLLER_NOT_DEFINED, $currentRoute['controller']));
            }

            $controller = new $controllerClass();

            $action = $currentRoute['action'];

            if (!method_exists($controller, $action)) {
                throw new RouteException(_message(ExceptionMessages::ACTION_NOT_DEFINED, $action));
            }

            if (method_exists($controller, '__before')) {
                call_user_func_array(array($controller, '__before'), $currentRoute['args']);

                if (RouteController::$csrfVerification) {
                    HookManager::call('csrfCheck');
                }
            }

            call_user_func_array(array($controller, $action), $currentRoute['args']);

            if (method_exists($controller, '__after')) {
                call_user_func_array(array($controller, '__after'), $currentRoute['args']);
            }
        }
    }