public function GetMenu($param = null)
 {
     $arrLocale = \Av\Localization\LocalizationController::GetLocale()->GetMoreLanguages();
     $base_url = \Av\DispatcherController::GetCurrentUrl()->GetCurrentUrlNoLocale();
     $base_url_locale = \Av\DispatcherController::GetCurrentUrl()->GetCurrentUrlLocale();
     $poz_x = $this->GetPozX();
     $poz_y = $this->GetPozY();
     $name = $this->GetPozName();
     $name_space = $this->GetPozNamespace();
     $oLanguageMenuCollaction = new \Av\Component\Menu\MenuCollectionContainer();
     foreach ($arrLocale as $country_id => $languages) {
         foreach ($languages as $language_id => $language) {
             //                $this->AddDebug(__METHOD__ . " #" .__LINE__ . " locale is :" . print_r($language,true));
             /*
              * create base menu item
              */
             $oLanguageMenu = new MenuContainer(array(MenuContainer::TAG => $name_space, MenuContainer::NAME => $name . "_" . $country_id . "_" . $language_id, MenuContainer::POS_X => $poz_x, MenuContainer::POS_Y => $poz_y));
             /*
              * add text resource (lable) to menu item
              */
             $oLanguageMenu->SetMenuRes(array(ResContainer::TYPE => 'text', ResContainer::VALUE => $language[LocalizationLocaleModel::COUNTRY_NAME] . " " . $language[LocalizationLocaleModel::LANGUAGE_NAME_SHORT], ResContainer::LOCALE => $language[LocalizationLocaleModel::LOCALE]));
             /*
              * add link resource to menu item
              */
             $language_selection_url = DIRECTORY_SEPARATOR . $language[LocalizationLocaleModel::COUNTRY_ID] . DIRECTORY_SEPARATOR . $language[LocalizationLocaleModel::LANGUAGE_ID] . $base_url;
             $oLanguageMenu->SetMenuRes(array(ResContainer::TYPE => 'link', ResContainer::VALUE => $language_selection_url, ResContainer::LOCALE => $language[LocalizationLocaleModel::LOCALE]));
             $oLanguageMenu->SetSelected(array(MenuContainer::MENU_SELECTED => $language_selection_url == $base_url_locale));
             /*
              * set "selected" is it is
              */
             $oLanguageMenuCollaction->AddToCollection($name_space, $poz_x, $poz_y, $oLanguageMenu);
             $poz_y++;
         }
     }
     //        $this->AddDebug(__METHOD__ . " #" .__LINE__ . " Base URL:" . print_r($base_url,true));
     //        $this->AddDebug(__METHOD__ . " #" .__LINE__ . " Base URL :" . print_r($base_url_locale,true));
     //        $this->AddDebug(__METHOD__ . " #" .__LINE__ . " Language Collection:" . print_r($oLanguageMenuCollaction,true));
     return $oLanguageMenuCollaction;
 }
예제 #2
0
 /**
  * Replace single MenuContainer object or array. Replace range of menus if MenuCollectionContainer
  * @param string $tag
  * @param int $x  - initial X of left-top conner where start replacement
  * @param int $y  - initial Y of left-top conner where start replacement
  * @param \Av\Component\Menu\MenuContainer|\Av\Component\Menu\MenuCollectionContainer|array $Menu
  */
 public function ReplaceInCollection($tag, $x, $y, $Menu)
 {
     if ($Menu instanceof \Av\Component\Menu\MenuContainer) {
         $this->_menu_collection[$tag][$x][$y] = $Menu;
     } elseif ($Menu instanceof \Av\Component\Menu\MenuCollectionContainer) {
         $y_original = $y;
         foreach ($Menu->GetCollection() as $menu_x_y) {
             foreach ($menu_x_y as $menu_y) {
                 $y = $y_original;
                 foreach ($menu_y as $menu) {
                     $this->_menu_collection[$tag][$x][$y] = $Menu;
                     $y++;
                 }
             }
             $x++;
         }
     } elseif (is_array($Menu)) {
         $this->_menu_collection[$tag][$x][$y] = new MenuContainer($Menu);
     }
 }