1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

Merge pull request #1272 from lonalore/master

Issue #6 Replaced hardcoded "ago" string with constant.
This commit is contained in:
Cameron
2015-12-12 14:01:56 -08:00
5 changed files with 204 additions and 170 deletions

View File

@@ -20,120 +20,125 @@ if (!defined('e107_INIT')) { exit; }
class comment_shortcodes extends e_shortcode class comment_shortcodes extends e_shortcode
{ {
var $var; var $var;
function sc_subject_input($parm='') function sc_subject_input($parm = '')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$pref = e107::getPref(); $pref = e107::getPref();
$form = e107::getForm();
if(vartrue($pref['nested_comments'])) if(vartrue($pref['nested_comments']))
{ {
return "<input class='tbox comment subject-input' type='text' placeholder='".COMLAN_324."' name='subject' size='61' value='".$tp->toForm($this->var['subject'])."' maxlength='100' />"; $options = array(
'class' => 'comment subject-input form-control',
'placeholder' => COMLAN_324,
'size' => 61,
);
$text = '<div class="form-group">';
$text .= $form->text('subject', $tp->toForm($this->var['subject']), 100, $options);
$text .= '</div>';
return $text;
} }
return;
} }
function sc_subject($parm='') function sc_subject($parm='')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$pref = e107::getPref(); $pref = e107::getPref();
global $SUBJECT, $NEWIMAGE; global $SUBJECT, $NEWIMAGE;
if (vartrue($pref['nested_comments'])) if (vartrue($pref['nested_comments']))
{ {
$SUBJECT = $NEWIMAGE." ".(empty($this->var['comment_subject']) ? $subject : $tp->toHTML($this->var['comment_subject'], TRUE)); $SUBJECT = $NEWIMAGE." ".(empty($this->var['comment_subject']) ? $SUBJECT : $tp->toHTML($this->var['comment_subject'], TRUE));
} }
else else
{ {
$SUBJECT = ''; $SUBJECT = '';
} }
return $SUBJECT; return $SUBJECT;
} }
function sc_username($parm='') function sc_username($parm='')
{ {
global $USERNAME; global $USERNAME;
if (isset($this->var['comment_author_id']) && $this->var['comment_author_id']) if (isset($this->var['comment_author_id']) && $this->var['comment_author_id'])
{ {
$USERNAME = $parm == 'raw' ? $this->var['comment_author_name'] : "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $this->var['comment_author_id'], 'name' => $this->var['comment_author_name']))."'>".$this->var['comment_author_name']."</a>\n"; $USERNAME = $parm == 'raw' ? $this->var['comment_author_name'] : "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $this->var['comment_author_id'], 'name' => $this->var['comment_author_name']))."'>".$this->var['comment_author_name']."</a>\n";
} }
else else
{ {
$this->var['user_id'] = 0; $this->var['user_id'] = 0;
$USERNAME = preg_replace("/[0-9]+\./", '', vartrue($this->var['comment_author_name'])); $USERNAME = preg_replace("/[0-9]+\./", '', vartrue($this->var['comment_author_name']));
$USERNAME = str_replace("Anonymous", LAN_ANONYMOUS, $USERNAME); $USERNAME = str_replace("Anonymous", LAN_ANONYMOUS, $USERNAME);
} }
return $USERNAME; return $USERNAME;
} }
function sc_timedate($parm='') function sc_timedate($parm='')
{ {
if($parm == 'relative') if($parm == 'relative')
{ {
return e107::getDate()->computeLapse($this->var['comment_datestamp'],time(),false, false, 'short'); return e107::getDate()->computeLapse($this->var['comment_datestamp'],time(),false, false, 'short');
} }
return e107::getDate()->convert_date($this->var['comment_datestamp'], "short"); return e107::getDate()->convert_date($this->var['comment_datestamp'], "short");
} }
function sc_reply($parm='') function sc_reply($parm='')
{ {
global $REPLY, $action, $table, $id, $thisaction, $thistable, $thisid; global $REPLY, $action, $table, $id, $thisaction, $thistable, $thisid;
$pref = e107::getPref(); $pref = e107::getPref();
$REPLY = ''; $REPLY = '';
if($this->var['comment_lock'] != "1" && $this->var['comment_blocked'] < 1) if($this->var['comment_lock'] != "1" && $this->var['comment_blocked'] < 1)
{ {
if ($thisaction == "comment" && $pref['nested_comments']) if ($thisaction == "comment" && $pref['nested_comments'])
{ {
$REPLY = "<a id='e-comment-reply-".$this->var['comment_id']."' class='e-comment-reply btn btn-default btn-mini btn-xs' data-type='".$this->var['comment_type']."' data-target='".e_HTTP."comment.php' href='".e_HTTP."comment.php?reply.".$thistable.".".$this->var['comment_id'].".".$thisid."'>".COMLAN_326."</a>"; $REPLY = "<a id='e-comment-reply-".$this->var['comment_id']."' class='e-comment-reply btn btn-default btn-mini btn-xs' data-type='".$this->var['comment_type']."' data-target='".e_HTTP."comment.php' href='".e_HTTP."comment.php?reply.".$thistable.".".$this->var['comment_id'].".".$thisid."'>".COMLAN_326."</a>";
} }
} }
return $REPLY; return $REPLY;
} }
function sc_comment_avatar($parm = '')
function sc_comment_avatar($parm='')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
// return $this->var['user_image']; // return $this->var['user_image'];
// $url = $tp->thumbUrl($this->var['user_image']); // $url = $tp->thumbUrl($this->var['user_image']);
// $text = $tp->parseTemplate("{USER_AVATAR=".vartrue($this->var['user_image'],USERIMAGE)."}"); // $text = $tp->parseTemplate("{USER_AVATAR=".vartrue($this->var['user_image'],USERIMAGE)."}");
// $text = $tp->parseTemplate("{USER_AVATAR=".$this->var['user_id']."}"); // $text = $tp->parseTemplate("{USER_AVATAR=".$this->var['user_id']."}");
$text = $tp->toAvatar($this->var); $text = $tp->toAvatar($this->var);
$text .= "<div class='field-help' style='display:none;'> $text .= '<div class="field-help" style="display:none;">';
<div class='left'>"; $text .= '<div class="left">';
$text .= "<h2>".$this->sc_username()."</h2>"; $text .= '<h2>' . $this->sc_username() . '</h2>';
// $text .= e107::getDate()-> // convert($this->var['user_lastvisit'],'short'); // $text .= e107::getDate()-> // convert($this->var['user_lastvisit'],'short');
$text .= $this->sc_joined()."<br />".$this->sc_comments()."<br />".$this->sc_rating().$this->sc_location; $text .= $this->sc_joined() . '<br />' . $this->sc_comments() . '<br />' . $this->sc_rating() . $this->sc_location;
$text .= '</div>';
$text .= " $text .= '</div>';
</div>
</div>"; return $text;
return $text; }
}
function sc_avatar($parm='')
function sc_avatar($parm='')
{ {
return $this->sc_comment_avatar($parm); return $this->sc_comment_avatar($parm);
// --------- Legacy Code for reference // --------- Legacy Code for reference
/* /*
global $AVATAR; global $AVATAR;
if (isset($this->var['user_id']) && $this->var['user_id']) { if (isset($this->var['user_id']) && $this->var['user_id']) {
@@ -150,18 +155,18 @@ class comment_shortcodes extends e_shortcode
return $this->var['user_image']; return $this->var['user_image'];
*/ */
} }
function sc_comments($parm='') function sc_comments($parm='')
{ {
global $COMMENTS; global $COMMENTS;
return (isset($this->var['user_id']) && $this->var['user_id'] ? LAN_COMMENTS.": ".$this->var['user_comments'] : COMLAN_194)."<br />"; return (isset($this->var['user_id']) && $this->var['user_id'] ? LAN_COMMENTS.": ".$this->var['user_comments'] : COMLAN_194)."<br />";
} }
function sc_joined($parm='') function sc_joined($parm='')
{ {
global $JOINED, $gen; global $JOINED, $gen;
$JOINED = ''; $JOINED = '';
@@ -171,26 +176,27 @@ class comment_shortcodes extends e_shortcode
} }
return $JOINED; return $JOINED;
} }
function sc_comment_itemid($parm='') // for ajax item id. function sc_comment_itemid($parm='') // for ajax item id.
{ {
return 'comment-'.intval($this->var['comment_id']); return 'comment-'.intval($this->var['comment_id']);
} }
function sc_comment_moderate($parm='') function sc_comment_moderate($parm='')
{ {
if(!getperms('0') && !getperms("B")) if(!getperms('0') && !getperms("B"))
{ {
return; return;
} }
// TODO put into a <ul> drop-down format. // TODO put into a <ul> drop-down format.
$text = "<a href='#' data-target='".e_HTTP."comment.php' id='e-comment-delete-".$this->var['comment_id']."' class='e-comment-delete btn btn-default btn-mini btn-xs'>".LAN_DELETE."</a> "; $text = "<a href='#' data-target='".e_HTTP."comment.php' id='e-comment-delete-".$this->var['comment_id']."' class='e-comment-delete btn btn-default btn-mini btn-xs'>".LAN_DELETE."</a> ";
if($this->var['comment_blocked'] == 2) // pending approval. if($this->var['comment_blocked'] == 2) // pending approval.
{ {
$text .= "<a href='#' data-target='".e_HTTP."comment.php' id='e-comment-approve-".$this->var['comment_id']."' class='e-comment-approve btn btn-default btn-mini btn-xs'>Approve</a> "; $text .= "<a href='#' data-target='" . e_HTTP . "comment.php' id='e-comment-approve-" . $this->var['comment_id'] . "' class='e-comment-approve btn btn-default btn-mini btn-xs'>" . COMLAN_404 . "</a> ";
} }
return $text; return $text;
/* /*
@@ -204,74 +210,102 @@ class comment_shortcodes extends e_shortcode
return $unblock.$block.$delete.$userinfo; return $unblock.$block.$delete.$userinfo;
* */ * */
} }
function sc_comment_button($parm = '')
function sc_comment_button($parm='')
{ {
$pref = e107::getPref('comments_sort'); $pref = e107::getPref('comments_sort');
$form = e107::getForm();
if($this->mode == 'edit') if($this->mode == 'edit')
{ {
$value = (varset($this->var['eaction']) == "edit" ? COMLAN_320 : COMLAN_9); $value = (varset($this->var['eaction']) == "edit" ? COMLAN_320 : COMLAN_9);
$pid = ($this->var['action'] == 'reply') ? $this->var['pid'] : 0; $pid = ($this->var['action'] == 'reply') ? $this->var['pid'] : 0;
return "<input data-pid='{$pid}' data-sort='{$pref}' data-target='".e_HTTP."comment.php' class='button btn btn-primary e-comment-submit' type='submit' name='".$this->var['action']."submit' value='".$value."' />"; $options = array(
} 'class' => 'button btn btn-primary e-comment-submit pull-right',
'data-pid' => $pid,
'data-sort' => $pref,
'data-target' => e_HTTP . 'comment.php',
);
return $form->submit($this->var['action'] . 'submit', $value, $options);
}
} }
function sc_author_input($parm='') function sc_author_input($parm = '')
{ {
if($this->mode == 'edit') if($this->mode == 'edit')
{ {
if (ANON == TRUE && USER == FALSE) // (anonymous comments - if allowed) if(ANON == true && USER == false) // (anonymous comments - if allowed)
{ {
$disabled = ($_SESSION['comment_author_name']) ? "disabled='disabled'" : ""; // prevent anon users changing names on the same session. $form = e107::getForm();
return "<input {$disabled} class='tbox comment author' type='text' placeholder=\"".COMLAN_16."\" name='author_name' size='61' value='{$_SESSION['comment_author_name']}' maxlength='100' />"; $options = array(
'class' => 'comment author form-control',
'placeholder' => COMLAN_16,
'size' => 61,
);
// Prevent anon users changing names on the same session.
if(vartrue($_SESSION['comment_author_name']))
{
$options['disabled'] = 'disabled';
}
$text = '<div class="form-group">';
$text .= $form->text('author_name', $_SESSION['comment_author_name'], 100, $options);
$text .= '</div>';
return $text;
} }
} }
} }
function sc_comment_rate($parm='') function sc_comment_rate($parm='')
{ {
if($this->var['comment_blocked'] > 0 || $this->var['rating_enabled'] == false) if($this->var['comment_blocked'] > 0 || $this->var['rating_enabled'] == false)
{ {
return; return;
} }
$curVal = array( $curVal = array(
'up' => $this->var['rate_up'], 'up' => $this->var['rate_up'],
'down' => $this->var['rate_down'], 'down' => $this->var['rate_down'],
'total' => $this->var['rate_votes'] 'total' => $this->var['rate_votes']
); );
return e107::getRate()->renderLike("comments",$this->var['comment_id'],$curVal); return e107::getRate()->renderLike("comments",$this->var['comment_id'],$curVal);
} }
function sc_comment_input($parm='') function sc_comment_input($parm = '')
{ {
$options = array( $options = array(
'class' => 'tbox input-xxlarge comment-input', 'class' => 'comment-input form-control',
'placeholder' => "Leave a message..." // TODO Lan 'placeholder' => COMLAN_403,
); );
$text = '<div class="form-group">';
if($parm == 'bbcode') if($parm == 'bbcode')
{ {
return e107::getForm()->bbarea('comment',$this->var['comval'],'comment','comment-'.$this->var['itemid'],'large',$options); $text .= e107::getForm()->bbarea('comment', $this->var['comval'], 'comment', 'comment-' . $this->var['itemid'], 'large', $options);
} }
else else
{ {
return e107::getForm()->textarea('comment',$this->var['comval'], 3, 80,$options); $text .= e107::getForm()->textarea('comment', $this->var['comval'], 3, 80, $options);
} }
}
$text .= '</div>';
return $text;
}
/* /*
function sc_user_avatar($parm='') function sc_user_avatar($parm='')
{ {
@@ -280,49 +314,51 @@ class comment_shortcodes extends e_shortcode
return $this->sc_comment_avatar($parm); return $this->sc_comment_avatar($parm);
} }
*/ */
function sc_comment($parm='')
function sc_comment($parm='')
{ {
// global $COMMENT, $pref; // global $COMMENT, $pref;
$tp = e107::getParser(); $tp = e107::getParser();
if($this->var['comment_blocked'] == 1) if($this->var['comment_blocked'] == 1)
{ {
return COMLAN_0; return COMLAN_0;
} }
return $tp->toHTML($this->var['comment_comment'], TRUE, FALSE, $this->var['user_id']); return $tp->toHTML($this->var['comment_comment'], TRUE, FALSE, $this->var['user_id']);
} }
function sc_comment_status($parm='') function sc_comment_status($parm='')
{ {
switch ($this->var['comment_blocked']) switch ($this->var['comment_blocked'])
{ {
case 2: case 2:
$text = "Pending Approval"; // TODO LAN $text = COMLAN_331;
break; break;
case 1: case 1:
$text = COMLAN_0; $text = COMLAN_0;
break; break;
default: default:
return; return;
break; break;
} }
return "<span id='comment-status-".$this->var['comment_id']."'>".$text."</span>"; return "<span id='comment-status-".$this->var['comment_id']."'>".$text."</span>";
} }
function sc_commentedit($parm='') function sc_commentedit($parm='')
{ {
global $COMMENTEDIT, $comment_edit_query; global $COMMENTEDIT, $comment_edit_query;
$pref = e107::getPref(); $pref = e107::getPref();
if ($pref['allowCommentEdit'] && USER && $this->var['user_id'] == USERID && ($this->var['comment_lock'] < 1)) if ($pref['allowCommentEdit'] && USER && $this->var['user_id'] == USERID && ($this->var['comment_lock'] < 1))
{ {
$adop_icon = (file_exists(THEME."images/commentedit.png") ? "<img src='".THEME_ABS."images/commentedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' class='icon' />" : "Edit"); $adop_icon = (file_exists(THEME."images/commentedit.png") ? "<img src='".THEME_ABS."images/commentedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' class='icon' />" : "Edit");
//Searching for '.' is BAD!!! It breaks mod rewritten requests. Why is this needed at all? //Searching for '.' is BAD!!! It breaks mod rewritten requests. Why is this needed at all?
if (strstr(e_QUERY, "&")) if (strstr(e_QUERY, "&"))
{ {
@@ -330,7 +366,7 @@ class comment_shortcodes extends e_shortcode
} }
else else
{ {
// return "<a href='".e_SELF."?".$comment_edit_query.".edit.".$this->var['comment_id']."'><img src='".e_IMAGE."generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>"; // return "<a href='".e_SELF."?".$comment_edit_query.".edit.".$this->var['comment_id']."'><img src='".e_IMAGE."generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>";
return "<a data-target='".e_HTTP."comment.php' id='e-comment-edit-".$this->var['comment_id']."' class='btn btn-default btn-mini btn-xs e-comment-edit' href='".SITEURL."comment.php?".$comment_edit_query.".edit.".$this->var['comment_id']."#e-comment-form'>".$adop_icon."</a>"; return "<a data-target='".e_HTTP."comment.php' id='e-comment-edit-".$this->var['comment_id']."' class='btn btn-default btn-mini btn-xs e-comment-edit' href='".SITEURL."comment.php?".$comment_edit_query.".edit.".$this->var['comment_id']."#e-comment-form'>".$adop_icon."</a>";
} }
} }
@@ -339,72 +375,68 @@ class comment_shortcodes extends e_shortcode
return ""; return "";
} }
} }
function sc_rating($parm='') function sc_rating($parm='')
{ {
global $RATING; global $RATING;
return $RATING; return $RATING;
} }
function sc_ipaddress($parm='') function sc_ipaddress($parm='')
{ {
global $IPADDRESS, $e107; global $IPADDRESS, $e107;
//require_once(e_HANDLER."encrypt_handler.php"); //require_once(e_HANDLER."encrypt_handler.php");
return (ADMIN ? "<a href='".SITEURL."userposts.php?0.comments.".$this->var['user_id']."'>".COMLAN_330." ".e107::getIPHandler()->ipDecode($this->var['comment_ip'])."</a>" : ""); return (ADMIN ? "<a href='".SITEURL."userposts.php?0.comments.".$this->var['user_id']."'>".COMLAN_330." ".e107::getIPHandler()->ipDecode($this->var['comment_ip'])."</a>" : "");
} }
function sc_level($parm='') function sc_level($parm='')
{ {
global $LEVEL, $pref; global $LEVEL, $pref;
//FIXME - new level handler, currently commented to avoid parse errors //FIXME - new level handler, currently commented to avoid parse errors
//$ldata = get_level($this->var['user_id'], $this->var['user_forums'], $this->var['user_comments'], $this->var['user_chats'], $this->var['user_visits'], $this->var['user_join'], $this->var['user_admin'], $this->var['user_perms'], $pref); //$ldata = get_level($this->var['user_id'], $this->var['user_forums'], $this->var['user_comments'], $this->var['user_chats'], $this->var['user_visits'], $this->var['user_join'], $this->var['user_admin'], $this->var['user_perms'], $pref);
return ($this->var['user_admin'] ? $ldata[0] : $ldata[1]); return ($this->var['user_admin'] ? vartrue($ldata[0]) : vartrue($ldata[1]));
} }
function sc_location($parm='') function sc_location($parm='')
{ {
global $LOCATION; global $LOCATION;
$tp = e107::getParser(); $tp = e107::getParser();
return (isset($this->var['user_location']) && $this->var['user_location'] ? COMLAN_313.": ".$tp->toHTML($this->var['user_location'], TRUE) : ''); return (isset($this->var['user_location']) && $this->var['user_location'] ? COMLAN_313.": ".$tp->toHTML($this->var['user_location'], TRUE) : '');
} }
function sc_signature($parm='') function sc_signature($parm='')
{ {
global $SIGNATURE; global $SIGNATURE;
$tp = e107::getParser(); $tp = e107::getParser();
$SIGNATURE = (isset($this->var['user_signature']) && $this->var['user_signature'] ? $tp->toHTML($this->var['user_signature'], true) : ''); $SIGNATURE = (isset($this->var['user_signature']) && $this->var['user_signature'] ? $tp->toHTML($this->var['user_signature'], true) : '');
return $SIGNATURE; return $SIGNATURE;
} }
function sc_comment_share($parm='') function sc_comment_share($parm='')
{ {
if(!$xup = e107::getUser()->getProviderName()) if(!$xup = e107::getUser()->getProviderName())
{ {
return; return;
} }
list($prov,$id) = explode("_",$xup); list($prov,$id) = explode("_",$xup);
$prov = strtolower($prov); $prov = strtolower($prov);
if($prov == 'facebook' || $prov == 'twitter') if($prov == 'facebook' || $prov == 'twitter')
{ {
//TODO Move styling to e107.css //TODO Move styling to e107.css
$text = "<img src='".e_IMAGE."xup/".$prov.".png' style='display:inline-block;width:26px;height:26px;vertical-align:middle' alt='Share' />"; $text = "<img src='".e_IMAGE."xup/".$prov.".png' style='display:inline-block;width:26px;height:26px;vertical-align:middle' alt='Share' />";
$text .= e107::getForm()->checkbox('comment_share',$prov,true); $text .= e107::getForm()->checkbox('comment_share',$prov,true);
$text .= "Share"; $text .= "Share";
return $text; return $text;
} }
} }
} }
?>

