Example #1
0
 public function renderTemplate($templateName, $parameters = array())
 {
     $controller = strtolower($this->name);
     $path = Manager::getBasePath('/views/' . $controller . '/', $this->module);
     $file = $templateName . '.html';
     if (file_exists($path . '/' . $file)) {
         $template = new \Maestro\UI\MTemplate($path);
         $template->load($file);
         $this->getParameters($parameters);
         $object = (object) ['template' => $template, 'parameters' => $this->data];
         $this->setResult(new Results\MRenderTemplate($object));
     } else {
         throw new ENotFoundException(_M("Template [%s] was not found!", array($templateName)));
     }
 }
Example #2
0
 private function getControlsFromInclude($node, &$controls, $handleChildren = false)
 {
     if ($node) {
         if ($this->ignoreElement($node)) {
             return NULL;
         }
         $attributes = $node->attributes();
         if ($attributes['file']) {
             $fileName = $attributes['file'];
             $file = $this->path . '/' . $this->processValue($fileName);
         } elseif ($attributes['component']) {
             $fileName = $attributes['component'];
             $file = Manager::getAppPath('components/' . $fileName);
         }
         $extension = pathinfo($file, PATHINFO_EXTENSION);
         if ($extension == 'xml') {
             $xmlControls = new MXMLControls();
             $xmlControls->loadFile($file, $this->context);
             foreach ($xmlControls->get() as $c) {
                 $controls->addControl($c);
             }
         } elseif ($extension == 'html') {
             $control = new MBaseControl('mhtml');
             $control->tag = 'div';
             $template = new \Maestro\UI\MTemplate(dirname($file));
             $template->multicontext(['page' => Manager::getPage(), 'data' => Manager::getData(), 'template' => $template, 'painter' => Manager::getPainter()]);
             $control->inner = $template->fetch($fileName);
             $controls->addControl($control);
         } elseif ($extension == 'php') {
             include_once $file;
             $fileName = end(explode('/', $fileName)) ?: $fileName;
             $className = str_replace('.' . $extension, '', $fileName);
             $c = new $className();
             $this->getPropertiesFromNode($c, $node);
             if ($handleChildren) {
                 $controls->addControl($c);
             } else {
                 $controls[] = $c;
             }
         }
     }
 }