Get page from a given menu name

@param string $menuName
@param string $lang
@return array
@todo : may be if we use a well join for source_id
500428
public function findPagesOfMenu($menuName, $lang = NULL)
    {
        $query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.label=:menuName ORDER BY m.position');
        $query->setParameter('menuName', $menuName);
        $results = $query->getResult();
        if (!is_null($lang) && isset($results[0]) && $results[0]->getLang() != $lang)
        {
            $tmp = array();
            foreach ($results as $result)
            {
               $tmp[] = $result->getId();
            }
            $query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p WHERE p.lang=:lang AND p.source_id IN (:source_ids)');
            $query->setParameter('lang', $lang);
            $query->setParameter('source_ids', $tmp);
            $results2 = $query->getResult();
            $tmp2 = array();
            foreach ($results as $result)
            {
                foreach ($results2 as $result2)
                {
                    if ($result->getId() == $result2->getSourceId())
                    {
                        $tmp2[] = $result2;
                        break;
                    }
                }
            }
            return $tmp2;
        }
        return $results;
    }
1080527
public static function get($args, $lang = null)
    {
        $lang = !is_null($lang) ? $lang : self::getLanguage();
        $args = is_array($args) ? $args : [$args, null];

        $text = $args[0];
        //unset($args[0]);

        $hash = md5($text);

        if (count(self::$translations) == 0) {
            if (file_exists(self::getFilePath())) {
                $json = file_get_contents(self::getFilePath());
                self::$translations = json_decode($json, true);
            }
        }

        if (isset(self::$translations[$hash])
            && isset(self::$translations[$hash][$lang])
        ) {
            if (!empty(self::$translations[$hash][$lang])) {
                $args[0] = self::$translations[$hash][$lang];
                return call_user_func_array('sprintf', $args);
            }
        } else {
            self::$translations[$hash]['origin'] = $text;
            foreach (self::getAvailableLanguages() as $language) {
                if (!isset(self::$translations[$hash][$language])) {
                    self::$translations[$hash][$language] = '';
                }
            }
            $json = json_encode(
                self::$translations,
                JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
            );
            file_put_contents(self::getFilePath(), $json);
            self::$translations = json_decode($json, true);
        }

        return call_user_func_array('sprintf', $args);
    }
806777
public function getPage(int $uid, int $languageUid = null) {
    $page   = null;
    $record = Page::find($uid);

    if ($record) {
      $record = $record->getAttributes();

      if (is_array($record) && !empty($record) && in_array($record['doktype'], self::PAGE_DOKTYPES)) {
        $page                  = $record;
        $l18nCfg               = isset($page['l18n_cfg']) ? $page['l18n_cfg'] : 0;
        $hideIfDefaultLanguage = (boolean) GeneralUtility::hideIfDefaultLanguage($l18nCfg);
        $hideIfNotTranslated   = (boolean) GeneralUtility::hideIfNotTranslated($l18nCfg);
        $languageUid           = isset($languageUid) ? $languageUid : $this->languageService->getLanguageUid();

        if ($hideIfDefaultLanguage) {
          $page['hidden'] = 1;
        }

        if ($languageUid > 0) {
          $constraints     = [['pid', '=', $uid], ['sys_language_uid', '=', $languageUid], ['deleted', '=', 0]];
          $languageOverlay = LanguageOverlay::where($constraints)->first();

          if ($languageOverlay) {
            $languageOverlayAttributes = [];
            $attributes                = $languageOverlay->getAttributes();

            foreach (self::PAGE_LANGUAGE_OVERLAY_ATTRIBUTES as $attribute) {
              if (is_string($attributes[$attribute]) && empty($attributes[$attribute])) {
                continue;
              }

              $languageOverlayAttributes[$attribute] = $attributes[$attribute];
            }

            $page = array_merge($page, $languageOverlayAttributes);

            if ($this->extensionService->runningInFallbackMode() && !$hideIfDefaultLanguage && !$hideIfNotTranslated) {
              $page['hidden'] = 0;
            }
          }
        }
      }
    }

    return $page;
  }
1019089
public function getSubMenu($menuName, $level = 1)
    {
        $currentParent = false;

        $mainMenuIterator = $this->getFullMenu($menuName);

        if (!$mainMenuIterator) {
            return false;
        }

        foreach ($mainMenuIterator as $menuItem) {
            if ($this->currentPath === $menuItem->getPath()
                || $this->currentPath === $menuItem->getInternalUrl()
            ) {
                $currentParent = $menuItem->getParentByLevel($level);
            }
        }

        if (!$currentParent) {
            return false;
        }

        $menuIterator = $this->menuManager->getChildrenByStatus(
            $currentParent,
            false,
            null,
            'ASC',
            false,
            $this->viewStatus
        );

        return $menuIterator;
    }
944894
public function getDropdown($name, $lang = 'fr_FR')
    {
        $listStrings = \return_app_list_strings_language($lang);
        if (!array_key_exists($name, $listStrings)) {
            return false;
        }

        return $listStrings[$name];
    }
184880
protected function getLanguages(array $siteList, $groupName)
    {
        $result = [];
        $allSame = true;
        $previousSA = null;
        foreach ($siteList as $siteaccess) {
            $result[$siteaccess] = $this->getParameter(
                'RegionalSettings', 'SiteLanguageList', 'site.ini', $siteaccess
            );
            if ($allSame && $previousSA !== null) {
                $allSame = ($result[$previousSA] === $result[$siteaccess]);
            }
            $previousSA = $siteaccess;
        }
        if ($allSame) {
            return [$groupName => $result[$previousSA]];
        }

        return $result;
    }
