예제 #1
0
 public function loadViewState()
 {
     $this->viewState = mrequest($this->id);
     if ($this->viewState) {
         $s = base64_decode($this->viewState);
         $this->variables = unserialize($s);
     }
 }
예제 #2
0
 public function addControl($control)
 {
     $control->addEvent("click", "dojo.publish('{$this->getName()}ChangeValue',[manager.byId('{$control->getId()}').get('value')]);", false);
     $control->setName($this->name);
     parent::addControl($control);
     $value = $this->value ?: mrequest($this->name) ?: $this->default;
     $control->setChecked($control->getValue() == $value);
 }
예제 #3
0
 public function getControlsFromOptions($options)
 {
     $name = $this->name;
     $controls = array();
     if (!$options) {
         $options = array();
     }
     if (!is_array($options)) {
         $options = array($options);
     }
     $n = count($options);
     for ($i = 0; $i < $n; $i++) {
         // we will accept an array of MCheckBox ...
         if ($options[$i] instanceof MCheckBox) {
             $controls[] = clone $options[$i];
         } else {
             // we will accept an array of MOption ...
             if ($options[$i] instanceof MOption) {
                 $oName = $name . '_' . $options[$i]->name;
                 $oLabel = $options[$i]->label;
                 $oValue = $options[$i]->value;
                 $oChecked = $options[$i]->checked || $oValue == mrequest($oName);
             } elseif (is_array($options[$i])) {
                 $oName = $name . '_' . $i;
                 $oLabel = $options[$i][0];
                 $oValue = $options[$i][1];
                 $oChecked = $oValue == mrequest($oName);
             } else {
                 $oName = $name . '_' . $i;
                 $oLabel = $oValue = $options[$i];
                 $oChecked = $oValue == mrequest($oName);
             }
             $option = new MCheckBox($oName, $oValue, $oLabel, $oChecked, $oLabel);
             if ($options[$i] instanceof MOption) {
                 $option->attrs = $options[$i]->attrs;
             }
             $controls[] = $option;
         }
     }
     return $controls;
 }
예제 #4
0
 /**
  * Compatibility
  * @param <type> $data
  */
 public function eventHandler($data = NULL)
 {
     $eventTarget = mrequest('__EVENTTARGET') ?: mrequest('event');
     if ($eventTarget) {
         if (method_exists($this, $eventTarget)) {
             $this->{$eventTarget}($data);
         } else {
             $eventTarget .= '_click';
             if (method_exists($this, $eventTarget)) {
                 $this->{$eventTarget}($data);
             }
         }
     }
 }
예제 #5
0
 public function request($vars, $component_name = '', $from = 'ALL')
 {
     $value = '';
     if ($vars != '') {
         $value = mrequest($vars, $from);
         if (!isset($value)) {
             if (!$component_name) {
                 $value = $this->state->get($vars);
             } else {
                 $value = $this->state->get($vars, $component_name);
             }
         }
     }
     return $value;
 }
예제 #6
0
 public function invokeHandler($m, $handler)
 {
     global $context, $module, $action, $item, $session, $page, $auth, $perms, $navbar, $theme, $history, $self, $url;
     if ($handler == '') {
         return false;
     }
     //$this->data = $data;
     $this->action = $handler;
     $app = Manager::getApp();
     if ($m == '' || $m == $app) {
         $module = $app;
         $path = Manager::getAppPath() . '/controllers/';
     } else {
         $module = $m;
         $path = Manager::getModulePath($module, 'controllers/');
     }
     //mdump("Handler:invokeHandler: [$module][$handler]");
     $context = Manager::getContext();
     $action = $context->getAction();
     $self = $context->getAction();
     $item = mrequest('item');
     $session = Manager::getSession();
     $navbar = new MNavigationBar();
     //$view = Manager::getView($module, 'handler', $action);
     $page = $this->theme;
     $url = Manager::getCurrentURL();
     $auth = Manager::getAuth();
     $perms = Manager::getPerms();
     $theme = $this->theme;
     $file = $path . $handler . '.inc.php';
     //mdump('Handler:invokeHandler: file : ' . $file);
     if ($return = file_exists($file)) {
         include $file;
     }
     return $return;
 }
