TWPUG之前有裝這個HACK:
http://twpug.net/modules/wfdownloads/singlefile.php?cid=5&lid=523
後來發現會影響一些原本的文章內容,所以原想修正一下,但是發現有很多程式碼需要看完才能夠順利搞定,而且這個HACK似乎包含了一些特定模組使用的程式碼(像是多國語言),而TWPUG好像用不到…
當時想要裝只是因為想要放FLASH動畫,懶得自己一個一個改,所以直接抓現成的用;為了延續這個目的,也避免影響舊有的內容,所以我換了個思考方向:
把HACK全部移除,只抓取我要的FLASH部分
移除這個HACK沒有問題,因為我在做壞事的時候有養成備份的習慣,因此三兩下就回復原狀,只是原本討論區中放的FLASH動畫也變成了只剩下代碼。
挖的步驟如下:
1. 要能夠支援FLASH的代碼,因此修改 class/module.textsanitizer.php,這個部份很單純,就只是在 function &xoopsCodeDecode 加上下面樣式:
$patterns[] = "/[swf=([\'"]?)([^"\']*)1,([\'"]?)([^"\']*)1]([^"]*)[/swf]/sU"; $rp = "<object codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\' width=\'2\' height=\'4\'>"; $rp .= "<param name=movie value=\'5\'>"; $rp .= "<param name=\'QUALITY\' value=\'high\'>"; $rp .= "<PARAM NAME=\'bgcolor\' VALUE=\'#FFFFFF\'>"; $rp .= "<param name=\'wmode\' value=\'transparent\'>"; $rp .= "<embed src=\'5\' quality=high bgcolor=\'#FFFFFF\' wmode=\'transparent\' pluginspage=\'http://www.macromedia.com/go/getflashplayer\' type=\'application/x-shockwave-flash\' width=\'2\' height=\'4\'></embed>"; $rp .= "</object>"; $replacements[] =$rp;
這樣子原本的動畫就正常了。
2. 你要知道我是個很懶的人,所以別叫我記這個特殊語法,我喜歡原本那樣子點一下就塞進去的功能;於是乎要先修改產生表單的程式 class/xoopsform/formdhtmltextarea.php
找到這一行:
$ret = "<a name=\'moresmiley\'></a><img onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/url.gif\' alt=\'url\' onclick=\'xoopsCodeUrl("".$this->getName()."", "".htmlspecialchars(_ENTERURL, ENT_QUOTES)."", "".htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES)."");\' /> <img onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/email.gif\' alt=\'email\' onclick=\'javascript:xoopsCodeEmail("".$this->getName()."", "".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."");\' /> <img onclick=\'javascript:xoopsCodeImg("".$this->getName()."", "".htmlspecialchars(_ENTERIMGURL, ENT_QUOTES)."", "".htmlspecialchars(_ENTERIMGPOS, ENT_QUOTES)."", "".htmlspecialchars(_IMGPOSRORL, ENT_QUOTES)."", "".htmlspecialchars(_ERRORIMGPOS, ENT_QUOTES)."");\' onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/imgsrc.gif\' alt=\'imgsrc\' /> <img onmouseover=\'style.cursor="hand"\' onclick=\'javascript:openWithSelfMain("".XOOPS_URL."/imagemanager.php?target=".$this->getName()."","imgmanager",400,430);\' src=\'".XOOPS_URL."/images/image.gif\' alt=\'image\' /> <img src=\'".XOOPS_URL."/images/code.gif\' onmouseover=\'style.cursor="hand"\' alt=\'code\' onclick=\'javascript:xoopsCodeCode("".$this->getName()."", "".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."");\' /> <img onclick=\'javascript:xoopsCodeQuote("".$this->getName()."", "".htmlspecialchars(_ENTERQUOTE, ENT_QUOTES)."");\' onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/quote.gif\' alt=\'quote\' /><br />n";
改成這樣:
$ret = "<a name=\'moresmiley\'></a><img onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/url.gif\' alt=\'url\' onclick=\'xoopsCodeUrl("".$this->getName()."", "".htmlspecialchars(_ENTERURL, ENT_QUOTES)."", "".htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES)."");\' /> <img onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/email.gif\' alt=\'email\' onclick=\'javascript:xoopsCodeEmail("".$this->getName()."", "".htmlspecialchars(_ENTEREMAIL, ENT_QUOTES)."");\' /> <img onclick=\'javascript:xoopsCodeImg("".$this->getName()."", "".htmlspecialchars(_ENTERIMGURL, ENT_QUOTES)."", "".htmlspecialchars(_ENTERIMGPOS, ENT_QUOTES)."", "".htmlspecialchars(_IMGPOSRORL, ENT_QUOTES)."", "".htmlspecialchars(_ERRORIMGPOS, ENT_QUOTES)."");\' onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/imgsrc.gif\' alt=\'imgsrc\' /> <img onmouseover=\'style.cursor="hand"\' onclick=\'javascript:openWithSelfMain("".XOOPS_URL."/imagemanager.php?target=".$this->getName()."","imgmanager",400,430);\' src=\'".XOOPS_URL."/images/image.gif\' alt=\'image\' /> <img src=\'".XOOPS_URL."/images/code.gif\' onmouseover=\'style.cursor="hand"\' alt=\'code\' onclick=\'javascript:xoopsCodeCode("".$this->getName()."", "".htmlspecialchars(_ENTERCODE, ENT_QUOTES)."");\' /> <img onclick=\'javascript:xoopsCodeQuote("".$this->getName()."", "".htmlspecialchars(_ENTERQUOTE, ENT_QUOTES)."");\' onmouseover=\'style.cursor="hand"\' src=\'".XOOPS_URL."/images/quote.gif\' alt=\'quote\' /> <img src=\'".XOOPS_URL."/images/swf.gif\' alt=\'"._ALTFLASH."\' onclick=\'xoopsCodeFlash("".$this->getName()."","".htmlspecialchars(_ENTERFLASHURL, ENT_QUOTES)."","".htmlspecialchars(_ENTERHEIGHT, ENT_QUOTES)."","".htmlspecialchars(_ENTERWIDTH, ENT_QUOTES)."");\' onmouseover=\'style.cursor="hand"\'/><br />n";
3. 接著如果急著看結果就會出現蠻多問題的,你必須要先有 images/swf.gif 這個圖,接著修改 include/xoops.js ,在裡面加上這兩個函數就行了:
function xoopsCodeFlash(id, enterFlashPhrase, enterFlashHeightPhrase, enterFlashWidthPhrase){ var selection = getSelct(); if (selection.length>0){ var text = prompt(enterFlashPhrase,selection); var selection=""; } else{ var text = prompt(enterFlashPhrase, ""); } var domobj = xoopsGetElementById(id); if ( text.length>0 ) { var text2 = prompt(enterFlashWidthPhrase, "480"); var text3 = prompt(enterFlashHeightPhrase, "330"); var result = "[swf="+text2+","+text3+"]" + text + "[/swf]"; xoopsInsertText(domobj, result); } domobj.focus();}function getSelct(){ if (window.getSelection) var selection = window.getSelection(); else if (document.getSelection) var selection = document.getSelection(); else if (document.selection) var selection = document.selection.createRange().text; else var selection = null; return selection;}
就這樣,只是單純多了加入FLASH的功能,未來有人要分享好康影片的時候再想辦法。
totem 15:32:01 on 2005 年 12 月 10 日 Permalink
我們的課程社群也是用LifeType架的, 我把你的RSS加到我們的主頁聯播, 希望可以跟你交流喔!!
http://blog.totematncu.net/
http://blog.totematncu.info/
kiang 19:50:37 on 2005 年 12 月 10 日 Permalink
歡迎