Example #1
0
 public static function buildSelect()
 {
     $menu = new self();
     $menu->checkPermissions = false;
     $pages = \Meta\Builder::read('pages');
     $items = $menu->buildItems($pages);
     return $menu->buildMenuHierarchy($items);
 }
Example #2
0
 public function checkErrors()
 {
     switch ($this->command) {
         case 'querySql':
             if (isset($this->paramValues[0])) {
                 $err = \Meta\Builder::sqlError($this->paramValues[0]);
                 if ($err) {
                     throw new \Exception(t('Error on SQL query validation: ' . $err));
                 }
             }
             break;
     }
 }
Example #3
0
 public function checkErrors()
 {
     // check for the linked frame page
     if ($this->linkedPage) {
         $pages = \Meta\Builder::read('pages');
         if (!isset($pages[$this->linkedPage])) {
             throw new \Exception(t('The page defined as sub-frame `' . $this->linkedPage . '` not exists'));
         } else {
             if ($pages[$this->linkedPage]['pageType'] != 'frame') {
                 throw new \Exception(t('The associated page frame (page ' . $this->linkedPage . ') not has been defined of type FRAME.'));
             }
         }
     }
     // test for urls and substitutions
     \Meta\Builder::replaceURL($this->extraArgs);
     parent::checkErrors();
 }
Example #4
0
 public static function pageExists($page)
 {
     $pages = \Meta\Builder::read('pages');
     return isset($pages[$page]);
 }
Example #5
0
 public function blockHtml($html)
 {
     // formatacao util para criar links ou expressoes html puros
     // ex.: <a href="usuarios/[id]">Meu link [id]</a>
     return \Meta\Builder::replaceOutput($this->row, $html);
 }
Example #6
0
    $pages = \Meta\Builder::read('pages');
    $page = new \Meta\Builder\Page($path, $pages[$path]);
    $object = $page->objects[$oid];
    echo json_encode($object);
});
route_add('builder/analizesql/*/*', function ($pname, $oid) {
    $errors = array();
    $cols = array();
    $sql = \Meta\Builder::replaceSQL(\Meta\Core\Db::sqlNormalize($_REQUEST['query']));
    $statement = \Meta\Core\Db::getPDO()->prepare($sql);
    if ($statement->execute()) {
        for ($i = 0; $i < $statement->columnCount(); $i++) {
            $meta = $statement->getColumnMeta($i);
            //            $cols[$meta['name']] = $meta['native_type'];
            $cols[$meta['name']] = $meta['name'];
        }
    } else {
        $errors = $statement->errorInfo();
    }
    // ataualiza colunas do SQL na base (array)
    $pages = \Meta\Builder::read('pages');
    $pages[$pname]['objects'][$oid]['sqlCols'] = $cols;
    \Meta\Builder::write('pages', $pages);
    echo json_encode(array('errors' => $errors, 'sql_cols' => $cols));
});
route_add('builder/print-metadata/*', function ($pname) {
    $pages = \Meta\Builder::read('pages');
    print_header();
    highlight_string("<?php\n" . var_export($pages[$pname], true));
    print_footer();
});
Example #7
0
 public static function checkCmds($cmds = array())
 {
     $cmdInstance = new self();
     foreach ($cmds as $cmd) {
         $cmd instanceof \Meta\Builder\Command;
         if (!method_exists($cmdInstance, $cmd->command)) {
             throw new \Exception(t('The command defined "' . $cmd->command . '" not exists in class Command'));
         }
         switch ($cmd->command) {
             case 'executePhpFunction':
                 $callback = $cmd->getArgument(0);
                 if (!function_exists($callback)) {
                     throw new \Exception(t('The defined public function "' . $callback . '" not found in system'));
                 }
                 break;
             case 'fetchFromSql':
                 $sql = $cmd->getArgument(0);
                 $this->errors[] = \Meta\Builder::sqlError($sql);
                 break;
             case 'fetchFromTable':
             case 'saveRecordInTable':
             case 'deleteRowFromTable':
                 $table = $cmd->getArgument(0);
                 if (!Db::tableExists($table)) {
                     throw new \Exception(t("The table '{$table}' was not found on database"));
                 }
                 break;
         }
     }
 }
Example #8
0
 public function checkErrors()
 {
     // check template
     if ($this->templateFile) {
         $file = abspath('views/' . $this->templateFile);
         if (!file_exists($file)) {
             throw new \Exception(t("The template '{$this->templateFile}' not found."));
         }
     }
     // sql query errors
     if ($this->query) {
         $error = \Meta\Builder::sqlError($this->query);
         if ($error) {
             throw new \Exception($error);
         }
     }
     parent::checkErrors();
 }
Example #9
0
 /**
  * Callback to execute before render page.
  * It allows a developer to modify behaviors and customize app.
  */
 public static function beforeRender($page_name, $callback)
 {
     static $pages;
     if (!$pages) {
         $pages = \Meta\Builder::read('pages');
     }
     // assina no globals
     self::$beforeRender[$page_name] = $callback;
 }
Example #10
0
 public function checkErrors()
 {
     // check for type-specific errors
     switch ($this->type) {
         case 'select':
         case 'radio':
             if ($this->optionsSql) {
                 $err = \Meta\Builder::sqlError($this->optionsSql);
                 if ($err) {
                     throw new \Exception(t('Error on SQL of field ' . $this->name . ': ' . $err));
                 }
             } else {
                 if ($this->optionsFunction && !function_exists($this->optionsFunction)) {
                     throw new \Exception(t("The public function defined `{$this->optionsFunction}` not exists"));
                 }
             }
             break;
         case 'btn_validated':
         case 'btn_simple':
             if ($this->commands) {
                 \Meta\Builder\Commands::checkCmds($this->commands);
             }
             break;
     }
     // check for validations errors
     foreach ($this->validations as $valid) {
         $valid instanceof Validation;
         $valid->checkErrors();
     }
 }