Exemple #1
0
 public function returnData()
 {
     switch ($this->responseType) {
         case 'TEXT':
             header('Content-type: text/plain; charset=' . MAjaxTransformer::findOutputCharset($this->baseNode->getEncoding()));
             $data = MAjaxTransformer::toString($this->baseNode);
             return $data;
             break;
         case 'JSON':
         case 'OBJECT':
             $data = MAjaxTransformer::toJSON($this->baseNode);
             $header = 'Content-type: text/plain; ';
             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=' . MAjaxTransformer::findOutputCharset($this->baseNode->getEncoding()));
             return $data;
             break;
         case 'E4X':
         case 'XML':
             header('Content-type:  text/xml; charset=' . MAjaxTransformer::findOutputCharset($this->baseNode->getEncoding()));
             $data = '<?xml version="1.0" encoding="' . MAjaxTransformer::find_output_charset($this->baseNode->getEncoding()) . '"?>' . MAjaxTransformer::toXML($this->baseNode);
             return $data;
             break;
         default:
             return 'ERROR: invalid response type \'' . $this->responseType . '\'';
     }
 }
Exemple #2
0
 public function generateInner()
 {
     $css = Manager::getAbsolutePath('core/classes/extensions/geshi/geshi.css');
     Manager::getPage()->addStyleSheet($css);
     $cssCustom = Manager::getAppPath('public/css/geshiCustom.css');
     if (file_exists($cssCustom)) {
         Manager::getPage()->addStyleSheet($cssCustom);
     }
     $source = $this->getText();
     $language = $this->getLanguage();
     $geshi = new GeSHi($source, $language);
     $this->setText($geshi->parse_code());
     $this->inner = $this->render();
 }
 public function pluginButton()
 {
     Manager::getPage()->setTemplateName('plugin');
     $fileInfo = pathinfo($this->data->filePath);
     $filePath = $this->data->filePath;
     do {
         $x = strpos($filePath, 'apps');
         if ($x !== false) {
             $filePath = substr($filePath, $x + 5);
         }
     } while ($x !== false);
     $filePath = str_replace('/modules', '', $filePath);
     $context = new MContext($filePath);
     $controller = Manager::getController($context->getApp(), $context->getModule(), $context->getController(), $context);
     $controller->render($fileInfo['filename']);
 }
 public function __construct($prompt)
 {
     parent::__construct();
     $this->ajax = Manager::getAjax();
     $this->page = Manager::getPage();
     if ($this->ajax->isEmpty()) {
         $this->page->setName($prompt->getId());
         $this->page->setContent($prompt);
         if (!$this->page->isPostBack()) {
             $this->page->onLoad("manager.doPrompt('{$prompt->getId()}')");
         }
         $this->ajax->setId($this->page->getName());
         $this->ajax->setType('prompt');
         $this->ajax->setData($this->page->generate());
     }
     $this->content = $this->ajax->returnData();
 }
