<?xml version="1.0" encoding="UTF-8"  standalone="yes" ?>
<rss version="2.0">
	<channel>
		<title>社群: Web Programming - 文件區</title>
		<description>台灣數位學習數位教學平台 RSS feed provider</description>
		<language>zh-tw</language>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doclist&amp;folderID=</link>
	<item>
		<title>CSS selector</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8678</link>
		<description>基礎子選擇器 &amp;gt;p &amp;gt; a &amp;nbsp;// &amp;lt;p&amp;gt; 下的「直接」子元素 a屬性選擇器 []a[href^=&#039;http://&#039;] &amp;nbsp;//&amp;nbsp;href 開頭為&amp;nbsp;http:// 的 a&amp;nbsp;a[href$=&#039;.pdf&#039;] &amp;nbsp; &amp;nbsp; // 結尾為 .pdfa[href*=&#039;jquery&#039;] &amp;nbsp; // 有出現 jqueryinput[type=&#039;text&#039;] &amp;nbsp;// type 是 text 的 inputdiv[title] &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// 有 title 屬性者div[title^=&#039;my&#039;] &amp;nbsp; &amp;nbsp;// title 開頭為 my 的 div位置選擇 : (pseudo-class, filter)a:firsta:oddli:last-child:not()       </description>
		<pubDate>Tue, 19 Jun 2012 21:48:58 +0800</pubDate>
	</item>
	<item>
		<title>好用的擴充</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8667</link>
		<description>在 form 中設定 readonly 並變顏色，測試範例 [form.setReadOnly.html、chapter7.setReadOnly.rar](function($) {&amp;nbsp; &amp;nbsp; $.fn.setReadOnly = function(readonly) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return this.filter(&#039;input:text&#039;)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .attr(&#039;readOnly&#039;, readonly)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .css(&#039;opacity&#039;, readonly ? 0.5 : 1.0)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .end();&amp;nbsp; &amp;nbsp; };})(jQuery); </description>
		<pubDate>Sat, 16 Jun 2012 09:17:19 +0800</pubDate>
	</item>
	<item>
		<title>擴充的模式 - 確保 $ 可用 (包進立即執行函數中)</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8666</link>
		<description>jQuery 習慣用 $ 來使用，但 $ 卻可能被其他定義所覆蓋，例如共用 prototype.js 時解法: 將 jQeury 用 $ 封裝到立即函數中(function($) {&amp;nbsp; $.say = function(msg) {&amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; }})(jQuery);$.fn 擴充 jQuery wrapper(function($) {&amp;nbsp; $.fn.makeItBlue = function() {&amp;nbsp; &amp;nbsp; return this.css(&#039;color&#039;: &#039;blue&#039;); &amp;nbsp;// jQuery chain&amp;nbsp; }})(jQuery);$.fn 中的 each() 的技巧(function($) {&amp;nbsp; $.fn.makeItBlue = function() {&amp;nbsp; &amp;nbsp; return this.each( &amp;nbsp;// jQuery chain&amp;nbsp; &amp;nbsp; &amp;nbsp; function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(this).css(&#039;color&#039;: &#039;blue&#039;);&amp;nbsp; &amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; );&amp;nbsp; &amp;nbsp; 或是直接用函數的方法進行迭代&amp;nbsp; &amp;nbsp;&amp;nbsp;return this.css(&#039;color&#039;:&amp;nbsp; &amp;nbsp; &amp;nbsp; function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return $(this).css(&#039;color&#039;: &#039;blue&#039;);&amp;nbsp; &amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; );&amp;nbsp; }})(jQuery);         </description>
		<pubDate>Sat, 16 Jun 2012 08:52:56 +0800</pubDate>
	</item>
	<item>
		<title>參數傳遞 - $.extend() 技巧</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8665</link>
		<description>傳遞多個參數時，最好使用 json 的方式 (options hash)，尤其是可省略的參數例如:var options = {&amp;nbsp; opt1: value1,&amp;nbsp; opt2: value2,&amp;nbsp; ...}並使用 $.extend() 合併參數與預設值function foo(options) {&amp;nbsp; var settings = $.extend({&amp;nbsp; &amp;nbsp; opt1: null, &amp;nbsp;// 列出所有的選項，對程式可讀性是非常有益且明智的&amp;nbsp; &amp;nbsp; opt2: default2,&amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; opt9: default9&amp;nbsp; }, options || {};&amp;nbsp; // function definition ..}       </description>
		<pubDate>Sat, 16 Jun 2012 08:44:38 +0800</pubDate>
	</item>
	<item>
		<title>疊代 iterator</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8655</link>
		<description>在 data collection 中，提供簡單的方法依序 (通常是 next) &amp;nbsp;取得元素var dataSet = (function() {&amp;nbsp; var index = 0,&amp;nbsp; &amp;nbsp; &amp;nbsp; data = [1, 2, 3, 4],&amp;nbsp; &amp;nbsp; &amp;nbsp; len = data.length;&amp;nbsp; return {&amp;nbsp; &amp;nbsp; next: function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; var el;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (!this.hasNext()) return null;&amp;nbsp; &amp;nbsp; &amp;nbsp; return data[index++];&amp;nbsp; &amp;nbsp; },&amp;nbsp; &amp;nbsp; hasNext: function() {&amp;nbsp; &amp;nbsp; },&amp;nbsp; &amp;nbsp; rewind: funciton() {&amp;nbsp; &amp;nbsp; },&amp;nbsp; &amp;nbsp; curr: function() {&amp;nbsp; &amp;nbsp; }&amp;nbsp; }})(); </description>
		<pubDate>Sat, 09 Jun 2012 19:54:52 +0800</pubDate>
	</item>
	<item>
		<title>模組範例</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8647</link>
		<description>利用以下特性，建立模組的範例 (p100 @ JavaScript Pattern)1. 命名空間 namespace2. 立即函式3. private (closure)4. 宣告相依性if (typeof FS.lib.array === &#039;undefined&#039;) {// 一般 lib 開發會很嚴謹，尤其是同一家公司，應該不會不小心被覆蓋，所以可以省略檢查FS.namespace(&#039;FS.lib.array&#039;);FS.lib.array = (function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; // 宣告相依性&amp;nbsp; var uobj = FS.lib.object,&amp;nbsp; &amp;nbsp; &amp;nbsp; ulang = FS.lib.lang,&amp;nbsp; &amp;nbsp; &amp;nbsp; // private 屬性&amp;nbsp; &amp;nbsp; &amp;nbsp; _str = &quot;...&quot;;&amp;nbsp; // init&amp;nbsp;&amp;nbsp;&amp;nbsp; // public API&amp;nbsp; return {&amp;nbsp; &amp;nbsp; inArray: function() { ... },&amp;nbsp; &amp;nbsp; isArray: funciton() { ... }}());}將 private 變成 public，物件完成後，決定開放那些 APIFS.lib.array = (function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; // 宣告相依性&amp;nbsp; var uobj = FS.lib.object,&amp;nbsp; &amp;nbsp; &amp;nbsp; ulang = FS.lib.lang,&amp;nbsp; &amp;nbsp; &amp;nbsp; // private 屬性&amp;nbsp; &amp;nbsp; &amp;nbsp; _str = &quot;...&quot;;&amp;nbsp; // init&amp;nbsp;&amp;nbsp;&amp;nbsp; // private method&amp;nbsp; inArray = function() { ... }&amp;nbsp; isArray = fucction() { ... }&amp;nbsp; // set public API&amp;nbsp; return {&amp;nbsp; &amp;nbsp; inArray: inArray,&amp;nbsp; &amp;nbsp; isArray: isArray}());     </description>
		<pubDate>Wed, 06 Jun 2012 21:39:57 +0800</pubDate>
	</item>
	<item>
		<title>鏈結模式 chain (return this, 就是 jQuery 的方式)</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8645</link>
		<description>var obj = {&amp;nbsp; &amp;nbsp; value: 1,&amp;nbsp; &amp;nbsp; inc: function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.value ++;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return this;&amp;nbsp; &amp;nbsp; },&amp;nbsp; &amp;nbsp; add: function(v) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.value += v;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return this;&amp;nbsp; &amp;nbsp; },&amp;nbsp; &amp;nbsp; out: function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(this.value);&amp;nbsp; &amp;nbsp; }};obj.inc().add(3).out(); </description>
		<pubDate>Wed, 06 Jun 2012 17:06:10 +0800</pubDate>
	</item>
	<item>
		<title>建立命名空間的習慣</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8643</link>
		<description>全大寫&amp;nbsp;var MYAPP = {};建立前先檢查if (typeof MYAPP === &#039;undefined&#039; {&amp;nbsp; var MYAPP = {};}orvar MYAPP = MYAPP || {};建立前檢查，利用&amp;nbsp;namespace() 的輔助 (p92 @ JavaScript Pattern)MYAPP.namespace = function(ns) {&amp;nbsp; var parts = ns.split(&#039;.&#039;),&amp;nbsp; &amp;nbsp; &amp;nbsp; parent = MYAPP,&amp;nbsp; &amp;nbsp; &amp;nbsp; i;&amp;nbsp; if (parts[0] === &quot;MYAPP&quot;) {&amp;nbsp; &amp;nbsp; parts = parts.slice(1);&amp;nbsp; }&amp;nbsp; for (i=0; i&amp;lt;parts.length; i++) {&amp;nbsp; &amp;nbsp; if (typeof parent[parts[i]] === &#039;undefined&#039;) {&amp;nbsp; &amp;nbsp; &amp;nbsp; parent[parts[i]] = {};&amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; parent = parent[parts[i]];&amp;nbsp; }&amp;nbsp; return parent;}var mod2 = MYAPP.namespace(&#039;MYAPP.modules.mod2&#039;);   </description>
		<pubDate>Wed, 06 Jun 2012 16:34:33 +0800</pubDate>
	</item>
	<item>
		<title>初始階段的分支 (避免執行時期每次都檢查)</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8642</link>
		<description>每次執行都檢查var utils = {&amp;nbsp; addListener: function(el, type, fn) {&amp;nbsp; &amp;nbsp; if (typeof window.addEventListener == &#039;function&#039;) {&amp;nbsp; &amp;nbsp; &amp;nbsp; el.addEventListerner(...);&amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; else { ... }&amp;nbsp; },&amp;nbsp; removeListener: function() ...}依照檢查結果定義不同的函式，避免每次都檢查var utils = {&amp;nbsp; addListener: null,&amp;nbsp; removeListener: null}if (typeof&amp;nbsp;window.addEventListener == &#039;function&#039;) {&amp;nbsp; utils.addListener = function ...} </description>
		<pubDate>Wed, 06 Jun 2012 16:13:25 +0800</pubDate>
	</item>
	<item>
		<title>立即函式 (Immediate function)</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8641</link>
		<description>1. 將運算包裝起來，減少全域變數var o = {&amp;nbsp; msg: (function(){&amp;nbsp; &amp;nbsp; var who = &quot;me&quot;,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; what = &quot;call&quot;;&amp;nbsp; &amp;nbsp; return what + &quot; &quot; + who;&amp;nbsp; }()),&amp;nbsp; getMsg: function() {&amp;nbsp; &amp;nbsp; return this.msg;&amp;nbsp; }}2. 沒有名字的需求，例如只執行一次的函式 init()(function() {&amp;nbsp; var days = [ ... ], &amp;nbsp;//&amp;nbsp;如果直接 var 就會產生 global 變數&amp;nbsp; &amp;nbsp; &amp;nbsp; today = new Date(),&amp;nbsp; &amp;nbsp; &amp;nbsp; msg = ...;&amp;nbsp; alert(msg);}() );3. 儲存 private 資料
 </description>
		<pubDate>Wed, 06 Jun 2012 16:05:35 +0800</pubDate>
	</item>
	<item>
		<title>自我重新定義函式 ~ 初始的技巧</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8640</link>
		<description>第一次沒有正式定義，之後就只做更少的事情 (lazy function definition)var func = function() {&amp;nbsp; alert(&quot;init ...&quot;);&amp;nbsp; func = function() {&amp;nbsp; &amp;nbsp; alert(&quot;real body ...&quot;);&amp;nbsp; }}func(); &amp;nbsp;// init ...func(); &amp;nbsp;// real body ... </description>
		<pubDate>Wed, 06 Jun 2012 15:53:48 +0800</pubDate>
	</item>
	<item>
		<title>回傳函式應用 (closure)</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8638</link>
		<description>var setup = function() {&amp;nbsp; var count = 0; &amp;nbsp;// closure, provide private used internal only&amp;nbsp; &amp;nbsp; return function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; return count ++;&amp;nbsp; &amp;nbsp; }}var next = setup();next(); &amp;nbsp;// 1next(); &amp;nbsp;// 2   </description>
		<pubDate>Wed, 06 Jun 2012 15:42:37 +0800</pubDate>
	</item>
	<item>
		<title>Callback 應用範例 (保持泛用)</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8637</link>
		<description>// just find nodesvar findNodes = function() {&amp;nbsp; var nodes=[], found;&amp;nbsp; while (true) {&amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; nodes.push(found);&amp;nbsp; }&amp;nbsp; return nodes;}// hide nodesvar hide = function(nodes) {&amp;nbsp; var i=0, max=nodes.length;&amp;nbsp; for ( ; i&amp;lt;max; i++) {&amp;nbsp; &amp;nbsp; nodes[i].style.display = &quot;none&quot;;&amp;nbsp; }}使用 callbackfindNodes 的同時做 hide 來增加效率，而且保持 findNodes 的泛用性 (less coupling)var findNodes = function(callback) {&amp;nbsp; var nodes=[], found;&amp;nbsp; if (typeof callback !== &quot;function&quot;) {&amp;nbsp; &amp;nbsp; callback = false;&amp;nbsp; }&amp;nbsp; while (true) {&amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; if (callback) {&amp;nbsp; &amp;nbsp; &amp;nbsp; callback(found);&amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; nodes.push(found);&amp;nbsp; }&amp;nbsp; return nodes;}var hide = function(node) {&amp;nbsp; node.style.display = &quot;none&quot;;};findNodes(hide); &amp;nbsp;// findNodes(function(node) { node.style.display = &quot;none&quot;; });物件 method 的作用域 Callback &amp;amp; Scope如果 callback 是物件的方法，需要做調整 (p.67 @ JavaScript Patterns)var app = {&amp;nbsp; color: &quot;green&quot;,&amp;nbsp; paint: function(node) { node.style.color = this.color; }}findNodes(app.paint); &amp;nbsp;// error，因為 this 會指向全域變數，因為 findNodes 是 globalfindNodes(app.paint, app);var findNodes = function(callback, obj) {&amp;nbsp;&amp;nbsp;if (typeof callback === &#039;string&#039;) { &amp;nbsp;// findNodes(&#039;paint&#039;, app); 少打一個 app (app.paint)&amp;nbsp; &amp;nbsp; callback = obj[callback];&amp;nbsp; }&amp;nbsp; if (typeof callback === &#039;function&#039;) {&amp;nbsp; &amp;nbsp; callback.call(obj, found);&amp;nbsp; }};           </description>
		<pubDate>Wed, 06 Jun 2012 15:28:40 +0800</pubDate>
	</item>
	<item>
		<title>function 中的 this</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8636</link>
		<description>this 一般會指向 global，因此如果是物件，要特別小心要用 newfunction obj() {&amp;nbsp; this.value = &quot;v&quot;;}var o = obj(); &amp;nbsp; &amp;nbsp; &amp;nbsp;// 錯誤，this 指向 global, browser 中通常是 windowvar o = new obj(); &amp;nbsp;// this 指向物件解決方法 ~ 自我呼叫的建構式function obj() {&amp;nbsp; if (!(this instanceof obj)) {&amp;nbsp; &amp;nbsp; return new obj();&amp;nbsp; }&amp;nbsp; this.value = &quot;v&quot;;}   </description>
		<pubDate>Wed, 06 Jun 2012 12:15:12 +0800</pubDate>
	</item>
	<item>
		<title>容易維護的程式碼必須具備的條件</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8629</link>
		<description>從書上看來的，心有戚戚焉1. 可讀性2. 一致姓3. 可預料的 (簡單邏輯)4. 看起來要像是同一個人寫的5. 文件化因為，程式在許多情況下需要重新查看、修改和調整1. 有 bug 被發現2. 新增功能3. 在新環境中執行 (新的瀏覽器)4. 程式用途改變5. 移植程式碼 ...如果程式碼缺乏上述的特點，將從撰寫時的 man-hours 演變成 man-weeks .... </description>
		<pubDate>Mon, 04 Jun 2012 22:06:35 +0800</pubDate>
	</item>
	<item>
		<title>Session</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8561</link>
		<description></description>
		<pubDate>Tue, 22 May 2012 23:10:30 +0800</pubDate>
	</item>
	<item>
		<title>程式撰寫規範</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8540</link>
		<description>減少全域變數一律使用 var未宣告就使用的變數, exfunction foo() {&amp;nbsp; var a = b = 0; &amp;nbsp;// b 未宣告，所以是global}變數宣告時同時初始化1. 在函數一開始就宣告&amp;nbsp; &amp;nbsp;- 被定義的變數只須尋找單一地方&amp;nbsp; &amp;nbsp;- 避免困擾，任何地方宣告都等同於一開始就宣告的特性 (hoisting)2. 初始化，提升可讀性&amp;nbsp; &amp;nbsp;var a = 1, &amp;nbsp; &amp;nbsp; &amp;nbsp;// a 是一個數字&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b = &quot;str&quot;; // b 是一個字串縮排4 個空白大括號永遠都加，即使只有一行的敘述 (換行)if (true) {&amp;nbsp; ...}這可以避免行尾自動加 ; 號的問題，例如function func() {&amp;nbsp; &amp;nbsp;return &amp;nbsp; // return undefined, 並且以下不會執行!&amp;nbsp; &amp;nbsp;{&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;name: &quot;tcsu&quot;&amp;nbsp; &amp;nbsp;}}PS: 同一行則不用加，例如 if (error) return false;空格為了閱讀上更清晰的目的，每個 , 號後面要留白for (var i=0; i&amp;lt;max; i++) { ... }命名建構式微首字母大寫， var a = new Person(); 看名稱就可以區隔函數變數: lastIndex (camel case，第二個詞以後的第一個字母大寫)全域變數: gMax (g 開頭，容易被識別出來，盡量不使用全域變數)常數: PI = 3.14 (全大寫)private: _name (底線開頭，警告開發者不要直接使用)     </description>
		<pubDate>Sun, 20 May 2012 23:21:12 +0800</pubDate>
	</item>
	<item>
		<title>更好的寫法</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8538</link>
		<description>迴圈 for，判斷式要先計算取得常數尤其在一些 HTML Collectionfor (var i=0; i&amp;lt;document.images.length; i++) { ... } // 速度很慢，每次都會重新檢查網頁for (var i=0, max=document.images.length; i&amp;lt;max; i++) { ... }   </description>
		<pubDate>Sun, 20 May 2012 09:42:21 +0800</pubDate>
	</item>
	<item>
		<title>容易出錯的寫法</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8536</link>
		<description>避免隱含的型別轉換，用 === 取代 ==false == 0 (true)false === 0 (false)使用 parseInt() 要加 base，可以改用 Number()尤其在 form 中的日期 (0 開頭會解釋為 8 進位)，例如var m = &#039;09&#039;;m = parseInt(09); &amp;nbsp;// m = 0, 因為 09 不是 8 進位m = Number(m); &amp;nbsp;// 速度更快避免使用 eval()不安全，尤其 ajax 的 json如果一定要，用 JSON.parse 或 Json.org 提供的 libsetTimeout() 比較好的寫法因為字串會被視為程式碼去解析setTimeout(&quot;func()&quot;, 1000); &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;gt;&amp;gt; setTimeout(func, 1000);setTimeout(&quot;func(1, 2)&quot;, 1000); &amp;gt;&amp;gt;&amp;nbsp;setTimeout(function() {func(1, 2);}, 1000);       </description>
		<pubDate>Sun, 20 May 2012 09:23:08 +0800</pubDate>
	</item>
	<item>
		<title>tools</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=8518</link>
		<description>online js + jqueryhttp://jsfiddle.net/cUSVj/
online json parserhttp://json.parser.online.fr/
 </description>
		<pubDate>Fri, 18 May 2012 10:28:11 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_block(&#039;view&#039;) - Generating the block content</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5791</link>
		<description>http://drupal.org/node/206759
&amp;nbsp;
if ($op == &#039;view&#039;) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $block[&#039;subject&#039;] = &#039;OnThisDate Subject&#039;;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; $block[&#039;content&#039;] = &#039;Onthisdate content&#039;;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $block;} </description>
		<pubDate>Mon, 09 May 2011 15:06:38 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_block($op = &#039;list&#039;) - Declaring block content</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5790</link>
		<description>http://drupal.org/node/206758
&amp;nbsp;
function onthisdate_block($op = &#039;list&#039;, $delta = 0, $edit = array()) {&amp;nbsp; &amp;nbsp; if ($op == &quot;list&quot;) {&amp;nbsp;&amp;nbsp;&amp;nbsp; // Generate listing of blocks from this module, for the admin/block page&amp;nbsp;&amp;nbsp;&amp;nbsp; $block = array();&amp;nbsp;&amp;nbsp;&amp;nbsp; $block[0][&quot;info&quot;] = t(&#039;On This Date&#039;);&amp;nbsp;&amp;nbsp;&amp;nbsp; return $block;&amp;nbsp; } } </description>
		<pubDate>Mon, 09 May 2011 15:01:10 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_perm()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5789</link>
		<description>http://drupal.org/node/206757
&amp;nbsp;
function onthisdate_perm() {&amp;nbsp; return array(&#039;access onthisdate content&#039;);}  </description>
		<pubDate>Mon, 09 May 2011 14:55:27 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_help() - Help Hook</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5788</link>
		<description>http://drupal.org/node/206756
&amp;nbsp;
function onthisdate_help($path, $arg) {&amp;nbsp; $output = &#039;&#039;;&amp;nbsp; //declare your output variable&amp;nbsp; switch ($path) {&amp;nbsp;&amp;nbsp;&amp;nbsp; case &quot;admin/help#onthisdate&quot;:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = &#039;&amp;lt;p&amp;gt;&#039;.&amp;nbsp; t(&quot;Displays links to nodes created on this date&quot;) .&#039;&amp;lt;/p&amp;gt;&#039;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&amp;nbsp; }&amp;nbsp; return $output;}  </description>
		<pubDate>Mon, 09 May 2011 14:54:42 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate.info - telling Drupal about your module</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5787</link>
		<description>http://drupal.org/node/206756
&amp;nbsp;
name = Module namedescription = A description of what your module does.core = 6.x </description>
		<pubDate>Mon, 09 May 2011 14:43:07 +0800</pubDate>
	</item>
	<item>
		<title>Name your module and create a folder / file</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5786</link>
		<description>1. name:&amp;nbsp;&amp;nbsp; onthisdate
2. folder: sites/all/modules/onthisdate
3. file:&amp;nbsp;&amp;nbsp;&amp;nbsp;onthisdate.module </description>
		<pubDate>Mon, 09 May 2011 14:41:13 +0800</pubDate>
	</item>
	<item>
		<title>Creating a module configuration (settings) page</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5781</link>
		<description>http://drupal.org/node/206761&amp;nbsp;
&amp;nbsp;
1. Create the configuration function
&amp;nbsp;
function onthisdate_admin() {&amp;nbsp; $form = array();&amp;nbsp; $form[&#039;onthisdate_maxdisp&#039;] = array(&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#type&#039; =&amp;gt; &#039;textfield&#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#title&#039; =&amp;gt; t(&#039;Maximum number of links&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#default_value&#039; =&amp;gt; variable_get(&#039;onthisdate_maxdisp&#039;, 3),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#size&#039; =&amp;gt; 2,&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#maxlength&#039; =&amp;gt; 2,&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#description&#039; =&amp;gt; t(&quot;The maximum number of links to display in the block.&quot;),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;#required&#039; =&amp;gt; TRUE,&amp;nbsp; );&amp;nbsp; return system_settings_form($form);}
&amp;nbsp;
&amp;nbsp;
2. define a URL by hook_menu
&amp;nbsp;
function onthisdate_menu() {&amp;nbsp; $items = array();&amp;nbsp; $items[&#039;admin/settings/onthisdate&#039;] = array(&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;title&#039; =&amp;gt; t(&#039;On this date module settings&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;description&#039; =&amp;gt; t(&#039;Description of your On this date settings page&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;page callback&#039; =&amp;gt; &#039;drupal_get_form&#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;page arguments&#039; =&amp;gt; array(&#039;onthisdate_admin&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;access arguments&#039; =&amp;gt; array(&#039;access administration pages&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;type&#039; =&amp;gt; MENU_NORMAL_ITEM,&amp;nbsp;&amp;nbsp; );&amp;nbsp; return $items;}
** clear the menu cache to&amp;nbsp;recognize the new URL (Administer &amp;gt;&amp;gt; Site Configuration &amp;gt;&amp;gt; Performance)
&amp;nbsp;
&amp;nbsp;
3. Validate the user input (a &quot;_validate&quot; suffix)
&amp;nbsp;
function onthisdate_admin_validate($form, &amp;amp;$form_state) {&amp;nbsp; $maxdisp = $form_state[&#039;values&#039;][&#039;onthisdate_maxdisp&#039;];&amp;nbsp; if (!is_numeric($maxdisp)) {...}
}
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp; </description>
		<pubDate>Sun, 08 May 2011 23:30:27 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_block(&#039;view&#039;) - Generating the block content</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5780</link>
		<description>http://drupal.org/node/206759
&amp;nbsp;
function onthisdate_block($op = &quot;list&quot;, $delta = 0) {
&amp;nbsp; if ($op == &quot;view&quot;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$block[&quot;subject&quot;] = t(&quot;Subject of On This Date&quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; $block[&quot;subject&quot;] = t(&quot;Content of OnThisDate&quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return $block;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } </description>
		<pubDate>Sun, 08 May 2011 22:49:46 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_block(&#039;list&#039;) - Declaring block content</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5779</link>
		<description>http://drupal.org/node/206758
&amp;nbsp;
function onthisdate_block($op = &#039;list&#039;, $delta = 0, $edit = array()) {&amp;nbsp; &amp;nbsp; if ($op == &quot;list&quot;) { // admin/block&amp;nbsp;&amp;nbsp;&amp;nbsp; $block = array();&amp;nbsp;&amp;nbsp;&amp;nbsp; $block[0][&quot;info&quot;] = t(&#039;On This Date&#039;);&amp;nbsp;&amp;nbsp;&amp;nbsp; return $block;&amp;nbsp; } } </description>
		<pubDate>Sun, 08 May 2011 22:38:59 +0800</pubDate>
	</item>
	<item>
		<title>Hooks</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5778</link>
		<description>http://api.drupal.org/api/drupal/includes--module.inc/group/hooks/6
&amp;nbsp;
Allow modules to interact with the Drupal core.
Drupal&#039;s module system is based on the concept of &quot;hooks&quot;. A hook is named moduleName_hookName </description>
		<pubDate>Sun, 08 May 2011 22:27:47 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_perm() - Specifying the available permissions</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5777</link>
		<description>http://drupal.org/node/206757
&amp;nbsp;
define&amp;nbsp;module permissions&amp;nbsp;(Administer&amp;nbsp;/ User management / Permissions page)
function onthisdate_perm() {&amp;nbsp; return array(&#039;access onthisdate content&#039;);} </description>
		<pubDate>Sun, 08 May 2011 22:18:55 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate_help() - Help Hook</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5774</link>
		<description>http://drupal.org/node/206756
&amp;nbsp;
function onthisdate_help($path, $arg) {&amp;nbsp; $output = &#039;&#039;;&amp;nbsp; //declare your output variable&amp;nbsp; switch ($path) {&amp;nbsp;&amp;nbsp;&amp;nbsp; case &quot;admin/help#onthisdate&quot;:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = &#039;&amp;lt;p&amp;gt;&#039;.&amp;nbsp; t(&quot;Displays links to nodes created on this date&quot;) .&#039;&amp;lt;/p&amp;gt;&#039;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&amp;nbsp; }&amp;nbsp; return $output;} </description>
		<pubDate>Sun, 08 May 2011 20:10:29 +0800</pubDate>
	</item>
	<item>
		<title>onthisdate.info</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5773</link>
		<description>http://drupal.org/node/206756
&amp;nbsp;
name = On this datedescription = A block module that lists links to content created one week ago.core = 6.x
dependencies, package (optional) </description>
		<pubDate>Sun, 08 May 2011 19:57:29 +0800</pubDate>
	</item>
	<item>
		<title>Name your module and create a folder</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5772</link>
		<description>http://drupal.org/node/206754
&amp;nbsp;
1. name: &amp;nbsp; onthisdate
2. folder: sites/all/modules/onthisdate&amp;nbsp;(the preferred place for non-core modules)
3. file: &amp;nbsp; onthisdate.module </description>
		<pubDate>Sun, 08 May 2011 19:53:04 +0800</pubDate>
	</item>
	<item>
		<title>node_invoke_nodeapi()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5706</link>
		<description>function node_invoke_nodeapi(&amp;amp;$node, $op, $a3 = NULL, $a4 = NULL) {&amp;nbsp; $return = array();&amp;nbsp; foreach (module_implements(&#039;nodeapi&#039;) as $name) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $function = $name .&#039;_nodeapi&#039;;&amp;nbsp;&amp;nbsp;&amp;nbsp; $result = $function($node, $op, $a3, $a4);&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isset($result) &amp;amp;&amp;amp; is_array($result)) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $return = array_merge($return, $result);&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; else if (isset($result)) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $return[] = $result;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; }&amp;nbsp; return $return;}
&amp;nbsp;

function module_implements() {
&amp;nbsp; $list = module_list(FALSE, TRUE, $sort);&amp;nbsp;&amp;nbsp;foreach ($list as $module) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (module_hook($module, $hook)) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$implementations[$hook][] = $module;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;}
&amp;nbsp; return (array)$implementations[$hook];
} </description>
		<pubDate>Sat, 30 Apr 2011 16:21:10 +0800</pubDate>
	</item>
	<item>
		<title>node_invoke()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5704</link>
		<description>function node_invoke(&amp;amp;$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {&amp;nbsp; if (node_hook($node, $hook)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $module = node_get_types(&#039;module&#039;, $node);&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($module == &#039;node&#039;) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $module = &#039;node_content&#039;; // Avoid function name collisions.&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; $function = $module .&#039;_&#039;. $hook;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ($function($node, $a2, $a3, $a4));&amp;nbsp; }} </description>
		<pubDate>Sat, 30 Apr 2011 16:19:06 +0800</pubDate>
	</item>
	<item>
		<title>node_hook()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5703</link>
		<description>function node_hook(&amp;amp;$node, $hook) {&amp;nbsp; $module = node_get_types(&#039;module&#039;, $node);&amp;nbsp; if ($module == &#039;node&#039;) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $module = &#039;node_content&#039;; // Avoid function name collisions.&amp;nbsp; }&amp;nbsp; return module_hook($module, $hook); &amp;nbsp;//&amp;nbsp;return function_exists($module .&#039;_&#039;. $hook);}}  </description>
		<pubDate>Sat, 30 Apr 2011 16:18:20 +0800</pubDate>
	</item>
	<item>
		<title>node_build_content()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5702</link>
		<description>function node_build_content($node, $teaser = FALSE, $page = FALSE) {
&amp;nbsp; if (node_hook($node, &#039;view&#039;))&amp;nbsp; // node_content_view
&amp;nbsp;&amp;nbsp;&amp;nbsp; $node = node_invoke($node, &#039;view&#039;, $teaser, $page);
&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp; $node = node_prepare($node, $teaser);
&amp;nbsp;
&amp;nbsp; node_invoke_nodeapi($node, &#039;view&#039;, $teaser, $page);
&amp;nbsp; return $node;} </description>
		<pubDate>Sat, 30 Apr 2011 16:11:01 +0800</pubDate>
	</item>
	<item>
		<title>node_view()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5701</link>
		<description>function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {&amp;nbsp; $node = node_build_content($node, $teaser, $page);
&amp;nbsp;&amp;nbsp;$content = drupal_render($node-&amp;gt;content);&amp;nbsp; node_invoke_nodeapi($node, &#039;alter&#039;, $teaser, $page);
&amp;nbsp; return theme(&#039;node&#039;, $node, $teaser, $page);} </description>
		<pubDate>Sat, 30 Apr 2011 16:08:11 +0800</pubDate>
	</item>
	<item>
		<title>node_show()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5700</link>
		<description>function node_show($node, $cid, $message = FALSE) {&amp;nbsp; $output = node_view($node, FALSE, TRUE);
&amp;nbsp; if (function_exists(&#039;comment_render&#039;) &amp;amp;&amp;amp; $node-&amp;gt;comment) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $output .= comment_render($node, $cid);&amp;nbsp; }
&amp;nbsp; node_tag_new($node-&amp;gt;nid); // Update the &#039;last viewed&#039; timestamp
&amp;nbsp; return $output;} </description>
		<pubDate>Sat, 30 Apr 2011 16:04:33 +0800</pubDate>
	</item>
	<item>
		<title>node_page_view()</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5699</link>
		<description>function node_page_view($node, $cid = NULL) {&amp;nbsp; drupal_set_title(check_plain($node-&amp;gt;title));&amp;nbsp; return node_show($node, $cid);}    </description>
		<pubDate>Sat, 30 Apr 2011 16:00:09 +0800</pubDate>
	</item>
	<item>
		<title>node_page_default</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5698</link>
		<description>function node_page_default() {
&amp;nbsp; while ($node = db_fetch_object($result)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $output .= node_view(node_load($node-&amp;gt;nid), 1);&amp;nbsp;&amp;nbsp;&amp;nbsp; $num_rows = TRUE;&amp;nbsp; }
&amp;nbsp; if ($num_rows) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $feed_url = url(&#039;rss.xml&#039;, array(&#039;absolute&#039; =&amp;gt; TRUE));&amp;nbsp;&amp;nbsp;&amp;nbsp; drupal_add_feed($feed_url, variable_get(&#039;site_name&#039;, &#039;Drupal&#039;) .&#039; &#039;. t(&#039;RSS&#039;));&amp;nbsp;&amp;nbsp;&amp;nbsp; $output .= theme(&#039;pager&#039;, NULL, variable_get(&#039;default_nodes_main&#039;, 10));&amp;nbsp; }
&amp;nbsp;
&amp;nbsp; drupal_set_title(&#039;&#039;);
&amp;nbsp; return $output;
} </description>
		<pubDate>Sat, 30 Apr 2011 15:42:39 +0800</pubDate>
	</item>
	<item>
		<title>flow</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5696</link>
		<description>1. require_once &#039;./includes/bootstrap.inc&#039;;
define constant
declare libraries
2. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once &#039;./includes/common.inc&#039;; // const &amp;amp; lib_drupal_bootstrap_full()
&amp;nbsp; require_once &#039;./includes/theme.inc&#039;;&amp;nbsp; require_once &#039;./includes/pager.inc&#039;;&amp;nbsp; require_once &#039;./includes/menu.inc&#039;;&amp;nbsp; require_once &#039;./includes/tablesort.inc&#039;;&amp;nbsp; require_once &#039;./includes/file.inc&#039;;&amp;nbsp; require_once &#039;./includes/unicode.inc&#039;;&amp;nbsp; require_once &#039;./includes/image.inc&#039;;&amp;nbsp; require_once &#039;./includes/form.inc&#039;;&amp;nbsp; require_once &#039;./includes/mail.inc&#039;;&amp;nbsp; require_once &#039;./includes/actions.inc&#039;;
&amp;nbsp;
&amp;nbsp; drupal_set_header(&#039;Content-Type: text/html; charset=utf-8&#039;);
&amp;nbsp; unicode_check();
&amp;nbsp; fix_gpc_magic();
&amp;nbsp; module_load_all();
&amp;nbsp;
3. 
&amp;nbsp;&amp;nbsp; </description>
		<pubDate>Sat, 30 Apr 2011 14:31:57 +0800</pubDate>
	</item>
	<item>
		<title>bootstrap.inc</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5695</link>
		<description>1. constant define
&amp;nbsp;
2. function
timer_start($name)
timer_read($name)
timer_stop($name)
conf_path($require_settings = TRUE, $reset = FALSE)
drupal_unset_globals()
drupal_valid_http_host($host)
conf_init()
drupal_get_filename($type, $name, $filename = NULL)
&amp;nbsp;
variable_init($conf = array())
variable_get($name, $default)
variable_set($name, $value)
variable_del($name)&amp;nbsp;
&amp;nbsp;
page_get_cache($status_only = FALSE)
bootstrap_invoke_all($hook)
drupal_load($type, $name)
&amp;nbsp;
drupal_page_header()
drupal_page_cache_header($cache)
&amp;nbsp;
bootstrap_hooks()
drupal_unpack($obj, $field = &#039;data&#039;)
referer_uri()
&amp;nbsp;
check_plain($text)
drupal_validate_utf8($text)
request_uri()
watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)
drupal_set_message($message = NULL, $type = &#039;status&#039;, $repeat = TRUE)
drupal_get_messages($type = NULL, $clear_queue = TRUE)
drupal_is_denied($type, $mask)
drupal_anonymous_user($session = &#039;&#039;)
drupal_bootstrap($phase)
_drupal_bootstrap($phase)
drupal_maintenance_theme()
get_t()
drupal_init_language()
language_list($field = &#039;language&#039;, $reset = FALSE)
language_default($property = NULL)
ip_address() </description>
		<pubDate>Sat, 30 Apr 2011 14:18:43 +0800</pubDate>
	</item>
	<item>
		<title>drupal_unpack() @ bootstrap.inc</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5694</link>
		<description>/**&amp;nbsp;* Unserializes and appends elements from a serialized string.&amp;nbsp;*&amp;nbsp;* @param $obj&amp;nbsp;*&amp;nbsp;&amp;nbsp; The object to which the elements are appended.&amp;nbsp;* @param $field&amp;nbsp;*&amp;nbsp;&amp;nbsp; The attribute of $obj whose value should be unserialized.&amp;nbsp;*/function drupal_unpack($obj, $field = &#039;data&#039;) {&amp;nbsp; if ($obj-&amp;gt;$field &amp;amp;&amp;amp; $data = unserialize($obj-&amp;gt;$field)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach ($data as $key =&amp;gt; $value) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!empty($key) &amp;amp;&amp;amp; !isset($obj-&amp;gt;$key)) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $obj-&amp;gt;$key = $value;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; }&amp;nbsp; return $obj;}  </description>
		<pubDate>Sat, 30 Apr 2011 12:05:20 +0800</pubDate>
	</item>
	<item>
		<title>user_load() @ user.module</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5691</link>
		<description>1. get user info
db_query(&#039;SELECT * FROM {users} u WHERE &#039;. implode(&#039; AND &#039;, $query), $params);
&amp;nbsp;
2. get user role
db_query(&#039;SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d&#039;, $user-&amp;gt;uid);
&amp;nbsp;
/**&amp;nbsp;* Fetch a user object.&amp;nbsp;*&amp;nbsp;* @param $user_info&amp;nbsp;*&amp;nbsp;&amp;nbsp; Information about the user to load, consisting of one of the following:&amp;nbsp;*&amp;nbsp;&amp;nbsp; - An associative array whose keys are fields in the {users} table (such as&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uid, name, pass, mail, status) and whose values are the field&#039;s value.&amp;nbsp;*&amp;nbsp;&amp;nbsp; - A numeric user ID.&amp;nbsp;*&amp;nbsp;* @return&amp;nbsp;*&amp;nbsp;&amp;nbsp; A fully-loaded $user object upon successful user load or FALSE if user&amp;nbsp;*&amp;nbsp;&amp;nbsp; cannot be loaded.&amp;nbsp;*/function user_load($user_info = array()) {&amp;nbsp; // Dynamically compose a SQL query:&amp;nbsp; $query = array();&amp;nbsp; $params = array();
&amp;nbsp; if (is_numeric($user_info)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $user_info = array(&#039;uid&#039; =&amp;gt; $user_info);&amp;nbsp; }&amp;nbsp; elseif (!is_array($user_info)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; return FALSE;&amp;nbsp; }
&amp;nbsp; foreach ($user_info as $key =&amp;gt; $value) {&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($key == &#039;uid&#039; || $key == &#039;status&#039;) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $query[] = &quot;$key = %d&quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $params[] = $value;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ($key == &#039;pass&#039;) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $query[] = &quot;pass = &#039;%s&#039;&quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $params[] = md5($value);&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $query[]= &quot;LOWER($key) = LOWER(&#039;%s&#039;)&quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $params[] = $value;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; }&amp;nbsp; $result = db_query(&#039;SELECT * FROM {users} u WHERE &#039;. implode(&#039; AND &#039;, $query), $params);
&amp;nbsp; if ($user = db_fetch_object($result)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $user = drupal_unpack($user);
&amp;nbsp;&amp;nbsp;&amp;nbsp; $user-&amp;gt;roles = array();&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($user-&amp;gt;uid) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $user-&amp;gt;roles[DRUPAL_AUTHENTICATED_RID] = &#039;authenticated user&#039;;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $user-&amp;gt;roles[DRUPAL_ANONYMOUS_RID] = &#039;anonymous user&#039;;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; $result = db_query(&#039;SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d&#039;, $user-&amp;gt;uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; while ($role = db_fetch_object($result)) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $user-&amp;gt;roles[$role-&amp;gt;rid] = $role-&amp;gt;name;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; user_module_invoke(&#039;load&#039;, $user_info, $user);&amp;nbsp; }&amp;nbsp; else {&amp;nbsp;&amp;nbsp;&amp;nbsp; $user = FALSE;&amp;nbsp; }
&amp;nbsp; return $user;} </description>
		<pubDate>Sat, 30 Apr 2011 11:27:07 +0800</pubDate>
	</item>
	<item>
		<title>Create a new action</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5690</link>
		<description>1. hook_action_info() - describe the action to Drupal 
&amp;nbsp;
function user_action_info()&amp;nbsp;&amp;nbsp; return array(&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;user_block_user_action&#039; =&amp;gt; array(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;description&#039; =&amp;gt; t(&#039;Block current user&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;type&#039; =&amp;gt; &#039;user&#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;configurable&#039; =&amp;gt; FALSE,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;hooks&#039; =&amp;gt; array(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;nodeapi&#039; =&amp;gt; array(&#039;presave&#039;, &#039;delete&#039;, &#039;insert&#039;, &#039;update&#039;, &#039;view&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;comment&#039; =&amp;gt; array(&#039;view&#039;, &#039;insert&#039;, &#039;update&#039;, &#039;delete&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;user&#039; =&amp;gt; array(&#039;logout&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;user_block_ip_action&#039; =&amp;gt; array(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&amp;nbsp; );}
&amp;nbsp;
1. http://drupal6/admin/settings/actions&amp;nbsp;
2. &#039;user_block_user_action&#039;
function name of the action (key)
modulename + description of what the function does + &#039;_action&#039;
user + block user + action
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
2. Writing an action
function user_block_user_action(&amp;amp;$object, $context = array()) {&amp;nbsp; // get the uid from the object&amp;nbsp; if (isset($object-&amp;gt;uid)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $uid = $object-&amp;gt;uid;&amp;nbsp; }&amp;nbsp; elseif (isset($context[&#039;uid&#039;])) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $uid = $context[&#039;uid&#039;];&amp;nbsp; }&amp;nbsp; else {&amp;nbsp;&amp;nbsp;&amp;nbsp; global $user;&amp;nbsp;&amp;nbsp;&amp;nbsp; $uid = $user-&amp;gt;uid;&amp;nbsp; }&amp;nbsp; // make sure we have a user record&amp;nbsp; if ($uid) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $user = user_load($uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; // block the user&amp;nbsp;&amp;nbsp;&amp;nbsp; db_query(&quot;UPDATE {users} SET status = 0 WHERE uid = %d&quot;, $uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; // log out the user&amp;nbsp;&amp;nbsp;&amp;nbsp; sess_destroy_uid($uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; // record a message noting the action taken&amp;nbsp;&amp;nbsp;&amp;nbsp; watchdog(&#039;action&#039;, &#039;Blocked user %name / uid=%uid.&#039;, array(&#039;%name&#039; =&amp;gt; check_plain($user-&amp;gt;name), &#039;%uid&#039; =&amp;gt; $uid));&amp;nbsp; }}?&amp;gt; </description>
		<pubDate>Sat, 30 Apr 2011 11:03:31 +0800</pubDate>
	</item>
	<item>
		<title>Code place</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5688</link>
		<description>1. includes/actions.inc The actions engine, which executes actions
&amp;nbsp;
2. modules/trigger.moduleThe dispatcher for actions
&amp;nbsp;
3. modules/system.moduleThe configuration screens for adding, removing, and configuring individual actions
&amp;nbsp;
4. modules/trigger.moduleThe interface for assigning actions to events (that is, hooks)
&amp;nbsp;
5. individual modulesThe hook that describes actions (hook_actions_info()) and the actions themselves live inEx. Actions that affect nodes, like the &quot;Publish node&quot; action, live in node.module </description>
		<pubDate>Sat, 30 Apr 2011 10:40:49 +0800</pubDate>
	</item>
	<item>
		<title>RegExp 物件</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5541</link>
		<description>1. exec()2. test() </description>
		<pubDate>Mon, 18 Apr 2011 01:04:17 +0800</pubDate>
	</item>
	<item>
		<title>String Method</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5540</link>
		<description>1. search()比對並傳回位置，return -1 或 第一個符合的子字串起點的位置ex. var pos = &quot;Javascript&quot;.search(/script/i); // return 42. replace()比對並取代，ex.1. text.replace(/javascript/gi, &quot;JavaScript&quot;);2. text.replace(/&quot;([^&quot;]*)&quot;/g, &quot;&#039;$1&#039;&quot;);3. match()比對並傳回陣列4. split()分割字串       </description>
		<pubDate>Mon, 18 Apr 2011 00:55:23 +0800</pubDate>
	</item>
	</channel>
	</rss>
