コード例 #1
0
 public function addModule($matches)
 {
     $matches[1] = str_replace(' AS ', ' as ', $matches[1]);
     $moduleVar = explode(' as ', $matches[1]);
     $moduleVar[0] = trim($moduleVar[0]);
     if (isset($moduleVar[1])) {
         $moduleVar[1] = trim($moduleVar[1]);
     }
     $query = explode('?', $moduleVar[0]);
     $file = __MODULE__ . '/' . $this->getModulePath($query[0]);
     if (file_exists($file)) {
         $this->className = $this->getClassName($query[0]);
         $nameSpace = isset($moduleVar[1]) ? $moduleVar[1] : $query[0];
         if (isset($this->module[$nameSpace])) {
             $this->throwException(E_ACTION_BUILD_NAMESPACEBEENUSED, $nameSpace);
         }
         $this->module[$nameSpace] = $this->className[1];
         if (isset($query[1])) {
             parse_str($query[1], $this->args[$nameSpace]);
         }
         if (!isset($this->moduleFile[$file])) {
             $this->moduleFile[$file] = filemtime($file);
             $this->moduleSource .= $this->replaceClassName(mgGetScript(php_strip_whitespace($file)), $this->className);
         }
     } else {
         $this->throwException(E_ACTION_TEMPLATEBUILD_MODULEFILENOTEXISTS, $file);
     }
     return NULL;
 }
コード例 #2
0
ファイル: action_build.php プロジェクト: baijd/magike
 public function addModule($matches)
 {
     $file = __MODULE__ . '/' . $this->getModulePath($matches);
     if (file_exists($file)) {
         $this->className = $this->getClassName($matches);
         if (!isset($this->moduleFile[$file])) {
             $this->moduleFile[$file] = filemtime($file);
             $this->moduleSource = $this->replaceClassName(mgGetScript(php_strip_whitespace($file)), $this->className);
             $this->moduleSource .= $this->extendsSrouce;
         }
     } else {
         $this->throwException(E_ACTION_BUILD_MODULEFILENOTEXISTS, $file);
     }
     return NULL;
 }
コード例 #3
0
ファイル: lib.magike_module.php プロジェクト: baijd/magike
 protected function loadModel($model, $triggerException = true)
 {
     if (isset($this->globalModel[$model])) {
         return $this->globalModel[$model];
     } else {
         mgTrace();
         $modelFile = __MODEL__ . '/model.' . $model . '.php';
         $object = mgFileNameToClassName($model);
         if (!class_exists($object . 'Model')) {
             if (file_exists($modelFile)) {
                 require_once $modelFile;
                 if (isset($this->stack['action']['application_cache_path'])) {
                     file_put_contents($this->stack['action']['application_cache_path'], __DEBUG__ ? file_get_contents($this->stack['action']['application_cache_path']) . mgGetScript(file_get_contents($modelFile)) : file_get_contents($this->stack['action']['application_cache_path']) . mgGetScript(php_strip_whitespace($modelFile)));
                 }
                 if (isset($this->stack['action']['application_config_path'])) {
                     $files = array();
                     require $this->stack['action']['application_config_path'];
                     $files[$modelFile] = filemtime($modelFile);
                     mgExportArrayToFile($this->stack['action']['application_config_path'], $files, 'files');
                 }
             } else {
                 if ($triggerException) {
                     $this->throwException(E_MODELFILENOTEXISTS, $modelFile);
                 } else {
                     return NULL;
                 }
             }
         }
         $object = $object . 'Model';
         $tmp = new $object();
         $this->globalModel[$model] = $tmp;
         mgTrace(false);
         mgDebug('Load Model', $tmp);
         return $tmp;
     }
 }
コード例 #4
0
ファイル: core.init.php プロジェクト: baijd/magike
function __autoload($className)
{
    global $stack;
    $found = false;
    $fileName = strtolower(__LIB__ . '/lib.' . mgClassNameToFileName($className) . '.php');
    if (file_exists($fileName)) {
        require_once $fileName;
        $found = true;
    }
    if (!$found) {
        $fileName = strtolower(__MODEL__ . '/model.' . mgClassNameToFileName($className) . '.php');
        if (file_exists($fileName)) {
            require_once $fileName;
            $found = true;
        }
        if (isset($stack['action']['application_cache_path']) && isset($stack['action']['application_config_path']) && $found) {
            file_put_contents($stack['action']['application_cache_path'], file_get_contents($stack['action']['application_cache_path']) . mgGetScript(php_strip_whitespace($fileName)));
            $files = array();
            require $stack['action']['application_config_path'];
            $files[$fileName] = filemtime($fileName);
            mgExportArrayToFile($stack['action']['application_config_path'], $files, 'files');
        }
    }
}