public function prase() { $this->module = array(); $this->args = array(); $this->moduleSource = ''; $this->extendsSrouce = ''; $this->moduleFile = array(); $this->findSection('module', 'addModule'); file_put_contents(__RUNTIME__ . '/template/' . mgPathToFileName($this->fileName) . '.mod.php', "<?php\n\$module = " . var_export($this->module, true) . ";\n" . "\$args = " . var_export($this->args, true) . ";\n?>" . $this->moduleSource . $this->extendsSrouce); $this->addCacheListenFile(); return $this->str; }
public function prase() { $this->include = array(); $this->include[$this->fileName] = filemtime($this->fileName); //循环连接所有文件 do { $this->found = false; $this->findSection('include', 'linkInclude'); } while ($this->found); //生成配置文件 mgExportArrayToFile(__RUNTIME__ . '/template/' . mgPathToFileName($this->fileName) . '.cnf.php', $this->include, 'files'); return $this->clearBOM($this->str); }
public function runAction() { $module = array(); //初始化module数组 $args = array(); //初始化args数组 $hasRun = array(); //已经运行的模块 $waitting = array(); //正在等待的模块 $this->stack['action']['application_cache_path'] = __RUNTIME__ . '/template/' . mgPathToFileName($this->compileFile) . '.mod.php'; $this->stack['action']['application_config_path'] = __RUNTIME__ . '/template/' . mgPathToFileName($this->compileFile) . '.cnf.php'; require $this->stack['action']['application_cache_path']; foreach ($module as $nameSpace => $object) { //创建module mgTrace(); $tmp = new $object(); mgTrace(false); mgDebug('Create Module', $tmp); if ($tmp->waittingFor && isset($module[$tmp->waittingFor]) && !isset($hasRun[$tmp->waittingFor])) { $waitting[$nameSpace] = $tmp; continue; } //运行模块入口函数runModule并将运行结果保存到临时堆栈中 mgTrace(); $stack = $tmp->runModule(isset($args[$nameSpace]) ? $args[$nameSpace] : array()); mgTrace(false); mgDebug('Run Module', $tmp); //将临时堆栈中的数据转移到全局堆栈中 $this->stack = $this->pushData(explode('.', $nameSpace), $stack, $this->stack); $hasRun[$nameSpace] = $object; } foreach ($waitting as $key => $object) { //运行模块入口函数runModule并将运行结果保存到临时堆栈中 mgTrace(); $stack = $object->runModule(isset($args[$key]) ? $args[$key] : array()); mgTrace(false); mgDebug('Run Module', $tmp); //将临时堆栈中的数据转移到全局堆栈中 $this->stack = $this->pushData(explode('.', $key), $stack, $this->stack); } $this->stack['action']['prase_time'] = substr(mgGetMicrotime() - $this->stack['action']['prase_time'], 0, 6); $this->stack['action']['content_type'] = "content-Type: {$this->stack['static_var']['content_type']}; charset={$this->stack['static_var']['charset']}"; //定义头文件 header($this->stack['action']['content_type']); $data = $this->stack; require __COMPILE__ . '/' . mgPathToFileName($this->compileFile) . '.php'; }