\|](.*?)\])|(\[#(\d+)\]))", $string, $links); $links = isset($links[0]) ? $links[0] : FALSE; if ($links) { foreach ($links as $link) { $idAndLink = mb_substr($link, 2, -1); $delimiter = strpos($idAndLink, '|') === FALSE ? '>' : '|'; $idAndLink = explode($delimiter, $idAndLink); $linkId = $idAndLink[0]; $linkName = isset($idAndLink[1]) ? $idAndLink[1] : ''; if ($linkId) { $linkPoint = Point::model()->getByPK($linkId); if ($linkPoint && $linkPoint->id) { $linkTitle = str_replace('"', 'ʺ', $linkPoint->name); switch ($replaceType) { case 'html': $linkName = $linkName ? $linkName : ''; $string = str_replace($link, '' . $linkName . '', $string); break; case 'js': $linkName = $linkName ? $linkName : ''; $string = str_replace($link, '' . $linkName . '', $string); break; default: $string = str_replace($link, $linkName, $string); break; } } } } } return $string; } public static function replaceImgs($string, $replaceType = 'clear') { preg_match_all("(\[img[\|]#(\d+)\])", $string, $images); $images = isset($images[0]) ? $images[0] : FALSE; if ($images) { foreach ($images as $img) { $imgAndId = mb_substr($img, 2, -1); $imgAndId = explode('#', $imgAndId); $imgId = (int)$imgAndId[1]; $imgObj = ArticlePhotos::model()->getByPK($imgId); if ($imgObj->name) { switch ($replaceType) { case 'html': $imgObj->caption = $linkTitle = str_replace('"', 'ʺ', $imgObj->caption); $imgTag = '
