星期五, 6月 26, 2009

CodeIgniter User Guide Version 1.7.1

General

  • Class names must have the first letter capitalized with the rest of the name lowercase.
    ex : class Model_name extends Model {}
  • The file name will be a lower case version of your class name.
    ex : application/models/user_model.php

Controller

  • A Controller is simply a class file that is named in a way that can be associated with a URI
  • If your controller contains a function named _remap(), it will always get called regardless of what your URI contains.
  • To make a function private, simply add an underscore as the name prefix and it will not be served via a URL request. ex: function _utility()

Views

  • Views are never called directly, they must be loaded by a controller.
  • $this->load->view('folder_name/file_name');
  • There is a third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser.
    ex : $string = $this->load->view('myfile', '', true);

Models

  • Models are PHP classes that are designed to work with information in your database.
  • Your models will typically be loaded and called from within your controller functions.
  • Once loaded, you will access your model functions using an object with the same name as your class:
    $this->load->model('Model_name');
    $this->Model_name->function();
  • If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:
    $this->load->model('Model_name', 'fubar');
    $this->fubar->function();
  • When a model is loaded it does NOT connect automatically to your database.
  • You can tell the model loading function to auto-connect by passing TRUE (boolean) via the third parameter, and connectivity settings, as defined in your database config file will be used:
    $this->load->model('Model_name', '', TRUE);

Helper Functions

  • Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions.
  • CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller and views.
  • Loading Multiple Helpers. ex: $this->load->helper( array('helper1', 'helper2', 'helper3') );
  • all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

Plugins

  • Plugins work almost identically to Helpers. The main difference is that a plugin usually provides a single function, whereas a Helper is usually a collection of functions.
  • Loading Multiple Plugins. ex: $this->load->plugin( array('plugin1', 'plugin2', 'plugin3') );

Common Functions

  • is_really_writable('path/to/file')
  • config_item('item_key')
  • show_error('message'), show_404('page'), log_message('level', 'message')

Scaffolding

  • Scaffolding is intended for development use only.
  • $this->load->scaffolding('table_name');
  • example.com/index.php/class/secret_word/

URI Routing

  • example.com/class/function/id/
  • example.com/product/1/ => $route['product/(:num)'] = "catalog/product_lookup_by_id/$1"
  • $route['product/:any'] = "catalog/product_lookup";

Error Handling

  • Disabling error reporting will NOT prevent log files from being written if there are errors.

codeIgniter

最近在使用新的手法來開發傳統的php網頁,所用的frame work叫codeIgniter,採用物件導向的寫法,這和Flex的本值很相像(物件導向不都是這樣),所以用起來還覺得滿親切的。
目前還是看它的manuel,會把它的重點慢慢的記下來

星期六, 5月 16, 2009

最珍貴的角落

今天(應該說是昨天了)是個值得紀念的日子,雖然回到外婆家已經很晚了,但還是一定要把心理的這份悸動紀錄下來!

星期五, 5月 15, 2009

還好我不是活在法國

今天看到一篇news『法國下議院通過非法下載三次即斷網一年的法例』,雖然還需要再通過上議院的審議才會正式的合法執行,但光是想到法國竟很認真的針對這個議題來立法,也夠叫人顫慄的。
還好我們這票人不是活在法國 ,不過我想最慘的應該會是jack同學吧,他會被斷線一輩子!

星期三, 5月 13, 2009

「鋼琴王子」李雲迪

今天在聽『不能說的秘密』原聲帶時,突然很想看一下周董彈琴,所以上去youtube去找了一下,結果發現周董在2007年香港演唱會的時候,竟然有和李雲迪一同上台表演,真是驚喜 !
李雲迪朗朗同是大陸最知名的彈琴家,而且都才20幾歲卻得獎無數,李雲迪比朗朗還早成名,但朗朗的表演和風格較俱行銷的手法,所以名氣反而比李雲迪大得多,連2008北京奧運會開幕式請的都是朗朗來演奏。
不過我還是比較喜歡李雲迪的演奏風格,優雅、內斂 、富有詩意,2007周董的演唱會請到他來彈奏不能說的秘密中的『secret』,真是精彩,而且在香港他們還一起四手聯彈表演過。
其實就在五月初,李雲迪在國家音樂廳有鋼琴獨奏會,但是我們剛好在趕中研院的案子無法去聽,真的很可惜,只能期待他下次再來台表演囉

星期日, 5月 10, 2009

Flex的中文字型嵌入

