From 8ae0a2d719e20d3835f4d3acedc85d1a9f235b64 Mon Sep 17 00:00:00 2001 From: wwccss Date: Thu, 25 Jul 2013 14:50:31 +0800 Subject: [PATCH] - move them to tools. --- build/tools/check.php | 212 ---------------------------------- build/tools/cn2tw.php | 18 --- build/tools/copylang.php | 17 --- build/tools/exportactions.php | 29 ----- build/tools/getallcommon.php | 28 ----- build/tools/initext.php | 73 ------------ build/tools/minifyfront.php | 107 ----------------- build/tools/preparetest.php | 60 ---------- build/tools/syncext.php | 100 ---------------- build/tools/tags.php | 22 ---- 10 files changed, 666 deletions(-) delete mode 100755 build/tools/check.php delete mode 100755 build/tools/cn2tw.php delete mode 100755 build/tools/copylang.php delete mode 100755 build/tools/exportactions.php delete mode 100755 build/tools/getallcommon.php delete mode 100755 build/tools/initext.php delete mode 100755 build/tools/minifyfront.php delete mode 100755 build/tools/preparetest.php delete mode 100755 build/tools/syncext.php delete mode 100755 build/tools/tags.php diff --git a/build/tools/check.php b/build/tools/check.php deleted file mode 100755 index f34fdb1bbc..0000000000 --- a/build/tools/check.php +++ /dev/null @@ -1,212 +0,0 @@ -getMethods(); - foreach($methods as $method) - { - $methodRef = new ReflectionMethod($method->class, $method->name); - if($methodRef->isPublic() and strpos($method->name, '__') === false) - { - $methodName = $method->name; - if(in_array($moduleName . '-' . strtolower($method->name), $whiteList)) continue; - if(strpos($methodName, 'ajax') !== false) continue; - - $exits = false; - foreach($lang->resource->$moduleName as $key => $label) - { - if(strtolower($methodName) == strtolower($key)) $exits = true; - } - if(!$exits) echo $moduleName . "\t" . $methodName . " not in the list. \n"; - } - } - } - } - - /* Checking extension files. */ - $extControlFiles = glob($modulePath . '/ext/control/*.php'); - if($extControlFiles) - { - foreach($extControlFiles as $extControlFile) - { - $methodFile = substr($extControlFile, strrpos($extControlFile, '/') + 1); - $methodName = substr($methodFile, 0, strpos($methodFile, '.')); - if(in_array($moduleName . '-' . strtolower($methodName), $whiteList)) continue; - if(strpos($methodName, 'ajax') !== false) continue; - - $exits = false; - foreach($lang->resource->$moduleName as $key => $label) - { - if(strtolower($methodName) == strtolower($key)) $exits = true; - } - if(!$exits) echo $moduleName . "\t" . $methodName . " not in the list. \n"; - } - } -} - -/* checking actions of every module. */ -echo '-------------lang checking-----------------' . "\n"; -include '../../module/common/lang/zh-cn.php'; -include '../../config/config.php'; -foreach(glob($moduleRoot . '*') as $modulePath) -{ - unset($lang); - $moduleName = basename($modulePath); - $mainLangFile = $modulePath . '/lang/zh-cn.php'; - if(!file_exists($mainLangFile)) continue; - $mainLines = file($mainLangFile); - - foreach($config->langs as $langKey => $langName) - { - if($langKey == 'zh-cn' or $langKey == 'zh-tw') continue; - $langFile = $modulePath . '/lang/' . $langKey . '.php'; - if(!file_exists($langFile)) continue; - $lines = file($langFile); - foreach($mainLines as $lineNO => $line) - { - if(strpos($line, '$lang') === false) - { - //if($line != $lines[$lineNO]) echo $moduleName . ' ' . $langKey . ' ' . $lineNO . "\n"; - } - else - { - list($mainKey, $mainValue) = explode('=', $line); - list($key, $value) = explode('=', $lines[$lineNO]); - if(trim($mainKey) != trim($key)) - { - $key = trim($key); - $lineNO = $lineNO + 1; - echo "module $moduleName need checking, command is:"; - echo " vim -O +$lineNO ../../module/$moduleName/lang/zh-cn.php +$lineNO ../../module/$moduleName/lang/en.php \n"; - break; - } - } - } - } - - foreach(glob($modulePath . '/ext/lang/zh-cn/*.php') as $extMainLangFile) - { - $extMainLines = file($extMainLangFile); - $extLangFile = basename($extMainLangFile); - $extEnFile = $modulePath . '/ext/lang/en/' . $extLangFile; - $extLines = file($extEnFile); - foreach($extMainLines as $lineNO => $line) - { - if(strpos($line, '$lang') === false) - { - //if($line != $lines[$lineNO]) echo $moduleName . ' ' . $langKey . ' ' . $lineNO . "\n"; - } - else - { - list($mainKey, $mainValue) = explode('=', $line); - list($key, $value) = explode('=', $extLines[$lineNO]); - if(trim($mainKey) != trim($key)) - { - $key = trim($key); - $lineNO = $lineNO + 1; - echo "module $moduleName need checking, command is:"; - echo " vim -O +$lineNO ../../module/$moduleName/ext/lang/zh-cn/$extLangFile +$lineNO ../../module/$moduleName/ext/lang/en/$extLangFile \n"; - break; - } - } - } - } -} - -echo '-------------php5.4 synatax checking-----------------' . "\n"; -class app {function loadLang() {}} -$app = new app; -$lang = new stdclass(); - -error_reporting(E_WARNING | E_STRICT ); -foreach(glob($moduleRoot . '*') as $modulePath) -{ - $moduleName = basename($modulePath); - $cnLangFile = $modulePath . '/lang/zh-cn.php'; - $enLangFile = $modulePath . '/lang/en.php'; - $configFile = $modulePath . '/config.php'; - - if(!isset($lang->$moduleName)) $lang->$moduleName = new stdclass(); - if(file_exists($cnLangFile)) include $cnLangFile; - if(file_exists($enLangFile)) include $enLangFile; - if(file_exists($configFile)) include $configFile; -} - -echo '-------------demo data checking. -----------------' . "\n"; -$demoSQL = file("../../db/demo.sql"); -foreach($demoSQL as $line => $sql) -{ - if(strpos($sql, 'INSERT') === false) continue; - - if(strpos($sql, $config->db->prefix . 'config') !== false or - strpos($sql, $config->db->prefix . 'company') !== false or - strpos($sql, $config->db->prefix . 'group') !== false) - { - die('line ' . ($line + 1) . " has error\n"); - } -} diff --git a/build/tools/cn2tw.php b/build/tools/cn2tw.php deleted file mode 100755 index 09656f3ac1..0000000000 --- a/build/tools/cn2tw.php +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env php - $targetLangFile"); - $defaultLang = file_get_contents($targetLangFile); - $targetLang = str_replace('zh-cn', $langDesc, $defaultLang); - file_put_contents($targetLangFile, $targetLang); -} -?> diff --git a/build/tools/copylang.php b/build/tools/copylang.php deleted file mode 100755 index d3478efe9d..0000000000 --- a/build/tools/copylang.php +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php - diff --git a/build/tools/exportactions.php b/build/tools/exportactions.php deleted file mode 100755 index 3bf58bdd0b..0000000000 --- a/build/tools/exportactions.php +++ /dev/null @@ -1,29 +0,0 @@ -getMethods(); - foreach($methods as $method) - { - $methodRef = new ReflectionMethod($method->class, $method->name); - if($methodRef->isPublic() and strpos($method->name, '__') === false) - { - echo "\$lang['action']['$moduleName']['$method->name'] = '$method->name';\n"; - } - } - echo "\n"; - } - } -} -?> diff --git a/build/tools/getallcommon.php b/build/tools/getallcommon.php deleted file mode 100755 index 226ec0ad1f..0000000000 --- a/build/tools/getallcommon.php +++ /dev/null @@ -1,28 +0,0 @@ - $maxLength) $maxLength = strlen($moduleName); -} - -foreach($modules as $modulePath) -{ - $moduleName = basename($modulePath); - if($moduleName == 'help' or $moduleName == 'editor') continue; - $langFile = $modulePath . "/lang/$langType.php"; - if(!file_exists($langFile)) continue; - include $langFile; - - $moduleTitle = ''; - if(isset($lang->$moduleName->common)) - { - $moduleTitle = $lang->$moduleName->common; - } - - echo "\$lang->editor->modules['$moduleName'] " . str_pad('', $maxLength - strlen($moduleName)) . "= '$moduleTitle';\n"; - -} diff --git a/build/tools/initext.php b/build/tools/initext.php deleted file mode 100755 index 2b6099b483..0000000000 --- a/build/tools/initext.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @package common - * @version $Id$ - * @link http://www.zentao.net - */ -include '../../config/config.php'; - -$modules = array(); -$moduleRoot = realpath('../../module/') . '/'; - -if(is_dir($moduleRoot)) -{ - if($dh = opendir($moduleRoot)) - { - while($module = readdir($dh)) - { - if(strpos(basename($module), '.') === false) $modules[] = $module; - } - closedir($dh); - } -} -else -{ - die("The module you input does not exist. \n"); -} - -foreach($modules as $module) -{ - /* 设定各个目录。*/ - $extRoot = $moduleRoot . DIRECTORY_SEPARATOR. $module . DIRECTORY_SEPARATOR . 'ext'; - $extControl = $extRoot . DIRECTORY_SEPARATOR . 'control'; - $extModel = $extRoot . DIRECTORY_SEPARATOR . 'model'; - $extView = $extRoot . DIRECTORY_SEPARATOR . 'view'; - $extCSS = $extRoot . DIRECTORY_SEPARATOR . 'css'; - $extJS = $extRoot . DIRECTORY_SEPARATOR . 'js'; - $extConfig = $extRoot . DIRECTORY_SEPARATOR . 'config'; - $extLang = $extRoot . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR; - - /* 建立各个扩展目录 */ - if(!file_exists($extRoot)) mkdir($extRoot, 0777); - if(!file_exists($extControl)) mkdir($extControl, 0777); - if(!file_exists($extModel)) mkdir($extModel, 0777); - if(!file_exists($extView)) mkdir($extView, 0777); - if(!file_exists($extCSS)) mkdir($extCSS, 0777); - if(!file_exists($extJS)) mkdir($extJS, 0777); - if(!file_exists($extConfig)) mkdir($extConfig, 0777); - if(!file_exists($extLang)) mkdir($extLang, 0777); - - /* Touch .gitkeep file. */ - touch($extControl . '/.gitkeep'); - touch($extModel . '/.gitkeep'); - touch($extView . '/.gitkeep'); - touch($extCSS . '/.gitkeep'); - touch($extJS . '/.gitkeep'); - touch($extConfig . '/.gitkeep'); - - /* 创建语言目录。*/ - $langs = array_keys($config->langs); - foreach($langs as $lang) - { - $langPath = $extLang . $lang; - if(!file_exists($langPath)) mkdir($langPath, 0777); - touch($langPath . '/.gitkeep'); - } - - echo "init $module ... \n"; -} diff --git a/build/tools/minifyfront.php b/build/tools/minifyfront.php deleted file mode 100755 index ab9c243d4e..0000000000 --- a/build/tools/minifyfront.php +++ /dev/null @@ -1,107 +0,0 @@ -langs); -$themes = array_keys($lang->themes); - -/* Create css files for every them and every lang. */ -foreach($langs as $lang) -{ - foreach($themes as $theme) - { - /* Common css files. */ - $cssCode = file_get_contents($themeRoot . 'default/yui.css'); - $cssCode .= file_get_contents($themeRoot . 'default/style.css'); - $cssCode .= file_get_contents($themeRoot . 'default/colorbox.css'); - $cssCode .= file_get_contents($themeRoot . 'default/chosen.css'); - $cssCode .= file_get_contents($themeRoot . 'default/treeview.css'); - $cssCode .= file_get_contents($themeRoot . 'default/datepicker.css'); - $cssCode .= file_get_contents($themeRoot . 'default/alert.css'); - - /* Css file for current lang and current them. */ - $cssCode .= file_get_contents($themeRoot . "lang/$lang.css"); - if($theme != 'default') - { - $themCode = file_get_contents($themeRoot . $theme . '/style.css'); - $cssCode .= str_replace('./images', "../$theme/images", $themCode); - } - - /* Combine them. */ - $cssFile = $themeRoot . "default/$lang.$theme.css"; - file_put_contents($cssFile, $cssCode); - - /* Compress it. */ - `java -jar ~/bin/yuicompressor/build/yuicompressor.jar --type css $cssFile -o $cssFile`; - } -} - -/* Create css files for every them and every lang. */ -foreach($langs as $lang) -{ - /* Common css files. */ - $cssCode = file_get_contents($themeRoot . 'default/jquery.mobile.css'); - $cssCode .= file_get_contents($themeRoot . 'default/m.style.css'); - - /* Css file for current lang and current them. */ - $cssCode .= file_get_contents($themeRoot . "lang/$lang.css"); - - /* Combine them. */ - $cssFile = $themeRoot . "default/m.$lang.default.css"; - file_put_contents($cssFile, $cssCode); - - /* Compress it. */ - `java -jar ~/bin/yuicompressor/build/yuicompressor.jar --type css $cssFile -o $cssFile`; -} diff --git a/build/tools/preparetest.php b/build/tools/preparetest.php deleted file mode 100755 index e9c9b8947b..0000000000 --- a/build/tools/preparetest.php +++ /dev/null @@ -1,60 +0,0 @@ - $database.sql;\n"; - $cmd .= "mysql -uroot $backupDatabase < $database.sql;\n"; - $cmd .= "rm -fr $database.sql"; - system($cmd); - } -} - -/* Restore stored backup databases. */ -function restore() -{ - global $databases; - foreach($databases as $database) - { - $backupDatabase = "back_$database"; - mysql_query("DROP DATABASE $database"); - mysql_query("CREATE DATABASE $database"); - $cmd = "mysqldump -u root $backupDatabase > $database.sql;\n"; - $cmd .= "mysql -uroot $database < $database.sql;\n"; - $cmd .= "rm -fr $database.sql"; - system($cmd); - } -} - -/* Connect to database. */ -function connectDB() -{ - global $config; - mysql_connect($config->db->host, $config->db->user, $config->db->password); -} diff --git a/build/tools/syncext.php b/build/tools/syncext.php deleted file mode 100755 index cad41b07ce..0000000000 --- a/build/tools/syncext.php +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env php -zentaophp->svnRoot = 'https://zentaophp.googlecode.com/svn/'; -$config->zentaophp->svnTrunk = 'trunk/'; -$config->zentaophp->svnTags = 'tags/'; - -$config->zentaopms->svnRoot = 'https://ZenTaoPMS.googlecode.com/svn/'; -$config->zentaopms->svnTrunk = 'trunk/'; -$config->zentaopms->svnTags = 'tags/'; - -if(count($argv) != 4) die(__FILE__ . " repo version releasetype:beta|alpa|stable\n"); - -$repo = $argv[1]; -$version = $argv[2]; -$release = $argv[3]; - -$sourceURL = $config->$repo->svnRoot . $config->$repo->svnTrunk; -$targetURL = $config->$repo->svnRoot . $config->$repo->svnTags . $repo . '_' . $version . '_' . $release . '_' . date('Ymd'); - -$svnCMD = "svn rm $targetURL -m 'remove it'; svn cp $sourceURL $targetURL -m 'tag $version of $repo'"; -system($svnCMD);