Maple¤òÍøÍѤ·¤¿·Ç¼¨ÈĺîÀ® http://www.ark-web.jp/sandbox/wiki/182.html

Maple¤òÍøÍѤ·¤¿·Ç¼¨ÈĺîÀ®

11·î¤«¤éÆþ¼Ò¤·¤¿¾®¾Â¤Ç¤¹¡£¸½ºß¸¦½¤Ãæ¤ÇPHP¤ÎÊÙ¶¯¤ò¤·¤Æ¤¤¤Þ¤¹¡£
PHP¤Î¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Ç¤¢¤ëMaple¤È¡¢javascript¤Î¥é¥¤¥Ö¥é¥ê¤Ç¤¢¤ëprototype.js¤òÍøÍѤ·¡¢·Ç¼¨ÈĤòºîÀ®¤·¤Þ¤·¤¿¡£
¤½¤³¤ÇÆÀ¤¿¥Î¥¦¥Ï¥¦¤Ê¤É¤ò¤³¤³¤Ëµ­½Ò¤·¤Æ¤¤¤­¤Þ¤¹¡£

¤Ê¤ª¥·¥¹¥Æ¥à¹½À®¤Ê¤ÉÀß·×¾ðÊó¤Ï¤³¤Á¤é¤Ëµ­½Ò¤·¤Æ¤¢¤ê¤Þ¤¹¡£

[edit]

Ìܼ¡

[edit]

´°À®ÉÊ

Maple+Ajax·Ç¼¨ÈÄ

[edit]

Maple¤Î¥¤¥ó¥¹¥È¡¼¥ë¤Ë¤Ä¤¤¤Æ

[edit]

¥¤¥ó¥¹¥È¡¼¥ëÊýË¡

¥¤¥ó¥¹¥È¡¼¥ë¤ÎÊýË¡¤Ï°Ê²¼¤Î£²¼ïÎब¤¢¤ê¤Þ¤¹¡£¾ÜºÙ¤Ï¥ê¥ó¥¯Àè¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

[edit]

¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¤¬É¬Í×

¥¤¥ó¥¹¥È¡¼¥ë¤ò¹Ô¤¦¤¿¤á¤Ë¤Ï¡¢¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¤ÎSmarty¤«HTML_Template_Flexy¤¬É¬ÍפǤ¹¡£¤É¤Á¤é¤«¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¡¢Maple¤¬Æ°ºî¤·¤Ê¤¤¤É¤³¤í¤«¡¢Maple¤Î¥¤¥ó¥¹¥È¡¼¥ë¤¹¤é¤Ç¤­¤Þ¤»¤ó¡£

[edit]

³«È¯

[edit]

Maple¥³¥Þ¥ó¥É

Maple¤Î³«È¯¤Ë¤ª¤¤¤Æ¤ÏMaple¥³¥Þ¥ó¥É¤ò»ÈÍѤ·¤Þ¤¹¡£

$maple webapp
$maple action ...

¤È¤¤¤Ã¤¿·Á¤Ç¤¹¡£¼Â¹Ô¤¹¤ë¤È¡¢¿÷·Á¤È¤Ê¤ë¥Ç¥£¥ì¥¯¥È¥ê¤È¥Õ¥¡¥¤¥ë¤¬¼«Æ°À¸À®¤µ¤ì¤Þ¤¹¡£
¼«Æ°À¸À®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ï¡¢¤½¤ì¼«ÂΤǤ¹¤Ç¤Ë¼Â¹Ô²Äǽ¤Ê¾õÂ֤ȤʤäƤ¤¤Þ¤¹¤¬¡¢Ãæ¿È¤Î½èÍý¤¬²¿¤âµ­½Ò¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£¤½¤ì¤¾¤ì¤ÎÍ×·ï¤Ë¤¢¤Ã¤¿·Á¤Ë½èÍý¤òµ­½Ò¤·¤Æ¤¤¤¯¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
Ruby On Rails¤Ë¤ª¤±¤ërails¥³¥Þ¥ó¥É¤ß¤¿¤¤¤Ê¤â¤Î¤À¤È»×¤¤¤Þ¤¹¡£