今天在做Flex的中文字型嵌入
其實這有好幾種方法,也從網路上看到了很多前輩的心得
我來整理一下:
  1. 在server端下手: 可以參考這篇文章,作者demo了在Flex端把文字輸入,再把這包string傳到server端給php去做即時的轉換,產生出一包新的且轉好字型的swf,再丟回去給Flex。這是需要對server有了解,且可以操作到server的user用的,但是真的可以做到即時的中文字型轉換
  2. 在Flex動手:主要也有四個方式
    • 將字型檔案全部embed進flex
    • 用連結的方式來載入外部的字型檔案
    • 用unicode的方式只載入所需的特定字
    • 將字在Flash中設定好(打好字、選好字型),再設定到Flex的css中(這有demo)
因為是從視覺出身的吧,對Flash還算小熟
所以最後的這個方法應該說是最無敵的
而且也是最穩定的方法

另外順帶一提
Flash Player 10可以抓到並支援local的中文字型
還可以開啟與儲存local檔案(這有demo)
這也是一大的福音呀

星期四, 5月 07, 2009

泰式民主與泰國人的眼淚

前陣子看到劉必榮教授的一篇文章『泰式民主與泰國人的眼淚』,解釋了泰國的政治歷史和紅衫軍、黃衫軍的立場,雖然紅衫軍的暴動結束了,但泰國的政壇並沒有隨之恢復平靜,塔信所帶來的政治問題並沒有得到解決,而泰王年事已高、臥病在床,這次也沒出面,所以未來的泰國政局還有待觀察。

泰式民主與泰國人的眼淚


前陣子看到劉必榮教授的一篇文章『泰式民主與泰國人的眼淚』,解釋了泰國的政治歷史和紅衫軍、黃衫軍的立場,雖然紅衫軍的暴動結束了,但泰國的政壇並沒有隨之恢復平靜,塔信所帶來的政治問題並沒有得到解決,而泰王年事已高、臥病在床,這次也沒出面,所以未來的泰國政局還有待觀察。

星期三, 4月 29, 2009

最後的朋友

最近大家在迷日劇『最後的朋友』,真是被它寫實又驚聳的劇情深深的吸引
看前幾集時,會以為這就是一部家庭暴力片,雖然暴力,但心卻被劇情緊緊的抓住
會忍不住往下看第二集
但在看了第二集之後,卻又忍不住會想知道第三集的發展
就這樣.....,很容易一口氣就看完了

之後再來回想
這是一部在訴說『愛』的故事
每個人有不同表達愛的方式
而愛,也以不同的形式存在著
劇中的每個人都掙扎在不同的關係和目的中
有的人只會愛自己,有的人只會愛別人
有的人很會表達愛,有的人只會收藏愛
就是因為太多太多不同的情感交錯在一起
讓這部戲精彩極了

每當宇多田的Prisoner of Love的音樂一起
心就又糾結了起來

第一次聽這首歌時還沒看日劇,所以一點感覺也沒有
但看過後再來聽,真是超有fu的
如果想要感受一下不同方式的愛和形式的愛
那請來看一下吧

星期日, 4月 12, 2009

AIG: Arrogance, Incompetence, Greed.


歐巴馬雖然還是會對AIG申出援手,但是AIG分發紅利的事件已經讓大家對它們失去耐心和同情,一位us的參議員說AIG = Arrogance, Incompetence, Greed.(傲慢、無能、貪婪),這真是說得太好了!
經濟學上說"Too big to fail"(太大了,以致於不能倒),是害怕這個金融怪獸一但垮了,會波及更多的人,但是不置之死地,怎麼會有重生的感覺呢 ? 像GM一樣的進行重整,也許才是讓AIG重新再站起來的方法,這一切,就看歐巴馬如何的對應了

星期三, 4月 08, 2009

沒更新不代表沒學習

真的很久沒有更新blog了!
雖說是威廉的學習日記,不過沒有更新不代表沒有學習喔
反而是學得太多、太快了
根本來不及學在blog上呀


花了一年的時間學習Flex,是真的有很多的進步
但還談不上到透徹的程度
仍需要花很多的時間去研究、看書
更重要的是,每天去寫它

除此之外,也花了很多的時間去看了不少課外讀物
由其是對世界歷史、經濟學還有歐巴馬很有興趣
以後要多多把讀書心得都記起來
不然以我建忘的個性,真的一下子就還給書本了

星期三, 7月 30, 2008

星期一, 7月 28, 2008

Flickr