예제 #7
0
 /**
  * Inicialização do Framework.
  * Método chamado para inicializar os atributos da classe Manager e registrar os AutoloadPaths.
  * @param string $configFile Arquivo de configuração do Maestro
  * @param string $basePath Diretório onde o Maestro está instalado
  * @param string $app Aplicação a ser executada.
  */
 public static function init()
 {
     $debug = self::getConf('maestro.debug.enabled');
     if ($debug) {
         $mode = self::getConf('maestro.options.mode') == 'DEV' ? Tracy\Debugger::DEVELOPMENT : Tracy\Debugger::PRODUCTION;
         Tracy\Debugger::enable($mode, self::$maestroPath . DIRECTORY_SEPARATOR . 'log');
         Tracy\Debugger::$logSeverity = self::getConf('maestro.debug.severity');
         Tracy\Debugger::$strictMode = self::getConf('maestro.debug.strictMode');
         Tracy\Debugger::$maxDepth = self::getConf('maestro.debug.maxDepth');
         // default: 3
         Tracy\Debugger::$maxLen = self::getConf('maestro.debug.maxLen');
         // default: 150
     }
     error_reporting(self::getConf('maestro.debug.severity'));
     // Maestro 1.0 compatibility
     // self::addAutoloadClass('mlogin', self::$classPath . '/Security/MLoginMaestro1.php');
     // Session
     self::$session = new MSession();
     self::$session->init($_REQUEST['sid'] === '0' ? 0 : mrequest('sid'));
     self::$baseURL = self::$request->getBaseURL(false);
     Manager::logMessage('[RESET_LOG_MESSAGES]');
     /*
             if (self::$java = ($_SERVER["SERVER_SOFTWARE"] == "JavaBridge")) {
        require_once (self::$home . "/java/Java.inc");
        self::$javaContext = java_context();
        self::$javaServletContext = java_context()->getServletContext();
             }
     * 
     */
     self::getLogin();
     self::$msg = new MMessages(self::getSession()->lang ?: self::getOptions('language'));
     self::$msg->loadMessages();
     self::$mode = self::getOptions("mode");
     date_default_timezone_set(self::getOptions("timezone"));
     setlocale(LC_ALL, self::getOptions("locale"));
     //self::$mad = self::getConf('maestro.mad.module');
     self::$app = self::getConf('maestro.app');
     register_shutdown_function("shutdown");
 }
예제 #8
0
 public function generateData()
 {
     if ($this->query instanceof RetrieveCriteria) {
         $this->query = $this->query->asQuery();
     }
     $this->orderBy = mrequest('orderby');
     $this->rowCount = $this->query->count();
     if ($this->ordered = isset($this->orderBy)) {
         $this->query->msql->setOrderBy($this->orderBy);
         $this->state->set('orderby', $this->orderBy, $this->name);
     }
     if ($this->pageLength) {
         $this->navigator = new MGridNavigator($this->pageLength, $this->rowCount, $this->getURL(), $this);
         $this->navigator->setGridParameters($this->pageLength, $this->rowCount, $this->getURL(), $this);
         $this->firstIndex = $this->navigator->idxFirst;
         //  $this->data = $this->query->getPage($this->navigator->getPageNumber());
         $range = new MRange($this->pageNumber, $this->pageLength, $this->rowCount);
         ////mdump($range);
         $this->query->setRange($range);
         $this->data = $this->query->getResult();
     } else {
         $this->data = $this->query->getResult();
         $this->navigator = null;
     }
 }
