Exemple #1
0
 public function buildCache()
 {
     $this->pathCache = array();
     $pathModel = new Database();
     $pathModel->fetch(array('table' => 'table.paths'), array('function' => array($this, 'pushPathData')));
     mgExportArrayToFile(__CACHE__ . '/permalink/permalink.php', $this->pathCache, 'permalink');
 }
 private function addCacheListenFile()
 {
     $files = array();
     require __RUNTIME__ . '/template/' . mgPathToFileName($this->fileName) . '.cnf.php';
     $files = array_merge($files, $this->moduleFile);
     mgExportArrayToFile(__RUNTIME__ . '/template/' . mgPathToFileName($this->fileName) . '.cnf.php', $files, 'files');
 }
 public function buildCache()
 {
     require __DIR__ . '/action/action_build.php';
     $actionBuild = new ActionBuild();
     $actionBuild->addModule($this->path);
     mgExportArrayToFile(__RUNTIME__ . '/module_output/' . $this->path . '.cnf.php', $actionBuild->moduleFile, 'files');
     file_put_contents(__RUNTIME__ . '/module_output/' . $this->path . '.mod.php', $actionBuild->moduleSource . $actionBuild->extendsSoruce);
 }
 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 buildCache()
 {
     $filterModel = $this->loadModel('comment_filters');
     $filter = $filterModel->fetch(array('table' => 'table.comment_filters'));
     $filterByType = array();
     foreach ($filter as $val) {
         if (!isset($filterByType[$val['comment_filter_type']])) {
             $filterByType[$val['comment_filter_type']] = array();
         }
         $filterByType[$val['comment_filter_type']][$val['comment_filter_name']] = $val['comment_filter_value'];
         if ('all' == $val['comment_filter_type']) {
             $filterByType['comment'][$val['comment_filter_name']] = $val['comment_filter_value'];
             $filterByType['ping'][$val['comment_filter_name']] = $val['comment_filter_value'];
         }
     }
     mgExportArrayToFile(__CACHE__ . '/comment_filter/comment_filter.php', $filterByType, 'filter');
 }
Exemple #6
0
 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;
     }
 }
Exemple #7
0
 public function buildCache()
 {
     $this->pathCache = array();
     $pathModel = new Database();
     $pathModel->fetch(array('table' => 'table.paths'), array('function' => array($this, 'pushPathData')));
     foreach ($this->pathCache as $key => $val) {
         mgExportArrayToFile(__CACHE__ . '/action/' . $key . '.php', $val, 'pathConfig', true);
     }
 }
Exemple #8
0
 public function buildCache()
 {
     $this->initStaticValue();
     mgExportArrayToFile(__CACHE__ . '/static_var/static_var.php', $this->staticVar, 'staticVar');
 }
Exemple #9
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');
        }
    }
}