Ts\Helper\AppInstall::moveAllApplicationResources PHP Method

moveAllApplicationResources() public static method

移动Ts中应用中所有的静态资源
Author: Seven Du ([email protected])
public static moveAllApplicationResources ( )
    public static function moveAllApplicationResources()
    {
        $handle = opendir(TS_APPLICATION);
        while (($file = readdir($handle)) !== false) {
            if (in_array($file, array('.', '..'))) {
                continue;
            }
            $manageFile = sprintf('%s/%s/manage.json', TS_APPLICATION, $file);
            if (!file_exists($manageFile) || !($manageInfo = json_decode(file_get_contents($manageFile), true))) {
                continue;
            } elseif (!isset($manageInfo['resource'])) {
                $manageInfo['resource'] = '_static';
            }
            Filesystem::mirror(sprintf('%s/%s/%s', TS_APPLICATION, $file, $manageInfo['resource']), sprintf('%s/%s/app/%s', TS_ROOT, TS_STORAGE, strtolower($file)));
        }
        closedir($handle);
    }

Usage Example

コード例 #1
0
ファイル: OpenSociax.php プロジェクト: medz/thinksns-4
    tsdefine('THEME_NAME', 'stv1');
}
//默认静态文件、模版文件目录
tsdefine('THEME_PATH', ADDON_PATH . '/theme/' . THEME_NAME);
tsdefine('THEME_URL', ADDON_URL . '/theme/' . THEME_NAME);
tsdefine('THEME_PUBLIC_PATH', THEME_PATH . '/_static');
tsdefine('THEME_PUBLIC_URL', THEME_URL . '/_static');
tsdefine('APP_PUBLIC_PATH', APP_PATH . '/_static');
// tsdefine('APP_PUBLIC_URL', APP_URL.'/_static');
tsdefine('APP_TPL_PATH', APP_PATH . '/Tpl/default');
tsdefine('APP_TPL_URL', APP_URL . '/Tpl/default');
tsdefine('CANVAS_PATH', SITE_PATH . '/config/canvas/');
/* 临时兼容代码,新方法开发中 */
$timer = sprintf('%s%s/app/timer', TS_ROOT, TS_STORAGE);
if (!file_exists($timer) || time() - file_get_contents($timer) > 604800) {
    \Ts\Helper\AppInstall::moveAllApplicationResources();
    // 移动应用所有的资源
    \Medz\Component\Filesystem\Filesystem::mkdir(dirname($timer), 0777);
    file_put_contents($timer, time());
}
define('APP_PUBLIC_URL', sprintf('%s%s/app/%s', SITE_URL, TS_STORAGE, strtolower(APP_NAME)));
//设置语言包
setLang();
/*
 * 新应用入口文件
 */
if (file_exists(sprintf('%s/bootstrap.php', APP_PATH))) {
    Ts::import(APP_PATH, 'bootstrap', '.php');
    /*
     * 兼容旧的应用
     */