網頁

2012年8月21日 星期二

CodeIgniter開發筆記-安裝

安裝CodeIgniter超簡單,先確定server有安裝php,我用的是php 5.3

1. 下載CodeIgniter,目前是2.1.2
網址:http://codeigniter.com/downloads/ 或 http://www.codeigniter.org.tw/downloads

2. 上傳至server上的apache root directory

3. 解壓縮

這樣就可以用了,容易吧

若要放入中文,可至https://github.com/CodeIgniter-TW/CodeIgniter-Language,最底下有安裝方式。
1. 先至system/language
2. git clone https://github.com/CodeIgniter-TW/CodeIgniter-Language.git
3. mv CodeIgniter-Language zh_tw
4. 編輯 applicaion/config/config.php,

找到$config['language'] = 'en';
改成$config['language'] = ' tw-zh';


參考網址:
原文官網:http://codeigniter.com/
中文官網:http://www.codeigniter.org.tw/
中文文件:http://www.codeigniter.org.tw/user_guide/

2012年8月20日 星期一

CentOS筆記-安裝ORACLE(sun) jdk

1. 先到http://www.oracle.com/technetwork/java/javase/downloads/index.html下載需要的jdk

2. 上傳到cent os上(想要直接用wget下載,不過看來都是javascript的轉址動作)
3. chmod 775 jdk-6u34-linux-x64-rpm.bin(我下載的是jdk 1.6)
4. ./jdk-6u34-linux-x64-rpm.bin
5. alternatives --config java(會有選項出現,就選擇自己剛安裝的那個,我的狀況是只有一個)

若不想執行第5步,其實可以用JAVA_HOME的方式,在執行的script前,寫入

JAVA_HOME=(java安裝的目錄)
export JAVA_HOME

[更新]
安裝好是放
/usr/java
在此可以看到剛才案裝好的,就
export JAVA_HOME=/usr/java/(java安裝的目錄)
export PATH:/usr/java/(java安裝的目錄)/bin:$PATH

這樣就可以的

參考網址:
CentOS – Install Java Sun JDK

jQuery Validate中文訊息的設定方式

工程師當久了,尤其是一開始在外商幫忙過,習慣看英文,但出來做了這段時間,客戶還是對中文感覺比較親切,雖然jQuery Validate好用,但放中文上去,就是都不行,找了找才發現,原來是我的問題,哈哈,設中文要如下:

var cnmsg = {
  required: "必選字段",
  remote: "請修正該字段",
  email: "請輸入正確格式的電子郵件",
  url: "請輸入合法的網址",
  date: "請輸入合法的日期",
  dateISO: "請輸入合法的日期 (ISO).",
  number: "請輸入合法的數字",
  digits: "只能輸入整數",
  creditcard: "請輸入合法的信用卡號",
  equalTo: "請再次輸入相同的值",
  accept: "請輸入擁有合法後綴名的字符串",
  maxlength: jQuery.format("請輸入一個長度最多是{0} 的字符串"),
  minlength: jQuery.format("請輸入一個長度最少是{0} 的字符串"),
  rangelength: jQuery.format("請輸入一個長度介於{0} 和{1} 之間的字符串"),
  range: jQuery.format("請輸入一個介於{0} 和{1} 之間的值"),
  max: jQuery.format("請輸入一個最大為{0} 的值"),
  min: jQuery.format("請輸入一個最小為{0} 的值")
};
jQuery.extend(jQuery.validator.messages, cnmsg);


我copy了我參考的網址,再都弄成繁體,我想很多人會想用吧,呵~
網路果然是共享的天堂。

參考網址:
http://blog.csdn.net/ecjtuxuan/article/details/5731130

2012年8月18日 星期六

Wordpress開發筆記 - 設定後台某個選單子選項的權限

最近出了個bug,是權限的問題,對wordpress不熟,找半天,才知道在設定後台menu時,其中的capability,是有差別的,而且現在的版本不再以1~10來分配,不過用到的那個plugin還是以數字來處理,看到裡頭設定為manager_options,想給這個管理者這個權限,又發現放進去後,就多了很多的選單,再找找看來這個使用者是"editor"這角色,只能針對那個功能給。

基本上walk around的解法是,在加上那個功能時,直接設定level,如:

add_submenu_page(basename('showdata.php'), '新功能', '新功能', 7,basename('showdata.php') ,'show_page');


如上述紅色數字,editor的level是7,自然可以使用這個功能。

不過後來的解決是,就挑個只有"Editor"能用的權限,設定進去就行了,例如'edit_private_posts'這個權限,就可以寫成
add_submenu_page(basename('showdata.php'), '新功能', '新功能', 'edit_private_posts',basename('showdata.php') ,'show_page');

這樣不用動到任何的東西。似乎有點取巧,哈哈

參考網址:
http://codex.wordpress.org/Roles_and_Capabilities#manage_options
http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/
http://justintadlock.com/archives/2009/08/30/users-roles-and-capabilities-in-wordpress

2012年8月10日 星期五

iOS開發筆記 - app內直接播放YouTuBe影片

最近有個需要,客戶想要做到的效果是YouTuBe影片在iOS上能
1. 在原有的app中執行,不可離開
2. 全螢幕
3. 橫向看

我的方式是先加入一個ViewController ,命名為YouTuBeController,為了設成橫向,如下所示:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == (UIDeviceOrientationLandscapeLeft) );
}

再來是要加入YouTuBe影片,用WebView來載入,我拿足球影片來當範例(取得影片的url,請參考我最底下網址參考的最後一個link,有官方說明)程式碼如下:

UIWebView *youTubeWebView = nil;
if (youTubeWebView == nil) {
        UIScreen *screen = [UIScreen mainScreen];
        CGRect frame = [screen applicationFrame];
        youTubeWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, frame.size.height, frame.size.width)];
        youTubeWebView.delegate = self;
}

NSString* embedHTML = @"\ 
    <html><head>\ 
    <style type=\"text/css\">\ 
    body {\ 
        background-color: transparent;\ 
        color: white;\ 
    }\ 
    </style>\ 
    </head><body style=\"margin:0\">\ 
   <iframe width=\"%0.0f\" height=\"%0.0f\" src=\"%@?rel=0\" frameborder=\"0\" allowfullscreen></iframe> \
    </body></html>";
    
    NSString* html = [NSString stringWithFormat:embedHTML, youTubeWebView.frame.size.width, youTubeWebView.frame.size.height, @"http://www.youtube.com/embed/yGS6F-buYZw"];

[youTubeWebView loadHTMLString:html baseURL:nil];
self.view = youTubeWebView; //將view設成剛建好的webview

參考網址
How To Play YouTube Videos Within an Application
How to play youtube movie?
How to Watch YouTube Videos on Your iPhone
YouTube APIs + iPhone = Cool mobile apps

官網:
如何嵌入 YouTube 影片