Changeset 743
- Timestamp:
- 01/03/09 14:02:08 (6 months ago)
- Files:
-
- 0.5/library/kumbia/helpers/helpers.php (modified) (1 diff)
- 0.5/library/kumbia/helpers/utils.php (modified) (1 diff)
- 0.5/library/kumbia/kumbia.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
0.5/library/kumbia/helpers/helpers.php
r95 r743 24 24 * @see Registry 25 25 */ 26 require_once "library/kumbia/registry/registry.php";26 require_once 'library/kumbia/registry/registry.php'; 27 27 28 28 /** 29 29 * Tags 30 30 */ 31 require_once "library/kumbia/helpers/tags.php";31 require_once 'library/kumbia/helpers/tags.php'; 32 32 33 33 /** 34 34 * Utils 35 35 */ 36 require_once "library/kumbia/helpers/utils.php";36 require_once 'library/kumbia/helpers/utils.php'; 37 37 38 38 0.5/library/kumbia/helpers/utils.php
r733 r743 287 287 function get_params($params){ 288 288 $data = array(); 289 $i = 0;290 289 foreach ($params as $p) { 291 290 if(is_string($p) && preg_match('/(\w+): (.*)/', $p, $match)){ 292 291 $data[$match[1]] = $match[2]; 293 292 } else { 294 $data[$i] = $p; 295 $i++; 293 $data[] = $p; 296 294 } 297 295 } 0.5/library/kumbia/kumbia.php
r741 r743 18 18 * @author Andres Felipe Gutierrez <andresfelipe@vagoogle.net> 19 19 * @copyright 2008-2008 Emilio Rafael Silveira Tovar <emilio.rst at gmail.com> 20 * @copyright 2007-200 8 Deivinson Jose Tejeda Brito <deivinsontejeda at gmail.com>20 * @copyright 2007-2009 Deivinson Jose Tejeda Brito <deivinsontejeda at gmail.com> 21 21 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt GNU/GPL 22 22 * @version SVN:$id 23 23 * @see Object 24 24 */ 25 require "library/kumbia/object.php";25 require 'library/kumbia/object.php'; 26 26 /** 27 27 * Esta es la clase principal del framework, contiene metodos importantes … … 68 68 * @var string 69 69 */ 70 static public $content = "";70 static public $content = ''; 71 71 /** 72 72 * Almacena el objeto Smarty … … 74 74 * @var string 75 75 */ 76 private static $_smarty_object = "";76 private static $_smarty_object = ''; 77 77 /** 78 78 * Lista de todos los modelos disponibles en la aplicacion … … 134 134 * Inicializar el ExceptionHandler 135 135 */ 136 set_exception_handler(array( "Kumbia", "manage_exceptions"));136 set_exception_handler(array('Kumbia', 'manage_exceptions')); 137 137 /** 138 138 * Crear el KUMBIA_PATH 139 139 */ 140 $delete_session_cache = false; 141 $path = join(array_slice(explode("/", dirname($_SERVER['PHP_SELF'])), 1, -1), "/"); 142 if (isset($_SESSION['KUMBIA_PATH'])) { 143 if ($path != $_SESSION['KUMBIA_PATH']) { 144 $delete_session_cache = true; 145 } 146 } 140 $path = dirname($_SERVER['PHP_SELF']); 147 141 $_SESSION['KUMBIA_PATH'] = $path; 148 if ($ _SESSION['KUMBIA_PATH']) {149 define('KUMBIA_PATH', "/" . $_SESSION['KUMBIA_PATH'] . "/");142 if ($path = '/') { 143 define('KUMBIA_PATH', '/'); 150 144 } else { 151 define('KUMBIA_PATH', "/"); 145 $path = str_replace($path,'public','');//substr($path, 0, -6) 146 define('KUMBIA_PATH', $path); 152 147 } 153 148 /** … … 170 165 * 171 166 */ 172 if (!isset($_SESSION['KUMBIA_MODULES'])) {173 $_SESSION['KUMBIA_MODULES'] = array();174 }175 if (!isset($_SESSION['KUMBIA_MODULES'][$_SESSION['KUMBIA_PATH']])) {176 $_SESSION['KUMBIA_MODULES'][$_SESSION['KUMBIA_PATH']] = array();177 }178 167 if (!isset($_SESSION['KUMBIA_MODULES'][$_SESSION['KUMBIA_PATH']][$active_app])) { 179 168 $_SESSION['KUMBIA_MODULES'][$_SESSION['KUMBIA_PATH']][$active_app] = array(); 180 169 if ($kumbia_config = Config::read('boot.ini')) { 181 $kumbia_config->modules->extensions = str _replace(" ", "", $kumbia_config->modules->extensions);182 $extensions = explode( ",", $kumbia_config->modules->extensions);170 $kumbia_config->modules->extensions = strtr($kumbia_config->modules->extensions,' ', ''); 171 $extensions = explode(',', $kumbia_config->modules->extensions); 183 172 foreach($extensions as $extension) { 184 $ex = explode( ".", $extension);185 if ($ex[0] == "kumbia") {173 $ex = explode('.', $extension); 174 if ($ex[0] == 'kumbia') { 186 175 $_SESSION['KUMBIA_MODULES'][$_SESSION['KUMBIA_PATH']][$active_app][] = "library/{$ex[0]}/{$ex[1]}/{$ex[1]}.php"; 187 176 } else { … … 197 186 * Cargar plug-ins de la aplicación 198 187 */ 199 if (!isset($_SESSION['KUMBIA_PLUGINS'])) {200 $_SESSION['KUMBIA_PLUGINS'] = array();201 }202 if (!isset($_SESSION['KUMBIA_PLUGINS'][$_SESSION['KUMBIA_PATH']])) {203 $_SESSION['KUMBIA_PLUGINS'][$_SESSION['KUMBIA_PATH']] = array();204 $_SESSION['KUMBIA_PLUGINS_CLASSES'][$_SESSION['KUMBIA_PATH']] = array();205 }206 188 if (!isset($_SESSION['KUMBIA_PLUGINS'][$_SESSION['KUMBIA_PATH']][$active_app])) { 207 189 $_SESSION['KUMBIA_PLUGINS'][$_SESSION['KUMBIA_PATH']][$active_app] = array(); … … 210 192 * Rutas a Plugins 211 193 */ 212 $config = Config::read( "config.ini");194 $config = Config::read('config.ini'); 213 195 $plugins_dir = "apps/{$config->$active_app->plugins_dir}"; 214 196 foreach(scandir($plugins_dir) as $plugin) { 215 if (strpos($plugin, ".php")) {197 if (strpos($plugin, '.php')) { 216 198 $_SESSION['KUMBIA_PLUGINS'][$_SESSION['KUMBIA_PATH']][$active_app][] = "{$plugins_dir}/$plugin";; 217 $plugin = str_replace( ".php", "", $plugin);199 $plugin = str_replace('.php', '', $plugin); 218 200 $_SESSION['KUMBIA_PLUGINS_CLASSES'][$_SESSION['KUMBIA_PATH']][$active_app][] = $plugin; 219 201 } … … 226 208 * Establecer el timezone para las fechas y horas 227 209 */ 228 $config = Config::read( "config.ini");210 $config = Config::read('config.ini'); 229 211 if (isset($config->kumbia->timezone)) { 230 212 date_default_timezone_set($config->kumbia->timezone); … … 246 228 * Rutas Base 247 229 */ 248 $config = Config::read( "config.ini");230 $config = Config::read('config.ini'); 249 231 //Aplicacion Activa 250 232 self::$active_app = $active_app = Router::get_application(); 251 233 //Directorio de controladores Activo 252 $controllers_dir = "apps/" . $config->$active_app->controllers_dir; 253 self::$active_controllers_dir = "apps/" . $config->$active_app->controllers_dir; 234 $controllers_dir = self::$active_controllers_dir = 'apps/' . $config->$active_app->controllers_dir; 254 235 //Directorio de modelos activo 255 $models_dir = "apps/" . $config->$active_app->models_dir; 256 self::$active_models_dir = "apps/" . $config->$active_app->models_dir; 236 $models_dir = self::$active_models_dir = 'apps/' . $config->$active_app->models_dir; 257 237 //Directorio de Vistas Activo 258 $views_dir = "apps/" . $config->$active_app->views_dir; 259 self::$active_views_dir = "apps/" . $config->$active_app->views_dir; 238 $views_dir = self::$active_views_dir = 'apps/' . $config->$active_app->views_dir; 260 239 //Directorio de Plugins Activo 261 $plugins_dir = "apps/" . $config->$active_app->plugins_dir; 262 self::$active_plugins_dir = $plugins_dir; 240 $plugins_dir = self::$active_plugins_dir = 'apps/' . $config->$active_app->plugins_dir; 263 241 //Directorio de Helpers Activo 264 $helpers_dir = "apps/" . $config->$active_app->helpers_dir; 265 self::$active_helpers_dir = $helpers_dir; 242 $helpers_dir = self::$active_helpers_dir = 'apps/' . $config->$active_app->helpers_dir; 266 243 /** 267 244 * Leer la configuración. La primera vez que se lee … … 351 328 * desde el core del framework 352 329 */ 353 if (Router::get_controller() == "builder"&& $config->$active_app->interactive) {354 Dispatcher::set_controller_dir( "library/kumbia/controller");330 if (Router::get_controller() == 'builder' && $config->$active_app->interactive) { 331 Dispatcher::set_controller_dir('library/kumbia/controller'); 355 332 } else { 356 333 Dispatcher::set_controller_dir($controllers_dir); … … 405 382 if (!empty($controller_name)) { 406 383 extract(self::$models, EXTR_OVERWRITE); 407 if (is_subclass_of($controller, "ApplicationController")) {384 if (is_subclass_of($controller, 'ApplicationController')) { 408 385 foreach($controller as $var => $value) { 409 386 $$var = $value; … … 434 411 */ 435 412 $view_cache_dir = null; 436 if ($controller_name != "") {413 if ($controller_name) { 437 414 /* 438 415 * Creando el directorio Cache … … 492 469 Kumbia::$_smarty_object->assign($_model_name, $_model); 493 470 } 494 Kumbia::$_smarty_object->display($action_name . ".tpl");471 Kumbia::$_smarty_object->display($action_name . '.tpl'); 495 472 Kumbia::$content = ob_get_contents(); 496 473 } … … 506 483 * Aqui verifica si existe un valor en minutos para el cache 507 484 */ 508 if (file_exists("$views_dir/layouts/" . $controller->template . ".phtml")) {485 if (file_exists("$views_dir/layouts/" . $controller->template . '.phtml')) { 509 486 ob_clean(); 510 487 if ($controller->get_layout_cache()) { … … 514 491 * para cada sesion 515 492 */ 516 if (!file_exists($view_cache_dir . "/layout")) {517 include "$views_dir/layouts/" . $controller->template . ".phtml";518 file_put_contents($view_cache_dir . "/layout", ob_get_contents());493 if (!file_exists($view_cache_dir . '/layout')) { 494 include "$views_dir/layouts/" . $controller->template . '.phtml'; 495 file_put_contents($view_cache_dir . '/layout', ob_get_contents()); 519 496 } else { 520 497 $time_cache = $controller->get_layout_cache(); 521 if ((time() - $time_cache * 60) < filemtime($view_cache_dir . "/layout")) {522 include $view_cache_dir . "/layout";498 if ((time() - $time_cache * 60) < filemtime($view_cache_dir . '/layout')) { 499 include $view_cache_dir . '/layout'; 523 500 } else { 524 include "$views_dir/layouts/" . $controller->template . ".phtml";525 file_put_contents($view_cache_dir . "/layout", ob_get_contents());501 include "$views_dir/layouts/" . $controller->template . '.phtml'; 502 file_put_contents($view_cache_dir . '/layout', ob_get_contents()); 526 503 } 527 504 } 528 505 } else { 529 include "$views_dir/layouts/" . $controller->template . ".phtml";506 include "$views_dir/layouts/" . $controller->template . '.phtml'; 530 507 } 531 508 Kumbia::$content = ob_get_contents(); … … 539 516 * para cada sesion 540 517 */ 541 if (!file_exists($view_cache_dir . "/layout")) {518 if (!file_exists($view_cache_dir . '/layout')) { 542 519 include "$views_dir/layouts/$controller_name.phtml"; 543 file_put_contents($view_cache_dir . "/layout", ob_get_contents());520 file_put_contents($view_cache_dir . '/layout', ob_get_contents()); 544 521 } else { 545 522 $time_cache = $controller->get_layout_cache(); 546 if ((time() - $time_cache * 60) < filemtime($view_cache_dir . "/layout")) {547 include $view_cache_dir . "/layout";523 if ((time() - $time_cache * 60) < filemtime($view_cache_dir . '/layout')) { 524 include $view_cache_dir . '/layout'; 548 525 } else { 549 526 include "$views_dir/layouts/" . $controller_name . ".phtml"; 550 file_put_contents($view_cache_dir . "/layout", ob_get_contents());527 file_put_contents($view_cache_dir . '/layout', ob_get_contents()); 551 528 } 552 529 } … … 613 590 if (!isset($config->$active_app->interactive) || !$config->$active_app->interactive) { 614 591 ob_end_clean(); 615 Kumbia::$content = "";592 Kumbia::$content = ''; 616 593 ob_start(); 617 594 } … … 633 610 private static function _init_models($models_dir) { 634 611 foreach(scandir($models_dir) as $model) { 635 if ( !in_array($model, array('.', '..', 'base'))) {636 if (is_dir($models_dir . "/" .$model)) {637 self::_init_models($models_dir . "/" .$model);638 } 639 } 640 if ( ereg("\.php$", $model)){612 if ( !in_array($model, array('.', '..', 'base'))) { 613 if (is_dir($models_dir.'/'.$model)) { 614 self::_init_models($models_dir.'/'.$model); 615 } 616 } 617 if (strpos($model, '.php')){ 641 618 require_once "$models_dir/$model"; 642 $model = str_replace( ".php", "", $model);643 $object_model = str _replace("_", " ", $model);619 $model = str_replace('.php', '', $model); 620 $object_model = strtr($model, '_', ' '); 644 621 $object_model = ucwords($object_model); 645 $object_model = str _replace(" ", "", $object_model);622 $object_model = strtr($object_model, ' ', ''); 646 623 if (!class_exists($object_model)) { 647 624 throw new KumbiaException("No se encontró la Clase \"$object_model\"", "Es necesario definir una clase en el modelo … … 649 626 } else { 650 627 self::$models[$object_model] = new $object_model(); 651 if (!is_subclass_of(self::$models[$object_model], "ActiveRecord")) {628 if (!is_subclass_of(self::$models[$object_model], 'ActiveRecord')) { 652 629 throw new KumbiaException("Error inicializando modelo \"$object_model\"", "El modelo '$model' debe ser una clase o sub-clase de ActiveRecord"); 653 630 } … … 708 685 */ 709 686 public static function is_model($model) { 710 if ( $model == '') {687 if (!$model) { 711 688 return false; 712 689 } … … 720 697 */ 721 698 public static function get_model_name($model) { 722 if ( $model == '') {699 if (!$model) { 723 700 return false; 724 701 } 725 $objModel = str _replace("_", " ", $model);702 $objModel = strtr($model, '_', ' '); 726 703 $objModel = ucwords($objModel); 727 $objModel = str _replace(" ", "", $objModel);704 $objModel = strtr($objModel, ' ', ''); 728 705 return $objModel; 729 706 } … … 734 711 */ 735 712 private static function _create_cache_dir($module_name, $controller_name){ 736 $view_cache_dir = "cache/" . session_id() . "/";737 if (!file_exists( "cache/" . session_id() . "/")) {713 $view_cache_dir = 'cache/' . session_id() . '/'; 714 if (!file_exists('cache/' . session_id() . '/')) { 738 715 mkdir($view_cache_dir); 739 716 } … … 792 769 */ 793 770 public static function stylesheet_link_tags() { 794 $imports = Registry::get( "KUMBIA_CSS_IMPORTS");771 $imports = Registry::get('KUMBIA_CSS_IMPORTS'); 795 772 if ($imports && is_array($imports)) { 796 773 foreach ($imports as $css) { … … 813 790 public static function route_to() { 814 791 $args = func_get_args(); 815 return call_user_func_array(array("Router", "route_to"), $args); 792 return Router::route_to($args); 793 //self::main(); 794 //return call_user_func_array(array("Router", "route_to"), $args); 816 795 } 817 796 /** … … 903 882 foreach(scandir($package_dir) as $file) { 904 883 if ($file != '.' && $file != '..') { 905 if (is_dir($package_dir . "/". $file)) {906 $files = self::_scandir_recursive($package_dir . "/". $file, $files);884 if (is_dir($package_dir . '/' . $file)) { 885 $files = self::_scandir_recursive($package_dir . '/' . $file, $files); 907 886 } else { 908 887 if (ereg("(.)+\.php$", $file)) { 909 $files[] = $package_dir . "/". $file;888 $files[] = $package_dir . '/' . $file; 910 889 } 911 890 } … … 920 899 */ 921 900 public static function import($package) { 922 $package_array = explode( ".", $package);923 $package_dir = "";924 $class = "";901 $package_array = explode('.', $package); 902 $package_dir = ''; 903 $class = ''; 925 904 if ($package_array[count($package_array) - 1] == '*') { 926 905 unset($package_array[count($package_array) - 1]); 927 $package_dir = join( ".", $package_array);906 $package_dir = join('.', $package_array); 928 907 $class = '*'; 929 908 } else { … … 931 910 } 932 911 if ($class == '*') { 933 $package_dir = str _replace('.', '/', $package_dir);912 $package_dir = strtr($package_dir, '.', '/'); 934 913 if (!file_exists($package_dir)) { 935 914 throw new kumbiaException("No existe el directorio '$package_dir'\n"); … … 983 962 * @see Dispatcher 984 963 */ 985 include_once "library/kumbia/dispatcher/dispatcher.php";964 include_once 'library/kumbia/dispatcher/dispatcher.php'; 986 965 /** 987 966 * @see Session 988 967 */ 989 include_once "library/kumbia/session/session.php";968 include_once 'library/kumbia/session/session.php'; 990 969 /** 991 970 * @see Controller 992 971 */ 993 include_once "library/kumbia/controller/controller.php";972 include_once 'library/kumbia/controller/controller.php'; 994 973 /** 995 974 * @see ApplicationController 996 975 */ 997 include_once "library/kumbia/controller/application/application.php";976 include_once 'library/kumbia/controller/application/application.php'; 998 977 /** 999 978 * @see StandardForm 1000 979 */ 1001 include_once "library/kumbia/controller/standard_form/standard_form.php";980 include_once 'library/kumbia/controller/standard_form/standard_form.php'; 1002 981 /** 1003 982 * @see BuilderController 1004 983 */ 1005 include_once "library/kumbia/controller/builder/builder.php";984 include_once 'library/kumbia/controller/builder/builder.php'; 1006 985 /** 1007 986 * @see Filter 1008 987 */ 1009 include_once "library/kumbia/filter/filter.php";988 include_once 'library/kumbia/filter/filter.php'; 1010 989 /** 1011 990 * @see Db 1012 991 */ 1013 include_once "library/kumbia/db/db.php";992 include_once 'library/kumbia/db/db.php'; 1014 993 /** 1015 994 * @see ActiveRecordBase 1016 995 */ 1017 include_once "library/kumbia/db/active_record_base/active_record_base.php";996 include_once 'library/kumbia/db/active_record_base/active_record_base.php'; 1018 997 /** 1019 998 * @see Flash 1020 999 */ 1021 include_once "library/kumbia/messages/flash.php";1000 include_once 'library/kumbia/messages/flash.php'; 1022 1001 /** 1023 1002 * @see Helpers 1024 1003 */ 1025 include_once "library/kumbia/helpers/helpers.php";1004 include_once 'library/kumbia/helpers/helpers.php'; 1026 1005 /** 1027 1006 * @see Benchmark 1028 1007 */ 1029 include_once 'library/kumbia/benchmark/benchmark.php';1008 //include_once 'library/kumbia/benchmark/benchmark.php'; 1030 1009 } 1031 1010 }