00001 <?php
00021 if(!defined('ZIG_MVC_DEFAULT_METHOD'))define('ZIG_MVC_DEFAULT_METHOD', 'main');
00022 load_module('app_helper', MOD_INTERNAL);
00023
00024 $controllerName = url_segment(0);
00025 if(strpos($controllerName, '.') !== false){
00026
00027 preg_match('~(\w+)\.(\w+)~', $controllerName, $m);
00028 if((count($m) < 3)){
00029 exit(zTemplate::sysNumeric('pu500'));
00030 }
00031 $projectName = $m[1];
00032 if(!fstab_getProjectDirByName($projectName)){
00033 exit(zTemplate::sysNumeric('p404', $projectName));
00034 }
00035 $controllerName = $m[2];
00036 $methodName = url_segment(1);
00037 if($methodName){
00038 $args = url_segment(ZIG_URL_SEGMENT_PATH);
00039
00040 foreach(array(0, 1) as $i)unset($args[$i]);
00041 }else{
00042 $methodName = ZIG_MVC_DEFAULT_METHOD;
00043 $args = array();
00044 }
00045
00046 }else{
00047
00048 $projectName = fstab_getPrimaryProject();
00049 if(!$projectName){
00050 exit(zTemplate::sysNumeric('pnopri'));
00051 }
00052 $methodName = url_segment(1);
00053 $args = url_segment(ZIG_URL_SEGMENT_PATH);
00054 foreach(array(0, 1) as $i)unset($args[$i]);
00055
00056 }
00057 $args = array_values($args);
00058
00059 if(!$controllerName){
00060
00061 $controllerName = 'default';
00062 }
00063 if(!$methodName){
00064 $methodName = ZIG_MVC_DEFAULT_METHOD;
00065 }
00066 $app_data = array('prj' => $projectName, 'class' => $controllerName, 'method' => $methodName);
00067 if(isset($__Z__isRouter) && $__Z__isRouter){
00068 if(!defined('Z_PROJECT_NAME'))define('Z_PROJECT_NAME', $controllerName);
00069 }else{
00070 if(!defined('Z_PROJECT_NAME'))define('Z_PROJECT_NAME', $projectName);
00071 if(!defined('Z_CONTROLLER_NAME'))define('Z_CONTROLLER_NAME', $controllerName);
00072 if(!defined('Z_METHOD_NAME'))define('Z_METHOD_NAME', $methodName);
00073 }
00074 $projectDir = fstab_getProjectDirByName(Z_PROJECT_NAME);
00075 if(!is_dir(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.$projectDir)){
00076 exit(zTemplate::sysNumeric('pd404', Z_PROJECT_NAME, $projectDir));
00077 }
00078
00079 if(!defined('Z_PROJECT_DIR'))define('Z_PROJECT_DIR', $projectDir);
00080
00081 if(!defined('Z_PROJECT_ROOT'))define('Z_PROJECT_ROOT', ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR);
00082
00083 if(file_exists(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS."mvc.rewrite.php")){
00084 include_once(ZIGROOT.DRS.MOD_KEY_NAME_INTERNAL.DRS."parser".DRS.'prs_rewrite.php');
00085 $realUrlPath = rewriteMapParser::matchCurrentUrlPath(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS."mvc.rewrite.php");
00086 if($realUrlPath){
00087 $realUrlPathExploded = rewriteMapParser::explode($realUrlPath);
00088 $controllerName = $realUrlPathExploded[0][0];
00089 if(strpos($controllerName, '.')){
00090 preg_match('~(\w+)\.(\w+)~', $controllerName, $m);
00091 if((count($m) < 3)){
00092 exit(zTemplate::sysNumeric('pu500'));
00093 }
00094 $projectName = $m[1];
00095 if(!fstab_getProjectDirByName($projectName)){
00096 exit(zTemplate::sysNumeric('p404', $projectName));
00097 }
00098 $controllerName = $m[2];
00099 }
00100 $methodName = $realUrlPathExploded[0][1];
00101 $app_data = array('prj' => $projectName, 'class' => $controllerName, 'method' => $methodName);
00102 $args = $realUrlPathExploded[1];
00103 }
00104 }
00105
00106
00107 if(isset($isCacheReq) && $isCacheReq){
00108 $app_data['method'] = $methodName;
00109 $cacheSrc = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.Z_DIR_CACHE_MVC.DRS."full".DRS."$controllerName.$methodName.cache";
00110 if(file_exists($cacheSrc)){
00111 include($cacheSrc);
00112 exit;
00113 }
00114 }
00115
00116
00117 foreach(parse_ini_file(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.'zig.ini.php', false) as $key => $val){
00118 if(eregi('^on$', $val))$val = true;
00119 if(eregi('^off$', $val))$val = false;
00120 if(!defined($key)){define($key, $val);}
00121 }
00122
00123 include_once(ZIGROOT.DRS.Z_DIR_INCLUDE.DRS.'shared_helper.php');
00124 include_once(ZIGROOT.DRS.Z_DIR_INCLUDE.DRS.'unit_handler.php');
00125 ?>