Esempio n. 1
0
 /**
  * Retorna a resposta formatada de acordo com o tipo definido em $responseType.
  * @return mixed
  */
 public function returnData()
 {
     $charset = MAjaxTransformer::findOutputCharset($this->getEncoding());
     switch ($this->responseType) {
         case 'TXT':
         case 'HTML':
             header('Content-type: text/plain; charset=' . $charset);
             $data = MAjaxTransformer::toString($this);
             return $data;
             break;
         case 'JSON':
         case 'OBJECT':
             $data = MAjaxTransformer::toJSON($this);
             //$header = 'Content-type: text/plain; ';
             $header = 'Content-type: application/json; ';
             if (Manager::getPage()->fileUpload) {
                 $newdata = "{\"base64\":\"" . base64_encode($data) . "\"}";
                 $data = "<html><body><textarea>{$newdata}</textarea></body></html>";
                 $header = 'Content-type: text/html; ';
             }
             header($header . 'charset=' . $charset);
             return $data;
             break;
         case 'E4X':
         case 'XML':
             header('Content-type:  text/xml; charset=' . $charset);
             $data = '<?xml version="1.0" encoding="' . $charset . '"?>' . MAjaxTransformer::toXML($this);
             return $data;
             break;
         default:
             return 'ERROR: invalid response type \'' . $this->responseType . '\'';
     }
 }
Esempio n. 2
0
 public function invoke()
 {
     $action = $this->context->getAction();
     if ($action != '') {
         $content = $this->component->{$action}();
     } else {
         $content = $this->component->generate();
     }
     Manager::getPage()->setContent($content);
     $this->renderPage();
 }
Esempio n. 3
0
 public function checkAccess($transaction, $access, $deny = false)
 {
     //mdump($transaction);
     //mdump('--------------------');
     //mdump($access);
     $module = Manager::getModule();
     $ok = false;
     if (!is_numeric($access)) {
         $access = $this->access[$access];
     }
     if ($this->auth->isLogged()) {
         $login = $this->auth->getLogin();
         // MLogin object
         $transaction = strtoupper($transaction);
         // Transaction name
         $isAdmin = $login->isAdmin();
         // Is administrator?
         $rights = (int) $login->getRights($transaction);
         // user rights
         $rightsInAll = (int) $login->getRights('ALL');
         // user rights in all transactions
         $ok = ($rights & $access) == $access || ($rightsInAll & $access) == $access || $isAdmin;
         if (!$ok && $deny) {
             $msg = _M('Acesso Negado') . "<br><br>\n" . "<center><big><i><font color=red>" . _M('Transação: ') . "{$transaction}</font></i></big></center><br><br>\n" . _M('Informe um login válido para acessar esta página.') . "<br>";
             //$go = Manager::getCurrentURL();
             //$error = MPrompt::error($msg, $go, $caption, '');
             //Manager::prompt($error, $deny);
             throw new \Maestro\Services\ESecurityException($msg);
         }
     } else {
         if ($deny) {
             $currentUrl = urlencode(\Manager::getCurrentURL());
             $module = Manager::getConf('maestro.login.module');
             $url = Manager::getURL("{$module}/main.login", array('return_to' => $currentUrl));
             Manager::getPage()->redirect($url);
         }
     }
     return $ok;
 }
Esempio n. 4
0
 public function renderFile(\Maestro\Types\MFile $file)
 {
     Manager::getPage()->window($file->getURL());
     $this->setResult(new Results\MBrowserFile($file));
 }
Esempio n. 5
0
 private function processTemplate()
 {
     $baseName = basename($this->viewFile);
     $template = Manager::getTemplate(dirname($this->viewFile));
     $template->context('manager', Manager::getInstance());
     $template->context('page', Manager::getPage());
     $template->context('view', $this);
     $template->context('data', $this->data);
     $template->context('template', $template);
     $template->context('painter', Manager::getPainter());
     return $template->fetch($baseName);
 }
Esempio n. 6
0
 public function renderFlush($viewName = '', $parameters = array())
 {
     Manager::getPage()->clearContent();
     $this->renderContent($viewName, $parameters);
     $output = Manager::getPage()->generate();
     $this->flush($output);
 }
Esempio n. 7
0
 public function getPage()
 {
     return Manager::getPage();
 }
Esempio n. 8
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;
             }
         }
     }
 }
Esempio n. 9
0
function tdump($var)
{
    Maestro\Manager::getPage()->addDump(Tracy\Dumper::toHtml($var));
}