Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
* remotes/upstream/master: diabook-theme: small fix Avoid tagging both '@Robert Johnson' and also '@Robert', when '@Robert Johnson' was already matched, and '@Robert' might be somebody different entirely. * master:
This commit is contained in:
commit
4c8a82456e
36
mod/item.php
36
mod/item.php
|
@ -444,9 +444,28 @@ function item_post(&$a) {
|
||||||
$tags[] = '@' . $parent_contact['nick'];
|
$tags[] = '@' . $parent_contact['nick'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tagged = array();
|
||||||
|
|
||||||
|
|
||||||
if(count($tags)) {
|
if(count($tags)) {
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag);
|
|
||||||
|
// If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
|
||||||
|
// Robert Johnson should be first in the $tags array
|
||||||
|
|
||||||
|
$fullnametagged = false;
|
||||||
|
for($x = 0; $x < count($tagged); $x ++) {
|
||||||
|
if(stristr($tagged[$x],$tag . ' ')) {
|
||||||
|
$fullnametagged = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($fullnametagged)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag);
|
||||||
|
if($success)
|
||||||
|
$tagged[] = $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,20 +880,26 @@ function item_content(&$a) {
|
||||||
* @param unknown_type $str_tags string to add the tag to
|
* @param unknown_type $str_tags string to add the tag to
|
||||||
* @param unknown_type $profile_uid
|
* @param unknown_type $profile_uid
|
||||||
* @param unknown_type $tag the tag to replace
|
* @param unknown_type $tag the tag to replace
|
||||||
|
*
|
||||||
|
* @return boolean true if replaced, false if not replaced
|
||||||
*/
|
*/
|
||||||
function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
||||||
|
|
||||||
|
$replaced = false;
|
||||||
|
|
||||||
//is it a hash tag?
|
//is it a hash tag?
|
||||||
if(strpos($tag,'#') === 0) {
|
if(strpos($tag,'#') === 0) {
|
||||||
//if the tag is replaced...
|
//if the tag is replaced...
|
||||||
if(strpos($tag,'[url='))
|
if(strpos($tag,'[url='))
|
||||||
//...do nothing
|
//...do nothing
|
||||||
return;
|
return $replaced;
|
||||||
//base tag has the tags name only
|
//base tag has the tags name only
|
||||||
$basetag = str_replace('_',' ',substr($tag,1));
|
$basetag = str_replace('_',' ',substr($tag,1));
|
||||||
//create text for link
|
//create text for link
|
||||||
$newtag = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
|
$newtag = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
|
||||||
//replace tag by the link
|
//replace tag by the link
|
||||||
$body = str_replace($tag, $newtag, $body);
|
$body = str_replace($tag, $newtag, $body);
|
||||||
|
$replaced = true;
|
||||||
|
|
||||||
//is the link already in str_tags?
|
//is the link already in str_tags?
|
||||||
if(! stristr($str_tags,$newtag)) {
|
if(! stristr($str_tags,$newtag)) {
|
||||||
|
@ -883,13 +908,13 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
||||||
$str_tags .= ',';
|
$str_tags .= ',';
|
||||||
$str_tags .= $newtag;
|
$str_tags .= $newtag;
|
||||||
}
|
}
|
||||||
return;
|
return $replaced;
|
||||||
}
|
}
|
||||||
//is it a person tag?
|
//is it a person tag?
|
||||||
if(strpos($tag,'@') === 0) {
|
if(strpos($tag,'@') === 0) {
|
||||||
//is it already replaced?
|
//is it already replaced?
|
||||||
if(strpos($tag,'[url='))
|
if(strpos($tag,'[url='))
|
||||||
return;
|
return $replaced;
|
||||||
$stat = false;
|
$stat = false;
|
||||||
//get the person's name
|
//get the person's name
|
||||||
$name = substr($tag,1);
|
$name = substr($tag,1);
|
||||||
|
@ -965,6 +990,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
||||||
}
|
}
|
||||||
//if there is an url for this persons profile
|
//if there is an url for this persons profile
|
||||||
if(isset($profile)) {
|
if(isset($profile)) {
|
||||||
|
$replaced = true;
|
||||||
//create profile link
|
//create profile link
|
||||||
$profile = str_replace(',','%2c',$profile);
|
$profile = str_replace(',','%2c',$profile);
|
||||||
$newtag = '@[url=' . $profile . ']' . $newname . '[/url]';
|
$newtag = '@[url=' . $profile . ']' . $newname . '[/url]';
|
||||||
|
@ -989,4 +1015,6 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $replaced;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<div id="pos_null">
|
<div id="pos_null" style="margin-bottom:-30px;">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sortable_boxes">
|
<div id="sortable_boxes">
|
||||||
|
|
||||||
<div id="close_pages">
|
<div id="close_pages" style="margin-top:30px;">
|
||||||
{{ if $page }}
|
{{ if $page }}
|
||||||
<div>$page</div>
|
<div>$page</div>
|
||||||
{{ endif }}
|
{{ endif }}
|
||||||
|
|
|
@ -117,8 +117,10 @@ if ($color=="dark") $color_path = "/diabook-dark/";
|
||||||
$a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
|
$a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
|
||||||
|
|
||||||
//load jquery.ui.js
|
//load jquery.ui.js
|
||||||
|
if($ccCookie != "9") {
|
||||||
$jqueryuiJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery-ui-1.8.20.custom.min.js";
|
$jqueryuiJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery-ui-1.8.20.custom.min.js";
|
||||||
$a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $jqueryuiJS);
|
$a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $jqueryuiJS);
|
||||||
|
}
|
||||||
|
|
||||||
//load jquery.twitter.search.js
|
//load jquery.twitter.search.js
|
||||||
if($_COOKIE['close_twitter'] != "1") {
|
if($_COOKIE['close_twitter'] != "1") {
|
||||||
|
|
Loading…
Reference in a new issue