[edit]

²èÌ̤ȥ¢¥¯¥·¥ç¥ó´Ö¤Ç¤Î¥Ç¡¼¥¿¤Î¼õ¤±ÅϤ·ÊýË¡¤Ë¤Ä¤¤¤Æ

¥Æ¥ó¥×¥ì¡¼¥È¡Ê²èÌ̡ˤ«¤é¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¡Êmodule¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Ë¤Ç¤­¤ë¥¯¥é¥¹¡Ë¤Î¥á¥ó¥ÐÊÑ¿ô¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤Ë°Ê²¼¤Î¤è¤¦¤Êµ­½Ò¤ò¤ª¤³¤Ê¤¦¤È¡¢

class Hoge
{
    var $val1;

    function execute(){

        return 'success';
    }

}

¥Æ¥ó¥×¥ì¡¼¥È²èÌ̤«¤é¤Ï°Ê²¼¤Î¤è¤¦¤Ëµ­½Ò¤¹¤ë¤³¤È¤Ç¡¢Ãͤò¼èÆÀ¤Ç¤­¤Þ¤¹¡£

<input type="text" name="" value="{$action.val1}">

µÕ¤Ë¡¢²èÌ̤ǥµ¥Ö¥ß¥Ã¥È¤·¤¿Ãͤò¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤Ç¼èÆÀ¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¥Æ¥ó¥×¥ì¡¼¥È²èÌ̤˰ʲ¼¤Î¤è¤¦¤Ëµ­½Ò¤·¤Þ¤¹¡£

<input type="text" name="val1" value="">

¤¹¤ë¤È¡¢¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤Îval1¤È¤¤¤¦¥á¥ó¥ÐÊÑ¿ô¤Ë¡¢¥µ¥Ö¥ß¥Ã¥È¤µ¤ì¤¿Ãͤ¬ÀßÄꤵ¤ì¤Þ¤¹¡£

[edit]

¥¢¥¯¥·¥ç¥ó¥Á¥§¡¼¥ó¤Ë¤Ä¤¤¤Æ

¥¢¥¯¥·¥ç¥ó¥Á¥§¡¼¥ó¤È¤¤¤¦¤Î¤ÏÊ£¿ô¤Î¥¢¥¯¥·¥ç¥ó¤òϢ³¤·¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤Ç¤¹¡£
Î㤨¤Ð¡¢º£²óºî¤Ã¤¿·Ç¼¨ÈĤǤϡ¢¿·µ¬Åê¹Æ¤ò¹Ô¤Ã¤¿¤È¤­¤Ë°Ê²¼¤ÎÆó¤Ä¤Î¥¢¥¯¥·¥ç¥ó¤ò¥Á¥§¡¼¥ó¤µ¤»¤Æ¤¤¤Þ¤¹¡£

ÊýË¡¤È¤·¤Æ¤Ï¡¢¥Á¥§¡¼¥ó¸µ¤Î¥¢¥¯¥·¥ç¥ó¤ÎÁ«°ÜÀè¤Ë¡¢¥Á¥§¡¼¥óÀè¤Î¥¢¥¯¥·¥ç¥ó¤òÀßÄꤹ¤ë¤À¤±¤Ç¤¹¡£

º£²óºî¤Ã¤¿Îã¤Ç¤Ï¡¢submit¥¢¥¯¥·¥ç¥ó¤ÈƱ³¬Áؤˤ¢¤ëmaple.ini¤ò°Ê²¼¤Î¤è¤¦¤Ëµ­½Ò¤·¤Þ¤·¤¿¡£

[View]
success = "action:display
 