예제 #9
0
 /**
  * Inicialização básica do Framework.
  * Inicializa "variáveis globais", sessão, log e FrontController.
  */
 public static function initialize()
 {
     if (self::$instance->java = $_SERVER["SERVER_SOFTWARE"] == "JavaBridge") {
         require_once self::$instance->home . "/java/Java.inc";
         self::$instance->javaContext = java_context();
         self::$instance->javaServletContext = java_context()->getServletContext();
     }
     self::$instance->getObject('login');
     self::$instance->session = new MSession();
     self::$instance->session->init(mrequest('sid'));
     self::$msg = new MMessages(self::$instance->getOptions('language'));
     self::$msg->loadMessages();
     self::$instance->mode = self::$instance->getOptions("mode");
     date_default_timezone_set(self::$instance->getOptions("timezone"));
     setlocale(LC_ALL, self::$instance->getOptions("locale"));
     self::$instance->setLog('manager');
     self::$instance->mad = self::$instance->conf['mad']['module'];
     self::$instance->controller = MFrontController::getInstance();
 }
예제 #10
0
 function addActionSelect($idSelect = '')
 {
     if ($idSelect != '') {
         $id = $this->name . '_SELECT';
         $this->idSelect = $idSelect ?: $id . '_CHECKED';
         $selecteds = mrequest($this->idSelect) ?: Manager::getData()->{$this->idSelect};
         $this->selecteds = explode(':', $selecteds);
         $this->select = new MGridActionSelect($this, $id);
         $this->addColumn($this->select);
     }
 }
예제 #11
0
 public function __construct()
 {
     parent::__construct('page' . uniqid());
     $this->scripts = new MScripts($this->name);
     $this->fileUpload = mrequest('__ISFILEUPLOAD') == 'yes';
     $this->content = new MBaseControl();
     $template = mrequest('__TEMPLATE') ?: (Manager::getConf('theme.template') ?: 'index');
     $this->setTemplateName($template);
     $this->setTemplate();
     $this->styleSheetCode = '';
     $this->renderType = "page";
     $this->renderId = $this->name;
     ob_start();
 }
예제 #12
0
function mrequest($vars, $from = 'ALL', $order = '')
{
    if (is_array($vars)) {
        foreach ($vars as $v) {
            $values[$v] = mrequest($v, $from);
        }
        return $values;
    } else {
        $value = NULL;
        // Seek in all scope?
        if ($from == 'ALL') {
            // search in REQUEST
            if (is_null($value)) {
                $value = isset($_REQUEST[$vars]) ? $_REQUEST[$vars] : NULL;
            }
            if (is_null($value)) {
                // Not found in REQUEST? try GET or POST
                // Order? Default is use the same order as defined in php.ini ("EGPCS")
                if (!isset($order)) {
                    $order = ini_get('variables_order');
                }
                if (strpos($order, 'G') < strpos($order, 'P')) {
                    $value = isset($_GET[$vars]) ? $_GET[$vars] : NULL;
                    // If not found, search in post
                    if (is_null($value)) {
                        $value = isset($_POST[$vars]) ? $_POST[$vars] : NULL;
                    }
                } else {
                    $value = isset($_POST[$vars]) ? $_POST[$vars] : NULL;
                    // If not found, search in get
                    if (is_null($value)) {
                        $value = isset($_GET[$vars]) ? $_GET[$vars] : NULL;
                    }
                }
            }
            // If we still didn't have the value
            // let's try in the global scope
            if (is_null($value) && strpos($vars, '[') === false) {
                $value = isset($_GLOBALS[$vars]) ? $_GLOBALS[$vars] : NULL;
            }
            // If we still didn't has the value
            // let's try in the session scope
            if (is_null($value)) {
                if ($vars) {
                    $value = isset($_SESSION[$vars]) ? $_SESSION[$vars] : NULL;
                }
            }
        } else {
            if ($from == 'GET') {
                $value = isset($_GET[$vars]) ? $_GET[$vars] : NULL;
            } elseif ($from == 'POST') {
                $value = isset($_POST[$vars]) ? $_POST[$vars] : NULL;
            } elseif ($from == 'SESSION') {
                $value = isset($_SESSION[$vars]) ? $_SESSION[$vars] : NULL;
            } elseif ($from == 'REQUEST') {
                $value = isset($_REQUEST[$vars]) ? $_REQUEST[$vars] : NULL;
            }
        }
        return $value;
    }
}
예제 #13
0
 /**
  * Compatibility: obtem um valor do request
  */
 public static function getFormValue($field)
 {
     return mrequest($field);
 }