Поправил регулярку, разбивающую текст на предложения; Обработка внутренних ссылок;
This commit is contained in:
parent
c0986a556d
commit
4203efc2c0
|
|
@ -6,4 +6,29 @@ class Helper
|
|||
{
|
||||
return (bool) $var;
|
||||
}
|
||||
|
||||
public static function replaceLinks($string)
|
||||
{
|
||||
preg_match_all("(\[#\d*\])", $string, $links);
|
||||
$links = isset($links[0]) ? $links[0] : FALSE;
|
||||
if ($links)
|
||||
{
|
||||
foreach ($links as $link)
|
||||
{
|
||||
$linkId = (int)mb_substr($link, 2, -1);
|
||||
|
||||
if ($linkId)
|
||||
{
|
||||
$linkPoint = Point::model()->getByPK($linkId);
|
||||
if ($linkPoint->id)
|
||||
{
|
||||
$linkPoint->name = str_replace('"', 'ʺ', $linkPoint->name);
|
||||
$string = str_replace($link, '[<a href="/page/point/id/'.$linkId.'" title="'.$linkPoint->name.'"><span class="glyphicon glyphicon-link"></span></a>]', $string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ class PageController extends Controller
|
|||
|
||||
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
||||
$point->categoryName = $categories[$point->categoryId]['name'];
|
||||
preg_match_all("/.*?[.?!](?:\s|$)/s", $point->descriptionHtml, $items);
|
||||
|
||||
$point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml);
|
||||
preg_match_all("/.*?(([.?!](?:\s|$))|$)/s", $point->descriptionHtml, $items);
|
||||
$randomPoint = Point::model()->getRandom();
|
||||
$similarPoints = Point::model()->getAll(array('where' => 'categoryId = '.$point->categoryId.' AND `id` <> '.$point->id.' ORDER BY RAND() LIMIT 6;'));
|
||||
$closestPoints = Point::model()->getClosestPoints($pointId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue