<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>@blog.justoneplanet.info &#187; コンピューター言語</title>
	<atom:link href="http://blog.justoneplanet.info/category/computer-language/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justoneplanet.info</link>
	<description>JavaScript、PHP、MySQLを使ったり</description>
	<lastBuildDate>Sun, 25 Jul 2010 07:34:20 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>pythonを触ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/25/python%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/25/python%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 07:31:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2791</guid>
		<description><![CDATA[さっそく触る！((o(￣ー￣)o))

from math import sqrt;
sqrt(pow(2, 4))# 4.0

コメントは#から行末までですな。pythonでは;セミコロンを書かなくても良い=3
■関数 [...]]]></description>
			<content:encoded><![CDATA[<p>さっそく触る！((o(￣ー￣)o))</p>
<pre class="brush: python;">
from math import sqrt;
sqrt(pow(2, 4))# 4.0
</pre>
<p>コメントは#から行末までですな。pythonでは;セミコロンを書かなくても良い=3</p>
<h3>■関数定義</h3>
<p>以下のようにする。</p>
<pre class="brush: python;">
def powpow(x):
    return pow(pow(x, 2), 2)
</pre>
<pre class="brush: python;">
powpow(2)#16
</pre>
<p>ふむふむ。</p>
<h3>■クラス定義</h3>
<pre class="brush: python;">
class Dog:
    def cry(str):
        return 'bow'
</pre>
<pre class="brush: python;">
pochi = Dog()
pochi.cry()#'bow'
</pre>
<p>なるほど！ヾ(＠＾▽＾＠)ﾉ</p>
<h3>■結論</h3>
<p>perlより好きだ★</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/25/python%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Layoutを触ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/25/zend_layout%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/25/zend_layout%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 19:55:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2786</guid>
		<description><![CDATA[■フロントコントローラ
大枠（レイアウト部分）が置いてあるディレクトリのパスはここで指定してもよいと思う。
/public_html/index.php

Zend_Layout::startMvc(array(
    [...]]]></description>
			<content:encoded><![CDATA[<h3>■フロントコントローラ</h3>
<p>大枠（レイアウト部分）が置いてあるディレクトリのパスはここで指定してもよいと思う。</p>
<h4>/public_html/index.php</h4>
<pre class="brush: php;">
Zend_Layout::startMvc(array(
    'layout'     =&gt; 'layout',// layout.phtml
    'layoutPath' =&gt; '../application/modules/admin/views/layouts/'// path
));
$front = Zend_Controller_Front::getInstance();
</pre>
<h3>■コントローラ</h3>
<p>まぁ大体一つのコントローラ内でレイアウトが変わるなんて事はないから、initで設定してイイよね。</p>
<pre class="brush: php;">
    /**
     * init
     * @return void
     */
    public function init()
    {
        $this-&gt;_helper-&gt;layout-&gt;setLayout('layout');// layout.phtml
        //$this-&gt;_helper-&gt;layout-&gt;setLayoutPath('../application');// path
        $this-&gt;_helper-&gt;layout-&gt;assign('menu', $this-&gt;view-&gt;render('menu.phtml'));
    }
</pre>
<p>こんな感じにしておけば、以下の様な感じでイケる！</p>
<h3>■ビュー</h3>
<p>/application/modules/admin/views/scripts/index/index.phtmlの部分は$this-&gt;layout()-&gt;contentに出力される。</p>
<h4>/application/modules/admin/views/layouts/layout.phtml</h4>
<pre class="brush: php;">
&lt;div id=&quot;sidebar&quot;&gt;
&lt;?php echo $this-&gt;layout()-&gt;menu ?&gt;
&lt;/div&gt;
&lt;div id=&quot;main&quot;&gt;
&lt;?php echo $this-&gt;layout()-&gt;content ?&gt;
&lt;/div&gt;
</pre>
<h3>■その他の設定</h3>
<pre class="brush: php;">
    /**
     * init
     * @return void
     */
    public function init()
    {
        $this-&gt;_helper-&gt;layout-&gt;setLayout('layout');// layout.phtml
        $this-&gt;_helper-&gt;layout-&gt;assign('menu', $this-&gt;view-&gt;render('menu.phtml'));
        $this-&gt;_helper-&gt;layout-&gt;disableLayout();// レイアウトを無効化できる
        $this-&gt;_helper-&gt;layout-&gt;setContentKey('main');// デフォルト名$this-&gt;layout()-&gt;contentを$this-&gt;layout()-&gt;mainに変更できる
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/25/zend_layout%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Formをもっと触ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/24/zend_form%e3%82%92%e3%82%82%e3%81%a3%e3%81%a8%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/24/zend_form%e3%82%92%e3%82%82%e3%81%a3%e3%81%a8%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 18:22:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2767</guid>
		<description><![CDATA[特定の要素をグルーピングしたい時だってある。 &#60;?php class Admin_IndexController extends Zend_Controller_Action { public function indexAction() { $this-&#62;view-&#62;form = $this-&#62;_createForm(); } public function registerAction() { $form = $this-&#62;createForm(); if(!form-&#62;isValid($this-&#62;_getAllParams())){// error $this-&#62;view-&#62;assign('form', $form); return $this-&#62;render('index'); } else{// success $this-&#62;_dbh-&#62;register($form-&#62;getValues()); } } private function _createForm() { $form = new Zend_Form(); $form-&#62;setAction('/admin/index/register/')-&#62;setMethod('post'); $form-&#62;addElement( 'text', 'name', array( 'validators' =&#62; array( array('Regex', false, array('/^[a-z]/i')) ), 'label' [...]]]></description>
			<content:encoded><![CDATA[<p>特定の要素をグルーピングしたい時だってある。</p>
<pre class="brush: php;">
&lt;?php
class Admin_IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this-&gt;view-&gt;form = $this-&gt;_createForm();
    }
    public function registerAction()
    {
        $form = $this-&gt;createForm();
        if(!form-&gt;isValid($this-&gt;_getAllParams())){// error
            $this-&gt;view-&gt;assign('form', $form);
            return $this-&gt;render('index');
        }
        else{// success
            $this-&gt;_dbh-&gt;register($form-&gt;getValues());
        }
    }
    private function _createForm()
    {
        $form = new Zend_Form();
        $form-&gt;setAction('/admin/index/register/')-&gt;setMethod('post');
        $form-&gt;addElement(
            'text',
            'name',
            array(
                'validators' =&gt; array(
                    array('Regex', false, array('/^[a-z]/i'))
                ),
                'label'      =&gt; 'Name : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement(
            'password',
            'pass',
            array(
                'validators' =&gt; array(
                    'Alnum'
                ),
                'label'      =&gt; 'Password : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addDisplayGroup(
            array(
                'name',
                'pass'
            ),
            'login',
            array(
                'disableLoadDefaultDecorators' =&gt; false
            )
        );
        $form-&gt;addElement('hash', 'checkHash');
        $form-&gt;addElement('submit', '送信');
        return $form;
    }
}
?&gt;
</pre>
<p>上述のようにしてグループ毎にfieldsetで括ることができる。addDisplayGroupは要素を定義した直後にコールしないとフォームの要素の順序が変わってしまうので注意が必要である。</p>
<h4>出力html</h4>
<pre class="brush: xml;">
&lt;form enctype=&quot;application/x-www-form-urlencoded&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
&lt;dl class=&quot;zend_form&quot;&gt;
&lt;dt id=&quot;login-label&quot;&gt;&amp;nbsp;&lt;/dt&gt;
&lt;dd id=&quot;login-element&quot;&gt;&lt;fieldset id=&quot;fieldset-login&quot;&gt;
&lt;dl&gt;
&lt;dt id=&quot;name-label&quot;&gt;&lt;label for=&quot;name&quot; class=&quot;required&quot;&gt;Name :&lt;/label&gt;&lt;/dt&gt;
&lt;dd id=&quot;name-element&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&quot;&gt;&lt;/dd&gt;
&lt;dt id=&quot;pass-label&quot;&gt;&lt;label for=&quot;pass&quot; class=&quot;required&quot;&gt;Password :&lt;/label&gt;&lt;/dt&gt;
&lt;dd id=&quot;pass-element&quot;&gt;&lt;input type=&quot;password&quot; name=&quot;pass&quot; id=&quot;pass&quot; value=&quot;&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/fieldset&gt;&lt;/dd&gt;
&lt;dt id=&quot;checkHash-label&quot;&gt;&amp;nbsp;&lt;/dt&gt;
&lt;dd id=&quot;checkHash-element&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;checkHash&quot; value=&quot;c15806d5c0f9bc7f6b414ba2cf40468d&quot; id=&quot;checkHash&quot;&gt;&lt;/dd&gt;
&lt;dt id=&quot;送信-label&quot;&gt;&amp;nbsp;&lt;/dt&gt;
&lt;dd id=&quot;送信-element&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;送信&quot; id=&quot;送信&quot; value=&quot;送信&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/form&gt;
</pre>
<p>なかなか構造化された綺麗なHTMLが出力される！</p>
<dl>
<dt>Zend_Form::addElement(string $type, string $name, array $options);</dt>
<dd>第一引数でtype属性を指定、第二引数でname属性、第三引数でバリデータやフィルタのオプション設定をする</dd>
<dt>Zend_Form::addDisplayGroup(array $elementNames, string $fieldsetName, array options);</dt>
<dd>第一引数で要素のname属性を配列で指定、第二引数でfieldsetの任意の名前、第三引数でオプション設定をする</dd>
</dl>
<h3>■フォームのデコレータ</h3>
<p>勝手にタグがついて全体をfieldsetで括ってくれて便利なんだが余計なお世話になるときだってある。そこでデフォルトでフォームに付加されるHTMLタグを変更する。</p>
<pre class="brush: php;">
&lt;?php
class Admin_IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this-&gt;view-&gt;form = $this-&gt;_createForm();
    }
    public function registerAction()
    {
        $form = $this-&gt;createForm();
        if(!form-&gt;isValid($this-&gt;_getAllParams())){// error
            $this-&gt;view-&gt;assign('form', $form);
            return $this-&gt;render('index');
        }
        else{// success
            $this-&gt;_dbh-&gt;register($form-&gt;getValues());
        }
    }
    private function _createForm()
    {
        $form = new Zend_Form();
        $form-&gt;setAction('/admin/index/register/')-&gt;setMethod('post');
        $form-&gt;addElement(
            'text',
            'name',
            array(
                'validators' =&gt; array(
                    array('Regex', false, array('/^[a-z]/i'))
                ),
                'label'      =&gt; 'Name : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement(
            'password',
            'pass',
            array(
                'validators' =&gt; array(
                    'Alnum'
                ),
                'label'      =&gt; 'Password : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement('hash', 'checkHash');
        $form-&gt;addElement('submit', '送信');
        $form-&gt;clearDecorators();
        $form-&gt;addDecorator('FormElements')-&gt;addDecorator('HtmlTag', array('tag' =&gt; 'ul', 'class' =&gt; 'form'))-&gt;addDecorator('Form');
        $form-&gt;setElementDecorators(array('ViewHelper', 'Label', array('HtmlTag', array('tag' =&gt; 'li'))));
        return $form;
    }
}
?&gt;
</pre>
<h4>出力コード</h4>
<pre class="brush: xml;">
&lt;form enctype=&quot;application/x-www-form-urlencoded&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
&lt;ul class=&quot;form&quot;&gt;
&lt;li&gt;&lt;label for=&quot;name&quot; class=&quot;required&quot;&gt;Name :&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;label for=&quot;pass&quot; class=&quot;required&quot;&gt;Password :&lt;/label&gt;&lt;input type=&quot;password&quot; name=&quot;pass&quot; id=&quot;pass&quot; value=&quot;&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;hidden&quot; name=&quot;checkHash&quot; value=&quot;f2bcb658321fb39cdc0bd92c61210f7d&quot; id=&quot;checkHash&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;label for=&quot;送信&quot; class=&quot;optional&quot;&gt;送信&lt;/label&gt;&lt;input type=&quot;submit&quot; name=&quot;送信&quot; id=&quot;送信&quot; value=&quot;送信&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/form&gt;
</pre>
<dl>
<dt>Zend_Form::addDecorator(string $className, , array $options = null);</dt>
<dd></dd>
<dt>Zend_Form::addDecorators(array $decorators);</dt>
<dd></dd>
</dl>
<div class="kakomi">
<p>いろんなデコレータ</p>
<pre class="brush: php;">
    private function _createForm()
    {
        $form = new Zend_Form();
        $form-&gt;setAction('/admin/index/register/')-&gt;setMethod('post');
        $form-&gt;addElement(
            'text',
            'name',
            array(
                'validators' =&gt; array(
                    array('Regex', false, array('/^[a-z]/i'))
                ),
                'label'      =&gt; 'Name : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement(
            'password',
            'pass',
            array(
                'validators' =&gt; array(
                    'Alnum'
                ),
                'label'      =&gt; 'Password : ',
                'required'   =&gt; true
            )
        );

        $name = $form-&gt;getElement('name');
        $name-&gt;setDescription('&lt;span class=&quot;description&quot;&gt;名前をいれる感じで&lt;/span&gt;');
        $name-&gt;addDecorator(//&lt;p&gt;
            'description',
            array(
                'class'  =&gt; 'descrition',
                'escape' =&gt; false
            )
        );

        $form-&gt;addElement('hash', 'checkHash');
        $form-&gt;addElement('submit', '送信');
        $form-&gt;clearDecorators();
        $form-&gt;addDecorator('FormElements')-&gt;addDecorator('HtmlTag', array('tag' =&gt; 'ul', 'class' =&gt; 'form'))-&gt;addDecorator('Form');
        $form-&gt;setElementDecorators(array('ViewHelper', 'Label', array('HtmlTag', array('tag' =&gt; 'li'))));
        return $form;
    }
</pre>
<h4>出力HTML</h4>
<pre class="brush: xml;">
&lt;form enctype=&quot;application/x-www-form-urlencoded&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
&lt;ul class=&quot;form&quot;&gt;
&lt;li&gt;&lt;label for=&quot;name&quot; class=&quot;required&quot;&gt;Name :&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&quot;&gt;&lt;/li&gt;
&lt;p class=&quot;descrition_class&quot;&gt;&lt;span class=&quot;description&quot;&gt;名前をいれる感じで&lt;/span&gt;&lt;/p&gt;
&lt;li&gt;&lt;label for=&quot;pass&quot; class=&quot;required&quot;&gt;Password :&lt;/label&gt;
&lt;input type=&quot;password&quot; name=&quot;pass&quot; id=&quot;pass&quot; value=&quot;&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;hidden&quot; name=&quot;checkHash&quot; value=&quot;0162b9bd58af60eb903fe52237bc6a8f&quot; id=&quot;checkHash&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;label for=&quot;送信&quot; class=&quot;optional&quot;&gt;送信&lt;/label&gt;
&lt;input type=&quot;submit&quot; name=&quot;送信&quot; id=&quot;送信&quot; value=&quot;送信&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/form&gt;
</pre>
</div>
<h3>■自作デコレータ</h3>
<p>以下のようにZend_Form_Decorator_Abstractを継承してあげればオリジナルデコレータができる！</p>
<p>../application/decorators/Original.php</p>
<pre class="brush: php;">
&lt;?php
class Jop_Decorator_Original extends Zend_Form_Decorator_Abstract
{
    public function render($content)
    {
         return &quot;&lt;span&gt;{$content}&lt;/span&gt;&quot;;
    }
}
?&gt;
</pre>
<p>以下のようにして使用する。</p>
<pre class="brush: php;">
    private function _createForm()
    {
        $form = new Zend_Form();
        $form-&gt;setAction('/admin/index/register/')-&gt;setMethod('post');
        $form-&gt;addPrefixPath('Jop_Decorator', '../application/decorators', 'decorator');
        //追加したフォーム要素に登録
        //$form-&gt;addElementPrefixPath('Jop_Decorator', 'path', 'decorator');
        $form-&gt;addElement(
            'text',
            'name',
            array(
                'validators' =&gt; array(
                    array('Regex', false, array('/^[a-z]/i'))
                ),
                'label'      =&gt; 'Name : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement(
            'password',
            'pass',
            array(
                'validators' =&gt; array(
                    'Alnum'
                ),
                'label'      =&gt; 'Password : ',
                'required'   =&gt; true
            )
        );

        $name = $form-&gt;getElement('name');
        //個別のフォーム要素に加える
        $name-&gt;addPrefixPath('Jop_Decorator', '../applications/decorators', 'decorator');
        $name-&gt;addDecorator('Original');

        $form-&gt;addElement('hash', 'checkHash');
        $form-&gt;addElement('submit', '送信');
        return $form;
    }
</pre>
<p>以下のようにspanで括られて出力される。</p>
<pre class="brush: xml;">
&lt;form enctype=&quot;application/x-www-form-urlencoded&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
&lt;dl class=&quot;zend_form&quot;&gt;
&lt;span&gt;&lt;dt id=&quot;name-label&quot;&gt;&lt;label for=&quot;name&quot; class=&quot;required&quot;&gt;Name :&lt;/label&gt;&lt;/dt&gt;
&lt;dd id=&quot;name-element&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&quot;&gt;&lt;/dd&gt;&lt;/span&gt;
&lt;dt id=&quot;pass-label&quot;&gt;&lt;label for=&quot;pass&quot; class=&quot;required&quot;&gt;Password :&lt;/label&gt;&lt;/dt&gt;
&lt;dd id=&quot;pass-element&quot;&gt;&lt;input type=&quot;password&quot; name=&quot;pass&quot; id=&quot;pass&quot; value=&quot;&quot;&gt;&lt;/dd&gt;
&lt;dt id=&quot;checkHash-label&quot;&gt;&amp;nbsp;&lt;/dt&gt;
&lt;dd id=&quot;checkHash-element&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;checkHash&quot; value=&quot;784473de7bc7e8048eff4538060bce03&quot; id=&quot;checkHash&quot;&gt;&lt;/dd&gt;
&lt;dt id=&quot;送信-label&quot;&gt;&amp;nbsp;&lt;/dt&gt;
&lt;dd id=&quot;送信-element&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;送信&quot; id=&quot;送信&quot; value=&quot;送信&quot;&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/form&gt;
</pre>
<h3>■エラーメッセージの日本語化</h3>
<p>以下のようにすると対応するエラーメッセージを日本語化できる。</p>
<pre class="brush: php;">
    private function _createForm()
    {
        $form = new Zend_Form();
        $form-&gt;setAction('/admin/index/register/')-&gt;setMethod('post');
        $form-&gt;addElement(
            'text',
            'name',
            array(
                'validators' =&gt; array(
                    array('Regex', false, array('/^[a-z]/i'))
                ),
                'label'      =&gt; 'Name : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement(
            'password',
            'pass',
            array(
                'validators' =&gt; array(
                    'Alnum'
                ),
                'label'      =&gt; 'Password : ',
                'required'   =&gt; true
            )
        );
        $form-&gt;addElement('hash', 'checkHash');
        $form-&gt;addElement('submit', '送信');
        $adapter = new Zend_Translate(
            'array',
            array(
                &quot;'%value%' has not only alphabetic and digit characters&quot; =&gt; &quot;'%value%' に英数字以外の文字が含まれています&quot;,
                &quot;'%value%' does not match against pattern '%pattern%'&quot;   =&gt; &quot;'%value%' は '%pattern%' にマッチしません。&quot;
            )
        );
        $form-&gt;setTranslator($adapter);
        return $form;
    }
</pre>
<p>全てのフォームに適用する場合は以下のようにする。
<pre class="brush: php;">
Zend_Form::setDefaultTranslator($adapter);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/24/zend_form%e3%82%92%e3%82%82%e3%81%a3%e3%81%a8%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tinyMCEのプラグインを作ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/23/tinymce%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/23/tinymce%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 16:12:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2765</guid>
		<description><![CDATA[samplepluginを作るとする。 ■メインの JavaScript plugins/sampleplugin (function(){ /** * include language files */ tinymce.PluginManager.requireLangPack('sampleplugin'); /** * define plugin */ tinymce.create( &#34;tinymce.plugins.SamplePlugin&#34;, { /** * init * @param {Object} editor : tinymce * @param {string} url */ &#34;init&#34; : function(editor, url){ editor.addCommand( &#34;sample&#34;, function(){ //コマンドが実行された時のアクション } ); editor.addButton( &#34;sample&#34;, { &#34;title&#34; : &#34;sampleplugin.desc&#34;, &#34;cmd&#34; : &#34;sample&#34; } ) [...]]]></description>
			<content:encoded><![CDATA[<p>samplepluginを作るとする。</p>
<h3>■メインの JavaScript</h3>
<ul>
<li>plugins/sampleplugin</li>
</ul>
<pre class="brush: jscript;">
(function(){
    /**
     * include language files
     */
    tinymce.PluginManager.requireLangPack('sampleplugin');

    /**
     * define plugin
     */
    tinymce.create(
        &quot;tinymce.plugins.SamplePlugin&quot;,
        {
            /**
             * init
             * @param {Object} editor : tinymce
             * @param {string} url
             */
            &quot;init&quot; : function(editor, url){
                editor.addCommand(
                    &quot;sample&quot;,
                    function(){
                        //コマンドが実行された時のアクション
                    }
                );
                editor.addButton(
                    &quot;sample&quot;,
                    {
                        &quot;title&quot; : &quot;sampleplugin.desc&quot;,
                        &quot;cmd&quot;   : &quot;sample&quot;
                    }
                )
            },

            /**
             * getInfo
             * information of plugin
             */
            &quot;getInfo&quot; : function (){
                return {
                    &quot;longname&quot;  : &quot;Sample tinyMCE Plugin&quot;,
                    &quot;author&quot;    : &quot;Mitsuaki Ishimoto&quot;,
                    &quot;authorurl&quot; : &quot;http://justoneplanet.info&quot;,
                    &quot;infourl&quot;   : &quot;http://justoneplanet.info&quot;,
                    &quot;version&quot;   : tinymce.majorVersion + &quot;.&quot; + tinymce.minorVersion
                }
            }
        }
    );

    /**
     * setup plugin
     */
    tinymce.PluginManager.add(
        &quot;sampleplugin&quot;,
        tinymce.plugins.SamplePlugin
    );
})();
</pre>
<h3>■ 言語ファイル</h3>
<ul>
<li>plugins/sampleplugin/langs/ja.js</li>
<li>plugins/sampleplugin/langs/en.js</li>
</ul>
<pre class="brush: jscript;">
tinyMCE.addI18n('ja.sampleplugin',{
    desc : 'さんぷる'
});
</pre>
<pre class="brush: jscript;">
tinyMCE.addI18n('en.sampleplugin',{
    desc : 'sample'
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/23/tinymce%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Formを触ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/21/zend_form%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/21/zend_form%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 14:44:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2761</guid>
		<description><![CDATA[■結論
コントローラ

&#60;?php
class Admin_IndexController extends Zend_Controller_Action
{
    public function indexAct [...]]]></description>
			<content:encoded><![CDATA[<h3>■結論</h3>
<h4>コントローラ</h4>
<pre class="brush: php;">
&lt;?php
class Admin_IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $form = $this-&gt;createForm();
        $this-&gt;view-&gt;form = $form;
    }
    public function registerAction()
    {
        $form = $this-&gt;createForm();
        if(!$form-&gt;isValid($this-&gt;_getAllParams())){// error
            $this-&gt;view-&gt;assign('form', $form);
            return $this-&gt;render('index');
        }
        else{// success
            $this-&gt;_dbh-&gt;register($form-&gt;getValues());
        }
    }
    private function createForm()
    {
        $form = new Zend_Form();
        $form-&gt;addElement(
            'text',
            'name',
            array(
                'validators' =&gt; array(
                    array('Regex', false, array('/^[a-z]/i'))
                ),
                'label'      =&gt; 'Name : ',
                'required'   =&gt; true
                'filters'    =&gt; array(
                    'StringToLower',
                    'StripTags'
                )
            )
        );
        $form-&gt;addElement('hash', 'checkHash');
        $form-&gt;addElement('submit', '送信');
        return $form;
    }
}
?&gt;
</pre>
<h4>index.phtml</h4>
<pre class="brush: php;">
&lt;?php echo $this-&gt;form; ?&gt;
</pre>
<div class="kakomi">
<p>最初にZend_Formのインスタンスを作成する。</p>
<h4>他のモジュールとの連携</h4>
<ul>
<li> バリデート（Zend_Validate）</li>
<li>フィルタリング（Zend_Filter）</li>
</div>
<h3>■Zend_Form</h3>
<h4>コントローラ</h4>
<pre class="brush: php;">
$form = new Zend_Form();
$form-&gt;setAction('/admin/index/register/')-&gt;setMethod('post');
$this-&gt;view-&gt;form = $form;
</pre>
<h4> ビュー</h4>
<pre class="brush: php;">
&lt;?php echo $this-&gt;form; ?&gt;
</pre>
<h4> 出力</h4>
<pre class="brush: xml;">
&lt;form enctype=&quot;application/x-www-form-urlencoded&quot; action=&quot;/admin/index/register/&quot; method=&quot;post&quot;&gt;
&lt;dl class=&quot;zend_form&quot;&gt;
&lt;/dl&gt;
&lt;/form&gt;
</pre>
<h3>■ 要素を作る</h3>
<p>簡単。（コントローラ）</p>
<pre class="brush: php;">
$name = $form-&gt;createElement('text', 'name');
</pre>
<p>addElement がもっと簡単（コントローラ）</p>
<pre class="brush: php;">
$form-&gt;addElement('text', 'name');
</pre>
<p>バリデートもフィルタリングも一緒に追加できちゃう。（コントローラ）</p>
<pre class="brush: php;">
$form-&gt;addElement(
    'text',
    'name',
    array(
        'validators' =&gt; array(
            array('Regex', false, array('/^[a-z]/i'))
        ),
        'label'      =&gt; 'Name : ',
        'required'   =&gt; true,
        'filters'    =&gt; array(
            'StringToLower',
            'StripTags'
        )
    )
);
</pre>
<p>こんなんもある。めんどー。（コントローラ）</p>
<pre class="brush: php;">
require_once 'Zend/Form/Element/Text.php';
$name = new Zend_Form_Element_Text('name');
</pre>
<h3>■ バリデータを作る</h3>
<pre class="brush: php;">
addValidator(mixed $nameOrValidator, bool $breakChainOnFailure, array $options)
</pre>
<pre class="brush: php;">
$name = new Zend_Form_Element_Text('name');
$name-&gt;addValidator('Alnum', false, array(true))
    -&gt;addValidator('Regex', false, array('/^[a-zA-Z\s]+/'))
    -&gt;setLabel('Name : ')
    -&gt;setRequired(true);
</pre>
<dl>
<dt>Zend_Form_Element::addValidator(string $class, bool $is_next, array $options);</dt>
<dd>第一引数で指定したバリデータを要素に付加する。</dd>
</dl>
<h4> バリデータ一覧</h4>
<p><a href="http://framework.zend.com/manual/ja/zend.validate.set.html">http://framework.zend.com/manual/ja/zend.validate.set.html</a></p>
<h3>■フィルターを作る</h3>
<pre class="brush: php;">
addFilter(mixed $nameOrFilter, array $options)
</pre>
<pre class="brush: php;">
$name = new Zend_Form_Element_Text('name');
$name-&gt;addFilter('StringToLower');
</pre>
<h4> フィルタ一覧</h4>
<p><a href="http://zendframework.com/manual/1.5/ja/zend.filter.set.html">http://zendframework.com/manual/1.5/ja/zend.filter.set.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/21/zend_form%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Viewをもっと触ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/21/zend_view%e3%82%92%e3%82%82%e3%81%a3%e3%81%a8%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/21/zend_view%e3%82%92%e3%82%82%e3%81%a3%e3%81%a8%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:31:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2740</guid>
		<description><![CDATA[■パーシャルビュー
scripts配下から指定する。

&#60;?php echo $this-&#62;partial('index/edit.phtml'); ?&#62;

他のビュースクリプトを呼び出すための仕組みだ [...]]]></description>
			<content:encoded><![CDATA[<h3>■パーシャルビュー</h3>
<p>scripts配下から指定する。</p>
<pre class="brush: php;">
&lt;?php echo $this-&gt;partial('index/edit.phtml'); ?&gt;
</pre>
<p>他のビュースクリプトを呼び出すための仕組みだ。</p>
<pre class="brush: php;">
&lt;?php
echo $this-&gt;partial(
    'index/edit.phtml',
    array(
        'val' =&gt; $this-&gt;val
    )
);
?&gt;
</pre>
<p>上述のように、変数は明示的して引数で渡す必要がある。</p>
<h3>■プレイスホルダ</h3>
<h4>コントローラ</h4>
<pre class="brush: php;">
$this-&gt;view-&gt;HeadScript()-&gt;appendFile('/admin/js/init.js');
</pre>
<h4>ビュー</h4>
<pre class="brush: php;">
&lt;?php echo $this-&gt;HeadScript(); ?&gt;
</pre>
<h4>出力</h4>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot; src=&quot;/admin/js/init.js&quot;&gt;&lt;/script&gt;
</pre>
<h3>■Zend_Translate</h3>
<p>その名の通り多言語サイトをつくるときに使うやつ。</p>
<pre class="brush: php;">
Zend_Registry::set(
    'Zend_Translate',
    new Zend_Translate(
        'array',
        array(
            'submit' =&gt; '送信'
        ),
        'ja'
    )
);
</pre>
<h4>ビュー</h4>
<pre class="brush: php;">
&lt;?php echo $this-&gt;formSubmit('', $this-&gt;translate('submit')); ?&gt;
</pre>
<h4>出力</h4>
<pre class="brush: xml;">
&lt;input type=&quot;submit&quot; name=&quot;&quot; id=&quot;&quot; value=&quot;送信&quot;&gt;
</pre>
<p>なんかファイルフォーマットのアダプタが<a href="http://zendframework.com/manual/ja/zend.translate.adapter.html">いっぱい</a>ある。</p>
<h3>■自作ビューヘルパー</h3>
<h4>クラスを定義</h4>
<p>application/modules/admin/views/helpers/Br.php</p>
<pre class="brush: php;">
&lt;?php
class Zend_View_Helper_Br
{
    //呼び出し元のZend_Viewが自動的に$viewに代入される
    public $view;
    public function setView(Zend_View_Interface $view)
    {
        $this-&gt;view = $view;
    }
    public function br()
    {
        return &quot;&lt;br /&gt;\n&quot;;
    }
}
?&gt;
</pre>
<h4>コントローラ</h4>
<pre class="brush: php;">
$this-&gt;view-&gt;addHelperPath('application/modules/admin/views/helpers', 'Zend_View_Helper_');
</pre>
<h4>ビュー</h4>
<pre class="brush: php;">
&lt;?php echo $this-&gt;br(); ?&gt;
</pre>
<p>どっちかというと命名規則が重要である。</p>
<dl>
<dt>自作クラス名</dt>
<dd>Zend_View_Helper_ + Br</dd>
<dt>自作クラス名(メソッド)</dt>
<dd>br</dd>
<dt>ビュー</dt>
<dd>echo $this-&gt;br();</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/21/zend_view%e3%82%92%e3%82%82%e3%81%a3%e3%81%a8%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&lt;mm_file&gt;から&lt;/mm_file&gt;を抜き出す</title>
		<link>http://blog.justoneplanet.info/2010/07/21/mm_file%e3%81%8b%e3%82%89mm_file%e3%82%92%e6%8a%9c%e3%81%8d%e5%87%ba%e3%81%99/</link>
		<comments>http://blog.justoneplanet.info/2010/07/21/mm_file%e3%81%8b%e3%82%89mm_file%e3%82%92%e6%8a%9c%e3%81%8d%e5%87%ba%e3%81%99/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:14:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2755</guid>
		<description><![CDATA[Dreamweaverのテキスト検索結果を保存するとxmlファイルになる。そっからファイル名だけを抜き出す。

$(function(){
    $('input#button').click(function(){
 [...]]]></description>
			<content:encoded><![CDATA[<p>Dreamweaverのテキスト検索結果を保存するとxmlファイルになる。そっからファイル名だけを抜き出す。</p>
<pre class="brush: jscript;">
$(function(){
    $('input#button').click(function(){
        var str = '';
        var txt = $('textarea#textarea').val();
        var ary = txt.split('&lt;mm_file&gt;');
        for(var i = 0; i &lt; ary.length; i++){
            ary[i] = ary[i].substring(0, ary[i].indexOf('&lt;/mm_file&gt;'));
        }
        var txt = ary.join(&quot;\n&quot;);
        $('textarea#textarea').val(txt);
    });
});
</pre>
<p>jQueryを使用。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/21/mm_file%e3%81%8b%e3%82%89mm_file%e3%82%92%e6%8a%9c%e3%81%8d%e5%87%ba%e3%81%99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPとGDで透過png画像テキストを出力する</title>
		<link>http://blog.justoneplanet.info/2010/07/21/php%e3%81%a8gd%e3%81%a7%e9%80%8f%e9%81%8epng%e7%94%bb%e5%83%8f%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/21/php%e3%81%a8gd%e3%81%a7%e9%80%8f%e9%81%8epng%e7%94%bb%e5%83%8f%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:03:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2746</guid>
		<description><![CDATA[透明度のあるイメージをつくる。

&#60;?php
$width  = 300;// px
$height = 40;// px
$text   = 'This is a sample.';// string
$font [...]]]></description>
			<content:encoded><![CDATA[<p>透明度のあるイメージをつくる。</p>
<pre class="brush: php;">
&lt;?php
$width  = 300;// px
$height = 40;// px
$text   = 'This is a sample.';// string
$font   = /usr/share/fonts/bitstream-vera/ACaslonPro-Bold.otf';// path

$img             = imagecreatetruecolor($width, $height);
$color           = imagecolorallocatealpha($img, 210, 0, 0, 255);
$backgroundColor = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagealphablending($img, true); // ブレンドモードを設定する
imagesavealpha($img, true); // 完全なアルファチャネルを保存する

imagefill($img, 0, 0, $backgroundColor); // 指定座標から指定色で塗る
imagettftext($img, 16, 0, 16, 40, $color, $font, $text);

header('Content-type: image/jpeg');
imagepng($img);
imagedestroy($img);
?&gt;
</pre>
<p>すけすけ画像テキストだ！=3</p>
<p><a href="/wp-content/uploads/2010/07/test1.png" rel="lightbox[2746]"><img src="/wp-content/uploads/2010/07/test1.png" alt="" title="sample画像テキスト" width="300" height="40" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/21/php%e3%81%a8gd%e3%81%a7%e9%80%8f%e9%81%8epng%e7%94%bb%e5%83%8f%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScriptで要素のスタイルを取得する</title>
		<link>http://blog.justoneplanet.info/2010/07/20/javascript%e3%81%a7%e8%a6%81%e7%b4%a0%e3%81%ae%e3%82%b9%e3%82%bf%e3%82%a4%e3%83%ab%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/20/javascript%e3%81%a7%e8%a6%81%e7%b4%a0%e3%81%ae%e3%82%b9%e3%82%bf%e3%82%a4%e3%83%ab%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 17:36:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2738</guid>
		<description><![CDATA[var str = ''; var declarations = getComputedStyle(document.getElementById('header'), ''); for(var i in declarations){ if(!i.match(/[0-9]+/) &#38;&#38; declarations[i] &#38;&#38; typeof declarations[i] === 'string'){ str += i + ':' + declarations[i] + '\n'; } } alert(str); 以上。]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript;">
var str = '';
var declarations = getComputedStyle(document.getElementById('header'), '');
for(var i in declarations){
    if(!i.match(/[0-9]+/) &amp;&amp; declarations[i] &amp;&amp; typeof declarations[i] === 'string'){
        str += i + ':' + declarations[i] + '\n';
    }
}
alert(str);
</pre>
<p>以上。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/20/javascript%e3%81%a7%e8%a6%81%e7%b4%a0%e3%81%ae%e3%82%b9%e3%82%bf%e3%82%a4%e3%83%ab%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScriptからstylesheetにアクセスする</title>
		<link>http://blog.justoneplanet.info/2010/07/20/javascript%e3%81%8b%e3%82%89stylesheet%e3%81%ab%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/20/javascript%e3%81%8b%e3%82%89stylesheet%e3%81%ab%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 17:12:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2736</guid>
		<description><![CDATA[JavaScriptからlinkで読み込んだstylesheetにアクセスできる。

var str = '';
for(var i = 0; i &#60; document.styleSheets.length; i+ [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScriptからlinkで読み込んだstylesheetにアクセスできる。</p>
<pre class="brush: jscript;">
var str = '';
for(var i = 0; i &lt; document.styleSheets.length; i++){
    var stylesheet = document.styleSheets[i];
	for(var i2 = 0; i2 &lt; stylesheet.cssRules.length; i2++){
		var rule = stylesheet.cssRules[i2];
		str += rule.cssText + &quot;\n&quot;;
	}
}
</pre>
<p>以上。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/20/javascript%e3%81%8b%e3%82%89stylesheet%e3%81%ab%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPとGDで画像テキストを出力する</title>
		<link>http://blog.justoneplanet.info/2010/07/19/php%e3%81%a8gd%e3%81%a7%e7%94%bb%e5%83%8f%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/19/php%e3%81%a8gd%e3%81%a7%e7%94%bb%e5%83%8f%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 09:35:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2732</guid>
		<description><![CDATA[こんな感じ。

$width  = 300;// px
$height = 40;// px
$text   = 'This is a sample.';// string
$font   = /usr/share/fo [...]]]></description>
			<content:encoded><![CDATA[<p>こんな感じ。</p>
<pre class="brush: php;">
$width  = 300;// px
$height = 40;// px
$text   = 'This is a sample.';// string
$font   = /usr/share/fonts/bitstream-vera/ACaslonPro-Bold.otf';// path

$im              = imagecreatetruecolor($width, $height);
$color           = imagecolorallocate($im, 0, 0, 0);
$backgroundColor = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 299, 99, $backgroundColor);
imagettftext($im, 14, 0, 14, 20, $color, $font, $text);

header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
</pre>
<p>さくっと。</p>
<p><a href="http://blog.justoneplanet.info/wp-content/uploads/2010/07/test.png" rel="lightbox[2732]"><img src="http://blog.justoneplanet.info/wp-content/uploads/2010/07/test.png" alt="" title="sample画像フォント" width="300" height="40" /></a></p>
<p>ファイル名とか使って上手くキャッシュできそうだ=3</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/19/php%e3%81%a8gd%e3%81%a7%e7%94%bb%e5%83%8f%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Viewを触ってみる</title>
		<link>http://blog.justoneplanet.info/2010/07/19/zend_view%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/07/19/zend_view%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 09:13:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2725</guid>
		<description><![CDATA[$this->_viewで色々設定できるらしー。
■パスの指定

class IndexController extends Zend_Controller_Action
{
    public function in [...]]]></description>
			<content:encoded><![CDATA[<p>$this->_viewで色々設定できるらしー。</p>
<h3>■パスの指定</h3>
<pre class="brush: php;">
class IndexController extends Zend_Controller_Action
{
    public function init()
    {
        $this-&gt;_session    = new Zend_Session_Namespace('global');
        $this-&gt;view-&gt;module     = $this-&gt;_getParam('module');
        $this-&gt;view-&gt;controller = $this-&gt;_getParam('controller');
        $this-&gt;view-&gt;action     = $this-&gt;_getParam('action');
    }

    public function indexAction()
    {
        // view 関連のディレクトリのパス（helpers,filters,scriptsが含まれる）
        $this-&gt;view-&gt;setBasePath('../views');
        // filters関連のディレクトリのパス
        $this-&gt;view-&gt;setFilterPath('../views/filters');
        // helpers関連のディレクトリのパス
        $this-&gt;view-&gt;setHelperPath('../views/helpers');
        // scripts関連のディレクトリのパス
        $this-&gt;view-&gt;setScriptPath('../views/scripts');
        // view 関連のディレクトリのパス（helpers,filters,scriptsが含まれる）
        $this-&gt;view-&gt;addBasePath('../views');
        // filters関連のディレクトリのパス
        $this-&gt;view-&gt;addFilterPath('../views/filters');
        // helpers関連のディレクトリのパス
        $this-&gt;view-&gt;addHelperPath('../views/helpers');
        // scripts関連のディレクトリのパス
        $this-&gt;view-&gt;addScriptPath('../views/scripts');
        $this-&gt;view-&gt;title = 'ページのタイトル';
    }
}
</pre>
<h3>■エンコードとエスケープ</h3>
<p>ガラパゴス携帯だからsjisとか。</p>
<pre class="brush: php;">
class IndexController extends Zend_Controller_Action
{
    public function init()
    {
        $this-&gt;_session    = new Zend_Session_Namespace('global');
        $this-&gt;view-&gt;module     = $this-&gt;_getParam('module');
        $this-&gt;view-&gt;controller = $this-&gt;_getParam('controller');
        $this-&gt;view-&gt;action     = $this-&gt;_getParam('action');
    }

    public function indexAction()
    {
        $this-&gt;view-&gt;encoding('Shift_JIS');// 文字コードを指定
        $this-&gt;view-&gt;escape('htmlentities');// escapeで使う関数を指定
        $this-&gt;view-&gt;title = 'ページのタイトル';
    }
}
</pre>
<h3>■フィルタ</h3>
<pre class="brush: php;">
class IndexController extends Zend_Controller_Action
{
    public function init()
    {
        $this-&gt;_session    = new Zend_Session_Namespace('global');
        $this-&gt;view-&gt;module     = $this-&gt;_getParam('module');
        $this-&gt;view-&gt;controller = $this-&gt;_getParam('controller');
        $this-&gt;view-&gt;action     = $this-&gt;_getParam('action');
    }

    public function indexAction()
    {
        $this-&gt;view-&gt;setFilter('hogeFilter');
        $this-&gt;view-&gt;title = 'ページのタイトル';
    }
}
</pre>
<p>views/filters配下に設置。</p>
<pre class="brush: php;">
class Zend_Filter_HogeFilter extends Zend_Filter
{
    public function filter($value)
    {
        $value = preg_replace('/&lt;p&gt;/', '&lt;p&gt;&lt;i&gt;', $value);
        return $value;
    }
}
</pre>
<h3>■ヘルパー</h3>
<p>よく使われる要素のビューヘルパはZend Frameworkで標準的に準備されてるらしー。</p>
<h4>フォーム</h4>
<p>第三引数でフォームの内容を指定できる。falseを指定すると開始タグしか出力されない。</p>
<pre class="brush: php;">
&lt;?php
echo $this-&gt;form(
    'form',
    array(
        'action' =&gt; '/index/register',
        'method' =&gt; 'post'
    ),
    $this-&gt;formText('dateTime', '', array('size' =&gt; '30')) .
    $this-&gt;formSubmit('', $this-&gt;translate('submit'))
);
?&gt;
</pre>
<h4>URL</h4>
<p>有用性が良く分からん。</p>
<pre class="brush: php;">
&lt;?php
echo $this-&gt;url(array(
    'controller' =&gt; 'Index',
    'action'     =&gt; 'index'
));
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/07/19/zend_view%e3%82%92%e8%a7%a6%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
