1
0
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:
Cameron
2013-03-13 02:39:00 -07:00
parent 6a784f28f8
commit e80c329818
6 changed files with 161 additions and 55 deletions

View File

@@ -17,15 +17,19 @@ if (!defined('e107_INIT')) { exit; }
/* Forum Header File */ /* Forum Header File */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
$code = <<<EON $jscode = <<<EON
$(document).ready(function() $(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 action = $(this).attr('data-forum-action');
var thread = $(this).attr('data-forum-thread'); 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') if(action != 'stick' && action !='unstick')
{ {
@@ -37,17 +41,31 @@ $(document).ready(function()
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: script, url: script,
data: { thread: thread, action: action }, data: { thread: thread, action: action, post: post, text: text },
success: function(data) { success: function(data) {
// alert(data);
var d = $.parseJSON(data); var d = $.parseJSON(data);
alert(d.msg); if(d)
if(d.hide)
{ {
var t = '#thread-' + thread ; if(d.msg)
$(t).hide('slow'); {
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; EON;
e107::js('inline',$code,'jquery'); e107::js('inline',$jscode,'jquery');
@@ -81,6 +99,7 @@ class e107forum
public function __construct() public function __construct()
{ {
$this->e107 = e107::getInstance(); $this->e107 = e107::getInstance();
$tp = e107::getParser();
$this->userViewed = array(); $this->userViewed = array();
$this->modArray = array(); $this->modArray = array();
$this->loadPermList(); $this->loadPermList();
@@ -89,6 +108,58 @@ class e107forum
$this->setDefaults(); $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(e_AJAX_REQUEST && MODERATOR) // see javascript above.
{ {
if(!vartrue($_POST['thread'])) if(!vartrue($_POST['thread']))
@@ -116,6 +187,25 @@ class e107forum
} }
break; 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': case 'lock':
if(e107::getDB()->update('forum_thread', 'thread_active=0 WHERE thread_id='.$id)) if(e107::getDB()->update('forum_thread', 'thread_active=0 WHERE thread_id='.$id))
{ {
@@ -168,6 +258,10 @@ class e107forum
} }
break; break;
default: default:
$ret['status'] = 'error'; $ret['status'] = 'error';
$ret['msg'] = 'No action selected'; $ret['msg'] = 'No action selected';
@@ -212,6 +306,9 @@ class e107forum
private function loadPermList() private function loadPermList()
{ {
$e107 = e107::getInstance(); $e107 = e107::getInstance();

View File

@@ -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_CONTAINER = $FORUM_VIEWFORUM_TEMPLATE['start'];
$FORUM_VIEW_START = $FORUMVIEW_TEMPLATE['header']; $FORUM_VIEW_START = $FORUM_VIEWFORUM_TEMPLATE['header'];
$FORUM_VIEW_FORUM = $FORUMVIEW_TEMPLATE['item']; $FORUM_VIEW_FORUM = $FORUM_VIEWFORUM_TEMPLATE['item'];
$FORUM_VIEW_FORUM_STICKY = $FORUMVIEW_TEMPLATE['item-sticky']; $FORUM_VIEW_FORUM_STICKY = $FORUM_VIEWFORUM_TEMPLATE['item-sticky'];
$FORUM_VIEW_FORUM_ANNOUNCE = $FORUMVIEW_TEMPLATE['item-announce']; $FORUM_VIEW_FORUM_ANNOUNCE = $FORUM_VIEWFORUM_TEMPLATE['item-announce'];
$FORUM_VIEW_END = $FORUMVIEW_TEMPLATE['footer']; $FORUM_VIEW_END = $FORUM_VIEWFORUM_TEMPLATE['footer'];
$FORUM_VIEW_END_CONTAINER = $FORUMVIEW_TEMPLATE['end']; $FORUM_VIEW_END_CONTAINER = $FORUM_VIEWFORUM_TEMPLATE['end'];
$FORUM_VIEW_SUB_START = $FORUMVIEW_TEMPLATE['sub-header']; $FORUM_VIEW_SUB_START = $FORUM_VIEWFORUM_TEMPLATE['sub-header'];
$FORUM_VIEW_SUB = $FORUMVIEW_TEMPLATE['sub-item']; $FORUM_VIEW_SUB = $FORUM_VIEWFORUM_TEMPLATE['sub-item'];
$FORUM_VIEW_SUB_END = $FORUMVIEW_TEMPLATE['sub-footer']; $FORUM_VIEW_SUB_END = $FORUM_VIEWFORUM_TEMPLATE['sub-footer'];
$FORUM_IMPORTANT_ROW = $FORUMVIEW_TEMPLATE['divider-important']; $FORUM_IMPORTANT_ROW = $FORUM_VIEWFORUM_TEMPLATE['divider-important'];
$FORUM_NORMAL_ROW = $FORUMVIEW_TEMPLATE['divider-normal']; $FORUM_NORMAL_ROW = $FORUM_VIEWFORUM_TEMPLATE['divider-normal'];
} }

View File

@@ -156,12 +156,12 @@ if (!vartrue($FORUMSTART))
// New in v2.x // New in v2.x
if(is_array($FORUMTOPIC_TEMPLATE)) if(is_array($FORUM_VIEWTOPIC_TEMPLATE))
{ {
$FORUMSTART = $FORUMTOPIC_TEMPLATE['start']; $FORUMSTART = $FORUM_VIEWTOPIC_TEMPLATE['start'];
$FORUMTHREADSTYLE = $FORUMTOPIC_TEMPLATE['thread']; $FORUMTHREADSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['thread'];
$FORUMEND = $FORUMTOPIC_TEMPLATE['end']; $FORUMEND = $FORUM_VIEWTOPIC_TEMPLATE['end'];
$FORUMREPLYSTYLE = $FORUMTOPIC_TEMPLATE['replies']; $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']) if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
{ {
//XXX Show only on the last page??
if (!vartrue($forum_quickreply)) if (!vartrue($forum_quickreply))
{ {
$tVars->QUICKREPLY = " $tVars->QUICKREPLY = "
<form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'> <form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'>
<p>" . LAN_393 . ":<br /> <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 /> <br />
<input type='submit' name='fpreview' value='" . LAN_394 . "' class='btn button' /> &nbsp; <input type='submit' name='fpreview' value='" . LAN_394 . "' class='btn button' /> &nbsp;
<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' /> <input type='hidden' name='thread_id' value='$thread_parent' />
</p> </p>
</form>"; </form>";

View File

@@ -9,6 +9,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{ {
parent::__construct(); parent::__construct();
$this->e107 = e107::getInstance(); $this->e107 = e107::getInstance();
$this->forum = new e107forum();
} }
function sc_top($parm='') function sc_top($parm='')
@@ -20,7 +21,8 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_joined() function sc_joined()
{ {
global $gen;
$gen = e107::getDate();
if ($this->postInfo['post_user']) if ($this->postInfo['post_user'])
{ {
return LAN_06.': '.$gen->convert_date($this->postInfo['user_join'], 'forum').'<br />'; 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? * What does this do?
*/ */
function sc_threaddatestamp() function sc_threaddatestamp($parm='')
{ {
$gen = e107::getDateConvert(); // XXX _URL_ check if all required info is there $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? // 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> "; // $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'); return $gen->convert_date($this->postInfo['post_datestamp'], 'forum');
@@ -325,7 +332,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_lastedit() function sc_lastedit()
{ {
global $gen; $gen = e107::getDate();
if ($this->postInfo['post_edit_datestamp']) if ($this->postInfo['post_edit_datestamp'])
{ {
return $gen->convert_date($this->postInfo['post_edit_datestamp'],'forum'); 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='".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') if ($type == 'thread')
{ {

View File

@@ -282,8 +282,8 @@ $FORUM_CRUMB['forum']['value'] = "{FORUM_TITLE}";
// <small>{BREADCRUMB}</small> //FIXME Breadcrumb looks crummy // <small>{BREADCRUMB}</small> //FIXME Breadcrumb looks crummy
$FORUMVIEW_TEMPLATE['start'] = ""; $FORUM_VIEWFORUM_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['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'> <table class='table table-hover table-striped'>
<colgroup> <colgroup>
<col style='width:3%' /> <col style='width:3%' />
@@ -295,30 +295,30 @@ $FORUMVIEW_TEMPLATE['header'] = "<div class='row'><div class='span9 pull-lef
{SUBFORUMS}"; {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"; $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";
$FORUMVIEW_TEMPLATE['item-sticky'] = $FORUMVIEW['item'] ; // "<tr><td>{THREADNAME}</td></tr>\n"; $FORUM_VIEWFORUM_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-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>"; $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>";
$FORUMVIEW_TEMPLATE['sub-item'] = "<tr><td>{NEWFLAG}</td> $FORUM_VIEWFORUM_TEMPLATE['sub-item'] = "<tr><td>{NEWFLAG}</td>
<td><div>{SUB_FORUMTITLE}</div><small>{SUB_DESCRIPTION}</small></td> <td><div>{SUB_FORUMTITLE}</div><small>{SUB_DESCRIPTION}</small></td>
<td>{SUB_REPLIESX}</td> <td>{SUB_REPLIESX}</td>
<td>{SUB_THREADSX}</td> <td>{SUB_THREADSX}</td>
<td><small>{SUB_LASTPOSTUSER} {SUB_LASTPOSTDATE}</small></td> <td><small>{SUB_LASTPOSTUSER} {SUB_LASTPOSTDATE}</small></td>
</tr>\n"; </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>"; $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>";
$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-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='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 class='span5 pull-left left' style='padding-top:10px'>{SEARCH}</div><div class='span3 pull-right right' style='padding-top:10px'>{NEWTHREADBUTTONX}</div>
</div>"; </div>";
$FORUMVIEW_TEMPLATE['end'] = "<!--- END --> \n"; $FORUM_VIEWFORUM_TEMPLATE['end'] = "<!--- END --> \n";

View File

@@ -305,7 +305,7 @@ $FORUM_CRUMB['forum']['value'] = "<a class='forumlink' href='{FORUM_HREF}'>{FORU
// {MODERATORS} {THREADSTATUS} // {MODERATORS} {THREADSTATUS}
$FORUMTOPIC_TEMPLATE['start'] = "<a id='top'></a> $FORUM_VIEWTOPIC_TEMPLATE['start'] = "<a id='top'></a>
<div class='row'> <div class='row'>
<div class='span6 pull-left'>{BACKLINK}</div> <div class='span6 pull-left'>{BACKLINK}</div>
@@ -318,7 +318,7 @@ $FORUMTOPIC_TEMPLATE['start'] = "<a id='top'></a>
{MESSAGE} {MESSAGE}
<table class='table table-striped'> <table id='forum-viewtopic' class='table table-striped'>
<colgroup> <colgroup>
<col style='width:20%' /> <col style='width:20%' />
<col /> <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> <div class='center'>{QUICKREPLY}</div>
@@ -350,15 +350,15 @@ $FORUMTOPIC_TEMPLATE['end'] = "</tr></table>
"; ";
$FORUMTOPIC_TEMPLATE['thread'] =" $FORUM_VIEWTOPIC_TEMPLATE['thread'] ="
<tr> <tr>
<td class='forumheader' style='vertical-align:middle'>{NEWFLAG} {USERCOMBO}{ANON_IP}</td> <td>{NEWFLAG} {USERCOMBO}{ANON_IP}</td>
<td>{THREADDATESTAMP}</td> <td>{THREADDATESTAMP=relative}</td>
<td style='text-align:right'>{POSTOPTIONS}</td> <td style='text-align:right'>{POSTOPTIONS}</td>
</tr> </tr>
<tr> <tr>
<td class='forumheader3'> <td>
{CUSTOMTITLE} {CUSTOMTITLE}
{AVATAR} {AVATAR}
<div> <div>
@@ -366,6 +366,7 @@ $FORUMTOPIC_TEMPLATE['thread'] ="
{LEVEL=badge} {LEVEL=pic} {LEVEL=badge} {LEVEL=pic}
</small> </small>
</div> </div>
</td> </td>
<td colspan='2'> <td colspan='2'>
{POLL} {POLL}
@@ -395,7 +396,7 @@ $FORUMTOPIC_TEMPLATE['thread'] ="
</tr>"; </tr>";
$FORUMTOPIC_TEMPLATE['replies'] = $FORUMTOPIC_TEMPLATE['thread']; $FORUM_VIEWTOPIC_TEMPLATE['replies'] = $FORUM_VIEWTOPIC_TEMPLATE['thread'];