1333054
public function getMenuItems($name, $lang)
    {
        /** @var MenuItem $menuRepo */
        $arrayResult = $this->repository->getMenuItemsForLanguage($name, $lang);

        // Make sure the parent item is not offline
        $foundIds = array();
        foreach ($arrayResult as $array) {
            $foundIds[] = $array['id'];
        }
        foreach ($arrayResult as $key => $array) {
            if (!is_null($array['parent']) && !in_array($array['parent']['id'], $foundIds)) {
                unset($arrayResult[$key]);
            }
        }

        return $arrayResult;
    }
175881
public function getPageLink($navId, $target, $lang = null)
    {
        $linkQuery = Yii::$app->menu->find();
        $linkQuery->where(['nav_id' => $navId]);
        $linkQuery->with(['hidden']);
        if ($lang) {
            $linkQuery->lang($lang);
        }
        $link = $linkQuery->one();
        
        // if a page is found, set the target value from the config.
        if ($link) {
            $link->setTarget($target);
        }
        
        return $link;
    }
1243757
public function menuPanelItems($lang = "")
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('PostType', 'read')) {
            return $this->noPermission();
        }

        // Find categories
        $categoryObj = Category::visible();
        if(Input::input('keyword')) {
            $categoryObj->where('title', 'like', '%'.Input::input('keyword').'%');
        }
        $categoryObj->orderBy('postTypeID', 'ASC');
        $categories = $categoryObj->paginate(25);

        // Append menuLink Parameters
        foreach($categories->all() as $category){
            $postTypeData = PostType::findByID($category->postTypeID);
            $category->postTypeName = $postTypeData->name;
            $category->belongsTo = 'category';
            $category->belongsToID = $category->categoryID;
            $category->label = $category->title;
            $category->menuLinkParameters = $category->menuLinkParameters();
        }

        // Append columns
        $results = $categories->toArray();
        $results['columns']= [
            'categoryID' => trans('id'),
            'title' => trans('base.title'),
            'postTypeName' => trans('postTypes.title'),
        ];

        return $results;
    }
593433
protected function _getLanguageSetTables($coreTableName = null)
    {
        $coreTableName = $coreTableName ? $coreTableName : $this->getCoreTableName();

        return oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class)->getAllMultiTables($coreTableName);
    }
1138464
public function getPageByUid(int $uid, int $languageUid = null) {
    return $this->getPage($uid, $languageUid);
  }
450791
public function getMenuItemsForLanguage($menuName, $locale)
    {
        $query = $this->createQueryBuilder('mi')
            ->select('mi, nt, p')
            ->innerJoin('mi.menu', 'm')
            ->leftJoin('mi.parent', 'p')
            ->leftJoin('mi.nodeTranslation', 'nt')
            ->leftJoin('nt.node', 'n')
            ->orderBy('mi.lft', 'ASC')
            ->where('m.locale = :locale')
            ->setParameter('locale', $locale)
            ->andWhere('m.name = :name')
            ->setParameter('name', $menuName)
            ->andWhere('nt.online = 1 OR mi.type = :url_type')
            ->setParameter('url_type', BaseMenuItem::TYPE_URL_LINK);

        $query = $query->getQuery();

        return $query->getArrayResult();
    }
447339
public static function getTitle($id, $lang, $context = 'default')
    {
        $name = self::getNameById($id);
        $class = self::getClassWithoutNamespace();

        return call_user_func(self::getCallback($lang), $name, $class, $context);
    }
963348
public function menuPanelItems($lang = "")
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('PostType', 'read')) {
            return $this->noPermission();
        }

        // Find post types
        if(Input::input('keyword')) {
            $postTypes = PostType::where('name', 'like', '%test%')->paginate(PostType::$rowsPerPage);
        }else{
            $postTypes = PostType::where("slug", '!=', "post_pages")->paginate(PostType::$rowsPerPage);
        }

        // Append extra attributes
        foreach($postTypes->all() as $postType){
            $postType->belongsTo = 'post_type';
            $postType->belongsToID = $postType->postTypeID;
            $postType->label = $postType->name;
            $postType->menuLinkParameters = $postType->menuLinkParameters();
        }

        // Append columns
        $results = $postTypes->toArray();
        $results['columns'] = [
            'postTypeID' => trans('id'),
            'name' => trans('base.title'),
        ];

        return $results;
    }
784962
public static function findBySlug($slug,$languageSlug = "")
    {
        $getMenuLink = array_where(
            MenuLink::all(), function ($value) use ($slug) {
                return ($value['slug'] == $slug);
            }
        );

        if($getMenuLink) {
            return array_first($getMenuLink);
        }
        return false;
    }
1279361
function alias($name,$params=NULL,$lang=NULL) {
		if (in_array($name,$this->global_aliases))
			return $this->f3->alias($name,$params);
		if (!is_array($params))
			$params=$this->f3->parse($params);
		if (!$lang)
			$lang=$this->current;
		if (isset($this->rules[$lang][$name]) && $this->rules[$lang][$name]===FALSE)
			return FALSE;
		$url=isset($this->rules[$lang][$name])?
			$this->rules[$lang][$name]:@$this->_aliases[$name];
		if (!$url)
			user_error(sprintf(\Base::E_Named,$name),E_USER_ERROR);
		return $this->f3->build(rtrim('/'.$lang.$url,'/'),$params);
	}
1120838
public function index($lang = "", $view = "")
    {
        $classNameArr = explode("\\", get_class($this));
        $className = str_replace("Controller", "", $classNameArr[4]);
        // check if user has permissions to access this link
        $key = ($view == 'list' || $view == '') ? 'read' : $view;
        if(!User::hasAccess($className, $key)) {
            return view('errors.permissions', compact('lang', 'view'));
        }
        return view('content');
    }