Esempio n. 1
0
 public function generateForm()
 {
     $this->property->action = $this->property->action ?: Manager::getCurrentURL();
     \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST');
     \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%");
     $this->property->role = "form";
     $fields = $buttons = $help = $tools = "";
     $fields = $this->generateFields();
     $buttons = $this->generateButtons();
     $help = $this->generateHelp();
     if ($this->tools != NULL) {
         mdump('has tools');
         $tools = $this->generateTools();
     }
     // menubar
     if ($this->property->menubar) {
         $menubar = PainterControl::generate($this->property->menubar);
     }
     // por default, o método de submissão é POST
     \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST");
     if ($this->property->onsubmit) {
         PainterControl::getPage()->onSubmit($this->property->onsubmit, $this->property->id);
     }
     // se o form tem fields com validators, define onSubmit
     $validators = '';
     if (count($this->property->toValidate)) {
         PainterControl::getPage()->onSubmit("\$('#{$this->property->id}').form('validate')", $this->property->id);
         $validators = implode(',', $this->property->bsValidator);
     }
     //mdump($fields);
     // obtem o codigo html via template
     $inner = PainterControl::fetch('painter/formdialog', $this, ['fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'tools' => $tools, 'validators' => $validators, 'menubar' => $menubar]);
     return $inner;
 }
Esempio n. 2
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. 3
0
 private static function getAction($action)
 {
     $app = Manager::getApp();
     $re = '#^(\\/?)' . $app . '\\/#';
     if (preg_match($re, $action)) {
         $action = preg_replace($re, '', $action);
     }
     return $app . '/' . $action;
 }
Esempio n. 4
0
 protected function nocache()
 {
     // headers apropriados para evitar caching
     Manager::$response->setHeader('Expires', 'Expires: Fri, 14 Mar 1980 20:53:00 GMT');
     Manager::$response->setHeader('Last-Modified', 'Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     Manager::$response->setHeader('Cache-Control', 'Cache-Control: no-cache, must-revalidate');
     Manager::$response->setHeader('Pragma', 'Pragma: no-cache');
     Manager::$response->setHeader('X-Powered-By', 'X-Powered-By: ' . Manager::version() . '/PHP ' . phpversion());
 }
Esempio n. 5
0
 public function listForLookup()
 {
     //$colorRepository = new InMemoryColorRepository();
     //$service = new QueryService($colorRepository);
     $queryService = Manager::getContainer()->get('ColorQueryService');
     $filter = (object) ['idColor' => 2];
     $list = $queryService->listForLookup();
     mdump($list);
     $this->render('formLogin');
 }
Esempio n. 6
0
 public static function getInstance()
 {
     if (self::$instance == NULL) {
         $configLoader = Manager::getConf('maestro.db.configLoader') ?: 'PHP';
         $manager = self::$instance = new PersistentManager();
         self::$container = Manager::getInstance();
         $manager->setConfigLoader($configLoader);
     }
     return self::$instance;
 }
Esempio n. 7
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. 8
0
 public function jcryption()
 {
     $path = Manager::getAppPath('conf');
     $pathPUB = $path . '/rsa_1024_pub.pem';
     $pathPVT = $path . '/rsa_1024_priv.pem';
     $jc = new jcryption($pathPUB, $pathPVT);
     $jc->go();
     header('Content-type: text/plain');
     print_r($_POST);
     die;
 }
Esempio n. 9
0
 public function getOutput()
 {
     Manager::$response->status = \Maestro\Services\HTTP\MStatusCode::OK;
     if (Manager::isAjaxCall()) {
         $this->nocache();
         return $this->content;
     } else {
         //Manager::$response->setHeader('Location:', $this->object->url);
         header('Location: ' . $this->object->url);
         die;
     }
 }
Esempio n. 10
0
 public static function hasType($type)
 {
     if (Type::hasType($type)) {
         return true;
     } else {
         $className = Manager::getConf('maestro.types')[$type];
         if (isset($type)) {
             Type::addType($type, $className);
             return true;
         }
     }
     return false;
 }
Esempio n. 11
0
 public function __construct($path = '')
 {
     if (function_exists('mb_internal_charset')) {
         mb_internal_charset('UTF-8');
     }
     $this->engine = new \Latte\Engine();
     $this->path = $path ?: Manager::getPublicPath() . '/templates';
     $this->engine->setTempDirectory(sys_get_temp_dir());
     $this->engine->getParser()->defaultSyntax = 'double';
     $this->engine->addFilter('translate', function ($s) {
         return _M($s);
     });
     $this->context = array();
     $this->context('manager', Manager::getInstance());
 }
Esempio n. 12
0
 public function setContent()
 {
     mdump('Executing MRuntimeError');
     try {
         $errorHtml = $this->fetch("runtime");
         if (Manager::isAjaxCall()) {
             $this->ajax->setType('page');
             $this->ajax->setData($errorHtml);
             $this->ajax->setResponseType('JSON');
             $this->content = $this->ajax->returnData();
         } else {
             $this->content = $errorHtml;
         }
     } catch (\Maestro\Services\Exception\EMException $e) {
     }
 }
Esempio n. 13
0
 /**
  * Processa o arquivo da view
  * @param type $controller
  * @param type $parameters
  * @return type
  */
 public function process($controller, $parameters)
 {
     mtrace('view file = ' . $this->viewFile);
     $extension = pathinfo($this->viewFile, PATHINFO_EXTENSION);
     if ($extension == 'xml') {
         $content = $this->processXML();
     } elseif ($extension == 'php') {
         $content = $this->processPHP();
     } else {
         $content = $this->processFile();
     }
     $parameters->manager = Manager::getInstance();
     $painter = Manager::getPainter();
     $result = $painter->generate($content, $parameters);
     return $result;
 }
Esempio n. 14
0
 /**
  * 
  * @param int $userId
  * @param string $challenge
  * @param string $response
  * @return boolean
  */
 public function validate($userId, $challenge, $response)
 {
     $user = Manager::getModelMAD('user');
     $user->getByLogin($userId);
     $login = $user->getLoginAtivo();
     mdump("Ldap validating userid = {$userId} - login ativo = {$login}");
     $filter = "uid={$login}";
     mdump("Ldap filter = {$filter}");
     $mldap = new \MLdap();
     $info = $mldap->search($filter, array('userPassword'));
     mdump($info);
     if ($info['count'] == 0) {
         return false;
     }
     $passLdap = trim($info[0]['userpassword'][0]);
     $hash_pass = md5(trim($login) . ':' . MLdap::ldapToMd5($passLdap) . ":" . $challenge);
     return $hash_pass == $response;
 }
Esempio n. 15
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $this->request = $request;
     $this->response = $response;
     // root path
     $this->rootDir = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
     $result = \Maestro\Manager::invoke($this);
     //\Maestro\Manager::process($conf, $dir);
     //$query  = $request->getQueryParams();
     //$target = isset($query['target']) ? $query['target'] : 'World';
     //$target = htmlspecialchars($target, ENT_HTML5, 'UTF-8');
     //$result = 'xxx';
     //$response->getBody()->write(sprintf(
     //    '<h1>result: %s!</h1>',
     //    $result
     //));
     //return $response->withHeader('Content-Type', 'text/html');
     $response->getBody()->write($result);
     return $response;
 }
Esempio n. 16
0
 public function preProcess()
 {
     $data = Manager::getData();
     if (Manager::isLogged()) {
         $login = Manager::getLogin();
         $userIdLanguage = $login->getUser()->getConfigData('fnbrIdLanguage');
     }
     $idLanguage = $data->lang;
     if ($idLanguage == '') {
         $idLanguage = Manager::getSession()->idLanguage;
         if ($idLanguage == '') {
             $idLanguage = $userIdLanguage;
             if ($idLanguage == '') {
                 $idLanguage = 1;
             }
         }
     }
     Manager::getSession()->idLanguage = $idLanguage;
     $db = $data->datasource ?: (Manager::getSession()->fnbrdb ?: Manager::getConf('db.active'));
     Manager::setConf('db.active', $db);
     //Manager::setConf('options.language', Base::languages()[$idLanguage]);
 }
Esempio n. 17
0
 public static function contextualize()
 {
     $context = self::$context = new MContext(Manager::$request);
     //$app = self::$app = Manager::$app = $context->getApp();
     self::$path = Manager::getAppPath();
     /*
             $fileAppStructure = Manager::getCachePath('app_' . $app . '.ser');
             if (is_file($fileAppStructure)) {
        $appStructure = unserialize(file_get_contents($fileAppStructure));
             } else {
        $appStructure = new MAppStructure($app, self::$path);
        if (Manager::getOptions('cacheStructure')) {
            file_put_contents($fileAppStructure, serialize($appStructure));
        }
             }
     * 
     */
     //$context->defineContext($appStructure);
     //self::$structure = $appStructure;
     self::$module = $context->getModule();
     //self::$pathModules = self::$path . '/modules';
     //$autoload = self::$path . '/vendor/autoload.php';
     //self::$loader = require $autoload;
 }
Esempio n. 18
0
 public function getBaseURL($absolute = false)
 {
     $url = $absolute ? $this->url->getBaseURL() : $this->url->getBasePath();
     $baseURL = str_replace('/' . Manager::getOptions('dispatcher') . '/', '', $url);
     return $baseURL;
 }
Esempio n. 19
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. 20
0
 public function renderFlush($viewName = '', $parameters = array())
 {
     Manager::getPage()->clearContent();
     $this->renderContent($viewName, $parameters);
     $output = Manager::getPage()->generate();
     $this->flush($output);
 }
Esempio n. 21
0
 public function log()
 {
     Manager::logError($this->message);
 }
Esempio n. 22
0
    public function msyntax($control)
    {
        Manager::import('core::classes::extensions::geshi::geshi', 'GeSHi');
        $css = Manager::getAbsolutePath('core/classes/extensions/geshi/geshi.css');
        $this->page->addStyleSheet($css);
        $cssCustom = Manager::getAppPath('public/css/geshiCustom.css');
        if (file_exists($cssCustom)) {
            $this->page->addStyleSheet($cssCustom);
        }
        $source = $control->text;
        $language = $control->language;
        $geshi = new GeSHi($source, $language);
        $text = $geshi->parse_code();
        return <<<EOT
        {$text}
EOT;
    }
Esempio n. 23
0
 public function addStyleSheetCode($code)
 {
     if (Manager::isAjaxCall()) {
         $fileName = md5($code) . '.css';
         $file = Manager::getFrameworkPath('var/files/' . $fileName);
         file_put_contents($file, $code);
         $url = Manager::getDownloadURL('cache', $fileName, true);
         $this->onLoad("\$('head').append('<link href=\"{$url}\" type=\"text/css\" rel=\"stylesheet\" />');");
     } else {
         $this->styleSheetCode .= "\n" . $code;
     }
 }
Esempio n. 24
0
 public function getService($service, $module = '')
 {
     $service = MApp::getService(Manager::getApp(), $module == '' ? Manager::getModule() : $module, $service);
     $service->setData();
     return $service;
 }
Esempio n. 25
0
 public function __construct()
 {
     $this->path = Manager::getHome() + '/';
 }
Esempio n. 26
0
 public function renderFile(\Maestro\Types\MFile $file)
 {
     Manager::getPage()->window($file->getURL());
     $this->setResult(new Results\MBrowserFile($file));
 }
Esempio n. 27
0
 public function getDatabase($name)
 {
     return Manager::getDatabase($name);
 }
Esempio n. 28
0
    public function generate()
    {
        $idPage = $this->idPage;
        $isAjax = Manager::isAjaxCall();
        $scripts = $this->getScripts();
        $hasCode = $scripts->scripts . $scripts->code . $scripts->onload . $scripts->onsubmit;
        if ($hasCode != '') {
            if ($isAjax) {
                $code = <<<HERE
<script type="text/javascript">
{$scripts->scripts}
{$scripts->code}
manager.onLoad["{$idPage}"] = function() {
    console.log("inside onload {$idPage}");
    {$scripts->onload};
};
{$scripts->onsubmit}                
//-->
</script>
                
HERE;
            } else {
                $code = <<<HERE
<script type="text/javascript">
{$scripts->scripts}
{$scripts->code}
    manager.ready = function() {
        jQuery(function(\$) {
            console.log("inside onload {$idPage}");
            {$scripts->onload};
        });
    };
{$scripts->onsubmit}               
//-->
</script>
                
HERE;
            }
            return "<div id=\"{$idPage}\" class=\"mScripts\">{$code}</div>";
        } else {
            return '';
        }
    }
Esempio n. 29
0
 public static function getData()
 {
     return Manager::getData();
 }
Esempio n. 30
0
 public function convertToPHPValue($value, $type)
 {
     if ($type == 'date') {
         return \Maestro\Manager::Date($value);
     } elseif ($type == 'timestamp') {
         return \Maestro\Manager::Timestamp($value);
     } elseif ($type == 'currency') {
         return \Maestro\Manager::currency($value);
     } elseif ($type == 'cnpj') {
         return \Maestro\Types\MCNPJ::create($value);
     } elseif ($type == 'cpf') {
         return \Maestro\Types\MCPF::create($value);
     } elseif ($type == 'currency') {
         return \Maestro\Manager::currency($value);
     } elseif ($type == 'boolean') {
         return !empty($value);
     } elseif ($type == 'blob') {
         $value = \Maestro\Types\MFile::file(base64_decode($value));
         return $value;
     } else {
         return $value;
     }
 }