Exemple #5
0
 public function renderHandler()
 {
     $view = Manager::getView($this->getApplication(), $this->getModule(), 'handler', $this->getAction());
     $page = Manager::getPage();
     if ($go = $page->redirectTo) {
         //mdump('redirecting: ' . $go);
         $this->setResult(new MRedirect($view, $go));
     } else {
         if ($window = $page->window) {
             $this->setResult(new MBrowserWindow());
         } else {
             if ($binary = $page->binary) {
                 //mdump('binary: ' . $binary);
                 $this->setResult(new MRenderBinary($binary));
             } else {
                 if ($download = $page->download) {
                     //mdump('download: ' . $download);
                     $this->setResult(new MRenderBinary($download, false));
                 } else {
                     if ($prompt = $page->prompt) {
                         $page->clearContent();
                         parent::renderPrompt($prompt);
                     } else {
                         if (Manager::isAjaxCall()) {
                             //mdump('mhandler:: renderjson');
                             $render = new MRenderJSON();
                             if (!$this->getResult()) {
                                 $this->setResult($render);
                             }
                         } else {
                             //mdump('mhandler:: renderpage');
                             $render = new MRenderPage();
                             if (!$this->getResult()) {
                                 $this->setResult($render);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #6
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 ESecurityException($msg);
         }
     } else {
         if ($deny) {
             $currentUrl = urlencode(Manager::getCurrentURL());
             $module = Manager::getConf('login.module');
             $url = Manager::getURL("{$module}/main.login", array('return_to' => $currentUrl));
             Manager::getPage()->redirect($url);
         }
     }
     return $ok;
 }
Exemple #7
0
 /**
  * Fetch the HTML template file and send to browser via redirect.
  *
  * @param string string the template file name
  *
  * @return string
  */
 public function execute($file)
 {
     $html = $this->fetch($file);
     $fname = substr(uniqid(md5(uniqid(""))), 0, 10) . '.html';
     $fileexp = Manager::home . '/' . Manager::getConf('home.reports') . '/' . $fname;
     $fp = fopen($fileexp, 'x');
     fwrite($fp, $html);
     fclose($fp);
     $fileout = Manager::getActionURL('manager', 'reports:' . $fname);
     Manager::getPage()->window($fileout);
 }
Exemple #8
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();
 }
Exemple #9
0
 public function renderFlush($viewName = '', $parameters = array())
 {
     Manager::getPage()->clearContent();
     $this->renderContent($viewName, $parameters);
     $output = Manager::getPage()->generate();
     $this->flush($output);
 }
Exemple #10
0
    public function generateInner()
    {
        $this->page->addDojoRequire('manager.TransferBox');
        $id = $this->getId();
        $idDiv = $id . '_div';
        $isReadOnly = $this->getReadOnly() ? 'none' : 'inline-block';
        // array Javascript com a lista
        $idListData = $id . '_data';
        $listData = "var {$idListData} = [];\n";
        if (!is_array($this->list)) {
            $this->list = array('0' => $this->list);
        }
        $i = 0;
        foreach ($this->list as $index => $value) {
            $listData .= "{$idListData}[{$i}] = { id: '{$index}', name: '{$value}', value: '{$value}' };\n";
            $i++;
        }
        // array Javascript com a lista de valores correntes
        $idListValue = $id . '_value';
        $listValue = "var {$idListValue} = [];\n";
        if (!is_array($this->value)) {
            if (!is_null($this->value)) {
                $this->value = array('0' => $this->value);
            }
        }
        if (is_array($this->value)) {
            $i = 0;
            foreach ($this->value as $index => $value) {
                $listValue .= "{$idListValue}[{$i}] = '{$index}';\n";
                $i++;
            }
        }
        $uniq = "store" . uniqid();
        // instancia MTransferBox
        $sort = $this->sort ? "name" : "";
        $code = <<<HERE
\t\tvar {$id}_transferbox;
\t\trequire([
\t\t\t"manager/TransferBox",
\t\t\t"dojo/store/Memory",
\t\t\t"dojo/store/Observable",
                        "dojo/dom-construct",
\t\t\t"dojo/domReady!"
\t\t], function(TransferBox, Memory, Observable, domConstruct){
            
                    var l = dojo.query("input[type='hidden']");
                    l.forEach(function(item){
                        if (item.id.search('{$id}') > -1){
                            domConstruct.destroy(item.id);
                        }
                    });
                    {$listData}
                    {$listValue}
                    var {$uniq} = new Memory({\tidentifier: "id", data: {$idListData} });
                    {$uniq} = Observable({$uniq});                    
                    {$id}_transferbox{$uniq} = new TransferBox({store: {$uniq}, value: {$idListValue}, idHidden:'{$id}', sortProperty:'{$sort}'}, "{$idDiv}");
\t\t});
        
HERE;
        $this->page->onLoad($code);
        if (!$this->width) {
            $this->width = '200px';
        }
        if (!$this->height) {
            $this->height = '150px';
        }
        $css = "#{$idDiv} .dgrid {width: {$this->width}; height: {$this->height}; display: inline-block; vertical-align: middle;} " . "#{$idDiv} .buttons {width: 27px; display: {$isReadOnly};}";
        Manager::getPage()->addStyleSheetCode($css);
        $controls = array(new MDiv($idDiv));
        $group = new MBaseGroup($id . 'BaseGroup', $this->getCaption(), $controls);
        $this->inner = $group;
    }
Exemple #11
0
    public function generate()
    {
        $this->page->addDojoRequire('manager.DGrid');
        $this->generateColumns();
        $columns = json_encode($this->dcolumns);
        $this->page->onLoad("{$this->id} = new Manager.DGrid('{$this->id}',{$this->firstIndex},'{$this->type}');");
        $this->page->onLoad("{$this->id}.idSelect = '{$this->idSelect}';");
        $this->page->onLoad("{$this->id}.firstIndex = {$this->firstIndex};");
        $value = array();
        foreach ($this->value as $i => $row) {
            foreach ($row as $j => $col) {
                $value[$i][$j] = $col->generate();
            }
        }
        $data = json_encode($value);
        $this->page->onLoad("{$this->id}.columns = {$columns};");
        $this->page->onLoad("{$this->id}.actionData = '{$this->actionData}';");
        $this->page->onLoad("{$this->id}.startup();");
        $div = new MContentpane($this->id);
        $div->setClass('mGrid');
        $div->setWidth($this->width);
        $this->scrollHeight = '20em';
        if ($this->scrollHeight) {
            $div->setHeight($this->scrollHeight);
        } else {
            // estilos para height:auto
            $this->cssCode .= <<<HERE
                #{$this->id} {
                    height: auto;
\t\t}
\t\t#{$this->id} .dgrid-scroller {
                    position: relative;
                    overflow-y: hidden;
\t\t}
\t\t.has-ie-6 #{$this->id} .dgrid-scroller {
                    /* IE6 doesn't react properly to hidden on this page for some reason */
                    overflow-y: visible;
\t\t}
\t\t#{$this->id} .dgrid-header-scroll {
                    display: none;
\t\t}
\t\t#{$this->id} .dgrid-header {
                    right: 0;
\t\t}
HERE;
        }
        Manager::getPage()->addStyleSheetCode($this->cssCode);
        return $div->generate();
    }
