示例#1
0
文件: model.php 项目: abachi/MVC
 /**
  * Load model form cliprz_application models folder.
  *
  * @param (string) $model - class file name without .php extension, Please read the note below.
  * @param (string) $directory - The folder that contains the class without / ending.
  * @return require path/class and start new model class.
  * @access protected.
  *
  * @note about $model variable file name in cliprz_application models directory must be same class name,
  *  do not forget all file names and class name in cliprz_application models must be lowercase characters,
  *  As an example : file name (cliprz.php), class name (cliprz).
  */
 public static final function load($model, $directory = '')
 {
     $model_path = APP_PATH . 'models' . DS . c_trim_path($directory) . $model . '.php';
     if (file_exists($model_path)) {
         require_once $model_path;
         $model_class = (string) strtolower($model);
         self::$_models[$model_class] = new $model_class();
     } else {
         trigger_error($model . ' not found.');
     }
 }
示例#2
0
文件: router.php 项目: abachi/MVC
 /**
  * Add new rule to routing.
  *
  * @param (array) $_action.
  *  $_action :
  *   'regex'      - Add url mask you want to use.
  *   'class'      - Add controller class.
  *   'function'   - Add controller class method (function), By default take self::$default_function value.
  *   'parameters' - Add parameters to controller class method (function).
  *   'path'       - If controller class in subfolder inside controllers folder, put the path name here.
  *   'method'     - Request method to access routing, By default GET u can use (PUT|HEAD|POST|GET).
  * @access public.
  */
 public static function rule($_action)
 {
     if (is_array($_action)) {
         self::$_rule[] = array("regex" => isset($_action['regex']) ? (string) $_action['regex'] : null, "class" => isset($_action['class']) ? (string) $_action['class'] : null, "function" => isset($_action['function']) ? (string) $_action['function'] : (string) self::$default_function, "parameters" => isset($_action['parameters']) ? (array) $_action['parameters'] : null, "path" => isset($_action['path']) ? c_trim_path($_action['path']) . '/' : "", "method" => isset($_action['method']) ? strtoupper($_action['method']) : "GET");
     }
 }
示例#3
0
文件: uri.php 项目: abachi/MVC
 /**
  * Detects the Request URI and fix the query string.
  *
  * @access protected.
  * @author CodeIgniter.
  */
 protected static function request_uri()
 {
     if (!isset($_SERVER['REQUEST_URI']) || !isset($_SERVER['SCRIPT_NAME'])) {
         if (C_DEVELOPMENT_ENVIRONMENT == true) {
             trigger_error("REQUEST_URI or SCRIPT_NAME cannot access to the request.");
         } else {
             cliprz::system(error)->show_400();
         }
     } else {
         $request_uri = $_SERVER['REQUEST_URI'];
         if (strpos($request_uri, $_SERVER['SCRIPT_NAME']) === 0) {
             $request_uri = mb_substr($request_uri, c_mb_strlen($_SERVER['SCRIPT_NAME']));
         } else {
             if (strpos($request_uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) {
                 $request_uri = mb_substr($request_uri, c_mb_strlen(dirname($_SERVER['SCRIPT_NAME'])));
             }
         }
         if (strncmp($request_uri, '?/', 2) === 0) {
             $request_uri = mb_substr($request_uri, 2);
         }
         $parts = preg_split('#\\?#i', $request_uri, 2);
         $request_uri = $parts[0];
         if (isset($parts[1])) {
             $_SERVER['QUERY_STRING'] = $parts[1];
             parse_str($_SERVER['QUERY_STRING'], $_GET);
         } else {
             $_SERVER['QUERY_STRING'] = '';
             $_GET = array();
         }
         if ($request_uri == '/' || empty($request_uri)) {
             #return '/';
             return;
         }
         $request_uri = parse_url($request_uri, PHP_URL_PATH);
         $request_uri = str_replace(array('//', '../'), '/', $request_uri);
         $uri = c_trim_path($request_uri);
         unset($request_uri);
         return $uri;
     }
 }
示例#4
0
文件: cliprz.php 项目: abachi/MVC
 /**
  * load your library file to use.
  *
  * @param (string) $directory - The folder that contains the main library class without / ending.
  * @param (string) $class - class file name without .php extension, Please read the note below.
  * @return require path/class and start new library class.
  * @access public.
  *
  * @note about $class variable file name in system library directory must be same class name,
  *  do not forget all file names and class name in system library must be lowercase characters,
  *  As an example : file name (cliprz.php), class name (cliprz).
  */
 public static function library_use($directory, $class)
 {
     $include_path = SYS_PATH . "libraries" . DS . c_trim_path($directory) . DS . $class . '.php';
     if (file_exists($include_path)) {
         require_once $include_path;
         $controller_class = (string) strtolower(self::$library_prefix . $class);
         self::$_libraries[$controller_class] = new $controller_class();
     } else {
         trigger_error($include_path . ' library not found in cliprz system libraries.');
     }
 }
示例#5
0
文件: css.php 项目: abachi/MVC
 /**
  * CSS style url.
  *
  * @param (string) $filename - file name.
  * @param (boolean) $compress - Compress CSS file.
  * @access public.
  */
 public static function style($filename, $compress = false)
 {
     if (file_exists(self::path() . $filename)) {
         if ($compress == true) {
             self::initializing($filename);
             return c_url("public" . DS . "css" . DS . c_trim_path(self::$min) . DS . $filename);
         } else {
             return c_url("public" . DS . "css" . DS . $filename);
         }
     }
 }
示例#6
0
 /**
  * Get website url.
  *
  * @param (string) $path - path.
  */
 function c_url($path = '')
 {
     global $_config;
     return c_trim_path($_config['output']['url']) . DS . $path;
 }
示例#7
0
文件: view.php 项目: abachi/MVC
 /**
  * load images files from public folder.
  *
  * @param (string) $file - file name.
  * @param (string) $folder- folder name inside public folder.
  * @access public.
  * @return string (http(s)://www.example.example/public/images/$folder/$file).
  */
 public static function image($file, $folder = '')
 {
     global $_config;
     // Path example = http://example.example/public/css/$folder/$file
     $path = c_trim_path($_config['output']['url']);
     $path .= DS . self::$public . DS . "images" . DS;
     $path .= isset($folder) && !empty($folder) ? c_trim_path($folder) . DS : "";
     $path .= $file;
     return $path;
 }