public function checkLogin() { Manager::logMessage('[LOGIN] Running CheckLogin'); // if not checking logins, we are done if (!MUtil::getBooleanValue(Manager::getConf('maestro.login.check'))) { Manager::logMessage('[LOGIN] I am not checking login today...'); return true; } // we have a session login? $session = Manager::getSession(); $login = $session->getValue('__sessionLogin'); if ($login) { if ($login->getLogin()) { Manager::logMessage('[LOGIN] Using session login: '******'[LOGIN] Using existing login:'******'[LOGIN] No Login but Login required!'); return false; }
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; }
public static function relationCriteria($className1, $className2, $relationEntry, $select = '*') { $er = new EntityRelation(); $criteria = $er->getCriteria(); $criteria->select($select); $cn1 = explode(' ', $className1); MUtil::SetIfNull($cn1[1], $className1); $cn2 = explode(' ', $className2); MUtil::SetIfNull($cn2[1], $className2); $alias = '_' . $cn1[1] . '_' . $cn2[1]; $criteria->join($className1, "entityrelation er{$alias}", "{$cn1[1]}.idEntity = er{$alias}.idEntity1"); $criteria->join("entityrelation er{$alias}", "relationtype rt{$alias}", "er{$alias}.idRelationType = rt{$alias}.idRelationType"); $criteria->join("entityrelation er{$alias}", $className2, "er{$alias}.idEntity2 = {$cn2[1]}.idEntity"); $criteria->where("rt{$alias}.entry = '{$relationEntry}'"); return $criteria; }
/** * Registra o path de uma classe (ou conjunto de classes) para posterior importação. * "import" não carrega a classe: apenas registra o path em self::autoload, para o "autoload" carregar a classe quando ela for efetivamente instanciada. * @param string $path Path no formato x\y\z * @param string $className Nome da classe * @return string Retorna o path registrado para a classe. */ public static function import($namespace, $classAlias = '') { mdump('import namespace = ' . $namespace); $path = str_replace('\\', DIRECTORY_SEPARATOR, $namespace); $tokens = explode(DIRECTORY_SEPARATOR, $path); $wildcard = end($tokens) == '*'; if ($wildcard) { $path = substr($path, 0, -2); $registerAlias = true; } // verifica se o primeiro token é a app ou um módulo, e obtem o path completo $structure = MApp::getStructure(self::getApp()); if ($structure->modules[$tokens[0]]) { $basePath = MApp::getPathModules() . DIRECTORY_SEPARATOR; } else { $basePath = Manager::$appsPath . DIRECTORY_SEPARATOR; } $fullPath = $basePath . $path; //mdump($fullPath); // seja o wildcard *, seja um unico arquivo, normaliza no array $files //$fullPath = realpath($fullPath); $files = array(); //$file = basename($fullPath); //$wildcard = ($file == '*'); if ($wildcard) { MUtil::dirToArray($fullPath, $files); // $registerAlias = true; } else { $fullPath .= '.php'; if (file_exists($fullPath)) { $files[] = $fullPath; } } //mdump($files); if (count($files)) { $classOriginal = $classAlias; foreach ($files as $file) { $fileName = basename($file, '.php'); //$classPath = $wildcard ? $file : $fullPath; $className = strtolower($classOriginal ?: $fileName); //self::$autoload[$className] = $classPath; $fileName = str_replace([$fullPath . DIRECTORY_SEPARATOR, '.php'], '', $file); $fileName = str_replace(DIRECTORY_SEPARATOR, '\\', $fileName); $nsClass = $wildcard ? str_replace('*', $fileName, $namespace) : $namespace; class_alias($nsClass, $className); //mdump('*************'.$className . ' - ' . $classPath . ' - ' . $nsClass); //mdump('*************'.$className . ' - ' . $nsClass); } } //mdump(self::$autoload); //mdump(self::$classAlias); mdump('import result = ' . $fullPath); return $fullPath; }
private function getControlFromNode($fieldClass, $node) { if ($this->ignoreElement($node)) { return NULL; } if ($fieldClass == 'css' || $fieldClass == 'style') { $control = $this->handleNodeCSS($node); } elseif ($fieldClass == 'javascript') { $control = $this->handleNodeJavascript($node); } else { if ($this->painter->hasMethod($fieldClass)) { //$control = new $fieldClass(); $control = new MBaseControl($fieldClass); $control->tag = $fieldClass; } else { $control = new MBaseControl('mhtml'); $control->tag = $fieldClass; } $this->getPropertiesFromNode($control, $node); \Maestro\Utils\MUtil::setIfNull($control->property->name, $control->property->id); $this->handleChildren($control, $node); if ($attributes['base'] != '') { $file = $this->path . '/' . $attributes['base'] . '.xml'; $baseControls = $this->fetch($file, $this->context); $first = $baseControls[0]; $first->addControl($control); return $first; } } return $control; }
public function setName($name) { \Maestro\Utils\MUtil::setIfNull($this->property->id, $name); $this->property->name = $name; }
public static function arrayMergeOverwrite($arr1, $arr2) { foreach ($arr2 as $key => $value) { if (array_key_exists($key, $arr1) && is_array($value)) { $arr1[$key] = MUtil::arrayMergeOverwrite($arr1[$key], $arr2[$key]); } else { $arr1[$key] = $value; } } return $arr1; }
public static function mpanel($control) { $control->options->title = $control->property->title; if ($control->property->close != '') { $control->options->closable = true; // captura o evento 'onClose' para executar action definida em $control->close $action = addslashes(Action::parseAction($control->close)); $onClose = "function(e) {manager.doAction(\"{$action}\");}"; $control->options->onClose = (object) $onClose; } $inner = ""; if ($control->property->menubar) { $inner .= $control->property->menubar->generate(); } if ($control->hasControls()) { foreach ($control->controls as $child) { $inner .= $child->generate(); } } $tools = ''; if ($control->property->tools) { $control->property->tools->id = $control->property->id > '_tools'; $control->options->tools = "#{$control->tools->id}"; $tools = self::mdiv($control->property->tools); } MUtil::setIfNull($control->style->width, "100%"); $control->plugin = 'panel'; self::setPluginClass($control); //self::createJS($control); $attributes = self::getAttributes($control); return <<<EOT <div {$attributes}> {$inner} </div> {$tools} EOT; }
public function generate() { // panel $panel = new MBaseControl('mpanel'); $panel->property->title = $this->property->title; $panel->style->width = $this->style->width; $panel->property->close = $this->property->close; $panel->property->class = $this->property->class; //mdump('--'); //mdump($this->style->border); $panel->options->border = isset($this->style->border) ? $this->style->border : false; $panel->generate(); //gera o panel para obter todos os atributos // propriedades $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"; // define o layout com base na classe bootstrap do form \Maestro\Utils\MUtil::setIfNull($this->property->layout, "horizontal"); $this->setClass("form-{$this->property->layout}"); // neste tema o mform é constituído de 3 blocos principais: fields, buttons e help $fields = $buttons = $help = ""; if ($this->fields != NULL) { $fields = $this->generateFields(); } if ($this->buttons != NULL) { $buttons = $this->generateButtons(); } if ($this->help != NULL) { $help = $this->generateHelp(); } // toolbar if ($this->toolbar) { $this->toolbar->tag = 'header'; $this->toolbar->setClass('datagrid-toolbar'); $toolbar = $this->toolbar->generate(); } // menubar if ($this->property->menubar) { $menubar = $this->property->menubar->generate(); } // por default, o método de submissão é POST \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST"); if ($this->property->onsubmit) { $this->page->onSubmit($this->property->onsubmit, $this->property->id); } // se o form tem fields com validators, define onSubmit $validators = ''; if (count($this->property->toValidate)) { $this->page->onSubmit("\$('#{$this->property->id}').form('validate')", $this->id); $validators = implode(',', $this->property->bsValidator); } // obtem o codigo html via template $result = $this->painter->fetch('mform', $this, ['panel' => $panel, 'fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'validators' => $validators, 'menubar' => $menubar, 'toolbar' => $toolbar]); return $result; }
public function saveAssociationById(PersistentObject $object, $associationName, $id) { $object->retrieveAssociation($associationName); $associationIds = \Maestro\Utils\MUtil::parseArray($object->{'get' . $associationName}()->getId()); //$ids = array_unique(array_merge($associationIds, MUtil::parseArray($id))); $classMap = $object->getClassMap(); $commands = array(); //$this->_saveAssociationById($object, $associationName, $commands, $classMap, $ids); $this->_saveAssociationById($object, $associationName, $commands, $classMap, $id); $this->execute($classMap->getDb(), $commands); }