Esempio n. 1
0
 public function index($paramList)
 {
     $place = BOL_ComponentService::PLACE_INDEX;
     $customize = !empty($paramList['mode']) && $paramList['mode'] == 'customize';
     $allowCustomize = OW::getUser()->isAdmin();
     $template = 'drag_and_drop_index';
     if ($customize) {
         if (!OW::getUser()->isAuthenticated()) {
             throw new AuthenticateException();
         }
         if (!$allowCustomize) {
             $this->redirect(OW::getRouter()->uriForRoute('base_index'));
         }
     }
     if ($allowCustomize) {
         $template = $customize ? 'drag_and_drop_index_customize' : 'drag_and_drop_index';
         if ($customize) {
             OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'main_menu_index');
         }
     }
     if ($customize) {
         $masterPageFileDir = OW::getThemeManager()->getMasterPageTemplate('dndindex');
         OW::getDocument()->getMasterPage()->setTemplate($masterPageFileDir);
         $this->setDocumentKey('base_index_page_customize');
     } else {
         $this->setDocumentKey('base_index_page');
     }
     $schemeList = $this->componentAdminService->findSchemeList();
     $state = $this->componentAdminService->findCache($place);
     if (empty($state)) {
         $state = array();
         $state['defaultComponents'] = $this->componentAdminService->findPlaceComponentList($place);
         $state['defaultPositions'] = $this->componentAdminService->findAllPositionList($place);
         $state['defaultSettings'] = $this->componentAdminService->findAllSettingList();
         $state['defaultScheme'] = (array) $this->componentAdminService->findSchemeByPlace($place);
         $this->componentAdminService->saveCache($place, $state);
     }
     $defaultComponents = $state['defaultComponents'];
     $defaultPositions = $state['defaultPositions'];
     $defaultSettings = $state['defaultSettings'];
     $defaultScheme = $state['defaultScheme'];
     if (empty($defaultScheme) && !empty($schemeList)) {
         $defaultScheme = reset($schemeList);
     }
     $componentPanel = new BASE_CMP_DragAndDropIndex($place, $defaultComponents, $customize, $template);
     $componentPanel->allowCustomize($allowCustomize);
     $customizeUrls = array('customize' => OW::getRouter()->urlForRoute('base_index_customize', array('mode' => 'customize')), 'normal' => OW::getRouter()->urlForRoute('base_index'));
     $componentPanel->customizeControlCunfigure($customizeUrls['customize'], $customizeUrls['normal']);
     $componentPanel->setSchemeList($schemeList);
     $componentPanel->setPositionList($defaultPositions);
     $componentPanel->setSettingList($defaultSettings);
     $componentPanel->setScheme($defaultScheme);
     /* $themeName = OW_Config::getInstance()->getValue('base', 'selectedTheme');
        $sidebarPosition = BOL_ThemeService::getInstance()->findThemeByName($themeName)->getSidebarPosition(); */
     $sidebarPosition = OW::getThemeManager()->getCurrentTheme()->getDto()->getSidebarPosition();
     $componentPanel->setSidebarPosition($sidebarPosition);
     $componentPanel->assign('adminPluginsUrl', OW::getRouter()->urlForRoute('admin_plugins_installed'));
     $this->addComponent('componentPanel', $componentPanel);
     $this->setDocumentKey('base_index_page');
 }