Beispiel #1
0
 /**
  * Formats view template file names.
  * @param  string
  * @param  string
  * @return array
  */
 public function formatTemplateFiles($presenter, $view)
 {
     if ($this->oldModuleMode) {
         $root = Environment::getVariable('templatesDir', Environment::getVariable('appDir') . '/templates');
         // back compatibility
         $presenter = str_replace(':', 'Module/', $presenter);
         $dir = '';
         if ($root === Environment::getVariable('appDir') . '/presenters') {
             // special supported case
             $pos = strrpos($presenter, '/');
             $presenter = $pos === FALSE ? 'templates/' . $presenter : substr_replace($presenter, '/templates', $pos, 0);
             $dir = 'templates/';
         }
         return array("{$root}/{$presenter}/{$view}.phtml", "{$root}/{$presenter}.{$view}.phtml", "{$root}/{$dir}@global.{$view}.phtml");
     }
     return parent::formatTemplateFiles($presenter, $view);
 }
 /**
  * ads 'modules/' to path where to find layouts
  * ads reversed order of modules to paths where to find layouts, ie. from Admin:News: to NewsModule:AdminModule
  *
  * @param  string
  * @param  string
  * @return array
  */
 public function formatLayoutTemplateFiles($presenter, $layout)
 {
     $paths = parent::formatTemplateFiles($presenter, $layout);
     $appDir = Environment::getVariable('appDir');
     $path = '/modules/' . str_replace(':', 'Module/', $presenter);
     $pathP = substr_replace($path, '/templates', strrpos($path, '/'), 0);
     $list = array("{$appDir}{$pathP}/@{$layout}.phtml", "{$appDir}{$pathP}.@{$layout}.phtml", "{$appDir}{$path}Module/templates/@{$layout}.phtml");
     //		dump($list);die();
     //		dump($path);
     //		dump($pathP);
     //		dump("$appDir$pathP/@$layout.phtml");
     //		dump($presenter);
     // ked pouzivam aj reversed order, tak nechcem prebublat az do '/app/modules/templates/@layout.phtml', resp. '/app/templates/@layout.phtml', tam sa dostanu az po skuseni reversed order
     //		while (($path = substr($path, 0, strrpos($path, '/'))) !== false) {
     while (($path = substr($path, 0, strrpos($path, '/'))) !== "/modules") {
         $list[] = "{$appDir}{$path}/templates/@{$layout}.phtml";
     }
     /* reversed order for modules, ie. from Admin:News: to NewsModule:AdminModule*/
     $chunks = explode(':', $presenter);
     // if no module [e.g. it's ErrorPresenter from no module] return - @deprecated, should not be needed
     if (!isset($chunks[1])) {
         return $paths;
     }
     $reversedModulePresenter = implode(':', array_merge(array($chunks[1], $chunks[0]), array_splice($chunks, 2)));
     $reversedModulePath = '/modules/' . str_replace(':', 'Module/', $reversedModulePresenter);
     $reversedModulePathP = substr_replace($reversedModulePath, '/templates', strrpos($reversedModulePath, '/'), 0);
     //        $reversedModulePath = substr_replace($reversedModulePath, '/templates', strrpos($reversedModulePath, '/'));
     //        dump($reversedModulePath);
     //        dump($reversedModulePathP);
     $list[] = "{$appDir}{$reversedModulePathP}/@{$layout}.phtml";
     $list[] = "{$appDir}{$reversedModulePathP}.@{$layout}.phtml";
     while (($reversedModulePath = substr($reversedModulePath, 0, strrpos($reversedModulePath, '/'))) !== FALSE) {
         $list[] = "{$appDir}{$reversedModulePath}/templates/@{$layout}.phtml";
     }
     //		dump($paths);
     //		dump($list);
     //		die();
     //      return array_merge($paths, $list);
     // finalize
     foreach ($list as &$l) {
         $l = MyTools::unifyPath($l);
         // if layout is an absolute path, trim everything before
         $absPathPos = strpos($l, '//');
         if ($absPathPos !== false) {
             $l = substr($l, $absPathPos + 2);
         }
     }
     return array_merge($list);
 }
Beispiel #3
0
 /** Enable templates overriding by app folder, although theme folder overrides even this
  */
 public function formatTemplateFiles()
 {
     $name = str_replace(":", ".", $this->getName());
     $list = parent::formatTemplateFiles();
     array_unshift($list, $this->context->params["appDir"] . "/templates/{$name}.{$this->view}.latte");
     return $list;
 }