Files
OMS/app/setup/lib/controller.php
2026-01-04 19:08:31 +08:00

70 lines
2.2 KiB
PHP

<?php
/**
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class setup_controller extends base_controller{
function __construct(&$app)
{
parent::__construct($app);
$helper = kernel::single('base_view_helper');
foreach(get_class_methods($helper) as $method){
$this->_compiler()->set_view_helper($method,'base_view_helper');
}
}//End Function
function display($tmpl_file,$app_id=null, $fetch = false){
array_unshift($this->_files,$tmpl_file);
$this->_vars = $this->pagedata;
if($p = strpos($tmpl_file,':')){
$object = kernel::service('tpl_source.'.substr($tmpl_file,0,$p));
if($object){
$tmpl_file_path = substr($tmpl_file,$p+1);
$last_modified = $object->last_modified($tmpl_file_path);
}
}else{
$tmpl_file = realpath(APP_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file);
$last_modified = filemtime($tmpl_file);
}
if(!$last_modified){
//无文件
}
$compile_id = $this->compile_id($tmpl_file);
if($object){
$compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
}else{
$compile_code = $this->_compiler()->compile_file($tmpl_file);
}
eval('?>'.$compile_code);
array_shift($this->_files);
}
function fetch($tmpl_file,$app_id=null){
ob_start();
$this->display($tmpl_file, $app_id);
$content = ob_get_contents();
ob_end_clean();
return $content;
}
}