Esempio n. 1
0
 function __construct()
 {
     $this->property = new \StdClass();
     $this->data = Manager::getData();
     $numArgs = func_num_args();
     //$className = get_class($this);
     //$names = array(
     //    'namespace' => array_slice(explode('\\', $className), 0, -1),
     //    'classname' => strtolower(join('', array_slice(explode('\\', $className), -1)))
     //);
     if ($numArgs == 0) {
         //    $this->className = $names['classname'];
         $this->args = array();
     } elseif ($numArgs == 1) {
         $arg0 = func_get_arg(0);
         if (is_string($arg0)) {
             $this->tag = $arg0;
             $this->args = array();
         } else {
             $this->tag = 'mbasecontrol';
             $this->args = $arg0;
         }
     } elseif ($numArgs == 2) {
         $this->tag = func_get_arg(0);
         $this->args = func_get_arg(1);
     }
     $this->onCreate();
 }
Esempio n. 2
0
 public function __construct($name = NULL)
 {
     $this->property = new \StdClass();
     $this->className = strtolower(get_class($this));
     $this->property->name = $name;
     $this->data = Manager::getData();
 }
Esempio n. 3
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. 4
0
 function __construct()
 {
     $this->property = new \StdClass();
     $this->data = Manager::getData();
     $numArgs = func_num_args();
     if ($numArgs == 0) {
         $this->tag = 'mbasecontrol';
         $this->args = array();
     } elseif ($numArgs == 1) {
         $arg0 = func_get_arg(0);
         if (is_string($arg0)) {
             $this->tag = $arg0;
             $this->args = array();
         } else {
             $this->tag = 'mbasecontrol';
             $this->args = $arg0;
         }
     } elseif ($numArgs == 2) {
         $this->tag = func_get_arg(0);
         $this->args = func_get_arg(1);
     }
     $this->onCreate();
 }
Esempio n. 5
0
 public static function getData()
 {
     return Manager::getData();
 }
Esempio n. 6
0
 public function setData($dataArray)
 {
     MFrontController::setData($dataArray);
     $this->data = Manager::getData();
 }
Esempio n. 7
0
 /**
  * Retorna a URL em execução.
  * Retorna o endereço URL da página sendo executada.
  *
  * @returns (string) URL address
  *
  */
 public static function getCurrentURL($parametrized = false)
 {
     $url = self::$request->getURL();
     if ($url == '') {
         $url = self::$baseURL . '/' . self::getConf('maestro.options.dispatcher');
     }
     if ($parametrized) {
         $url .= "?";
         foreach (Manager::getData() as $key => $value) {
             if (strpos($key, "__") !== 0 && strpos($key, "grid") !== 0) {
                 $value = urlencode($value);
                 $url .= $key . "=" . $value . "&";
             }
         }
     }
     return $url;
 }
Esempio n. 8
0
 private function getControlsFromInclude($node, &$controls, $handleChildren = false)
 {
     if ($node) {
         if ($this->ignoreElement($node)) {
             return NULL;
         }
         $attributes = $node->attributes();
         if ($attributes['file']) {
             $fileName = $attributes['file'];
             $file = $this->path . '/' . $this->processValue($fileName);
         } elseif ($attributes['component']) {
             $fileName = $attributes['component'];
             $file = Manager::getAppPath('components/' . $fileName);
         }
         $extension = pathinfo($file, PATHINFO_EXTENSION);
         if ($extension == 'xml') {
             $xmlControls = new MXMLControls();
             $xmlControls->loadFile($file, $this->context);
             foreach ($xmlControls->get() as $c) {
                 $controls->addControl($c);
             }
         } elseif ($extension == 'html') {
             $control = new MBaseControl('mhtml');
             $control->tag = 'div';
             $template = new \Maestro\UI\MTemplate(dirname($file));
             $template->multicontext(['page' => Manager::getPage(), 'data' => Manager::getData(), 'template' => $template, 'painter' => Manager::getPainter()]);
             $control->inner = $template->fetch($fileName);
             $controls->addControl($control);
         } elseif ($extension == 'php') {
             include_once $file;
             $fileName = end(explode('/', $fileName)) ?: $fileName;
             $className = str_replace('.' . $extension, '', $fileName);
             $c = new $className();
             $this->getPropertiesFromNode($c, $node);
             if ($handleChildren) {
                 $controls->addControl($c);
             } else {
                 $controls[] = $c;
             }
         }
     }
 }
Esempio n. 9
0
 /**
  * Método auxiliar para montagem de grids de dados. 
  * Retorna objeto JSON relativo a um criteria ou um array de dados. Os atributos "page" (número da página, 0-based) 
  * e "rows" (número de linhas a serem retornadas) devem estar devidos em $this->data.
  * @param basecriteria|array $source Fonte de dados.
  * @param boolean $rowsOnly Se o JSON deve conter apenas os dados das linhas ou se deve conter também o total.
  * @param integer total 
  * @return JSON object
  */
 public function gridDataAsJSON($source, $rowsOnly = false, $total = 0)
 {
     $data = Manager::getData();
     $result = (object) ['rows' => array(), 'total' => 0];
     if ($source instanceof \Maestro\Persistence\Criteria\BaseCriteria) {
         $criteria = $source;
         $result->total = $criteria->asQuery()->count();
         if ($data->page > 0) {
             $criteria->range($data->page, $data->rows);
         }
         $source = $criteria->asQuery();
     }
     if ($source instanceof \Maestro\Database\MQuery) {
         $result->rows = $source->asObjectArray();
     } elseif (is_array($source)) {
         $rows = array();
         foreach ($source as $row) {
             $r = new \StdClass();
             foreach ($row as $c => $col) {
                 $field = is_numeric($c) ? 'F' . $c : $c;
                 $r->{$field} = "{$col}";
             }
             $rows[] = $r;
         }
         $result->rows = $rows;
         $result->total = $total != 0 ? $total : count($rows);
     }
     if ($rowsOnly) {
         return \Maestro\Services\MJSON::encode($result->rows);
     } else {
         return \Maestro\Services\MJSON::encode($result);
     }
 }