アクセスしてきたクライアントに対して、Nucleus が Content-Type ヘッダを返す直前に呼び出されます
このイベントによって、クライアントに返す Content-Type ヘッダを変更する事が出来ます
globalfunctions.php 398行目
$manager->notify( 'PreSendContentType', array( 'contentType' => &$contenttype, 'charset' => &$charset, 'pageType' => $pagetype ) );
NP_CustomURL v0.3.01 より
function event_PreSendContentType($data) { global $blogid, $CONF; $ext = substr(serverVar('PATH_INFO'), -4); if ($ext == '.rdf' || $ext == '.xml') { $p_info = trim(serverVar('PATH_INFO'), '/'); $path_arr = explode('/', $p_info); switch (end($path_arr)) { case 'rss1.xml': case 'index.rdf': case 'rss2.xml': case 'atom.xml': $data['contentType'] = 'application/xml'; break; default: break; } } }
この例では charset の変更は無いので、contentType のみを書き換えて返しています
これは、受け取った URL の末尾4文字が「.rdf」か「.xml」、かつ、switch文で指定した URL のリクエストを受けた場合に、Content-Type に「application/xml」を返す処理をしています
NP_MobileWithSinglePage より
function event_PreSendContentType(&$data) { if($this->_isMobileUA()) { $data['charset'] = 'Shift_JIS'; $data['contentType'] = 'text/html'; } }
function _isMobileUA() で携帯電話からのアクセスかどうかを確認後、携帯電話からのアクセスであった場合、 charset に Shift_JIS を、contentType に text/html を返しています