Archive

‘PHP’ 分類過的Archive

載入module下的model

2011年4月20日 尚無評論

首先感謝我在此找到解答,趕快做個筆記!

Zend Framework modular app, can’t load models for each module, autoloading models?

controller:
/application/modules/member/controllers/AuthController.php

<?php

class Member_AuthController extends Zend_Controller_Action
{
    public function init()
    {
        /* Initialize action controller here */
        $this->_helper->layout()->setLayout('layouta');
    }

    public function indexAction()
    {
        // action body
    }

    public function loginAction()
    {
        // action body
        $user = new Member_Model_User();  //之前就是這個一直顯示錯誤
        // 底下略
    }
}

閱讀全文…

Categories: Zend Framework Tags:

PHP的多語系環境建立-part1-系統設定

2011年3月21日 尚無評論

系統要確定中文語系:


$ less /usr/share/i18n/SUPPORTED |grep zh_

如何新增中文語系:
#參考http://plog.longwin.com.tw/my_note-unix/2009/11/18/ubuntu-910-add-set-locale-gen-2009

$ sudo locale-gen zh_TW
$ sudo locale-gen zh_TW.UTF-8
$ sudo locale-gen zh_CN
$ sudo locale-gen zh_CN.UTF-8

閱讀全文…

Categories: PHP, 程式設計 Tags: ,

Zend Framework資源

2011年3月9日 尚無評論
Categories: PHP, Zend Framework Tags:

Zend Framework DOCTYPE!

2011年2月15日 1 則評論

現行最普遍好用的DOCTYPE是 XHTML1_TRANSITIONAL

XHTML11:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

XHTML1_STRICT:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML1_TRANSITIONAL:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML1_FRAMESET:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML1_RDFA:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

XHTML_BASIC1:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">

HTML4_STRICT:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

HTML4_LOOSE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

HTML4_FRAMESET:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

HTML5:
<!DOCTYPE html>

Zend Framework 產生 FORM

2011年1月21日 尚無評論

產生留言版的 FORM

指令:
zf create form Guestbook

andy@nb3vm:~/www/rdlab/application$ zf create form Guestbook
Creating a form at /home/andy/www/rdlab/application/forms/Guestbook.php
Updating project profile ‘/home/andy/www/rdlab/.zfproject.xml’

產生 application/forms/Guestbook.php

編輯一下原本的內容修改成我們需要的,如下:

<?php
class Application_Form_Guestbook extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
        // Set the method for the display form to POST
        $this->setMethod('post');

        // Add an email element
        $this->addElement('text', 'email', array(
            'label'      => 'Your email address:',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'EmailAddress',
            )
        ));

        // Add the comment element
        $this->addElement('textarea', 'comment', array(
            'label'      => 'Please Comment:',
            'required'   => true,
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 20))
                )
        ));

        // Add a captcha
        $this->addElement('captcha', 'captcha', array(
            'label'      => 'Please enter the 5 letters displayed below:',
            'required'   => true,
            'captcha'    => array(
                'captcha' => 'Figlet',
                'wordLen' => 5,
                'timeout' => 300
            )
        ));

        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Sign Guestbook',
        ));

        // And finally add some CSRF protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));
    }
}

接著要將 signAction() 加到 GuestbookController 以處理 FORM 的遞送
用以下的方式建立 action並且關聯到 view 裡

andy@nb3vm:~/www/rdlab/application$ zf create action sign Guestbook
Creating an action named sign inside controller at /home/andy/www/rdlab/application/controllers/GuestbookController.php
Updating project profile ‘/home/andy/www/rdlab/.zfproject.xml’
Creating a view script for the sign action method at /home/andy/www/rdlab/application/views/scripts/guestbook/sign.phtml
Updating project profile ‘/home/andy/www/rdlab/.zfproject.xml’

經由執行結果看到新增了一個 signAction() 方法到 controller 以及相對應的 view 內容。

閱讀全文…

Categories: PHP, Zend Framework Tags: ,