私はモデルWikiPageを持っています。WikiPage->データベースから取得したテキスト。メソッド「wikify」を作成し、class::wikify($Page->getText()) でページ上にテキストを生成しました。テキスト I have construction [リンク名] では、次のリンクを生成します。
$text = preg_replace('@\[(.*) (.*)\]@', '<a href="\\1" class="<?php Wiki::httpresponse($\\1) ?>">\\2</a>', $text);
アイデアは、関数 httpresponse で URL をチェックし、ページがない場合はクラスを変更することです。
http応答:
static public function httpresponse($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_exec ($ch);
$intReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode != 304) { return "red"; } else return "blue";
}
2 つの問題:
localhost ページで httpresponce をテストすると、それらが見つかりません。Web ページでテストすると、すべて問題ありません。
(次のようなチェックされたリンク
http://localhost:8080/category/page
、カテゴリは最初のモジュール、ページはisecond、ホームページはモジュール:カテゴリ、アクション:インデックス、カテゴリ/ページはモジュールのルート:ページ、アクション:表示)生成されたリンクのクラスは、
<?php Wiki::httpresponse($\\1) ?>
メソッド httpresponce が実行されていないままです。
何ができるでしょうか?たぶん、このタスクを実行するためのより良い方法がありますか?