Exemple #1
0
 /**
  * Reposition Contents
  * @param type $array
  * @return array
  */
 protected function reposition($array)
 {
     $newArray = $array;
     foreach ($array as $key => $content) {
         if (is_array($content)) {
             $pos = 'after';
             $reposition = FALSE;
             if (isset($content['before']) && !empty($content['before'])) {
                 $reposition = TRUE;
                 $pos = 'before';
                 $index = $content['before'];
             }
             if (isset($content['after']) && !empty($content['after'])) {
                 $reposition = TRUE;
                 $pos = 'after';
                 $index = $content['after'];
             }
             if ($reposition && isset($newArray[$index])) {
                 $contentx = $newArray[$key];
                 unset($newArray[$key]);
                 $newArray = \Dxapp\Utility\ArrayManager::array_insert($newArray, $index, array($key => $contentx), $pos);
             }
         }
     }
     return $newArray;
 }
Exemple #2
0
 /**
  * Position an Element
  * @param array $elements Array of Elements
  * @param array $ele The Element to insert
  * @return array The new Array of Elements
  */
 public function orderElement($name, $elements, $ele)
 {
     $positions = array('after', 'before');
     if (!isset($ele['name'])) {
         $ele['name'] = $name;
     }
     foreach ($positions as $pos) {
         if (isset($ele[$pos])) {
             if (isset($elements[$ele[$pos]])) {
                 $keyPos = $ele[$pos];
                 unset($ele[$pos]);
                 $elements = \Dxapp\Utility\ArrayManager::array_insert($elements, $keyPos, array($name => $ele), $pos);
                 return $elements;
             }
         }
     }
     $elements[$name] = $ele;
     return $elements;
 }
Exemple #3
0
 /**
  * Set the Layout based on themes-scheme
  */
 public function setLayout(MvcEvent $e)
 {
     $app = $e->getParam('application');
     $sm = $app->getServiceManager();
     $config = $sm->get('dxapp_module_options');
     $mobileDetect = $sm->get('dxMobileDetect');
     $viewModel = $e->getViewModel();
     $template = 'layout/layout';
     //$viewModel->getTemplate();
     $frontendThemex = $config->getFrontendTheme();
     $templateMaps = $config->getTemplateMaps();
     $frontendThemes = $config->getFrontendThemes();
     //array('dxdefault');
     $viewResolver = $sm->get('ViewResolver');
     $viewThemeResolver = new \Zend\View\Resolver\AggregateResolver();
     $templateMapResolver = new \Zend\View\Resolver\TemplateMapResolver();
     $pathResolver = new \Zend\View\Resolver\TemplatePathStack();
     $asseticConfiguration = array();
     if (!in_array($frontendThemex, $frontendThemes)) {
         $frontendThemes[] = $frontendThemex;
     }
     foreach ($frontendThemes as $frontendTheme) {
         if (isset($templateMaps['front'][$frontendTheme]['view_manager']['template_map'])) {
             $templateMapResolver->add($templateMaps['front'][$frontendTheme]['view_manager']['template_map']);
         }
         if (isset($templateMaps['front'][$frontendTheme]['view_manager']['template_path_stack'])) {
             $pathResolver->addPaths($templateMaps['front'][$frontendTheme]['view_manager']['template_path_stack']);
             $defaultPathStack = $sm->get('ViewTemplatePathStack');
             $pathResolver->setDefaultSuffix($defaultPathStack->getDefaultSuffix());
             $viewThemeResolver->attach($pathResolver);
         }
         if (isset($templateMaps['front'][$frontendTheme]['assetic_configuration'])) {
             $asseticConfiguration = \Dxapp\Utility\ArrayManager::merge($asseticConfiguration, $templateMaps['front'][$frontendTheme]['assetic_configuration']);
         }
     }
     $viewThemeResolver->attach($templateMapResolver);
     $viewResolver->attach($viewThemeResolver, 100);
     if (!empty($asseticConfiguration)) {
         $as = $sm->get('dxThemeAssets');
         $response = $e->getResponse();
         if (!$response) {
             $response = new Response();
             $e->setResponse($response);
         }
         $router = $e->getRouteMatch();
         $as->setThemeAssets($asseticConfiguration);
         if ($router) {
             $as->setRouteName($router->getMatchedRouteName());
             $as->setControllerName($router->getParam('controller'));
             $as->setActionName($router->getParam('action'));
         }
         $as->renderThemeAssets();
         $as->initLoadedModules($this->getLoadedModules());
         $as->setupRenderer($sm->get('ViewRenderer'));
     }
     $section = $config->getApplicationSection();
     if ($section == 'admin') {
         if (FALSE === strpos($template, 'admin-')) {
             $template = str_replace('/', '/admin-', $template);
         }
     }
     $viewModel->setTemplate($template);
 }