AjaxなURL(#!)を変換する奴を書かれたものをPHP用にポーティング

http://github.com/sasezaki/Zend_Uri_HttpCrawlableHash

@see http://code.google.com/intl/ja/web/ajaxcrawling/docs/specification.html
@see http://subtech.g.hatena.ne.jp/mala/20101018/1287419036

とりあえずテストコードに書かれた分はパスしてますって程度ですね。

<?php
require_once 'Diggin/Uri/HttpCrawlableHashTest.php';

$uri = Zend_Uri::factory("http://twitter.com/#!/wozozo", 'Diggin_Uri_HttpCrawlableHash');

// 変換したURIオブジェクトが欲しいとき(cloneして返します)
echo $uri->getFragmentToQuery(); // http://twitter.com/?_escaped_fragment_=/wozozo

// uriオブジェクトを変換して保持する場合
$uri->filterFragmentToQuery();
echo $uri; // http://twitter.com/?_escaped_fragment_=/wozozo

// 常に変換を掛けたい場合
//(zf2だとスタティックコンフィグじゃなくなるんで結構いまさらできても意味ない)
Zend_Uri::setConfig(array('convert_always' => 'query'));
$uri2 = Zend_Uri::factory("http://twitter.com/#!/gusagi", 'Diggin_Uri_HttpCrawlableHash');
echo $uri2; // http://twitter.com/?_escaped_fragment_=/gusagi


Zend_Uri、コンストラクタは置き換えられませんが、factoryでのクラスは置き換えられます。
(Zend Framework 1.10.5以上)
http://framework.zend.com/issues/browse/ZF-9925
http://framework.zend.com/manual/ja/zend.uri.chapter.html (Creating a New Custom-Class URI)