mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Forum template fixes.
This commit is contained in:
@@ -17,15 +17,19 @@ if (!defined('e107_INIT')) { exit; }
|
||||
/* Forum Header File */
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
$code = <<<EON
|
||||
$jscode = <<<EON
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('a[data-forum-thread]').on('click', function(e)
|
||||
$('a[data-forum-action], input[data-forum-action]').on('click', function(e)
|
||||
{
|
||||
|
||||
var action = $(this).attr('data-forum-action');
|
||||
var thread = $(this).attr('data-forum-thread');
|
||||
var post = $(this).attr('data-forum-post');
|
||||
var text = $('#forum-quickreply-text').val();
|
||||
|
||||
|
||||
|
||||
if(action != 'stick' && action !='unstick')
|
||||
{
|
||||
@@ -37,17 +41,31 @@ $(document).ready(function()
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: script,
|
||||
data: { thread: thread, action: action },
|
||||
data: { thread: thread, action: action, post: post, text: text },
|
||||
success: function(data) {
|
||||
// alert(data);
|
||||
|
||||
var d = $.parseJSON(data);
|
||||
|
||||
alert(d.msg);
|
||||
|
||||
if(d.hide)
|
||||
if(d)
|
||||
{
|
||||
var t = '#thread-' + thread ;
|
||||
$(t).hide('slow');
|
||||
if(d.msg)
|
||||
{
|
||||
alert(d.msg);
|
||||
}
|
||||
|
||||
if(action == 'quickreply')
|
||||
{
|
||||
$('#forum-viewtopic tr:last').after(d.html);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(d.hide)
|
||||
{
|
||||
var t = '#thread-' + thread ;
|
||||
$(t).hide('slow');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +82,7 @@ $(document).ready(function()
|
||||
|
||||
EON;
|
||||
|
||||
e107::js('inline',$code,'jquery');
|
||||
e107::js('inline',$jscode,'jquery');
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +99,7 @@ class e107forum
|
||||
public function __construct()
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$tp = e107::getParser();
|
||||
$this->userViewed = array();
|
||||
$this->modArray = array();
|
||||
$this->loadPermList();
|
||||
@@ -89,6 +108,58 @@ class e107forum
|
||||
$this->setDefaults();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
if(varset($_POST['action']) == 'quickreply' && vartrue($_POST['text']))
|
||||
{
|
||||
|
||||
$postInfo = array();
|
||||
$postInfo['post_ip'] = e107::getIPHandler()->getIP(FALSE);
|
||||
if (USER)
|
||||
{
|
||||
$postInfo['post_user'] = USERID;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$postInfo['post_user_anon'] = $_POST['anonname'];
|
||||
}
|
||||
|
||||
$postInfo['post_entry'] = $_POST['text'];
|
||||
$postInfo['post_forum'] = intval($_POST['post']);
|
||||
$postInfo['post_datestamp'] = time();
|
||||
$postInfo['post_thread'] = intval($_POST['thread']);
|
||||
|
||||
// $ret['msg'] = print_r($_POST,true);
|
||||
|
||||
|
||||
$tmpl = e107::getTemplate('forum','forum_viewtopic','replies');
|
||||
//FIXME - send parsed template back to $ret['html'] for inclusion in page.
|
||||
|
||||
// $sc = e107::getScBatch('view', 'forum');
|
||||
// $ret['msg'] = print_r($sc, true);
|
||||
// $sc->setScVar('postInfo', $postInfo);
|
||||
|
||||
// $ret['html'] = $tp->parseTemplate($tmpl, true, vartrue($forum_shortcodes)) . "\n";
|
||||
$ret['html'] = "<tr><td>".$tp->toHtml($_POST['text'])."</td></tr>";
|
||||
$this->postAdd($postInfo); // save it.
|
||||
$ret['status'] = 'ok';
|
||||
$ret['msg'] = print_r($postInfo,true); // "You post has been added";
|
||||
|
||||
echo json_encode($ret);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST && MODERATOR) // see javascript above.
|
||||
{
|
||||
if(!vartrue($_POST['thread']))
|
||||
@@ -116,6 +187,25 @@ class e107forum
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deletepost':
|
||||
if(!$postId = vartrue($_POST['post']))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if($this->postDelete($postId))
|
||||
{
|
||||
$ret['msg'] = 'Deleted Post #'.$id;
|
||||
$ret['hide'] = true;
|
||||
$ret['status'] = 'ok';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret['msg'] = "Couldn't Delete the Post";
|
||||
$ret['status'] = 'error';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
if(e107::getDB()->update('forum_thread', 'thread_active=0 WHERE thread_id='.$id))
|
||||
{
|
||||
@@ -168,6 +258,10 @@ class e107forum
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
$ret['status'] = 'error';
|
||||
$ret['msg'] = 'No action selected';
|
||||
@@ -212,6 +306,9 @@ class e107forum
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private function loadPermList()
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
|
@@ -86,21 +86,21 @@ if (!vartrue($FORUM_VIEW_START))
|
||||
}
|
||||
|
||||
|
||||
if(is_array($FORUMVIEW_TEMPLATE)) // New Template.
|
||||
if(is_array($FORUM_VIEWFORUM_TEMPLATE)) // New Template.
|
||||
{
|
||||
|
||||
$FORUM_VIEW_START_CONTAINER = $FORUMVIEW_TEMPLATE['start'];
|
||||
$FORUM_VIEW_START = $FORUMVIEW_TEMPLATE['header'];
|
||||
$FORUM_VIEW_FORUM = $FORUMVIEW_TEMPLATE['item'];
|
||||
$FORUM_VIEW_FORUM_STICKY = $FORUMVIEW_TEMPLATE['item-sticky'];
|
||||
$FORUM_VIEW_FORUM_ANNOUNCE = $FORUMVIEW_TEMPLATE['item-announce'];
|
||||
$FORUM_VIEW_END = $FORUMVIEW_TEMPLATE['footer'];
|
||||
$FORUM_VIEW_END_CONTAINER = $FORUMVIEW_TEMPLATE['end'];
|
||||
$FORUM_VIEW_SUB_START = $FORUMVIEW_TEMPLATE['sub-header'];
|
||||
$FORUM_VIEW_SUB = $FORUMVIEW_TEMPLATE['sub-item'];
|
||||
$FORUM_VIEW_SUB_END = $FORUMVIEW_TEMPLATE['sub-footer'];
|
||||
$FORUM_IMPORTANT_ROW = $FORUMVIEW_TEMPLATE['divider-important'];
|
||||
$FORUM_NORMAL_ROW = $FORUMVIEW_TEMPLATE['divider-normal'];
|
||||
$FORUM_VIEW_START_CONTAINER = $FORUM_VIEWFORUM_TEMPLATE['start'];
|
||||
$FORUM_VIEW_START = $FORUM_VIEWFORUM_TEMPLATE['header'];
|
||||
$FORUM_VIEW_FORUM = $FORUM_VIEWFORUM_TEMPLATE['item'];
|
||||
$FORUM_VIEW_FORUM_STICKY = $FORUM_VIEWFORUM_TEMPLATE['item-sticky'];
|
||||
$FORUM_VIEW_FORUM_ANNOUNCE = $FORUM_VIEWFORUM_TEMPLATE['item-announce'];
|
||||
$FORUM_VIEW_END = $FORUM_VIEWFORUM_TEMPLATE['footer'];
|
||||
$FORUM_VIEW_END_CONTAINER = $FORUM_VIEWFORUM_TEMPLATE['end'];
|
||||
$FORUM_VIEW_SUB_START = $FORUM_VIEWFORUM_TEMPLATE['sub-header'];
|
||||
$FORUM_VIEW_SUB = $FORUM_VIEWFORUM_TEMPLATE['sub-item'];
|
||||
$FORUM_VIEW_SUB_END = $FORUM_VIEWFORUM_TEMPLATE['sub-footer'];
|
||||
$FORUM_IMPORTANT_ROW = $FORUM_VIEWFORUM_TEMPLATE['divider-important'];
|
||||
$FORUM_NORMAL_ROW = $FORUM_VIEWFORUM_TEMPLATE['divider-normal'];
|
||||
|
||||
}
|
||||
|
||||
|
@@ -156,12 +156,12 @@ if (!vartrue($FORUMSTART))
|
||||
|
||||
|
||||
// New in v2.x
|
||||
if(is_array($FORUMTOPIC_TEMPLATE))
|
||||
if(is_array($FORUM_VIEWTOPIC_TEMPLATE))
|
||||
{
|
||||
$FORUMSTART = $FORUMTOPIC_TEMPLATE['start'];
|
||||
$FORUMTHREADSTYLE = $FORUMTOPIC_TEMPLATE['thread'];
|
||||
$FORUMEND = $FORUMTOPIC_TEMPLATE['end'];
|
||||
$FORUMREPLYSTYLE = $FORUMTOPIC_TEMPLATE['replies'];
|
||||
$FORUMSTART = $FORUM_VIEWTOPIC_TEMPLATE['start'];
|
||||
$FORUMTHREADSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['thread'];
|
||||
$FORUMEND = $FORUM_VIEWTOPIC_TEMPLATE['end'];
|
||||
$FORUMREPLYSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['replies'];
|
||||
}
|
||||
|
||||
|
||||
@@ -344,15 +344,16 @@ unset($loop_uid);
|
||||
|
||||
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
|
||||
{
|
||||
//XXX Show only on the last page??
|
||||
if (!vartrue($forum_quickreply))
|
||||
{
|
||||
$tVars->QUICKREPLY = "
|
||||
<form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'>
|
||||
<p>" . LAN_393 . ":<br />
|
||||
<textarea cols='80' rows='4' class='tbox input-xxlarge' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
|
||||
<textarea cols='80' rows='4' id='forum-quickreply-text' class='tbox input-xxlarge' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
|
||||
<br />
|
||||
<input type='submit' name='fpreview' value='" . LAN_394 . "' class='btn button' />
|
||||
<input type='submit' name='reply' value='" . LAN_395 . "' class='btn btn-success button' />
|
||||
<input type='submit' data-forum-post='".$thread->threadInfo['thread_forum_id']."' data-forum-thread='".$threadId."' data-forum-action='quickreply' name='reply' value='" . LAN_395 . "' class='btn btn-success button' />
|
||||
<input type='hidden' name='thread_id' value='$thread_parent' />
|
||||
</p>
|
||||
</form>";
|
||||
|
@@ -9,6 +9,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
{
|
||||
parent::__construct();
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->forum = new e107forum();
|
||||
}
|
||||
|
||||
function sc_top($parm='')
|
||||
@@ -20,7 +21,8 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
|
||||
function sc_joined()
|
||||
{
|
||||
global $gen;
|
||||
|
||||
$gen = e107::getDate();
|
||||
if ($this->postInfo['post_user'])
|
||||
{
|
||||
return LAN_06.': '.$gen->convert_date($this->postInfo['user_join'], 'forum').'<br />';
|
||||
@@ -30,10 +32,15 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
/**
|
||||
* What does this do?
|
||||
*/
|
||||
function sc_threaddatestamp()
|
||||
function sc_threaddatestamp($parm='')
|
||||
{
|
||||
$gen = e107::getDateConvert(); // XXX _URL_ check if all required info is there
|
||||
|
||||
if($parm == 'relative')
|
||||
{
|
||||
return $gen->computeLapse($this->postInfo['post_datestamp'], time(), false, false, 'short');
|
||||
}
|
||||
|
||||
// XXX what is this line meant to do?
|
||||
// $text = "<a id='post_{$this->postInfo['post_id']}' href='".$this->e107->url->create('forum/thread/post', array('name' => $this->postInfo['thread_name'], 'thread' => $this->postInfo['post_thread'], 'id' => $this->postInfo['post_id']))."'>".IMAGE_post."</a> ";
|
||||
return $gen->convert_date($this->postInfo['post_datestamp'], 'forum');
|
||||
@@ -325,7 +332,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
|
||||
function sc_lastedit()
|
||||
{
|
||||
global $gen;
|
||||
$gen = e107::getDate();
|
||||
if ($this->postInfo['post_edit_datestamp'])
|
||||
{
|
||||
return $gen->convert_date($this->postInfo['post_edit_datestamp'],'forum');
|
||||
@@ -452,7 +459,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
$text .= "<li><a href='".e107::getUrl()->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>Edit</a></li>";
|
||||
}
|
||||
|
||||
$text .= "<li><a href='#'>Delete (fixme)</a></li>"; //FIXME - putting a form here could break layout. Ajax?
|
||||
$text .= "<li><a href='".e_REQUEST_URI."' data-forum-action='deletepost' data-forum-post='".$this->postInfo['post_id']."'>Delete (fixme)</a></li>";
|
||||
|
||||
if ($type == 'thread')
|
||||
{
|
||||
|
@@ -282,8 +282,8 @@ $FORUM_CRUMB['forum']['value'] = "{FORUM_TITLE}";
|
||||
|
||||
// <small>{BREADCRUMB}</small> //FIXME Breadcrumb looks crummy
|
||||
|
||||
$FORUMVIEW_TEMPLATE['start'] = "";
|
||||
$FORUMVIEW_TEMPLATE['header'] = "<div class='row'><div class='span9 pull-left'><h3>{FORUMTITLE}</h3></div><div class='span3 pull-right right' style='padding-top:10px'>{NEWTHREADBUTTONX}</div></div>
|
||||
$FORUM_VIEWFORUM_TEMPLATE['start'] = "";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['header'] = "<div class='row'><div class='span9 pull-left'><h3>{FORUMTITLE}</h3></div><div class='span3 pull-right right' style='padding-top:10px'>{NEWTHREADBUTTONX}</div></div>
|
||||
<table class='table table-hover table-striped'>
|
||||
<colgroup>
|
||||
<col style='width:3%' />
|
||||
@@ -295,30 +295,30 @@ $FORUMVIEW_TEMPLATE['header'] = "<div class='row'><div class='span9 pull-lef
|
||||
|
||||
{SUBFORUMS}";
|
||||
|
||||
$FORUMVIEW_TEMPLATE['item'] = "<tr><td>{ICON}</td><td>{THREADNAME}<div><small class='clearfix'>by {POSTER} {THREADTIMELAPSE} {PAGESX}</small></div></td><td>{REPLIESX}</td><td>{VIEWSX}</td><td><small>{LASTPOSTUSER} {LASTPOSTDATE} </small><div class='span2 right pull-right'>{ADMINOPTIONS}</div></td></tr>\n";
|
||||
$FORUMVIEW_TEMPLATE['item-sticky'] = $FORUMVIEW['item'] ; // "<tr><td>{THREADNAME}</td></tr>\n";
|
||||
$FORUMVIEW_TEMPLATE['item-announce'] = $FORUMVIEW['item'] ; // "<tr><td>{THREADNAME}</td></tr>\n";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['item'] = "<tr><td>{ICON}</td><td>{THREADNAME}<div><small class='clearfix'>by {POSTER} {THREADTIMELAPSE} {PAGESX}</small></div></td><td>{REPLIESX}</td><td>{VIEWSX}</td><td><small>{LASTPOSTUSER} {LASTPOSTDATE} </small><div class='span2 right pull-right'>{ADMINOPTIONS}</div></td></tr>\n";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['item-sticky'] = $FORUMVIEW['item'] ; // "<tr><td>{THREADNAME}</td></tr>\n";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['item-announce'] = $FORUMVIEW['item'] ; // "<tr><td>{THREADNAME}</td></tr>\n";
|
||||
|
||||
|
||||
$FORUMVIEW_TEMPLATE['sub-header'] = "<tr><th colspan='2'>".FORLAN_20."</th><th>".LAN_55."</th><th>".FORLAN_21."</th><th>".FORLAN_22."</th></tr>";
|
||||
$FORUMVIEW_TEMPLATE['sub-item'] = "<tr><td>{NEWFLAG}</td>
|
||||
$FORUM_VIEWFORUM_TEMPLATE['sub-header'] = "<tr><th colspan='2'>".FORLAN_20."</th><th>".LAN_55."</th><th>".FORLAN_21."</th><th>".FORLAN_22."</th></tr>";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['sub-item'] = "<tr><td>{NEWFLAG}</td>
|
||||
<td><div>{SUB_FORUMTITLE}</div><small>{SUB_DESCRIPTION}</small></td>
|
||||
<td>{SUB_REPLIESX}</td>
|
||||
<td>{SUB_THREADSX}</td>
|
||||
<td><small>{SUB_LASTPOSTUSER} {SUB_LASTPOSTDATE}</small></td>
|
||||
</tr>\n";
|
||||
|
||||
$FORUMVIEW_TEMPLATE['sub-footer'] = "";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['sub-footer'] = "";
|
||||
|
||||
$FORUMVIEW_TEMPLATE['divider-important'] = "<tr><th colspan='2'>".LAN_411."</th><th>".LAN_55."</th><th>".LAN_56."</th><th>".LAN_57."</th></tr>";
|
||||
$FORUMVIEW_TEMPLATE['divider-normal'] = "<tr><th colspan='2'>".LAN_412."</th><th>".LAN_55."</th><th>".LAN_56."</th><th>".LAN_57."</th></tr>";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['divider-important'] = "<tr><th colspan='2'>".LAN_411."</th><th>".LAN_55."</th><th>".LAN_56."</th><th>".LAN_57."</th></tr>";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['divider-normal'] = "<tr><th colspan='2'>".LAN_412."</th><th>".LAN_55."</th><th>".LAN_56."</th><th>".LAN_57."</th></tr>";
|
||||
|
||||
$FORUMVIEW_TEMPLATE['footer'] = "</table>
|
||||
$FORUM_VIEWFORUM_TEMPLATE['footer'] = "</table>
|
||||
<div class='row'>
|
||||
<div class='span5 pull-left left' style='padding-top:10px'>{SEARCH}</div><div class='span3 pull-right right' style='padding-top:10px'>{NEWTHREADBUTTONX}</div>
|
||||
|
||||
</div>";
|
||||
$FORUMVIEW_TEMPLATE['end'] = "<!--- END --> \n";
|
||||
$FORUM_VIEWFORUM_TEMPLATE['end'] = "<!--- END --> \n";
|
||||
|
||||
|
||||
|
||||
|
@@ -305,7 +305,7 @@ $FORUM_CRUMB['forum']['value'] = "<a class='forumlink' href='{FORUM_HREF}'>{FORU
|
||||
|
||||
|
||||
// {MODERATORS} {THREADSTATUS}
|
||||
$FORUMTOPIC_TEMPLATE['start'] = "<a id='top'></a>
|
||||
$FORUM_VIEWTOPIC_TEMPLATE['start'] = "<a id='top'></a>
|
||||
|
||||
<div class='row'>
|
||||
<div class='span6 pull-left'>{BACKLINK}</div>
|
||||
@@ -318,7 +318,7 @@ $FORUMTOPIC_TEMPLATE['start'] = "<a id='top'></a>
|
||||
{MESSAGE}
|
||||
|
||||
|
||||
<table class='table table-striped'>
|
||||
<table id='forum-viewtopic' class='table table-striped'>
|
||||
<colgroup>
|
||||
<col style='width:20%' />
|
||||
<col />
|
||||
@@ -332,7 +332,7 @@ $FORUMTOPIC_TEMPLATE['start'] = "<a id='top'></a>
|
||||
|
||||
|
||||
|
||||
$FORUMTOPIC_TEMPLATE['end'] = "</tr></table>
|
||||
$FORUM_VIEWTOPIC_TEMPLATE['end'] = "</tr></table>
|
||||
|
||||
<div class='center'>{QUICKREPLY}</div>
|
||||
|
||||
@@ -350,15 +350,15 @@ $FORUMTOPIC_TEMPLATE['end'] = "</tr></table>
|
||||
";
|
||||
|
||||
|
||||
$FORUMTOPIC_TEMPLATE['thread'] ="
|
||||
$FORUM_VIEWTOPIC_TEMPLATE['thread'] ="
|
||||
<tr>
|
||||
<td class='forumheader' style='vertical-align:middle'>{NEWFLAG} {USERCOMBO}{ANON_IP}</td>
|
||||
<td>{THREADDATESTAMP}</td>
|
||||
<td>{NEWFLAG} {USERCOMBO}{ANON_IP}</td>
|
||||
<td>{THREADDATESTAMP=relative}</td>
|
||||
<td style='text-align:right'>{POSTOPTIONS}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>
|
||||
<td>
|
||||
{CUSTOMTITLE}
|
||||
{AVATAR}
|
||||
<div>
|
||||
@@ -366,6 +366,7 @@ $FORUMTOPIC_TEMPLATE['thread'] ="
|
||||
{LEVEL=badge} {LEVEL=pic}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td colspan='2'>
|
||||
{POLL}
|
||||
@@ -395,7 +396,7 @@ $FORUMTOPIC_TEMPLATE['thread'] ="
|
||||
</tr>";
|
||||
|
||||
|
||||
$FORUMTOPIC_TEMPLATE['replies'] = $FORUMTOPIC_TEMPLATE['thread'];
|
||||
$FORUM_VIEWTOPIC_TEMPLATE['replies'] = $FORUM_VIEWTOPIC_TEMPLATE['thread'];
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user