/src/tools/clean-xheditor.php
PHP | 275 lines | 238 code | 6 blank | 31 comment | 14 complexity | e47c68c41f4c55e7f7e6796a6c832fc1 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1
- <?php
- // ??????
- define('ABS_PATH',dirname(__FILE__));
- // ???????
- $op_files = array(
- array('D','demos'),
- array('D','jquery'),
- array('D','serverscript'),
- array('D','xheditor_emot'),
- array('C','src/xheditor-zh-cn.src.js','xheditor.js','translate'),
- array('D','src'),
- array('M','LGPL-LICENSE.txt','LGPL-LICENSE'),
- array('D','*.txt'),
- array('D','*.html'),
- array('D','*.min.js'),
- array('D','xheditor_plugins'),
- array('A','plugins'),
- array('M','xheditor_skin','skins'),
- array('D','skins/default'),
- array('D','skins/o2007blue'),
- array('D','skins/o2007silver'),
- array('D','skins/vista'),
- array('M','skins/nostyle','skins/default','process_css'),
- );
- foreach ($op_files as $action) {
- switch($action[0]) {
- // ?????
- case 'A':
- @mkdirs(ABS_PATH.'/'.$action[1]);
- break;
- // ????
- case 'D':
- foreach((array)glob($action[1]) as $file) {
- $abs_path = ABS_PATH.'/'.$file;
- if (is_dir($abs_path)) {
- @rmdirs($abs_path);
- echo "Delete floder: {$file}\n";
- } elseif(is_file($abs_path)) {
- @unlink($abs_path);
- echo "Delete file: {$file}\n";
- }
- }
- break;
- // ????
- case 'M':
- if (count($action)>=3) {
- @rename(ABS_PATH.'/'.$action[1], ABS_PATH.'/'.$action[2]);
- echo "Changed path ".$action[1]." to ".$action[2]."\n";
- // ??????
- if (isset($action[3])) {
- call_user_func($action[3], $action[1], $action[2]);
- }
- }
- break;
- // ????
- case 'C':
- if (count($action)>=3) {
- @copy(ABS_PATH.'/'.$action[1], ABS_PATH.'/'.$action[2]);
- echo "Copyed path ".$action[1]." to ".$action[2]."\n";
- // ??????
- if (isset($action[3])) {
- call_user_func($action[3], $action[1], $action[2]);
- }
- }
- break;
- }
- }
- // ??CSS
- function process_css($source,$target) {
- if ($source=='skins/nostyle' && $target=='skins/default') {
- $content = file_get_contents(ABS_PATH.'/'.$target.'/ui.css');
- $content = str_replace('.xhe_nostyle', '.xhe_default', $content);
- file_put_contents(ABS_PATH.'/'.$target.'/ui.css', $content);
- }
- }
- // ??
- function translate($source,$target) {
- $translates = array(
- array("xheditor_skin/","skins/"),
- array("xheditor_emot/","emots/"),
- array("[\w-\:]","[\w\-\:]"),
- array("tool=arrEmbed[target.type.toLowerCase()];","var lazyType=$(target).attr('lazytype'); tool=lazyType ? lazyType : arrEmbed[target.type.toLowerCase()];"),
- array("t:'????'","t:_('Paragraph')"),
- array("t:'??1'","t:_('Heading 1')"),
- array("t:'??2'","t:_('Heading 2')"),
- array("t:'??3'","t:_('Heading 3')"),
- array("t:'??4'","t:_('Heading 4')"),
- array("t:'??5'","t:_('Heading 5')"),
- array("t:'??6'","t:_('Heading 6')"),
- array("t:'?????'","t:_('Preformatted')"),
- array("t:'??'","t:_('Address')"),
- array("t:'??'","t:_('xx-small')"),
- array("t:'??'","t:_('x-small')"),
- array("t:'?'","t:_('small')"),
- array("t:'?'","t:_('medium')"),
- array("t:'?'","t:_('large')"),
- array("t:'??'","t:_('x-large')"),
- array("t:'??'","t:_('xx-large')"),
- array("{n:'??',c:'SimSun'},{n:'???',c:'FangSong_GB2312'},{n:'??',c:'SimHei'},{n:'??',c:'KaiTi_GB2312'},{n:'????',c:'Microsoft YaHei'},{n:'Arial'},","{n:'Arial'},"),
- array("s:'???'","s:_('Align left')"),
- array("s:'??'","s:_('Align center')"),
- array("s:'???'","s:_('Align right')"),
- array("s:'????'","s:_('Align full')"),
- array("s:'????'","s:_('Ordered list')"),
- array("s:'????'","s:_('Unordered list')"),
- array("???????(Ctrl+V)??????????? ??","' + _('Use Ctrl+V on your keyboard to paste the text.') + '"),
- array("value=\"??\"","value=\"' + _('Ok') + '\""),
- array("????:","' + _('Link URL:') + '"),
- array("????:","' + _('Target: ') + '"),
- array("????:","' + _('Link Text:') + '"),
- array("????:","' + _('Img URL: ') + '"),
- array("????:","' + _('Alt text:') + '"),
- array("????:","' + _('Alignment:') + '"),
- array("????:","' + _('Dimension:') + '"),
- array("????:","' + _('Border: ') + '"),
- array("????:","' + _('Hspace: ') + '"),
- array("????:","' + _('Vspace:') + '"),
- array("????:","' + _('Flash URL:') + '"),
- array("????:","' + _('Media URL:') + '"),
- array("????:","' + _('Rows&Cols: ') + '"),
- array("????:","' + _('Headers: ') + '"),
- array("????:","' + _('CellSpacing:') + '"),
- array("????:","' + _('CellPadding:') + '"),
- array("????:","' + _('Caption: ') + '"),
- array("????: <input type=\"text\" id=\"xheTableBorder\"","' + _('Border: ') + ' <input type=\"text\" id=\"xheTableBorder\""),
- array("<option selected=\"selected\" value=\"\">??</option>","<option selected=\"selected\" value=\"\">' + _('Default') +'</option>"),
- array("<option value=\"_blank\">???</option>","<option value=\"_blank\">' + _('New window') + '</option>"),
- array("<option value=\"_self\">????</option>","<option value=\"_self\">' + _('Same window') + '</option>"),
- array("<option value=\"_parent\">???</option>","<option value=\"_parent\">' + _('Parent window') + '</option>"),
- array("<option value=\"left\">???</option>","<option value=\"left\">' + _('Left') + '</option>"),
- array("<option value=\"right\">???</option>","<option value=\"right\">' + _('Right') + '</option>"),
- array("<option value=\"top\">??</option>","<option value=\"top\">' + _('Top') + '</option>"),
- array("<option value=\"middle\">??</option>","<option value=\"middle\">' + _('Middle') + '</option>"),
- array("<option value=\"center\">??</option>","<option value=\"center\">' + _('Center') + '</option>"),
- array("<option value=\"baseline\">??</option>","<option value=\"baseline\">' + _('Baseline') + '</option>"),
- array("<option value=\"bottom\">??</option>","<option value=\"bottom\">' + _('Bottom') + '</option>"),
- array("<option selected=\"selected\" value=\"\">?</option>","<option selected=\"selected\" value=\"\">' + _('None') + '</option>"),
- array("<option value=\"row\">???</option>","<option value=\"row\">' + _('First row') + '</option>"),
- array("<option value=\"col\">???</option>","<option value=\"col\">' + _('First column') + '</option>"),
- array("<option value=\"both\">???????</option>","<option value=\"both\">' + _('Both') + '</option>"),
- array("xhEditor???jQuery????????XHTML??????<a href=\"http://www.gnu.org/licenses/lgpl.html\" target=\"_blank\">LGPL</a>???????","' + _('xhEditor is a platform independent WYSWYG XHTML editor based by jQuery,released as Open Source under <a href=\"http://www.gnu.org/licenses/lgpl.html\" target=\"_blank\">LGPL</a>.') + '"),
- array("name:'??'","name:_('Default')"),
- array("'smile':'??'","'smile':_('Smile')"),
- array("'tongue':'???'","'tongue':_('Tongue')"),
- array("'titter':'??'","'titter':_('Titter')"),
- array("'laugh':'??'","'laugh':_('Laugh')"),
- array("'sad':'??'","'sad':_('Sad')"),
- array("'wronged':'??'","'wronged':_('Wronged')"),
- array("'fastcry':'???'","'fastcry':_('Fast cry')"),
- array("'cry':'?'","'cry':_('Cry')"),
- array("'wail':'??'","'wail':_('Wail')"),
- array("'mad':'??'","'mad':_('Mad')"),
- array("'knock':'??'","'knock':_('Knock')"),
- array("'curse':'??'","'curse':_('Curse')"),
- array("'crazy':'??'","'crazy':_('Crazy')"),
- array("'angry':'??'","'angry':_('Angry')"),
- array("'ohmy':'??'","'ohmy':_('Oh my')"),
- array("'awkward':'??'","'awkward':_('Awkward')"),
- array("'panic':'??'","'panic':_('Panic')"),
- array("'shy':'??'","'shy':_('Shy')"),
- array("'cute':'??'","'cute':_('Cute')"),
- array("'envy':'??'","'envy':_('Envy')"),
- array("'proud':'??'","'proud':_('Proud')"),
- array("'struggle':'??'","'struggle':_('Struggle')"),
- array("'quiet':'??'","'quiet':_('Quiet')"),
- array("'shutup':'??'","'shutup':_('Shut up')"),
- array("'doubt':'??'","'doubt':_('Doubt')"),
- array("'despise':'??'","'despise':_('Despise')"),
- array("'sleep':'??'","'sleep':_('Sleep')"),
- array("'bye':'??'","'bye':_('Bye')"),
- array("t:'?? (Ctrl+X)'","t:_('Cut (Ctrl+X)')"),
- array("t:'?? (Ctrl+C)'","t:_('Copy (Ctrl+C)')"),
- array("t:'?? (Ctrl+V)'","t:_('Paste (Ctrl+V)')"),
- array("t:'????'","t:_('Paste as plain text')"),
- array("t:'????'","t:_('Block tag')"),
- array("t:'??'","t:_('Font family')"),
- array("t:'????'","t:_('Font size')"),
- array("t:'?? (Ctrl+B)'","t:_('Bold (Ctrl+B)')"),
- array("t:'?? (Ctrl+I)'","t:_('Italic (Ctrl+I)')"),
- array("t:'??? (Ctrl+U)'","t:_('Underline (Ctrl+U)')"),
- array("t:'??? (Ctrl+S)'","t:_('Strikethrough (Ctrl+S)')"),
- array("t:'????'","t:_('Select text color')"),
- array("t:'????'","t:_('Select background color')"),
- array("t:'?? (Ctrl+A)'","t:_('SelectAll (Ctrl+A)')"),
- array("t:'??????'","t:_('Remove formatting')"),
- array("t:'??'","t:_('Align')"),
- array("t:'??'","t:_('List')"),
- array("t:'???? (Shift+Tab)'","t:_('Outdent (Shift+Tab)')"),
- array("t:'???? (Tab)'","t:_('Indent (Tab)')"),
- array("t:'??? (Ctrl+K)'","t:_('Insert/edit link (Ctrl+K)')"),
- array("t:'?????'","t:_('Unlink')"),
- array("t:'??'","t:_('Insert/edit image')"),
- array("t:'Flash??'","t:_('Insert/edit flash')"),
- array("t:'?????'","t:_('Insert/edit media')"),
- array("t:'??'","t:_('Emotions')"),
- array("t:'??'","t:_('Insert a new table')"),
- array("t:'???'","t:_('Edit source code')"),
- array("t:'??'","t:_('Preview')"),
- array("t:'?? (Ctrl+P)'","t:_('Print (Ctrl+P)')"),
- array("t:'???? (Esc)'","t:_('Toggle fullscreen (Esc)')"),
- array("t:'?? xhEditor'","t:_('About xhEditor')"),
- array("defLinkText:'??????'","defLinkText:_('Click to open link')"),
- array("'??textarea?????????????????xhEditor???????textarea?width?height??'","_('Current textarea is hidden, please make it show before initialization xhEditor, or directly initialize the height.')"),
- array("'????????????'","_('Upload file extension required for this: ')"),
- array("'??????????????'","_('You can only drag and drop the same type of file.')"),
- array("<title>??</title>","<title>' + _('Preview') + '</title>"),
- array("?????????
","' + _('File uploading,please wait...') + '"),
- array("'?????????'+upMultiple+'???'","_('Please do not upload more then \{\$upMultiple\} files.').replace('\{\$upMultiple\}', upMultiple)"),
- array("'?????(Esc????)'","_('File uploading(Esc cancel)')"),
- array("' ?????????","_(' upload interface error!') + '"),
- array("????????:","' + _('return error:') + '"),
- array("title=\"?? (Esc)\"","title=\"' + _('Close (Esc)') + '\""),
- array("value=\"??\"","value=\"' + _('Cancel') + '\""),
- array("'???????????????????????????(Ctrl + X)???'","_('Currently not supported by your browser, use keyboard shortcuts(Ctrl+X) instead.')"),
- array("'???????????????????????????(Ctrl + C)???'","_('Currently not supported by your browser, use keyboard shortcuts(Ctrl+C) instead.')"),
- array("'???????????????????????????(Ctrl + V)???'","_('Currently not supported by your browser, use keyboard shortcuts(Ctrl+V) instead.')"),
- array("'??????????: '","_('Upload file extension required for this: ')"),
- array("'??'","_('Upload')"),
- array("'????'","_('Upload file')"),
- array("arrCmd=['Link','Img','Flash','Media']","arrCmd=['Link','Img','Flash','Media','Video']"),
- array("sText=url[1]?url[1]:","sText=url[1]?url[1].replace(/%20/g,' '):"),
- array("sLink=sLink.replace('xhe_tmptext',url[1]?url[1]:","sLink=sLink.replace('xhe_tmptext',url[1]?url[1].replace(/%20/g,' '):"),
- /*array("_this.showIframeModal(_('Upload file'),toUrl.substr(1),setUploadMsg,null,null,function(){bShowPanel=true;});","var wh,w=null,h=null,i,s = toUrl.substr(1);
- if ((i=s.indexOf('||')) != -1) {
- wh = s.substr(0,i);
- s = s.substr(i+2);
- w = wh.substr(0, wh.indexOf('x'));
- h = wh.substr(wh.indexOf('x')+1);
- }
- _this.showIframeModal(_('Upload file'),s,setUploadMsg,w,h,function(){bShowPanel=true;});"),*/
- );
- $content = file_get_contents(ABS_PATH.'/'.$source);
- foreach($translates as $t) {
- $content = str_replace($t[0],$t[1],$content);
- }
- file_put_contents(ABS_PATH.'/'.$target, $content);
- }
- /**
- * ?????
- *
- * @param string $path ?????????
- * @return bool
- */
- function rmdirs($path){
- if ($dh=@opendir($path)) {
- while (false !== ($file=readdir($dh))) {
- if ($file != "." && $file != "..") {
- $file_path = $path.'/'.$file;
- is_dir($file_path) ? rmdirs($file_path) : @unlink($file_path);
- }
- }
- closedir($dh);
- }
- return @rmdir($path);
- }
- /**
- * ??????
- *
- * @param string $path ?????
- * @param int $mode ??
- * @return bool
- */
- function mkdirs($path, $mode = 0777){
- if (!is_dir($path)) {
- mkdirs(dirname($path), $mode);
- return mkdir($path, $mode);
- }
- return true;
- }