°ÊÁ°¤É¤³¤«¤Ç¥¢¥¯¥·¥ç¥ó¥Á¥§¡¼¥ó¤Ï¤¢¤Þ¤ê»ÈÍѤ·¤Ê¤¤¤Û¤¦¤¬¤¤¤¤¤È¤¤¤¦µ­½Ò¤ò¸Æ¤ó¤Àµ­²±¤¬¤¢¤ê¤Þ¤¹¡Ê³Î¤«Struts¥¤¥ó¥¢¥¯¥·¥ç¥ó¡Ë¡£Íýͳ¤È¤·¤Æ¤Ï¡¢

¤È¤¤¤¦¤³¤È¤À¤Ã¤¿¤È»×¤¤¤Þ¤¹¡£
¸Ä¿ÍŪ¤Ë¤Ï¥¢¥¯¥·¥ç¥ó¥Á¥§¡¼¥ó¤¬Í­¸ú¤Ê¾ì¹ç¤â¤¢¤ë¤È»×¤¤¤Þ¤¹¡£¤·¤«¤·¾å¤Î¤è¤¦¤Ê´ÑÅÀ¤â¤¢¤ë¤È¤¤¤¦¤³¤È¤Ç¡¢¥Á¥§¡¼¥ó¤Ç¼ÂÁõ¤¹¤ëÁ°¤Ë¡¢ËÜÅö¤Ë¤½¤¦¤¹¤ë¤Î¤¬ºÇÁ±¤«¡¢¥í¥¸¥Ã¥¯¤¬Å¬ÀÚ¤Ëʬ³ä¤Ç¤­¤Æ¤¤¤Ê¤¤¤Î¤Ç¤Ï¤Ê¤¤¤«¡¢¤È¤¤¤¦¤³¤È¤ò¤â¤¦°ìÅÙ¸¡Æ¤¤·¤¿Êý¤¬¾¬Îɤ¤¤Î¤«¤â¤·¤ì¤Þ¤»¤ó¡£

 

¢¨¸Ä¿ÍŪ¤Ê¤³¤È¤Ç¤¹¤¬¡¢»ä¤Ï¥¢¥¯¥·¥ç¥ó¥Á¥§¡¼¥ó¤ò¼ÂÁõ¤·¤Æ¤¤¤ëºÇÃæ°Ê²¼¤Î¥¨¥é¡¼¤Ë¶ì¤·¤ß¤Þ¤·¤¿¡£

Cannot redeclare class db

¡ÖDB¥¯¥é¥¹¤òºÆÄêµÁ¤Ç¤­¤Þ¤»¤ó¡×¤È¤¤¤¦¤³¤È¤Ç¤·¤ç¤¦¤«¡£
·ë¶Érequire('DB.php')¤È¤ä¤Ã¤Æ¤¤¤ë²Õ½ê¤òrequire_once('DB.php')¤È¤¹¤ë¤³¤È¤Çľ¤ê¤Þ¤·¤¿¡£
¥¢¥¯¥·¥ç¥ó¥Á¥§¡¼¥ó¤ò»È¤Ã¤¿¤³¤È¤Ç¡¢°ì²ó¤ÎÆ°ºî¤ÎÃæ¤Ç£²²órequire('DB.php')¤¬¤ª¤³¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¤³¤È¤¬¸¶°ø¤È»×¤ï¤ì¤Þ¤¹¡£
requrie¤Î¸ºß²ÁÃͤ¬¤¤¤Þ¤¤¤Áʬ¤«¤ê¤Þ¤»¤ó¡£³°Éô¥é¥¤¥Ö¥é¥ê¤¬É¬Íפˤʤ俤é¾ï¤Ërequire_once¤·¤¿¤Û¤¦¤¬°ÂÁ´¤¸¤ã¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡©

[edit]

ÆþÎÏ¥Á¥§¥Ã¥¯¤Ë¤Ä¤¤¤Æ

