Beispiel #1
0
 /**
  * Define template and template variables
  */
 public function setTemplate()
 {
     $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../templates/pages');
     $this->template = Manager::getTemplate($path);
     $this->template->context('manager', Manager::getInstance());
     $this->template->context('page', $this);
     $this->template->context('charset', Manager::getOptions('charset'));
     $this->template->context('template', $this->template);
 }
 public function apply($request, $response)
 {
     $response->status = MStatusCode::INTERNAL_ERROR;
     $format = $request->format;
     $response->setContentType($response->getMimeType("xx." + format));
     $this->tracestack = str_replace('#', '<br>#', $this->exception->trace);
     $errorHtml = "Not found";
     try {
         $template = new MTemplate();
         $template->context('result', $this->exception);
         $language = Manager::getOptions('language');
         $errorHtml = $template->fetch("errors/{$language}/" . $response->status . "." . ($format == null ? "html" : $format));
         if ($request->isAjax() && $format == "html") {
             if ($this->ajax->isEmpty()) {
                 $this->ajax->setId('error');
                 $this->ajax->setType('page');
                 $this->ajax->setData($errorHtml);
             }
             $response->out = $this->ajax->returnData();
         } else {
             $response->out = $errorHtml;
         }
     } catch (Exception $e) {
         throw new EMException($e);
     }
 }
Beispiel #3
0
 /**
  * Define template and template variables
  */
 public function setTemplate()
 {
     $path = Manager::getThemePath();
     $this->template = new MTemplate($path);
     $this->template->context('manager', Manager::getInstance());
     $this->template->context('page', $this);
     $this->template->context('charset', Manager::getOptions('charset'));
     $this->template->context('layout', $this->layout);
     $this->template->context('template', $this->template);
 }
Beispiel #4
0
 public function apply($request, $response)
 {
     $response->status = MStatusCode::NOT_FOUND;
     $format = $request->format;
     if ($request->isAjax() && $format == "html") {
         $format = "json";
     }
     $response->setContentType($response->getMimeType("xx." + format));
     $errorHtml = "Not found";
     try {
         $template = new MTemplate();
         $template->context('result', $this);
         $language = Manager::getOptions('language');
         $errorHtml = $template->fetch("errors/{$language}/404.html");
         if ($request->isAjax()) {
             $this->ajax->setResponse('html', $errorHtml);
             $response->out = $this->ajax->returnData();
         } else {
             $response->out = $errorHtml;
         }
     } catch (EMException $e) {
     }
 }
Beispiel #5
0
 public function generate()
 {
     if (!count($this->columnWidth)) {
         return '';
     }
     // default code for row selection
     if ($this->select != '') {
         $select = MActionControl::getHref($this->select);
         $this->addCode("{$this->tableId}.customSelect = function() { " . "var cells = this.get(this.rowSelected);" . "var url = '{$select}'; " . "for (c = 0; c < cells.length; ++c) {" . "   url = url.replace('%' + c + '%', cells[c]);" . "}" . "manager.doLinkButton(url,'','','{$this->tableId}'); " . "};");
     }
     $data = json_encode($this->value);
     $cols = json_encode($this->title);
     foreach ($this->columnStyle as $i => $style) {
         $cssCode .= ".field-" . $this->title[$i] . ' ' . ($style ?: '{}') . ' ';
     }
     $cssCode .= '.dgrid-row-even {background-color: #EEE}';
     Manager::getPage()->addStyleSheetCode($cssCode);
     $template = new MTemplate(__DIR__);
     $template->context('manager', Manager::getInstance());
     $template->context('data', $data);
     $template->context('cols', $cols);
     $template->context('id', $this->id);
     $js = $template->fetch('mtexttable.js');
     $this->page->onLoad($js);
     $div = new MContentpane($this->id);
     $div->setWidth($this->width);
     $div->setHeight($this->scrollHeight);
     return $div->generate();
 }
Beispiel #6
0
 /**
  * Processa o arquivo da view e inclui o conteudo no objeto Page.
  * @param type $controller
  * @param type $parameters
  * @return type 
  */
 public function process($controller, $parameters)
 {
     mtrace('view file = ' . $this->viewFile);
     $path = $this->getPath();
     Manager::addAutoloadPath($path);
     $extension = pathinfo($this->viewFile, PATHINFO_EXTENSION);
     $baseName = basename($this->viewFile);
     $content = '';
     $page = Manager::getPage();
     $this->controller = $controller;
     $this->data = $parameters;
     //        $mlabelTemporario = new MFieldLabel(); // remover esta linha
     if ($extension == 'php') {
         $viewName = basename($this->viewFile, '.php');
         mtrace($viewName);
         include_once $this->viewFile;
         $view = new $viewName();
         $view->setView($this);
         $view->load();
         if ($page->isPostBack()) {
             $view->eventHandler($this->data);
             $view->postback();
         }
         $page->addContent($view);
     } elseif ($extension == 'xml') {
         $container = new MContainer();
         $container->setView($this);
         $controls = $container->getControlsFromXML($this->viewFile);
         if (is_array($controls)) {
             foreach ($controls as $view) {
                 if (is_object($view)) {
                     //$view->setView($this);
                     $view->load();
                     if ($page->isPostBack()) {
                         $view->postback();
                     }
                     $page->addContent($view);
                 }
             }
         }
     } elseif ($extension == 'js' || $extension == 'html') {
         $template = new MTemplate(dirname($this->viewFile));
         $template->context('manager', Manager::getInstance());
         $template->context('page', Manager::getPage());
         $template->context('view', $this);
         $template->context('data', $parameters);
         $template->context('template', $template);
         $content = $template->fetch($baseName);
         mtrace($baseName);
         $page->setContent($content);
     } elseif ($extension == 'wiki') {
         $wikiPage = file_get_contents($this->viewFile);
         $wiki = new MWiki();
         $content = $wiki->parse('', $wikiPage);
         $page->setContent($content);
     }
     //        return $content;
 }