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; }
/** * 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 . '\''; } }
private static function getAction($action) { $app = Manager::getApp(); $re = '#^(\\/?)' . $app . '\\/#'; if (preg_match($re, $action)) { $action = preg_replace($re, '', $action); } return $app . '/' . $action; }
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()); }
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'); }
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; }
public function invoke() { $action = $this->context->getAction(); if ($action != '') { $content = $this->component->{$action}(); } else { $content = $this->component->generate(); } Manager::getPage()->setContent($content); $this->renderPage(); }
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; }
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; } }
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; }
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()); }
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) { } }
/** * 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; }
/** * * @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; }
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; }
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]); }
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; }
public function getBaseURL($absolute = false) { $url = $absolute ? $this->url->getBaseURL() : $this->url->getBasePath(); $baseURL = str_replace('/' . Manager::getOptions('dispatcher') . '/', '', $url); return $baseURL; }
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); }
public function renderFlush($viewName = '', $parameters = array()) { Manager::getPage()->clearContent(); $this->renderContent($viewName, $parameters); $output = Manager::getPage()->generate(); $this->flush($output); }
public function log() { Manager::logError($this->message); }
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; }
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; } }
public function getService($service, $module = '') { $service = MApp::getService(Manager::getApp(), $module == '' ? Manager::getModule() : $module, $service); $service->setData(); return $service; }
public function __construct() { $this->path = Manager::getHome() + '/'; }
public function renderFile(\Maestro\Types\MFile $file) { Manager::getPage()->window($file->getURL()); $this->setResult(new Results\MBrowserFile($file)); }
public function getDatabase($name) { return Manager::getDatabase($name); }
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 ''; } }
public static function getData() { return Manager::getData(); }
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; } }