예제 #1
0
 /**
  * Loads a view file.
  *
  * @param string $url
  * @param mixed[] $data
  */
 public function load($file, $data = array())
 {
     $request = $this->getRequest();
     $view = new \Ilch\View($request, $this->getTranslator(), $this->getRouter());
     $view->setArray($data);
     echo $view->loadScript(APPLICATION_PATH . '/modules/' . $request->getModuleName() . '/views/' . $file);
 }
예제 #2
0
 /**
  * Gets the box with the given key.
  *
  * @param string $moduleKey
  * @param string $boxKey
  * @return string
  */
 public function getBox($moduleKey, $boxKey = '')
 {
     if (empty($boxKey)) {
         $boxKey = $moduleKey;
     }
     $class = '\\Modules\\' . ucfirst($moduleKey) . '\\Boxes\\' . ucfirst($boxKey);
     $view = new \Ilch\View($this->getRequest(), $this->getTranslator(), $this->getRouter());
     $this->getTranslator()->load(APPLICATION_PATH . '/modules/' . $moduleKey . '/translations');
     $boxObj = new $class($this, $view, $this->getRequest(), $this->getRouter(), $this->getTranslator());
     $boxObj->render();
     $viewPath = APPLICATION_PATH . '/' . dirname($this->getFile()) . '/override/' . $moduleKey . '/boxes/views/' . $boxKey . '.php';
     if (!file_exists($viewPath)) {
         $viewPath = APPLICATION_PATH . '/modules/' . $moduleKey . '/boxes/views/' . $boxKey . '.php';
     }
     $view->setLayoutKey($this->getLayoutKey());
     return $view->loadScript($viewPath);
 }
예제 #3
0
 /**
  * Gets the menu items as html-string.
  * 
  * @param string $tpl
  * @param array $options
  * @return string
  */
 public function getItems($tpl = '', $options = array())
 {
     $html = '';
     $locale = '';
     $htmlMenuItems = '';
     $menuMapper = new \Modules\Admin\Mappers\Menu();
     $items = $menuMapper->getMenuItemsByParent($this->getId(), 0);
     $boxMapper = new \Modules\Admin\Mappers\Box();
     $config = \Ilch\Registry::get('config');
     if ((bool) $config->get('multilingual_acp')) {
         if ($this->layout->getTranslator()->getLocale() != $config->get('content_language')) {
             $locale = $this->layout->getTranslator()->getLocale();
         }
     }
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($item->getType() == 0 || $item->getType() == 4) {
                 $html = str_replace('%c', $htmlMenuItems, $html);
                 $htmlMenuItems = '';
                 $html .= str_replace('%s', $item->getTitle(), $tpl);
                 if ($item->getType() == 4) {
                     if ($item->getBoxId()) {
                         $box = $boxMapper->getBoxByIdLocale($item->getBoxId(), $locale);
                     } else {
                         $parts = explode('_', $item->getBoxKey());
                         $moduleKey = $parts[0];
                         $boxKey = $parts[1];
                         $class = '\\Modules\\' . ucfirst($moduleKey) . '\\Boxes\\' . ucfirst($boxKey);
                         $view = new \Ilch\View($this->layout->getRequest(), $this->layout->getTranslator(), $this->layout->getRouter());
                         $this->layout->getTranslator()->load(APPLICATION_PATH . '/modules/' . $moduleKey . '/translations');
                         $boxObj = new $class($this->layout, $view, $this->layout->getRequest(), $this->layout->getRouter(), $this->layout->getTranslator());
                         $boxObj->render();
                         $viewPath = APPLICATION_PATH . '/' . dirname($this->layout->getFile()) . '/override/' . $moduleKey . '/boxes/views/' . $boxKey . '.php';
                         if (!file_exists($viewPath)) {
                             $viewPath = APPLICATION_PATH . '/modules/' . $moduleKey . '/boxes/views/' . $boxKey . '.php';
                         }
                         $view->setLayoutKey($this->layout->getLayoutKey());
                         $output = $view->loadScript($viewPath);
                         $box = new \Modules\Admin\Models\Box();
                         $box->setContent($output);
                     }
                     $html = str_replace('%c', $box->getContent(), $html);
                 } else {
                     $htmlMenuItems .= $this->recGetItems($item, $locale, $options);
                 }
             }
         }
         $html = str_replace('%c', $htmlMenuItems, $html);
         $htmlMenuItems = '';
     }
     return $html;
 }