View File

@@ -844,7 +844,7 @@ class news_shortcodes extends e_shortcode
} }
else else
{ {
return "None"; return LAN_NONE;
} }
} }

View File

@@ -211,7 +211,7 @@ class user_shortcodes extends e_shortcode
function sc_user_daysregged($parm) function sc_user_daysregged($parm)
{ {
return e107::getDate()->computeLapse($this->var['user_join'])." ".LAN_USER_34; return e107::getDate()->computeLapse($this->var['user_join']);
} }

View File

@@ -620,7 +620,7 @@ class convert
} }
if($format == 'short' && count($outputArray) == 1) { break; } if($format == 'short' && count($outputArray) == 1) { break; }
} }
return ($mode ? $outputArray : implode(", ", $outputArray) . " ago"); //XXX LAN return ($mode ? $outputArray : implode(", ", $outputArray) . " " . LANDT_AGO);
} }

View File

@@ -67,6 +67,8 @@ define("COMLAN_400", "approved");
define("COMLAN_401", "blocked"); define("COMLAN_401", "blocked");
define("COMLAN_402", "pending"); define("COMLAN_402", "pending");
define("COMLAN_403", "Leave a message...");
define("COMLAN_404", "Approve");
define("COMLAN_TYPE_1", "news"); define("COMLAN_TYPE_1", "news");
define("COMLAN_TYPE_2", "download"); define("COMLAN_TYPE_2", "download");