Example #1
0
 function __construct($table = NULL, $key = NULL)
 {
     parent::__construct();
     $this->table = str_replace('table.', __DBPREFIX__, $table ? $table : 'table.' . str_replace('_model', '', mgClassNameToFileName(get_class($this))));
     $this->clearArgs();
     $this->key = $key ? $this->table . "." . $key : $this->findPrimaryKey();
 }
Example #2
0
 public function replaceClassNameCallback($matches)
 {
     if ($matches[2] == 'MagikeModule') {
         return "class {$this->className[1]} extends MagikeModule {{$matches[3]}}";
     } else {
         $path = explode('__', $this->className[1]);
         while (array_pop($path)) {
             $file = __MODULE__ . '/' . implode('/', $path) . 'module.' . mgClassNameToFileName($matches[2]) . '.php';
             $class = $this->className[1];
             $inpath = $path;
             array_push($inpath, $matches[2]);
             $inpath = implode('__', $inpath);
             if (isset($this->moduleFile[$file])) {
                 return "class {$class} extends {$inpath} {{$matches[3]}}\r\n";
             } else {
                 if (file_exists($file)) {
                     $this->moduleFile[$file] = filemtime($file);
                     $this->className = array($matches[2], $inpath);
                     $this->extendsSrouce .= $this->replaceClassName(mgGetScript(php_strip_whitespace($file)), $this->className);
                     return "class {$class} extends {$inpath} {{$matches[3]}}\r\n";
                     break;
                 }
             }
         }
     }
     $this->throwException(E_ACTION_BUILD_MODULECLASSNOTEXISTS, $matches[2]);
 }
Example #3
0
 private function runKernelModule()
 {
     $requireObjects = array();
     require __DIR__ . '/action/require_objects.php';
     foreach ($requireObjects as $file => $object) {
         require_once __DIR__ . '/kernel/' . $file;
         //创建核心模块
         mgTrace();
         $tmp = new $object();
         mgTrace(false);
         mgDebug('Create Kernel Module', $tmp);
         //运行入口函数
         $moduleName = mgClassNameToFileName($object);
         mgTrace();
         $this->stack[$moduleName] = $tmp->runModule();
         mgTrace(false);
         mgDebug('Run Kernel Module', $tmp);
     }
 }
Example #4
0
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');
        }
    }
}