Exemplo n.º 1
0
    /**
     * @package load.class.php
     * @method view()
     * @desc Loads a view
     * @example 1) $this->Load->View('Inicio/view.php');
     *          2) $data['mi_var']; $this->Load->View('folder/view.php',$data);
     *          3) $this->putContent('{list}',$listValues);$this->Load->View('folder/view.php');
     * @since 0.1 Beta
     */
    public function view($view, $data = array(), $ReturnResult = false)
    {
        // False: Imprime resultado, true devuelve resultado
        $this->ReturnResult = $ReturnResult;
        $view_file = 'app/views/' . $view;
        $view_file_path = SYSTEM_PATH . $view_file;
        $view_exist = false;
        if (fk_file_exists($view_file)) {
            $view_exist = true;
        }
        if ($view_exist == FALSE) {
            //view no existe
            if ($GLOBALS['FKORE']['RUNNING']['app']['interactive'] == true) {
                try {
                    throw new FkException("Archivo: " . $view_file . " no existe ");
                } catch (FkException $e) {
                    $e->description = 'Es requerido el archivo view <b>' . $view_file . '</b>,
					                    sin embargo no fue encontrado';
                    $e->solution = 'Cree el archivo <b>' . $view_file . '</b> y agregue el codigo requerido.
					                 Ejemplo:';
                    $e->solution_code = fk_str_format('<?php fk_header();?>
Este es el archivo ' . $view_file . '
<?php fk_footer();?> ', 'html');
                    $e->show('code_help');
                }
            } else {
                die("<fieldset><h1>Error 404 -1: La p&aacute;gina no existe </h1></fieldset>");
            }
        } else {
            // Preprocesar la vista
            return $this->PreProcessFile($view_file_path, $data);
        }
    }
Exemplo n.º 2
0
 /**
  *@package db_mysql
  *@method query()
  *@desc Send a MySQL query
  *@since v0.1 beta
  *@return bool & Populates $this->resource
  * */
 public function query($query)
 {
     $this->sql_query = $query;
     if ($this->resource = mysql_query($query)) {
         return TRUE;
     } else {
         // is hanled error
         $error_no = mysql_errno();
         $is_handed = false;
         if (array_key_exists($error_no, $this->arr_handled_errors)) {
             $is_handed = true;
         }
         if ($is_handed == true) {
             $this->error_code = $this->arr_handled_errors[$error_no];
             return FALSE;
         } else {
             // if uknown error
             try {
                 throw new FkException("Mysql Error");
             } catch (FkException $e) {
                 $e->description = 'Mysql Respondi&oacute;:' . mysql_error() . '</b>';
                 $e->solution = 'Verifique la consulta';
                 $e->solution_code = fk_str_format($query, 'html');
                 $e->error_code = $error_no;
                 $e->show('code_help');
             }
             return FALSE;
         }
     }
     // End else
 }
Exemplo n.º 3
0
function __($str)
{
    if (!defined($str)) {
        return fk_str_format($str, 'html:no-tags');
    } else {
        return fk_str_format(constant($str), 'html:no-tags');
    }
}
Exemplo n.º 4
0
    /**
     *@package fkore
     *@method Initialize()
     *@since v0.1 beta
     *@desc  runs freekore
     **/
    public static function InitializeFK($P_GET)
    {
        //load view
        if (isset($P_GET['url'])) {
            $url_rs = self::url_processor($P_GET['url']);
        }
        if (!isset($url_rs)) {
            $url_rs['controller'] = 'IndexController';
            $url_rs['module'] = 'index';
            $url_rs['action'] = 'index';
            $url_rs['file_controller'] = 'index.controller.php';
            $url_rs['file_view'] = 'index/index.view.php';
        }
        $controller_exist = false;
        if (file_exists(SYSTEM_PATH . 'app/controllers/' . $url_rs['file_controller'])) {
            $controller_exist = true;
        }
        if ($controller_exist == true) {
            // controler existe
            // view existe
            //EJECUTAR CONTROLLER
            require SYSTEM_PATH . 'app/controllers/' . $url_rs['file_controller'];
            //EJECUTAR CONTROLLER
            $page = new $url_rs['controller']($url_rs);
        } else {
            // controler no existe
            if ($GLOBALS['FKORE']['RUNNING']['app']['interactive'] == true) {
                if (self::dynamic_page($url_rs['file_controller'], $url_rs) == false) {
                    // MOSTRAR ERROR Y AYUDA
                    $cont_control = str_replace('__ControlerName__', $url_rs['controller'], file_get_contents(SYSTEM_PATH . 'freekore/build/templates/controller-layout.tpl'));
                    try {
                        throw new FkException('El Controlador "' . $url_rs['file_controller'] . '" no existe');
                    } catch (FkException $e) {
                        $e->description = 'Es requerido el archivo Controllador <b>' . $url_rs['file_controller'] . '</b>
						                    , sin embargo no fue encontrado.';
                        $e->solution = '1. Crea la clase <b>' . $url_rs['controller'] . '</b> en el archivo
						                    <b>' . $url_rs['file_controller'] . '</b> ';
                        $e->solution_code = fk_str_format($cont_control, 'html');
                        $e->show('code_help');
                    }
                }
            } else {
                if (self::dynamic_page($url_rs['file_controller'], $url_rs)) {
                    if (file_exists(SYSTEM_PATH . 'app/errors/error_404.php')) {
                        require SYSTEM_PATH . 'app/errors/error_404.php';
                    } else {
                        require SYSTEM_PATH . 'freekore/sys_messages/page/default_error_404.php';
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
 /**
  *@package AppController
  *@method page_keywords()
  *@desc sets the Html meta keywords
  *@since v0.1 beta
  * */
 public function page_keywords($p)
 {
     # Keywords de la pagina
     $p = fk_str_format($p, 'html');
     fk_page('KEYWORDS', $p);
 }
Exemplo n.º 6
0
 /**
  *@package db_oracle
  *@method query()
  *@desc Send a Oracle query
  *@since v0.1 beta
  *@return bool & Populates $this->resource
  * */
 public function query($query)
 {
     $this->sql_query = $query;
     // Prepare the statement
     $this->resource = oci_parse(self::$conn, $query);
     if (!$this->resource) {
         $e = oci_error($this->conn);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Perform the logic of the query
     $ok = oci_execute($this->resource);
     if ($ok) {
         return TRUE;
     } else {
         //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
         // is hanled error
         $o_err = oci_error($this->resource);
         $is_handed = false;
         if (array_key_exists($o_err['code'], $this->arr_handled_errors)) {
             $is_handed = true;
         }
         if ($is_handed == true) {
             $this->error_code = $this->arr_handled_errors[$o_err['code']];
             return FALSE;
         } else {
             $this->error_code = $o_err['code'];
             // if uknown error
             try {
                 throw new FkException("Oracle Error");
             } catch (FkException $e) {
                 $e->description = 'Oracle Respondi&oacute;:' . $o_err['message'] . '</b>';
                 $e->solution = 'Verifique la consulta';
                 $e->solution_code = fk_str_format($query, 'html');
                 $e->error_code = $o_err['code'];
                 $e->show('code_help');
             }
             return FALSE;
         }
     }
     return $this->resource;
 }
Exemplo n.º 7
0
 private static function url_processor($url, $mod_rewrite = true)
 {
     $file_lst = array();
     if ($mod_rewrite) {
         //----------------
         //MOD REWRITE TRUE
         //----------------
         $url_div = explode('/', $url);
         $tot = count($url_div);
         $cnt = 0;
         for ($i = 0; $i < $tot; $i++) {
             if (trim($url_div[$i]) != '') {
                 $cnt++;
                 $file_lst['url'][$cnt]['value'] = $url_div[$i];
                 $file_lst['url'][$cnt]['is_file_or_dir'] = 'dir';
             }
         }
         // last is file
         $file_lst['url'][$cnt]['is_file_or_dir'] = 'file';
     } else {
         //----------------
         //MOD REWRITE FALSE
         //----------------
         $_slash = '::';
         $_q_mark = '?';
         $url_and_vars = explode($_q_mark, $url);
         $the_url = $url_and_vars[0];
         $the_vars = @$url_and_vars[1];
         $url_div = explode($_slash, $the_url);
         $tot = count($url_div);
         $cnt = 0;
         for ($i = 0; $i < $tot; $i++) {
             if (trim($url_div[$i]) != '') {
                 $cnt++;
                 $file_lst['url'][$cnt]['value'] = $url_div[$i];
                 $file_lst['url'][$cnt]['is_file_or_dir'] = 'dir';
             }
         }
         // last is file
         $file_lst['url'][$cnt]['is_file_or_dir'] = 'file';
         //get prams
         $the_vars = trim($the_vars, '{');
         $the_vars = trim($the_vars, '}');
         $the_vars_arr = explode(';', $the_vars);
         $file_lst['get_vars'] = array();
         if (count($the_vars_arr) > 0) {
             foreach ($the_vars_arr as $k => $v) {
                 $new_v = explode('=', $v);
                 if (isset($new_v[0]) && isset($new_v[1])) {
                     $file_lst['get_vars'][$new_v[0]] = $new_v[1];
                 }
             }
         }
     }
     // return controller , view  &  model files
     $file_view = '';
     $file_controller = '';
     $controller = '';
     $module = '';
     $action = 'index';
     $i = 0;
     foreach ($file_lst['url'] as $k => $v) {
         // Controller
         if ($i == 0) {
             $module = $v['value'];
             $file_view .= $v['value'] . '/';
             $file_controller = $v['value'] . CONTROLLER . '.php';
             $controller = fk_str_format($v['value'], 'php_var', 'camelcase');
             $controller = $controller . 'Controller';
         }
         if ($i == 1) {
             $action = $v['value'];
             $file_view .= $v['value'] . VIEW . '.php';
         }
         $i++;
     }
     // end foreach
     $ext = substr($file_view, strlen($file_view) - 9, strlen($file_view));
     if ($ext != VIEW . '.php') {
         $file_view .= 'index' . VIEW . '.php';
     }
     $file_rs = array();
     $file_rs['module'] = fk_str_format($module, 'php_var');
     $file_rs['action'] = fk_str_format($action, 'php_var');
     $file_rs['file_view'] = $file_view;
     $file_rs['file_controller'] = $file_controller;
     $file_rs['controller'] = $controller;
     $file_rs['directory_track'] = $file_lst['url'];
     $file_rs['get_vars'] = @$file_lst['get_vars'];
     return $file_rs;
 }