Added : Turn plain urls in href links

This commit is contained in:
Saqib Razzaq 2016-10-20 12:07:02 +05:00
parent b633eac2f0
commit d6f3de163b
2 changed files with 24 additions and 1 deletions

View file

@ -5682,6 +5682,29 @@
}
}
function AutoLinkUrls($str,$popup = FALSE){
if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches)){
$pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
for ($i = 0; $i < count($matches['0']); $i++){
$period = '';
if (preg_match("|\.$|", $matches['6'][$i])){
$period = '.';
$matches['6'][$i] = substr($matches['6'][$i], 0, -1);
}
$str = str_replace($matches['0'][$i],
$matches['1'][$i].'<a href="http'.
$matches['4'][$i].'://'.
$matches['5'][$i].
$matches['6'][$i].'"'.$pop.'>http'.
$matches['4'][$i].'://'.
$matches['5'][$i].
$matches['6'][$i].'</a>'.
$period, $str);
}//end for
}//end if
return $str;
}//end AutoLinkUrls
include( 'functions_db.php' );
include( 'functions_filter.php' );

View file

@ -83,7 +83,7 @@
<div class="tab-content clearfix">
<div class="tab-pane fade in clearfix active" id="cb-item-info">
<div class="clearfix watch-vid-details">
<p>{$video.description|unescape:"html"}</p>
<p>{AutoLinkUrls($video.description|unescape:"html")}</p>
<ul class="clearfix desc-list">
<li><strong>{lang code='category'}</strong>:&nbsp;{$vdo.category|categories:video}</li>
<li><strong>{lang code='duration'}</strong>:&nbsp;{if $video.duration>1}{$video.duration|SetTime}{else}00:00{/if}</li>