Exemple #12
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;
 }
Exemple #13
0
 private function handleNodeJavascript($node)
 {
     foreach ($node->attributes() as $property => $value) {
         if ($property == 'onload') {
             Manager::getPage()->onLoad($this->processValue(trim(utf8_decode((string) $value))));
         } elseif ($property == 'code') {
             Manager::getPage()->addJsCode($this->processValue(trim(utf8_decode((string) $value))));
         } elseif ($property == 'helper') {
             Manager::getPage()->onLoad($this->processValue(trim(utf8_decode((string) $value))));
         } elseif ($property == 'file') {
             Manager::getPage()->addJsFile($this->processValue(trim(utf8_decode((string) $value))));
         }
     }
 }
 public function handlerComponent()
 {
     $module = $this->context->getModule();
     $component = $this->context->getComponent();
     mtrace('handler component=' . $component);
     $fileName = $component . '.php';
     $file = Manager::getAppPath('components/' . $fileName, $module);
     $mlabelTemporario = new MFieldLabel();
     // remover esta linha
     if (file_exists($file)) {
         include_once $file;
         $control = new $component();
         $action = $this->context->getAction();
         if ($action) {
             $content = $control->{$action}();
         } else {
             $content = $control->generate();
         }
         Manager::getPage()->setContent($content);
         if (Manager::isAjaxCall()) {
             $this->setResult(new MRenderJSON());
         } else {
             $this->setResult(new MRenderPage());
         }
     } else {
         throw new ERunTimeException(_M("App: [{$this->context->app}], Module: [{$this->context->module}], Component: [{$component}] not found!"));
     }
 }
Exemple #15
0
 public function js($type, $value)
 {
     if ($type == 'file') {
         Manager::getPage()->addJsFile($value);
     } elseif ($type == 'script') {
         Manager::getPage()->addScriptURL($value);
     } elseif ($type == 'code') {
         if (substr($value, -2) == 'js') {
             $value = file_get_contents($value);
         }
         Manager::getPage()->addJsCode($value);
     }
 }
Exemple #16
0
 public function __construct($description = '', $code = 0, $goTo = '')
 {
     parent::__construct($description);
     $this->ajax = Manager::getAjax();
     $this->page = Manager::getPage();
 }
Exemple #17
0
 public function getPage()
 {
     return Manager::getPage();
 }
Exemple #18
0
 public function __construct()
 {
     $this->page = Manager::getPage();
 }