<?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>toyosystem &#187; PHP</title>
	<atom:link href="http://www.jamboree.jp/cms/archives/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jamboree.jp/cms</link>
	<description>名古屋在住のWebプログラマー</description>
	<lastBuildDate>Fri, 26 Aug 2011 12:41:42 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>CakePHP1.2でキャッシュが消えない</title>
		<link>http://www.jamboree.jp/cms/archives/533</link>
		<comments>http://www.jamboree.jp/cms/archives/533#comments</comments>
		<pubDate>Wed, 09 Sep 2009 07:28:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/?p=533</guid>
		<description><![CDATA[CakePHP の自動キャッシュクリアが効くのは、コントローラ名＝モデル名のときだけ : akiyan.com ↑という時用 behaviorsで指定すれば多少ましかもしれないと思った。 たとえばPostモデルってのがあるんだけど、Postモデルにsave()かdelete()があったときにはトップページのtopっていうアクションのビューも削除して欲しいって時には。 post.php PLAIN TEXT PHP: var $actsAs = array&#40;'ClearCache'=&#62;array&#40;'names'=&#62;array&#40;'top'&#41;&#41;&#41;; として 以下のコードをclear_cache.phpとかで/models/behaviorsに保存しておけば PLAIN TEXT PHP: &#60;?php /* *&#160; キャッシュクリア */ class ClearCacheBehavior extends ModelBehavior &#123; &#160; &#160; &#160; var $names = array&#40;&#41;; &#160; &#160; &#160; function setup&#40;&#38;$model, $config = array&#40;&#41;&#41;&#123; &#160; &#160; &#160; &#160; if&#40;!empty&#40;$config&#91;'names'&#93;&#41;&#41; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.akiyan.com/blog/archives/2007/04/cakephp.html" target="_blank">CakePHP の自動キャッシュクリアが効くのは、コントローラ名＝モデル名のときだけ : akiyan.com</a><br />
↑という時用 behaviorsで指定すれば多少ましかもしれないと思った。</p>
<p>たとえばPostモデルってのがあるんだけど、Postモデルにsave()かdelete()があったときにはトップページのtopっていうアクションのビューも削除して欲しいって時には。</p>
<p>post.php</p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showCodeTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$actsAs</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ClearCache'</span>=&gt;array<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'names'</span>=&gt;array<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'top'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
として</p>
<p>以下のコードをclear_cache.phpとかで/models/behaviorsに保存しておけば</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/*</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *&nbsp; キャッシュクリア</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> ClearCacheBehavior extends ModelBehavior <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$names</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> setup<span style="color:#006600; font-weight:bold;">&#40;</span>&amp;<span style="color:#0000FF;">$model</span>, <span style="color:#0000FF;">$config</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'names'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">names</span> = <span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'names'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> afterSave<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$created</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_clear<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> afterDelete<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_clear<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _clear<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">names</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clearCache<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$name</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Postモデルが更新されるたびにtopのビューキャッシュもクリアされて<br />
いいと思います</p>
<h2>まとめ</h2>
<p>あと、CakePHPのビューのキャッシュはアクション名ベース（？）なので?id=99みたいなGETパラメータには対応していないとかもあるので、いっそビューのキャッシュはあきらめるというのも手です。</p>
<p><a href="http://www.exgear.jp/blog/2008/11/cakephp12-behavior%E3%81%A7%E3%83%A2%E3%83%87%E3%83%AB%E3%81%AE%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E3%82%92%E8%A1%8C%E3%81%86/" target="_blank">CakePHP1.2 Behaviorでモデルのメソッドキャッシュを行う : エクスギア　Blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/533/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AjaxZip2.0のjsonファイルをPHPで圧縮管理する</title>
		<link>http://www.jamboree.jp/cms/archives/350</link>
		<comments>http://www.jamboree.jp/cms/archives/350#comments</comments>
		<pubDate>Tue, 17 Feb 2009 17:17:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/?p=350</guid>
		<description><![CDATA[Webのフォームで郵便番号から住所を自動入力するJavaScriptで AjaxZip 2.0 - Ajax郵便番号→住所自動入力フォーム（CGI不要版） というのがあって、以下点が気に入っているのでよく使わせていただいています。 ・JavaScriptだけで動作（CGI・DB不要） ・さまざまな住所入力フォームに対応（都道府県がセレクトボックスとか郵便番号が2分割型など） これのすごいのはCGIとDBを不要にするために郵便番号データを、あらかじめ約1000個のjson形式のファイルにするという斬新な方法が使われているということで、これを初めて見た時はその発想にとても感動しました。 大抵の場合はそのまま設置して使うのですが、約1000個というjsonファイルの管理が面倒なので、今回PHPを使って別の方法を探してみました（CGI不要の意味はなくなりますね） 今回やりたかったこと ・約1000個のファイルを扱わないようにしたい ・そのためならPHPなどを使っても良い ・そのためなら多少遅くなっても良い ・ただしDBは使いたくない ・AjaxZip2.0のフロント部分はそのまま使いたい 方法 （１）jsonファイルをZIPで一つにする （２）zip-xxx.jsonに来たGETリクエストをPHPに転送（mod_rewrite） （３）ZIPの中から必要なファイルだけ展開して返す 手順 (1)ajaxzip2をダウンロードしてくる (2)展開してできたdata以下の.jsonファイルをallzip.zipという名前で保存 (3)mod_rewrite用の.htaccessをつくりdataに入れる PLAIN TEXT CODE: RewriteEngine On RewriteRule ^zip-&#40;&#91;0-9&#93;+&#41;\.json$ ajaxzip2.php?zip=$1 &#91;L&#93; (4)ajaxzip2.phpという名前でPHPも作ってdataにいれる PLAIN TEXT PHP: &#60;?php define&#40;"ALL_ZIP_FILE", "./allzip.zip"&#41;; &#160; if&#40;!isset&#40;$_GET&#91;'zip'&#93;&#41; &#124;&#124; !preg_match&#40;"/[0-9]{3}/",$_GET&#91;'zip'&#93;&#41;&#41;&#123; &#160; exit; &#125; &#160; $zip = $_GET&#91;'zip'&#93;; $za = new ZipArchive&#40;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>Webのフォームで郵便番号から住所を自動入力するJavaScriptで<br />
<a href="http://www.kawa.net/works/ajax/ajaxzip2/ajaxzip2.html">AjaxZip 2.0 - Ajax郵便番号→住所自動入力フォーム（CGI不要版） </a><br />
というのがあって、以下点が気に入っているのでよく使わせていただいています。</p>
<p>・JavaScriptだけで動作（CGI・DB不要）<br />
・さまざまな住所入力フォームに対応（都道府県がセレクトボックスとか郵便番号が2分割型など）</p>
<p>これのすごいのはCGIとDBを不要にするために郵便番号データを、あらかじめ約1000個のjson形式のファイルにするという斬新な方法が使われているということで、これを初めて見た時はその発想にとても感動しました。</p>
<p>大抵の場合はそのまま設置して使うのですが、約1000個というjsonファイルの管理が面倒なので、今回PHPを使って別の方法を探してみました（CGI不要の意味はなくなりますね）</p>
<h2>今回やりたかったこと</h2>
<p>・約1000個のファイルを扱わないようにしたい<br />
・そのためならPHPなどを使っても良い<br />
・そのためなら多少遅くなっても良い<br />
・ただしDBは使いたくない<br />
・AjaxZip2.0のフロント部分はそのまま使いたい</p>
<h2>方法</h2>
<p>（１）jsonファイルをZIPで一つにする<br />
（２）zip-xxx.jsonに来たGETリクエストをPHPに転送（mod_rewrite）<br />
（３）ZIPの中から必要なファイルだけ展開して返す</p>
<h2>手順</h2>
<p>(1)ajaxzip2をダウンロードしてくる<br />
(2)展開してできたdata以下の.jsonファイルをallzip.zipという名前で保存<br />
(3)mod_rewrite用の.htaccessをつくりdataに入れる</p>
<div class="igBar"><span id="lcode-7"><a href="#" onclick="javascript:showCodeTxt('code-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-7">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RewriteEngine On</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RewriteRule ^zip-<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span>-<span style="color:#800000;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span>+<span style="color:#006600; font-weight:bold;">&#41;</span>\.<span style="">json</span>$ ajaxzip2.<span style="">php</span>?zip=$<span style="color:#800000;color:#800000;">1</span> <span style="color:#006600; font-weight:bold;">&#91;</span>L<span style="color:#006600; font-weight:bold;">&#93;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
(4)ajaxzip2.phpという名前でPHPも作ってdataにいれる</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/define"><span style="color:#000066;">define</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"ALL_ZIP_FILE"</span>, <span style="color:#FF0000;">"./allzip.zip"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'zip'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> || !<a href="http://www.php.net/preg_match"><span style="color:#000066;">preg_match</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"/[0-9]{3}/"</span>,<span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'zip'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/exit"><span style="color:#000066;">exit</span></a>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$zip</span> = <span style="color:#0000FF;">$_GET</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'zip'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$za</span> = <span style="color:#000000; font-weight:bold;">new</span> ZipArchive<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$za</span>-&gt;<span style="color:#006600;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>ALL_ZIP_FILE<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$json</span> = <span style="color:#0000FF;">$za</span>-&gt;<span style="color:#006600;">getFromName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'zip-'</span> . <span style="color:#0000FF;">$zip</span> .<span style="color:#FF0000;">'.json'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$za</span>-&gt;<span style="color:#006600;">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Content-Type: text/javascript; charset=utf-8"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$json</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
(5)data以下はajaxzip2.phpと.htaccessとallzip.zipだけにする<br />
(6)完成</p>
<h2>ダウンロード</h2>
<p><a href='http://www.jamboree.jp/cms/wp-content/uploads/2009/02/data.zip'>data(1,550KB)</a></p>
<h2>まとめ</h2>
<p>・1000個のファイルを扱わなくていいようになった<br />
・jsonは約9Mあったのが、圧縮することで1.6Mぐらいになるという嬉しい副作用<br />
・必要なファイルだけ解凍するのでメモリも食わない<br />
・スピードも実用レベル<br />
・AjaxZip2は超便利 <a href="http://www.kawa.net/">Kawa.net</a>様に感謝</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/350/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.2で使えるテンプレート</title>
		<link>http://www.jamboree.jp/cms/archives/338</link>
		<comments>http://www.jamboree.jp/cms/archives/338#comments</comments>
		<pubDate>Tue, 03 Feb 2009 03:58:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/?p=338</guid>
		<description><![CDATA[CakePHPのサイトはカッコいいのに、CakePHPにデフォルトで入っているテンプレートはかっこ悪い。 もっと管理画面用のテンプレートってないのかなと思ったので、まず自分が一個公開します。 もとはフリーのテンプレートですがフォームやnotice,errorの部分などをCake風にアレンジしてあります。 見た目 ファイル default.ctpとstyle.cssが入っているので、適切な場所に配置してください。 minimalistic.zip(9KB) ライセンスはGPLです。 参考サイト Minimalistic Design]]></description>
			<content:encoded><![CDATA[<p><a href="http://cakephp.org/">CakePHPのサイト</a>はカッコいいのに、CakePHPにデフォルトで入っているテンプレートはかっこ悪い。<br />
もっと管理画面用のテンプレートってないのかなと思ったので、まず自分が一個公開します。<br />
もとはフリーのテンプレートですがフォームやnotice,errorの部分などをCake風にアレンジしてあります。</p>
<h2>見た目</h2>
<p><a href="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp001.png"><img src="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp001-300x204.png" alt="cakephp001" title="cakephp001" width="300" height="204" class="aligncenter size-medium wp-image-340" /></a></p>
<p><a href="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp002.png"><img src="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp002-300x200.png" alt="cakephp002" title="cakephp002" width="300" height="200" class="aligncenter size-medium wp-image-339" /></a></p>
<h2>ファイル</h2>
<p>default.ctpとstyle.cssが入っているので、適切な場所に配置してください。<br />
<a href="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/minimalistic.zip">minimalistic.zip(9KB)</a><br />
ライセンスはGPLです。</p>
<h2>参考サイト</h2>
<p><a href="http://www.minimalistic-design.net/">Minimalistic Design</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/338/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xampp環境からPHPのメール送信を行う</title>
		<link>http://www.jamboree.jp/cms/archives/274</link>
		<comments>http://www.jamboree.jp/cms/archives/274#comments</comments>
		<pubDate>Mon, 01 Dec 2008 07:21:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/274</guid>
		<description><![CDATA[xampp環境でWebアプリケーションを開発していて困るのがメール送信だ。 今回はこれを解決する。 やりたいこと ・ローカルにSMTPサーバを立ててXAMPPのPHPからメール送信テストを行えるようにしたい ・ただし実際にメールは送らなくて良い 準備 ・Radish 札幌ソフト開発工場 手順 php.iniの編集 C:\xampp\apache\bin\php.iniを編集する。 PLAIN TEXT CODE: &#91;mail function&#93; ; For Win32 only. SMTP = localhost smtp_port = 25 &#160; ; For Win32 only. sendmail_from = xxxx@example.com ってな感じにする、僕の場合はsendmail_fromのコメントアウトをはずしてメールアドレスを自分の物にしました。 Radishの起動＋設定 Radishを起動する。これだけでメールは送信されるのだけど、実際に送信される必要はないので メインメニューから 「設定」－＞「SMTP/POP3サーバ」を押して 「基本設定」タブを開き キュー常時処理という項目のチェックをはずす。すると自動でメールが送信されなくなりSMTPサーバに蓄積されるだけになる。 まとめ ・Radishすごい ・こんなに簡単ならもっと前からやっておけばよかった]]></description>
			<content:encoded><![CDATA[<p>xampp環境でWebアプリケーションを開発していて困るのがメール送信だ。<br />
今回はこれを解決する。</p>
<h2>やりたいこと</h2>
<p>・ローカルにSMTPサーバを立ててXAMPPのPHPからメール送信テストを行えるようにしたい<br />
・ただし実際にメールは送らなくて良い</p>
<h2>準備</h2>
<p>・<a href="http://homepage2.nifty.com/spw/software/radish/">Radish</a> 札幌ソフト開発工場</p>
<h2>手順</h2>
<h3>php.iniの編集</h3>
<p>C:\xampp\apache\bin\php.iniを編集する。</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showCodeTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span>mail function<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">; For Win32 only.</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">SMTP</span> = localhost</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">smtp_port = <span style="color:#800000;color:#800000;">25</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">; For Win32 only.</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">sendmail_from</span> = xxxx@example.<span style="">com</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
ってな感じにする、僕の場合はsendmail_fromのコメントアウトをはずしてメールアドレスを自分の物にしました。</p>
<h3>Radishの起動＋設定</h3>
<p>Radishを起動する。これだけでメールは送信されるのだけど、実際に送信される必要はないので<br />
メインメニューから<br />
「設定」－＞「SMTP/POP3サーバ」を押して<br />
「基本設定」タブを開き<br />
キュー常時処理という項目のチェックをはずす。すると自動でメールが送信されなくなりSMTPサーバに蓄積されるだけになる。</p>
<h2>まとめ</h2>
<p>・Radishすごい<br />
・こんなに簡単ならもっと前からやっておけばよかった</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/274/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>phpThumbnailerで背景を埋める処理</title>
		<link>http://www.jamboree.jp/cms/archives/272</link>
		<comments>http://www.jamboree.jp/cms/archives/272#comments</comments>
		<pubDate>Tue, 18 Nov 2008 10:13:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/272</guid>
		<description><![CDATA[Index of /projects/phpThumbnailer というPHPで画像のリサイズをしてくれるライブラリがあって、これが1ファイルでできている上にリサイズするだけなら PLAIN TEXT PHP: &#60;? include&#40;"../class.Thumbnail.php"&#41;; $tn_image = new Thumbnail&#40;"sample.jpg", 0, 0, 25&#41;; $tn_image-&#62;save&#40;"tn_sample.jpg"&#41;; ?&#62; というシンプルさなのでとても重宝しています。 使い方とか、キャッシュをする方法は以前書いたのでこちらをご覧下さい。 Webアプリには必要十分なのですが唯一つ、画像のリサイズで空白を埋めるというのをやってほしかったので拡張をしました。 たとえばw100xh50の画像を50x50にリサイズしたときに、結果として50x25の画像を受け取るのではなく、50x50の画像ができあがって、縦の足りない部分は背景色を表示するというような感じです。 thumbnail.inc.phpに下記のメソッドを追加して使ってください。 PLAIN TEXT PHP: /** &#160; &#160; &#160;* Resizes image to maxWidth x maxHeight &#160; &#160; &#160;* &#160; &#160; &#160;* @param int $maxWidth &#160; &#160; &#160;* @param int $maxHeight &#160; &#160; &#160;* @param [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hido.net/projects/phpThumbnailer/">Index of /projects/phpThumbnailer</a><br />
というPHPで画像のリサイズをしてくれるライブラリがあって、これが1ファイルでできている上にリサイズするだけなら</p>
<div class="igBar"><span id="lphp-13"><a href="#" onclick="javascript:showCodeTxt('php-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-13">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"../class.Thumbnail.php"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$tn_image</span> = <span style="color:#000000; font-weight:bold;">new</span> Thumbnail<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"sample.jpg"</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#CC66CC;color:#800000;">25</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$tn_image</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"tn_sample.jpg"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
というシンプルさなのでとても重宝しています。<br />
使い方とか、キャッシュをする方法は以前書いたので<a href="http://www.jamboree.jp/cms/archives/147">こちら</a>をご覧下さい。</p>
<p>Webアプリには必要十分なのですが唯一つ、画像のリサイズで空白を埋めるというのをやってほしかったので拡張をしました。<br />
たとえばw100xh50の画像を50x50にリサイズしたときに、結果として50x25の画像を受け取るのではなく、50x50の画像ができあがって、縦の足りない部分は背景色を表示するというような感じです。</p>
<p>thumbnail.inc.phpに下記のメソッドを追加して使ってください。</p>
<div class="igBar"><span id="lphp-14"><a href="#" onclick="javascript:showCodeTxt('php-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-14">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp;* Resizes image to maxWidth x maxHeight</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp;*</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp;* @param int $maxWidth</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp;* @param int $maxHeight</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp;* @param string $color</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp;*/</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> resizeFar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxWidth</span> = <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#0000FF;">$maxHeight</span> = <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#0000FF;">$color</span> = <span style="color:#FF0000;">"FFFFFF"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">resize</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxWidth</span>, <span style="color:#0000FF;">$maxHeight</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxWidth</span>&gt; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'width'</span><span style="color:#006600; font-weight:bold;">&#93;</span> || <span style="color:#0000FF;">$maxHeight</span>&gt; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'height'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/function_exists"><span style="color:#000066;">function_exists</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"ImageCreateTrueColor"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">workingImage</span> = ImageCreateTrueColor<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxWidth</span>, <span style="color:#0000FF;">$maxHeight</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">workingImage</span> = ImageCreate<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxWidth</span>, <span style="color:#0000FF;">$maxHeight</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$color</span> = imagecolorallocate<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">workingImage</span>, <a href="http://www.php.net/hexdec"><span style="color:#000066;">hexdec</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'0x'</span> . <span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#125;</span> . <span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <a href="http://www.php.net/hexdec"><span style="color:#000066;">hexdec</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'0x'</span> . <span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span> . <span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC66CC;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <a href="http://www.php.net/hexdec"><span style="color:#000066;">hexdec</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'0x'</span> . <span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC66CC;color:#800000;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span> . <span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC66CC;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imageFill<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">workingImage</span>,<span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#CC66CC;color:#800000;">0</span>,<span style="color:#0000FF;">$color</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ImageCopy<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">workingImage</span>,</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">newImage</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxWidth</span> - <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'width'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> / <span style="color:#CC66CC;color:#800000;">2</span>,</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$maxHeight</span> - <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'height'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> / <span style="color:#CC66CC;color:#800000;">2</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">0</span>,</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC66CC;color:#800000;">0</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'width'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'height'</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">newImage</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">workingImage</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'width'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$maxWidth</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">currentDimensions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'height'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$maxHeight</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/272/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHPの匿名関数のメモ(多次元配列のソート)</title>
		<link>http://www.jamboree.jp/cms/archives/259</link>
		<comments>http://www.jamboree.jp/cms/archives/259#comments</comments>
		<pubDate>Thu, 30 Oct 2008 17:23:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/259</guid>
		<description><![CDATA[最近存在を知ってからよく使うのだけど、何度も忘れて検索するのでメモ 2次元配列とかでソートしたいときに便利 PLAIN TEXT PHP: $langs = array&#40; &#160; &#160; &#160; &#160; &#160;array&#40;"name" =&#62; "php","age" =&#62; "13"&#41;, &#160; &#160; &#160; &#160; &#160;array&#40;"name" =&#62; "ruby","age" =&#62; "15"&#41; &#160; &#160; &#160; &#160;&#41;; ↑これのageでソートしたいって時が結構ある まず普通はusortとユーザ定義関数でやる PLAIN TEXT PHP: function sortByAge&#40;$a,$b&#41;&#123; &#160; return $a&#91;"age"&#93;&#62; $b&#91;"age"&#93;; &#125; usort&#40;$langs,"sortByAge"&#41;; これでOK。だけどなんだか関数の定義が面倒くさい。 んで、そんなときにusortとphpの匿名関数であるcreate_functionを使うとすっきりかける PLAIN TEXT PHP: usort&#40;$langs, create_function&#40;'$a,$b','return $a[&#34;age&#34;]&#62; $b[&#34;age&#34;];'&#41;&#41;; これだけで$langsがageでソートされるので便利。 まとめ ・PHPよりRubyが年上なのが少し驚いた [...]]]></description>
			<content:encoded><![CDATA[<p>最近存在を知ってからよく使うのだけど、何度も忘れて検索するのでメモ<br />
2次元配列とかでソートしたいときに便利</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showCodeTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$langs</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"name"</span> =&gt; <span style="color:#FF0000;">"php"</span>,<span style="color:#FF0000;">"age"</span> =&gt; <span style="color:#FF0000;">"13"</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"name"</span> =&gt; <span style="color:#FF0000;">"ruby"</span>,<span style="color:#FF0000;">"age"</span> =&gt; <span style="color:#FF0000;">"15"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
↑これのageでソートしたいって時が結構ある<br />
まず普通はusortとユーザ定義関数でやる</p>
<div class="igBar"><span id="lphp-19"><a href="#" onclick="javascript:showCodeTxt('php-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-19">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> sortByAge<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$a</span>,<span style="color:#0000FF;">$b</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$a</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"age"</span><span style="color:#006600; font-weight:bold;">&#93;</span>&gt; <span style="color:#0000FF;">$b</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"age"</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/usort"><span style="color:#000066;">usort</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$langs</span>,<span style="color:#FF0000;">"sortByAge"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
これでOK。だけどなんだか関数の定義が面倒くさい。<br />
んで、そんなときにusortとphpの匿名関数であるcreate_functionを使うとすっきりかける</p>
<div class="igBar"><span id="lphp-20"><a href="#" onclick="javascript:showCodeTxt('php-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-20">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/usort"><span style="color:#000066;">usort</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$langs</span>, <a href="http://www.php.net/create_function"><span style="color:#000066;">create_function</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'$a,$b'</span>,<span style="color:#FF0000;">'return $a[&quot;age&quot;]&gt; $b[&quot;age&quot;];'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
これだけで$langsがageでソートされるので便利。</p>
<h2>まとめ</h2>
<p>・PHPよりRubyが年上なのが少し驚いた<br />
・匿名関数と無名関数。どちらの言い方が正しいのか知りたい。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/259/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.1のページングでGETパラメータを正しく引き継ぐ</title>
		<link>http://www.jamboree.jp/cms/archives/232</link>
		<comments>http://www.jamboree.jp/cms/archives/232#comments</comments>
		<pubDate>Sat, 27 Sep 2008 13:00:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/232</guid>
		<description><![CDATA[以前にCakePHP1.1用のPaginationコンポーネントを紹介したんですが、getパラメータに配列を使うと正しくリンクを作ってくれなかったのでそれの補足。 要するにhttp://example.com/?data[Search][name]=1とかって感じの配列がGETパラメータにある場合に、このパラメータを引き継いでくれない（data=Arrayとかってなる）バグを修正した。 /views/helpers/pagination.phpの_generateUrlってメソッドを修正する。 http_build_queryっていう関数を使ったんですが、これは配列もしくはオブジェクトからURL エンコードされたクエリ文字列を生成する関数で、なんと多次元配列にも対応している。さすがPHP！（オブジェクトに対応してるほうが変か） PLAIN TEXT PHP: function _generateUrl &#40;$page=NULL,$pageDetails=NULL&#41; &#160; &#160; &#123; &#160; &#160; &#160; &#160; $pageDetails = $pageDetails?$pageDetails:$this-&#62;_pageDetails; &#160; &#160; &#160; &#160; $getParams = $this-&#62;getParams; // Import any other pre-existing get parameters &#160; &#160; &#160; &#160; if &#40;$this-&#62;_pageDetails&#91;'paramStyle'&#93;=="pretty"&#41; &#160; &#160; &#160; &#160; &#123; &#160; &#160; &#160; &#160; &#160; &#160; $pageParams=$pageDetails&#91;'importParams'&#93;; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>以前にCakePHP1.1用のPaginationコンポーネントを<a href="http://www.jamboree.jp/cms/archives/14">紹介した</a>んですが、getパラメータに配列を使うと正しくリンクを作ってくれなかったのでそれの補足。</p>
<p>要するにhttp://example.com/?data[Search][name]=1とかって感じの配列がGETパラメータにある場合に、このパラメータを引き継いでくれない（data=Arrayとかってなる）バグを修正した。</p>
<p>/views/helpers/pagination.phpの_generateUrlってメソッドを修正する。<br />
http_build_queryっていう関数を使ったんですが、これは配列もしくはオブジェクトからURL エンコードされたクエリ文字列を生成する関数で、なんと多次元配列にも対応している。さすがPHP！（オブジェクトに対応してるほうが変か）</p>
<div class="igBar"><span id="lphp-22"><a href="#" onclick="javascript:showCodeTxt('php-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-22">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> _generateUrl <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$page</span>=<span style="color:#000000; font-weight:bold;">NULL</span>,<span style="color:#0000FF;">$pageDetails</span>=<span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageDetails</span> = <span style="color:#0000FF;">$pageDetails</span>?<span style="color:#0000FF;">$pageDetails</span>:<span style="color:#0000FF;">$this</span>-&gt;_pageDetails;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$getParams</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getParams</span>; <span style="color:#FF9933; font-style:italic;">// Import any other pre-existing get parameters</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_pageDetails<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'paramStyle'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">"pretty"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span>=<span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'importParams'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'show'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'show'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortBy'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortBy'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'direction'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'direction'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'page'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$page</span>?<span style="color:#0000FF;">$page</span>:<span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'page'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortByClass'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortByClass'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortByClass'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$getString</span> = <a href="http://www.php.net/array"><span style="color:#000066;">Array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span> = <a href="http://www.php.net/array"><span style="color:#000066;">Array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'paramStyle'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">"get"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$getParams</span> = am<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$getParams</span>,<span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageParams</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$key</span> =&gt; <span style="color:#0000FF;">$value</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Defaults'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$key</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>up<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Defaults'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$key</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>&lt;&gt;up<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$value</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">"$key{$pageDetails['paramSeperator']}$value"</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">"$key{$pageDetails['paramSeperator']}$value"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">url</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span> = <a href="http://www.php.net/implode"><span style="color:#000066;">implode</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"/"</span>, <span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> .= <span style="color:#0000FF;">$prettyString</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$getParams</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> .= <span style="color:#FF0000;">"?"</span>. http_build_query<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$getParams</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$url</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/232/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.1でキャリアごとの絵文字を表示</title>
		<link>http://www.jamboree.jp/cms/archives/227</link>
		<comments>http://www.jamboree.jp/cms/archives/227#comments</comments>
		<pubDate>Fri, 05 Sep 2008 11:02:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/227</guid>
		<description><![CDATA[すでにいろいろな方法があるようです。 CakePHPで3キャリア携帯の絵文字を表示する :: Webプログラマー＋WebデザイナーなZARU日記（DB使用） ひでぶろぐ CAKEPHP絵文字入力・出力ヘルパー（DB使用） EmojiHelper - キャリアを意識せずに絵文字を出力できるCakePHPのHelperクラス - 芋ではない日記（JSON使用） 僕はDBを使うのが嫌だったのとJSONは使ったことがなかったのでMobilePictogramConverterという絵文字ライブラリがあるのでそれを使いました。 特徴 * DoCoMo, au, SoftBankの絵文字を相互変換可能 * 端末からサーバーへ送信された絵文字の変換が可能（掲示板など） * SJIS/UTF-8に対応 * PCでの絵文字表示が可能（画像） * 絵文字画像は全て透過GIFでアニメーションに対応 * DoCoMo隠し絵文字一部対応 * バイナリコード, Web入力コード, imgタグからの変換が可能 * 絵文字の削除が可能 * 文字列に含まれる絵文字の数を検出 * UserAgentからキャリアを判別し、キャリアに合った絵文字に自動変換が可能 すごいです。作った人。 手順 (1)MobilePictogramConverterを取得して解凍 (2)MobilePictogramConverterを/app/vendorsにいれる (3)MobilePictogramConverterのimgをWEBROOT_DIR/img/m/にいれる (4)/app/app_controller.phpを編集 PLAIN TEXT PHP: &#60;?php vendor&#40;'MobilePictogramConverter/MobilePictogramConverter'&#41;; &#160; class AppController extends Controller &#123; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>すでにいろいろな方法があるようです。<br />
<a href="http://blog.tofu-kun.org/080715194417.php" target="_blank">CakePHPで3キャリア携帯の絵文字を表示する :: Webプログラマー＋WebデザイナーなZARU日記（DB使用）</a><br />
<a href="http://www.hideblog.net/nikkis/show/11" target="_blank">ひでぶろぐ CAKEPHP絵文字入力・出力ヘルパー（DB使用）</a><br />
<a href="http://d.hatena.ne.jp/ymkn/20080131/p1" target="_blank">EmojiHelper - キャリアを意識せずに絵文字を出力できるCakePHPのHelperクラス - 芋ではない日記（JSON使用）</a></p>
<p>僕はDBを使うのが嫌だったのとJSONは使ったことがなかったので<a href="http://php-develop.org/MobilePictogramConverter/" target="_blank">MobilePictogramConverter</a>という絵文字ライブラリがあるのでそれを使いました。</p>
<blockquote><p>
特徴<br />
    *  DoCoMo, au, SoftBankの絵文字を相互変換可能<br />
    * 端末からサーバーへ送信された絵文字の変換が可能（掲示板など）<br />
    * SJIS/UTF-8に対応<br />
    * PCでの絵文字表示が可能（画像）<br />
    * 絵文字画像は全て透過GIFでアニメーションに対応<br />
    * DoCoMo隠し絵文字一部対応<br />
    * バイナリコード, Web入力コード, imgタグからの変換が可能<br />
    * 絵文字の削除が可能<br />
    * 文字列に含まれる絵文字の数を検出<br />
    * UserAgentからキャリアを判別し、キャリアに合った絵文字に自動変換が可能</p></blockquote>
<p>すごいです。作った人。</p>
<h2>手順</h2>
<p>(1)MobilePictogramConverterを取得して解凍<br />
(2)MobilePictogramConverterを/app/vendorsにいれる<br />
(3)MobilePictogramConverterのimgをWEBROOT_DIR/img/m/にいれる<br />
(4)/app/app_controller.phpを編集</p>
<div class="igBar"><span id="lphp-24"><a href="#" onclick="javascript:showCodeTxt('php-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-24">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">vendor<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'MobilePictogramConverter/MobilePictogramConverter'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> AppController extends Controller <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//app_controllerのいろいろは省略</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> beforeFilter<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/ob_start"><span style="color:#000066;">ob_start</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent::<span style="color:#006600;">beforeFilter</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> afterFilter<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent::<span style="color:#006600;">afterFilter</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// バッファを取得して、出力バッファをクリア</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <a href="http://www.php.net/ob_get_clean"><span style="color:#000066;">ob_get_clean</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"webservices"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"webservices"</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#FF0000;">"Mobile"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <a href="http://www.php.net/mb_convert_kana"><span style="color:#000066;">mb_convert_kana</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$out</span>,<span style="color:#FF0000;">"k"</span>,<span style="color:#FF0000;">"UTF-8"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$mpc</span> =&amp; MobilePictogramConverter::<span style="color:#006600;">factory</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$out</span>, MPC_FROM_EZWEB, MPC_FROM_CHARSET_UTF8, MPC_FROM_OPTION_WEB<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$mpc</span>-&gt;<span style="color:#006600;">setImagePath</span><span style="color:#006600; font-weight:bold;">&#40;</span>WEBROOT_DIR . <span style="color:#FF0000;">'img/m/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <span style="color:#0000FF;">$mpc</span>-&gt;<span style="color:#006600;">autoConvert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$out</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
バッファをためて一括で変換しています。絵文字と一緒に全角カナも半角カナに直してしまいます。<br />
$this->params["webservices"]で判別しているのはShin x blogさんの「<a href="http://www.1x1.jp/blog/2006/09/cakephp_mobile.html">CakePHP 携帯用ビューを表示する</a>」を使用して携帯のビューを切り替えているからです。</p>
<p>これで携帯のビュー内で&gt;img localsrc="180"/&lt;とかってやると絵文字が表示されます。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/227/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>akismetでスパム対策が簡単かつ強力</title>
		<link>http://www.jamboree.jp/cms/archives/223</link>
		<comments>http://www.jamboree.jp/cms/archives/223#comments</comments>
		<pubDate>Wed, 27 Aug 2008 15:15:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/223</guid>
		<description><![CDATA[当ブログはwordpressを利用しており、スパム対策にakismetというのを使用しています。 これがなかなか強力で今までで1000以上のスパムを間違いなしで弾いてくれています。 今回べつのサイトの掲示板にて、botによる荒らしがひどかったためスパム対策をしようとしたところ akismetがwordpress以外にも簡単に利用できることがわかったため導入してみました。 準備 http://akismet.com/ ダウンロードしたらユーザ登録をしてAPIキーを入手 APIキーを入手するにはwordpress.comのアカウントを作成する必要があります。 サインアップページ http://wordpress.com/signup/ アカウントを作るとブログがもらえますが今回は必要ないので「Just a username, please.」にチェックを入れるようにします。 アクティベーション用のメールがきますので、本文に記述されているURLをクリックして登録を完了させます。 すると再度メールがきてAPIキーが手に入ります。 次にPHP用のクラスライブラリを手に入れます。 http://akismet.com/development/ ここにはRoR用やJava用や、各種ブログ用などすぐに使えるライブラリがたくさん用意されています。 今回はPHP5なので「PHP 5 class by Alex」を落とします。 あとは書き込みの直前などで以下のコードを実行 コード PLAIN TEXT PHP: include&#40;"Akismet.class.php"&#41;; $akismet = new Akismet&#40;"http://"."サイトURL","自分のAPIキー"&#41;; $akismet-&#62;setCommentAuthor&#40;$data&#91;'name'&#93;&#41;; $akismet-&#62;setCommentAuthorEmail&#40;$data&#91;'email'&#93;&#41;; $akismet-&#62;setCommentAuthorURL&#40;$data&#91;'url'&#93;&#41;; $akismet-&#62;setCommentContent&#40;$data&#91;'body'&#93;&#41;; if&#40;$akismet-&#62;isCommentSpam&#40;&#41;&#41;&#123; &#160; &#160; exit&#40;"大変申し訳ありませんが、システムの都合で書き込みができませんでした。"&#41;; &#125; これで完了。 Author,AuthorEmail,AuthorURLは空文字でもいいみたいです。 まとめ CAPTCHAなどの導入も考えましたがユーザの負担がないのが一番ですからね。 あとは誤認識があっても大丈夫なようにエラーメッセージをキャッチする仕組みを用意すれば万全です。 ブログでの実績からすれば全然大丈夫だと思いますが、これでしばらく様子を見てみます。]]></description>
			<content:encoded><![CDATA[<p>当ブログはwordpressを利用しており、スパム対策にakismetというのを使用しています。<br />
これがなかなか強力で今までで1000以上のスパムを間違いなしで弾いてくれています。</p>
<p>今回べつのサイトの掲示板にて、botによる荒らしがひどかったためスパム対策をしようとしたところ<br />
akismetがwordpress以外にも簡単に利用できることがわかったため導入してみました。</p>
<h2>準備</h2>
<p>http://akismet.com/</p>
<p>ダウンロードしたらユーザ登録をしてAPIキーを入手</p>
<p>APIキーを入手するにはwordpress.comのアカウントを作成する必要があります。</p>
<p>サインアップページ</p>
<p>http://wordpress.com/signup/</p>
<p>アカウントを作るとブログがもらえますが今回は必要ないので「Just a username, please.」にチェックを入れるようにします。<br />
アクティベーション用のメールがきますので、本文に記述されているURLをクリックして登録を完了させます。<br />
すると再度メールがきてAPIキーが手に入ります。</p>
<p>次にPHP用のクラスライブラリを手に入れます。</p>
<p>http://akismet.com/development/</p>
<p>ここにはRoR用やJava用や、各種ブログ用などすぐに使えるライブラリがたくさん用意されています。</p>
<p>今回はPHP5なので「PHP 5 class by Alex」を落とします。<br />
あとは書き込みの直前などで以下のコードを実行</p>
<h2>コード</h2>
<div class="igBar"><span id="lphp-26"><a href="#" onclick="javascript:showCodeTxt('php-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-26">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Akismet.class.php"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$akismet</span> = <span style="color:#000000; font-weight:bold;">new</span> Akismet<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"http://"</span>.<span style="color:#FF0000;">"サイトURL"</span>,<span style="color:#FF0000;">"自分のAPIキー"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$akismet</span>-&gt;<span style="color:#006600;">setCommentAuthor</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$akismet</span>-&gt;<span style="color:#006600;">setCommentAuthorEmail</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'email'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$akismet</span>-&gt;<span style="color:#006600;">setCommentAuthorURL</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'url'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$akismet</span>-&gt;<span style="color:#006600;">setCommentContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'body'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$akismet</span>-&gt;<span style="color:#006600;">isCommentSpam</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/exit"><span style="color:#000066;">exit</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"大変申し訳ありませんが、システムの都合で書き込みができませんでした。"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
これで完了。<br />
Author,AuthorEmail,AuthorURLは空文字でもいいみたいです。</p>
<h2>まとめ</h2>
<p>CAPTCHAなどの導入も考えましたがユーザの負担がないのが一番ですからね。<br />
あとは誤認識があっても大丈夫なようにエラーメッセージをキャッチする仕組みを用意すれば万全です。<br />
ブログでの実績からすれば全然大丈夫だと思いますが、これでしばらく様子を見てみます。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/223/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>デザイナーのためのCakePHP1.1メモ</title>
		<link>http://www.jamboree.jp/cms/archives/156</link>
		<comments>http://www.jamboree.jp/cms/archives/156#comments</comments>
		<pubDate>Sat, 17 May 2008 19:10:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/156</guid>
		<description><![CDATA[「デザイナーのためのCakePHP入門」というエントリを書いていたのですが、さしあたって1.1の説明が必要になったのでデザイナーさん向けのメモ。主にビューでのHTMLヘルパーの説明になります。 どこを編集すればいいのか？ /app/views テンプレートファイルがあります /app/webroot Stylesheet、Javascript、画像、そのほかのファイルなどはこちらにおきます。css,js,imgというディレクトリがあらかじめ用意されています。大変申し訳ないのですがディレクトリ名はこのまま使ってください。（変えたい場合はプログラマに相談してください） テンプレートの構造 ここからは/app/views以下の話になります。 まずレイアウトが/layout以下にあり、layoutファイルの中の &#60;?php echo $content_for_layout ?&#62; という記述のところに中身が差し込まれます。 &#60;?php echo $this-&#62;renderElement('なんとか'); ?&#62; という記述を見つけたら、それは「/views/element/なんとか」ってファイルを取り込んでいますので、そちらを見てください（layoutファイル以外でも使われます） 各種タグなど 各種外部ファイルの読み込み PLAIN TEXT PHP: &#60;?php echo $html-&#62;css&#40;'import'&#41;; ?&#62; //スタイルシートを読み込む &#60;?php echo $javascript-&#62;link&#40;'prototype'&#41;;?&#62; //Javascriptを読み込む 拡張子は省略できます。それぞれ/app/webroot/css,/app/webroot/jsに入れておいてください。 画像を表示 PLAIN TEXT PHP: &#60;?php echo $html-&#62;image&#40;"logo.gif"&#41; ?&#62; これで/app/webroot/imgにあるlogo.gifを表示します。 PLAIN TEXT PHP: $html-&#62;image&#40;'logo.gif',array&#40;"id"=&#62;"logo","alt"=&#62;"会社ロゴ"&#41;&#41;; 第2引数にハッシュを渡してやることでimgタグにid="logo",alt="会社ロゴ"が追加されます。 リンク PLAIN TEXT PHP: &#60;?php echo $html-&#62;link&#40;"トップ" [...]]]></description>
			<content:encoded><![CDATA[<p>「<a href="http://www.jamboree.jp/cms/archives/139">デザイナーのためのCakePHP入門</a>」というエントリを書いていたのですが、さしあたって1.1の説明が必要になったのでデザイナーさん向けのメモ。主にビューでのHTMLヘルパーの説明になります。</p>
<h2>どこを編集すればいいのか？</h2>
<h3>/app/views</h3>
<p>テンプレートファイルがあります</p>
<h3>/app/webroot</h3>
<p>Stylesheet、Javascript、画像、そのほかのファイルなどはこちらにおきます。css,js,imgというディレクトリがあらかじめ用意されています。大変申し訳ないのですがディレクトリ名はこのまま使ってください。（変えたい場合はプログラマに相談してください）</p>
<h2>テンプレートの構造</h2>
<p>ここからは/app/views以下の話になります。<br />
まずレイアウトが/layout以下にあり、layoutファイルの中の</p>
<pre class="php">&lt;?php <span class="func" >echo</span> <span class="vars" >$content_for_layout</span> ?&gt;</pre>
<p>という記述のところに中身が差し込まれます。</p>
<pre class="php">&lt;?php <span class="func" >echo</span> <span class="vars" >$this</span>-&gt;renderElement(<span class="string" >'なんとか'</span>); ?&gt;</pre>
<p>という記述を見つけたら、それは「/views/element/なんとか」ってファイルを取り込んでいますので、そちらを見てください（layoutファイル以外でも使われます）</p>
<h2>各種タグなど</h2>
<h3>各種外部ファイルの読み込み</h3>
<div class="igBar"><span id="lphp-33"><a href="#" onclick="javascript:showCodeTxt('php-33'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-33">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'import'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> <span style="color:#FF9933; font-style:italic;">//スタイルシートを読み込む</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$javascript</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'prototype'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt; <span style="color:#FF9933; font-style:italic;">//Javascriptを読み込む </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
拡張子は省略できます。それぞれ/app/webroot/css,/app/webroot/jsに入れておいてください。</p>
<h3>画像を表示</h3>
<div class="igBar"><span id="lphp-34"><a href="#" onclick="javascript:showCodeTxt('php-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-34">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">image</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"logo.gif"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
これで/app/webroot/imgにあるlogo.gifを表示します。</p>
<div class="igBar"><span id="lphp-35"><a href="#" onclick="javascript:showCodeTxt('php-35'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-35">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">image</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'logo.gif'</span>,<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"id"</span>=&gt;<span style="color:#FF0000;">"logo"</span>,<span style="color:#FF0000;">"alt"</span>=&gt;<span style="color:#FF0000;">"会社ロゴ"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
第2引数にハッシュを渡してやることでimgタグにid="logo",alt="会社ロゴ"が追加されます。</p>
<h3>リンク</h3>
<div class="igBar"><span id="lphp-36"><a href="#" onclick="javascript:showCodeTxt('php-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-36">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"トップ"</span> , <span style="color:#FF0000;">"/top"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
とやると、/topへのトップというリンクを表示します。</p>
<div class="igBar"><span id="lphp-37"><a href="#" onclick="javascript:showCodeTxt('php-37'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-37">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"トップ"</span> , <span style="color:#FF0000;">"/top"</span>,<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"target"</span>=&gt;<span style="color:#FF0000;">"_blank"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
このタグもハッシュで属性を追加できます。この場合はtarget="_blank"が追加されます。</p>
<h3>画像でのリンク</h3>
<div class="igBar"><span id="lphp-38"><a href="#" onclick="javascript:showCodeTxt('php-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-38">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">image</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"/logo.gif"</span>,<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"id"</span>=&gt;<span style="color:#FF0000;">"logo"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#FF0000;">"/top"</span>,<span style="color:#000000; font-weight:bold;">false</span>,<span style="color:#000000; font-weight:bold;">false</span>,<span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
画像でのリンクは画像とリンクのタグを組み合わせるとできます。後半にfalseが3つも並んでいて無駄に見えますがこれは必要なので書くようにしてください。</p>
<h2>まとめ</h2>
<p>この他にもフォームを書くときなども専用のコードを書く必要があります。面倒くさいですね・・・</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/156/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

