ã¯ããã«
ãæ¬é£è¼ã§ã¯ãPHPä¸ã§åä½ããã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ããZend Frameworkã«ã¤ãã¦ç´¹ä»ãã¦ããã¾ããä»åã¯å¼ãç¶ãZend_Controllerã®ææ°æ©è½ãç´¹ä»ãããã¨æãã¾ããååã¯ã«ã¼ãã£ã³ã°ã®æ°æ©è½ãè¦ã¦ã¿ã¾ããããä»åã¯ã¢ã¯ã·ã§ã³ã³ã³ããã¼ã©ã¼ã¾ããã®å¤æ´ãç´¹ä»ãããã¨æãã¾ãã
対象èªè
ãPHPã®åºæ¬æ§æãã«ã¤ãã¦ã¯ä¸éãç解ãã¦ããæ¹ã対象ã¨ãã¦ãã¾ããã¾ããéå»ã®è¨äºããã®å·®åãä¸å¿ã«æ±ã£ã¦ãããããå¿ è¦ã«å¿ãã¦éå»ã®è¨äºãåç §ãã¦ãã ããã
å¿ è¦ãªç°å¢
ãZend Frameworkã¯PHP 5.2.4以éã¨Webãµã¼ããã¤ã³ã¹ãã¼ã«ããã¦ããç°å¢ã§å©ç¨å¯è½ã§ããæ¬ç¨¿ã§ã¯Webãµã¼ãã¨ãã¦Apache 2.2ããOSã«Windows XPãæ¡ç¨ããã¢ããªã±ã¼ã·ã§ã³ãä½æãã¦ããã¾ãã
ã以ä¸ã«ãä»åã¢ããªã±ã¼ã·ã§ã³ä½æï¼åä½ç¢ºèªã«ç¨ããç°å¢ã示ãã¾ãï¼ã¤ã³ã¹ãã¼ã«ã«ããã£ã¦ã¯ææ°å®å®çã®ä½¿ç¨ãæ¨å¥¨ãã¾ãï¼ãåé ç®ã®è©³ç´°ãªã¤ã³ã¹ãã¼ã«æé ã¯ãããµã¼ããµã¤ãæè¡ã®å¦ã³è - WINGSãããããµã¼ããµã¤ãç°å¢æ§ç¯è¨å®æé ããåç §ãã ããã
- Windows XP SP3
- PHP 5.3.3
- Apache 2.2.16
ãLinuxãFreeBSDãªã©UNIXç³»OSãã使ãã®æ¹ãã³ãã³ãã¯ã»ã¼ä¸ç·ãªã®ã§ããã¹ãªã©ã¯é©å®èªã¿æ¿ãã¦ãã ããã
ã¢ã¯ã·ã§ã³ãã«ãã¼
ãã¢ã¯ã·ã§ã³ãã«ãã¼ã¯ä»¥åç´¹ä»ããã¨ãããã¢ã¯ã·ã§ã³ã³ã³ããã¼ã©ã¼ã®æ©è½ãè£å©ãã¾ãããã®ã¢ã¯ã·ã§ã³ãã«ãã¼ã¯ä»¥åç´¹ä»ããã¨ãããï¼ã¤ã種é¡ãå¢ãã¦ãã¾ãã
åé¡ | ãã«ãã¼å | 説æ |
å¾æ¥ãããã£ããã® | FlashMessenger | ãªã¯ã¨ã¹ããã¾ããã£ãã¡ãã»ã¼ã¸ã®ä¿å |
ViewRenderer | Zend_Viewã³ã³ãã¼ãã³ãã¨ã®é£æº | |
Redirector | ãªãã¤ã¬ã¯ãé¢ä¿ | |
追å ããããã® | AutoComplete | è£å®æ©è½ã¤ãããã¹ãå ¥åã®è£å©ï¼ãªã¼ãã³ã³ããªã¼ãï¼ |
ContextSwitch | è¦æ±ãã©ã¼ãããã«å¯¾å¿ãã¦åºåãå¤æ´ | |
AjaxContext | ContextSwitchã®AJAXç¨ç | |
Json | JSONå½¢å¼ã§ã®åºå |
ãå¢ããã¢ã¯ã·ã§ã³ãã«ãã¼ã¯4種é¡ã§ã大é¨åãAJAXæ©è½ãè£å©ããããã®ãã®ã§ãããã¡ãã«ã¤ãã¦ãé çªã«è¦ã¦ããã¾ãããã
è£å®æ©è½ã¤ãããã¹ãå ¥åã®è£å©ï¼AutoCompleteï¼
ãå¤ãã®JavaScriptãã¼ã«ãããã§ã¯ãã¦ã¼ã¶ãå ¥åãã¦ããããã¹ããè£å®ããæ©è½ï¼ãªã¼ãã³ã³ããªã¼ãï¼ãæã¤ããã¹ãå ¥åãæä¾ãã¦ãã¾ããä¾ãã°Dojoãã¼ã«ããããªãComboBoxã¦ã£ã¸ã§ããã«ãã®ãããªæ©è½ãããã¾ãã
ãAutoCompleteã¢ã¯ã·ã§ã³ãã«ãã¼ã¯ããã®ãããªãªã¼ãã³ã³ããªã¼ãæ©è½ã®ããã¦ã£ã¸ã§ããã«å¯¾ãã¦ãè£å®ã®åè£ãéãæ©è½ãæä¾ãã¾ããç¾å¨ãAutoCompleteã¢ã¯ã·ã§ã³ãã«ãã¼ã対å¿ãã¦ããã®ã¯Dojoãã¼ã«ãããã¨Scriptaculousãã¼ã«ãããã§ãã
ãããã§ãDojoã®ComboBoxã¦ã£ã¸ã§ããã対象ã¨ãã¦ãAutoCompleteã¢ã¯ã·ã§ã³ãã«ãã¼ãå©ç¨ããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãããªãããã®ããã«Zend_Dojoã³ã³ãã¼ãã³ããå©ç¨ãã¾ããZend_Dojoã®è©³ç´°ã«ã¤ãã¦ã¯ä»¥åã®è¨äºãåç §ãã¦ãã ããã
ãããã§ã¯ãã¾ãZend_Dojoã³ã³ãã¼ãã³ãã®è¨å®ã¨ComboBoxã®ä½æããè¦ã¦ããã¾ãããã
public function comboboxAction() { $view = $this->view; /* ï¼1ï¼Zend_Dojoãæå¹ã«ãã */ Zend_Dojo::enableView($view); Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); $dojo = $view->dojo(); /* ï¼2ï¼Dojoã®å ´æãæå®ãã */ $dojo->setCdnVersion('1.5.0'); $dojo->setCdnBase(Zend_Dojo::CDN_BASE_AOL); /* ï¼3ï¼Dojoå´ã§å©ç¨ãããã¡ã¤ã«ã®æå® */ $dojo->addStyleSheetModule('dijit.themes.tundra'); $dojo->requireModule('dijit.form.ComboBox'); $dojo->requireModule('dijit.form.Form'); $dojo->requireModule('dojo.data.ItemFileReadStore'); /* ï¼4ï¼ComboBoxãå«ããã©ã¼ã ã®ä½æ */ $url = $view->url(array('action'=>'autocomplete')); //ï¼4-1ï¼ $form = new Zend_Dojo_Form; $form->addElement('ComboBox','cbox', array('label'=>'Combo Box', 'value'=>'beta', 'autocomplete'=>true, 'storeId' => 'cboxStore', 'storeType' => 'dojo.data.ItemFileReadStore', 'storeParams' => array('url' => $url),//ï¼4-2ï¼ ) ); $view->assign('form', $form); }
ãï¼1ï¼ã§ã¯ãã¾ãZend_Dojoã³ã³ãã¼ãã³ããå©ç¨ããããã®ä¸æºåããã¦ãã¾ããï¼2ï¼ã§Dojoãã¼ã«ãããã®å ´æãæå®ãã¦ãã¾ããããã§ã¯AOLãæä¾ãã¦ããCDNã«ãããã®ãå©ç¨ããããã«è¨å®ãã¦ãã¾ããï¼3ï¼ã§ã¯Dojoå´ã§ãã©ã®ãããªãã¡ã¤ã«ãå©ç¨ãããã®è¨å®ããã¦ãã¾ãã
ãããã¦ï¼4ï¼ã§å®éã«ComboBoxãä½æãã¦ãã¾ãããã®ä¸ã®ï¼4-2ï¼ã§æ¸¡ãã¦ãããstoreParamsããã©ã¡ã¼ã¿ã§è£å®ã®åè£ãçæããURLãæå®ãã¦ãã¾ãããã®URLã¯ï¼4-1ï¼ã§ä½æãã¦ããããautocompleteãã¢ã¯ã·ã§ã³ã示ãURLã«ãªã£ã¦ãã¾ãã
ããã®ãåè£ãä½æãããautocompleteãã¢ã¯ã·ã§ã³ã§autoCompleteã¢ã¯ã·ã§ã³ãã«ãã¼ã使ãã¾ãã
public function autocompleteAction() { /* åè£ã®ä¸è¦§ */ $data = array('alpha','beta','gamma','delta','epsilon','zeta', 'eta','theta','iota','kappa','lambda','mu', 'nu','xi','omicron','pi','rho','sigma','tau', 'upsilon','phi','chi','psi','omega'); /* åè£ãJSONå½¢å¼ã§éä¿¡ */ $this->_helper->autoCompleteDojo($data); }
ããã®ããã«ãåè£ãé åã«æ ¼ç´ãã¦ããã¾ããããã¦ãä»åã¯Dojoãã¼ã«ããããå©ç¨ããã®ã§ãautoCompleteDojoã¢ã¯ã·ã§ã³ãã«ãã¼ã«æ¸¡ãã ãã§ãJSONå½¢å¼ã§è£å®ã®åè£ãéä¿¡ããã¾ãã
ã以åã®ä¾ã§ã¯Zend_Dojo_Dataã¯ã©ã¹ã®ãªãã¸ã§ã¯ããèªåã§ä½æãããã¨å¤å°æéããããã¾ãããããã®ããã«autoCompleteã¢ã¯ã·ã§ã³ãã«ãã¼ãå©ç¨ããã°ç°¡åã«ãªã¼ãã³ã³ããªã¼ãã®ããããã¹ãå ¥åãä½æã§ãã¾ãã