これを処理するのは簡単なことではありませんが、この種のことを処理し、適切なphpファイルを含めるためのコントローラーマジックとともに、カスタムルートを作成することは可能です。
まず第一に-あなたのルートはおそらく(ZF1.9 application.iniの規則では)
resources.router.routes.phorum.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.phorum.route = "messageboard(?:/(.*))?"
resources.router.routes.phorum.defaults.controller = "phorum"
resources.router.routes.phorum.defaults.action = "wrapper"
resources.router.routes.phorum.defaults.module = "default"
resources.router.routes.phorum.defaults.page = "index.php"
resources.router.routes.phorum.map.1 = "page"
これで、へのすべてのリクエストをmessageboard/whatever.php
PhorumController ::wrapperAction()にルーティングし、「whatever.php」を含める必要があります。$this->getRequest()->getParam('page')
次に、「ラッパー」アクションをリダイレクトして、phorumから適切なphpファイルを含めるという単純な問題になるはずです。私が持っている同様のコントローラーからいくつかのコードを追加しました(私のものにはphpファイルは含まれていませんでした-それはコンテンツのディレクトリを提供するためだけのものでした)
public function wrapperAction() {
$phorumPath = APPLICATION_PATH."../ext/phorum/";
$file = realpath($phorumPath . $this->getRequest()->getParam('page');
if (!$file || !is_file($file)) throw new Exception("File not found");
// disable default viewRenderer - layout should still render at this point
$this->_helper->viewRenderer->setNoRender(true);
// determine extension to determine mime-type
preg_match("#\.([^.]+)$#", $filename, $matches);
switch (strtolower($matches[1]))
{
case "php":
// patch the request over to phorum
include($file);
return; // exit from the rest of the handler, which deals specifically
// with other types of files
case "js":
$this->getResponse()->setHeader('Content-Type', 'text/javascript');
ini_set('html_errors', 0);
break;
case "css":
$this->getResponse()->setHeader('Content-Type', 'text/css');
ini_set('html_errors', 0);
break;
case "html":
$this->getResponse()->setHeader('Content-Type', 'text/html');
break;
// you get the idea... add any others like gif/etc that may be needed
default:
$this->getResponse()->setHeader('Content-Type', 'text/plain');
ini_set('html_errors', 0);
break;
}
// Disable Layout
$this->_helper->layout->disableLayout();
// Sending 304 cache headers if the file hasn't changed can be a bandwidth saver
$mtime = filemtime($fn);
if ($modsince = $this->getRequest()->getServer('HTTP_IF_MODIFIED_SINCE'))
{
$modsince = new Zend_Date($modsince);
$modsince = $modsince->getTimestamp();
if ($mtime <= $modsince) {
$this->getResponse()->setHttpResponseCode(304);
return;
}
}
$this->getResponse()->setHeader('Last-Modified', gmdate("D, d M Y H:i:s",$mtime). " GMT");
readfile($fn);
}
お願いします-ページでなどを使用してリクエストを作成しようとしている人のために、このコードをテスト..
してください。