Exemplo n.º 1
0
 public function LoadMenu($params = null)
 {
     $current_url = \Av\DispatcherController::GetCurrentUrl()->GetCurrentUrlLocale();
     $oMenuMapper = new MenuModel();
     $this->_menu_collection = $oMenuMapper->LoadMenu($params);
     if ($this->_menu_collection instanceof \Av\Component\Menu\MenuCollectionContainer) {
         $this->_menu_collection_array = array();
         foreach ($this->_menu_collection->GetCollection() as $tag => $menu_x_y) {
             foreach ($menu_x_y as $x => $menu_y) {
                 foreach ($menu_y as $y => $oMenu) {
                     if ($oMenu instanceof \Av\Component\Menu\MenuContainer) {
                         /**
                          * 1. check if selected
                          */
                         $currentRes = $oMenu->GetMenuRes(array(\Av\Component\Menu\MenuContainer::TYPE => self::TYPE_LINK));
                         $bSelected = false;
                         if ($currentRes instanceof \Av\Res\ResContainer) {
                             $value = $currentRes->GetResValue();
                             $bSelected = $value == $current_url;
                         }
                         $oMenu->SetSelected(array(self::MENU_SELECTED => $bSelected));
                         /**
                          * 2. build if dynamic
                          */
                         if (($oMenuDynamic = $oMenu->GetMenuDynamic()) instanceof \Av\Component\Menu\MenuClassMapContainer) {
                             $dynamic_class = $oMenuDynamic->GetMenuClassName();
                             $dynamic_method = $oMenuDynamic->GetMenuMethodName();
                             $dynamicparams = $oMenuDynamic->GetMenuMethodParams();
                             if ($dynamic_class !== false && $dynamic_method !== false) {
                                 if (PHP_MAJOR_VERSION <= 5 && PHP_MINOR_VERSION < 4) {
                                     $oClass = new $dynamic_class($oMenu);
                                     $oMenuDinamicCollection = $oClass->{$dynamic_method}($dynamicparams);
                                 } else {
                                     $oMenuDinamicCollection = (new $dynamic_class($oMenu))->{$dynamic_method}($dynamicparams);
                                 }
                                 if ($oMenuDinamicCollection !== false) {
                                     $this->_menu_collection->ReplaceInCollection($tag, $x, $y, $oMenuDinamicCollection);
                                 }
                             }
                         }
                         /*
                          * 3. fill menu data as array
                          */
                         $this->_menu_collection_array[$tag][$x][$y] = self::ResourceAsArray($oMenu);
                     }
                 }
             }
         }
     }
     //        $this->AddDebugAsObject($this->_menu_collection_array, __METHOD__ . " # " . __LINE__ . "Menu Array: ");
 }
 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;
 }
Exemplo n.º 3
0
 /**
  * call http://dev.avftest.com/test/redirect/redirect-other-test
  * will redirect to
  * http://dev.avftest.com/authorization/signup/google-plus?test=kuku&othr_test=mumu
  */
 public function RedirectOtherTestAction()
 {
     $params_redirect = array(\Av\DispatcherController::REDIRECT_URL => "/authorization/signup/google-plus", \Av\DispatcherController::REDIRECT_PARAMETERS => array('test' => 'kuku', 'othr_test' => 'mumu'));
     \Av\DispatcherController::Redirect($params_redirect);
 }