Php 维基风格的链接。如果目标页面没有';不存在
我有一个模型页面。WikiPage->我从数据库中获取的文本。我创建了方法“wikify”,并按class::wikify($page->getText())在页面上生成文本。 在文本中,我有构造[link name],我用以下内容生成链接:Php 维基风格的链接。如果目标页面没有';不存在,php,symfony1,symfony-1.4,propel,Php,Symfony1,Symfony 1.4,Propel,我有一个模型页面。WikiPage->我从数据库中获取的文本。我创建了方法“wikify”,并按class::wikify($page->getText())在页面上生成文本。 在文本中,我有构造[link name],我用以下内容生成链接: $text = preg_replace('@\[(.*) (.*)\]@', '<a href="\\1" class="<?php Wiki::httpresponse($\\1) ?>">
$text = preg_replace('@\[(.*) (.*)\]@', '<a href="\\1" class="<?php Wiki::httpresponse($\\1) ?>">\\2</a>', $text);
2个问题:
http://localhost:8080/category/page
,类别是第一个模块,页面是第二个模块,主页是模块:类别,操作:索引,类别/页面是模块的路径:页面,操作:显示)
方法HttpResponse未执行
$reg_inURL = "@\[(\w*)\/(\w*) (.*)\]\]@";
preg_match_all($reg_inURL, $text, $matches);
$count = 0;
$links = count($matches[0]);
foreach ($matches[0] as $pattern)
{
$cat = $matches[1][$count];
$pag = $matches[2][$count];
$q = WikiPageQuery::create()
->leftJoin('WikiPage.WikiCategory')
->where('WikiCategory.category_address = ?', $cat)
->filterByAddress($pag)
->findOne();
if (!$q)
{
$link_class = 'red';
$url = $cat.'/add';
}
else
{
$link_class = 'blue';
$url = $cat.'/'.$pag;
}
$title = $matches[3][$count];
$text = str_replace ($pattern, '<a href='.$url.' class='.$link_class.'>'.$title.'</a>', $text);
$count = $count+1;
}
$reg\u inURL=“@\[(\w*)\/(\w*)(.*)\]\]@”;
preg_match_all($reg_inURL,$text,$matches);
$count=0;
$links=count($matches[0]);
foreach($matches[0]为$pattern)
{
$cat=$matches[1][$count];
$pag=$matches[2][$count];
$q=WikiPageQuery::create()
->leftJoin('WikiPage.WikiCategory')
->其中('WikiCategory.category_address=?',$cat)
->filterByAddress($pag)
->芬顿();
如果(!$q)
{
$link_class='red';
$url=$cat.'/add';
}
其他的
{
$link_class='blue';
$url=$cat.'/'.$pag;
}
$title=$matches[3][$count];
$text=str_replace($pattern,,$text);
$count=$count+1;
}
$reg_inURL = "@\[(\w*)\/(\w*) (.*)\]\]@";
preg_match_all($reg_inURL, $text, $matches);
$count = 0;
$links = count($matches[0]);
foreach ($matches[0] as $pattern)
{
$cat = $matches[1][$count];
$pag = $matches[2][$count];
$q = WikiPageQuery::create()
->leftJoin('WikiPage.WikiCategory')
->where('WikiCategory.category_address = ?', $cat)
->filterByAddress($pag)
->findOne();
if (!$q)
{
$link_class = 'red';
$url = $cat.'/add';
}
else
{
$link_class = 'blue';
$url = $cat.'/'.$pag;
}
$title = $matches[3][$count];
$text = str_replace ($pattern, '<a href='.$url.' class='.$link_class.'>'.$title.'</a>', $text);
$count = $count+1;
}