ÆþÎϹàÌܤËÂФ·¤Æ¤ª¤³¤Ê¤¦¥Á¥§¥Ã¥¯¤âmaple.ini¤Ëµ­½Ò¤·¤Þ¤¹¡£
º£²ó¤Î·Ç¼¨ÈĤǤϿ·µ¬Åê¹Æ»þ¤Ë¡¢É¬¿Ü¥Á¥§¥Ã¥¯¤ò¹Ô¤¦¤è¤¦¤ËÀßÄꤷ¤Þ¤·¤¿¡£
maple.ini¤ÎÆâÍƤǤ¹¡£

[Validate]
name.required = "1,name is required"
message.required = "1, message is required"

name¤ämessage¤È½ñ¤«¤ì¤Æ¤¤¤ë¤È¤³¤í¤¬¡¢ÆþÎÏ¥Á¥§¥Ã¥¯ÂоݤιàÌܤǤ¹¡£¤³¤ì¤Ï²èÌ̾åÆþÎϹàÌܤÎname°À­¤ÈÂбþ¤·¤Þ¤¹¡£
¼¡¤Îrequired¤È½ñ¤«¤ì¤Æ¤¤¤ë¤Î¤¬¡¢¥Á¥§¥Ã¥¯ÊýË¡¤Ç¤¹¡£required¤Î¾¤Ë¡¢maxLength¤ädate¤Ê¤É¤¬¤¢¤ê¤Þ¤¹¡£
1¤È½ñ¤«¤ì¤Æ¤¤¤ë¤È¤³¤í¤Ï¥¹¥È¥Ã¥Ñ¡¼¤Ç¤¹¡£1¤Î¤Û¤«¤Ë0¤¬»ØÄê¤Ç¤­¤Þ¤¹¡£¥¹¥È¥Ã¥Ñ¡¼¤¬1¤Ë¤Ê¤Ã¤Æ¤¤¤ëÆþÎÏ¥Á¥§¥Ã¥¯¤Ë°ú¤Ã¤«¤«¤Ã¤¿¾ì¹ç¡¢°Ê¹ß¤Î¤½¤Î¹àÌܤËÂФ¹¤ëÆþÎÏ¥Á¥§¥Ã¥¯¤ò¤ª¤³¤Ê¤¤¤Þ¤»¤ó¡£

name is required¤È¤Ê¤Ã¤Æ¤¤¤ë¤È¤³¤í¤Ï¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Ç¤¹¡£
¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Ï°Ê²¼¤Î¤è¤¦¤Ëµ­½Ò¤¹¤ë¤³¤È¤Ç¡¢²èÌ̤Ëɽ¼¨¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

{errorList->getMessages assign=messages}
{foreach from=$messages|smarty:nodefaults item=message}
<font color="#ff0000">{$message}</font><br>
{/foreach}

ÆþÎÏ¥Á¥§¥Ã¥¯¤Ë¤Ä¤¤¤Æ¤Î¾ÜºÙ¤Ï¤³¤³¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

ɬ¿Ü¥Á¥§¥Ã¥¯°Ê³°¤Ë¤âmaxlenght¤Î¥Á¥§¥Ã¥¯¤Ê¤É¤¤¤í¤¤¤í¤¢¤ë¤è¤¦¤Ç¤¹¡£¤Þ¤¿Validate¥¢¥¯¥·¥ç¥ó¤ò³ÈÄ¥¤¹¤ë¤³¤È¤Ç¡¢¿·¤·¤¤ÆþÎÏ¥Á¥§¥Ã¥¯¤ò¥«¥¹¥¿¥Þ¥¤¥º¤¹¤ë¤³¤È¤â¤Ç¤­¤ë¤è¤¦¤Ç¤¹¡£

[edit]

Ajax¤Ë¤Ä¤¤¤Æ