This is a test post from flickr, a fancy photo sharing thing.

真的很開心,終於找到一個超棒的圖片網站
我的照片實在太多了,而且欠太多人照片沒給了
所以有了flickr後,一定會好好整理一下
敬請期待吧!

星期日, 7月 27, 2008

What is The Optimal Business Model for Today's Web?

好久沒有更新學習日記了,我想是這段時間都在瞎忙,沒有學習當然沒有東西可以記!應該再多用功一點!

今天看到一篇文章:What is The Optimal Business Model for Today's Web?
講的是當今web最理想的商業模式,其中的一些想法很好:
  1. Once upon a time, if you wanted to create a successful application, one of the keys to success was to 'offer a lot of features your competitors don't have. Adobe's Photoshop is one such application.
    做得比對手更多、更龐大,這是很好的,
    但這已是過去的方式。
  2. I think [a] better [approach] is to find the lowest common denominator, an underlying basic need that connects all these various niches, cater to that, open it up and let mashups do the rest. This way, people can choose exactly which features they want to use, and your application becomes a fluid, modular service that can be as simple or as complex as the use wants it to be.
    找到一個簡易的模式切入,並開放它(API),讓多人的力量使程式更強大,而且因為簡易使人們更好去選則自己所需的
  3. We need to be really careful not to mistake the apparent simplicity of less for real simplicity that can lead to a paradigm shift.
    真正的簡單能引起思維的轉換
  4. Simple things should be simple and hard things should be possible
    讓簡單的事保持簡單,使困難的事成為可能
很適合我們現在的心境呀!

星期三, 1月 02, 2008

flash player跨網域的問題 (flex3與flash cs3都適用)

今天花了一整天的時間在研究RSS,先是用flex3來寫RSS的簡易版閱讀器,完成後卻發現本機可以執行,一upload到網路後卻動彈不得了,原來是flash player跨網域的問題。

flash player要讀遠端的RSS資料(也就是載入一個遠端的XML),基本的解法,如是在不同子網域(如www.m-w.com.tw或npbp.m-w.com.tw),那就只需要在flash中寫一個System.security.allowDomain("*.m-w.com.tw")就可以了;若是不同的網域(如www.m-w.com.tw或www.edimax.com.tw那就需要寫一個crossDomain.xml(寫法可參考這),然後把這crossDomain.xml檔案放到提供資料的那一端才行,比如你想載入yahoo的RSS(就像這個),那你需要將crossDomain.xml這檔案放到yahoo的server中才可以。...............這怎麼可能呢?在作夢嗎?

我在想,這是不是flex3的限制,所以改採flash cs3也寫一個RSS的簡易版閱讀器,結果一樣,無法解決flash player跨網域的問題,有一篇在介紹flash player安全性的文章寫得很好,可以參考一下。

最後,想到了個方法,先用php將遠端yahoo的RSS讀進來,這不就是在本地端了嗎,然後再用flash去載入php不就解決了!沒錯,這就是正解,雖然很笨,但還是解決了(成品在師大師培處網站的左上方新聞區),看了網路上一些前輩們似乎也是用相同的方法來解決兩個不同網域的問題。

其實我想,應該有更高級一點的解法,flex3都可以支援wsdl直接轉換成as來用了,表示flex對於web service的支援性相當的好,RSS(XML)應該更不在話下,小弟才疏學淺,如果有哪位前輩通曉解決良方,望請指導一下囉!

星期六, 12月 01, 2007

Mac or Windows

今天在youTube看了很多Steve Jobs在WWDC 2007中介紹Mac新OS "Leopard "的功能,讓我又心動了很久,一直在視覺與程式間游移,總覺得作設計的好像就應該要用Mac才算是專業,但是很多的網路應用又的確是windows比較有彈性,我想那天我應該會先去買台Mac Mini來玩玩吧。

Apple WWDC 2007 (Safari)




Apple WWDC 2007 (iChat)


引用:
華盛頓後面的那個是微軟的執行長Steve Ballmer,人瘋瘋癲癲的
有關他的介紹http://en.wikipedia.org/wiki/Steve_Ballmer
有關他的影片http://www.youtube.com/watch?v=uB1DXm4vBgk
常常在公開的場合冷嘲熱諷有關Apple的產品
http://www.youtube.com/watch?v=C5oGaZIKYvo&feature=related
Phil用他的照片在這段影片講的是"I love my Mac"



Apple WWDC 2007 (Time Machine)


星期四, 9月 15, 2005

My blog is opening.

My blog is opening.