º£²ó¤Î¸¦½¤¤Ç¤Ï¥Ú¡¼¥¸¥ó¥°Éôʬ¡ÊÁ°¤Î¥Ú¡¼¥¸¤ä¼¡¤Î¥Ú¡¼¥¸¤Ë°ÜÆ°¤¹¤ëµ¡Ç½¡Ë¤ËAjax¤ò»ÈÍѤ·¤Þ¤·¤¿¡£Ajax()¤Î³«È¯¤Ë¤ª¤¤¤Æ¤Ï¤½¤Î̾¾Î¤ÎÄ̤êjavascript¤¬Ãæ¿´¤È¤Ê¤ê¤Þ¤¹¡£¤³¤³¤ËÁ´¤Æ¤Îjavascript¥½¡¼¥¹¤ò°úÍѤ·¤Þ¤¹¡£

function getArticles(page_num) {

    new Ajax.Updater(
        "list",
        "index.php",
        {
            method: "get",
            parameters: "action=articles_display&page_num=" + page_num
        }
    );
}

º£²ó¤Îjavascript¤ÎÃæ¤ÇÃæ¿´¤È¤Ê¤ë´Ø¿ô¤Ç¤¹¡£
¥Ú¡¼¥¸ÈÖ¹æ¤ò°ú¿ô¤Ë¼è¤ê¡¢¥µ¡¼¥Ð¤Ë¥ê¥¯¥¨¥¹¥È¤òȯ¹Ô¤·¡¢¤½¤Î·ë²Ì¡Ê³ºÅö¤¹¤ë¥Ú¡¼¥¸¤ÎHTML¡Ë¤ò¼èÆÀ¤·²èÌ̤Ëɽ¼¨¤·¤Þ¤¹¡£
prototype.js¤ÎAjax.Updater¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£

function getNextArticles() {
    getArticles(getPageNum() + 1);
}

¡Ö¼¡¤Ø¡×¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¤Ë¸Æ¤Ð¤ì¤ë´Ø¿ô¤Ç¤¹¡£
¸½ºß¤Î¥Ú¡¼¥¸ÈÖ¹æ¤Ë1¤ò²Ã¤¨¤¿ÃͤÇgetArticles()¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤Þ¤¹¡£

function getPrevArticles() {
    getArticles(getPageNum() - 1);
}

¡ÖÁ°¤Ø¡×¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¤Ë¸Æ¤Ð¤ì¤ë´Ø¿ô¤Ç¤¹¡£
¸½ºß¤Î¥Ú¡¼¥¸ÈÖ¹æ¤Ë1¤ò°ú¤¤¤¿ÃͤÇgetArticles()¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤Þ¤¹¡£

function getPageNum() {
    return new Number($F('page_num'));
}

¥Ú¡¼¥¸ÈÖ¹æ¤ò¼èÆÀ¤¹¤ë´Ø¿ô¤Ç¤¹¡£
prototype.js¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë´Ø¿ô$F()¤ò»ÈÍѤ·¤Æ¡¢²èÌ̾å¤Îid¤¬"page_num"¤Ç¤¢¤ëÍ×ÁǤÎÃͤò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£

[edit]

»²¹Í»ñÎÁ

[edit]

ÊÙ¶¯²ñ

¤³¤Î¸¦½¤¤Ç³Ø¤ó¤ÀÆâÍƤò¸µ¤Ë¼ÒÆâ¤ÇÊÙ¶¯²ñ¤ò³«¤­¤Þ¤·¤¿¡£
¤½¤Î»þ¤Ë»ÈÍѤ·¤¿¥ì¥¸¥å¥á¤¬²¼µ­¤Î¥Ú¡¼¥¸¤Ç¤¹¡£
ÊÙ¶¯²ñ/Maple¤ÈAjax¤ò»ÈÍѤ·¤¿·Ç¼¨ÈÄ

tag: PHP, Maple, Ajax, JavaScript, prototype.js, MVC¥Õ¥ì¡¼¥à¥ï¡¼¥¯


¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS
Last-modified: 2006-12-05 (²Ð) 11:04:33 (6562d)

¥¢¡¼¥¯¥¦¥§¥Ö¤Î¥µ¡¼¥Ó¥¹¤ä¥½¥ê¥å¡¼¥·¥ç¥ó¤Ï¤³¤Á¤é