From e80c3298182124f1c4c76a3268d5fa85e1f43e69 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 13 Mar 2013 02:39:00 -0700 Subject: [PATCH] Forum template fixes. --- e107_plugins/forum/forum_class.php | 119 ++++++++++++++++-- e107_plugins/forum/forum_viewforum.php | 26 ++-- e107_plugins/forum/forum_viewtopic.php | 15 +-- .../shortcodes/batch/view_shortcodes.php | 15 ++- .../templates/forum_viewforum_template.php | 24 ++-- .../templates/forum_viewtopic_template.php | 17 +-- 6 files changed, 161 insertions(+), 55 deletions(-) diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index c54d306d8..90ca14aa2 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -17,15 +17,19 @@ if (!defined('e107_INIT')) { exit; } /* Forum Header File */ if (!defined('e107_INIT')) { exit; } -$code = <<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'] = "".$tp->toHtml($_POST['text']).""; + $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)) { @@ -166,7 +256,11 @@ class e107forum $ret['msg'] = "failed to unstick thread"; $ret['status'] = 'error'; } - break; + break; + + + + default: $ret['status'] = 'error'; @@ -212,6 +306,9 @@ class e107forum + + + private function loadPermList() { $e107 = e107::getInstance(); diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php index 5dfc7bdc8..4b3bf960a 100644 --- a/e107_plugins/forum/forum_viewforum.php +++ b/e107_plugins/forum/forum_viewforum.php @@ -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']; } diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 0d7286f99..c019600f7 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -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 = "
$thread->threadId)) . "' method='post'>

" . LAN_393 . ":
- +
  - +

"; diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 5a0be5dc3..fcaf6dab6 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -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').'
'; @@ -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 = " $this->postInfo['thread_name'], 'thread' => $this->postInfo['post_thread'], 'id' => $this->postInfo['post_id']))."'>".IMAGE_post." "; 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 .= "
  • $this->postInfo['post_id']))."'>Edit
  • "; } - $text .= "
  • Delete (fixme)
  • "; //FIXME - putting a form here could break layout. Ajax? + $text .= "
  • Delete (fixme)
  • "; if ($type == 'thread') { diff --git a/e107_plugins/forum/templates/forum_viewforum_template.php b/e107_plugins/forum/templates/forum_viewforum_template.php index a6d8c70e7..db15a2366 100644 --- a/e107_plugins/forum/templates/forum_viewforum_template.php +++ b/e107_plugins/forum/templates/forum_viewforum_template.php @@ -282,8 +282,8 @@ $FORUM_CRUMB['forum']['value'] = "{FORUM_TITLE}"; // {BREADCRUMB} //FIXME Breadcrumb looks crummy -$FORUMVIEW_TEMPLATE['start'] = ""; -$FORUMVIEW_TEMPLATE['header'] = "

    {FORUMTITLE}

    {NEWTHREADBUTTONX}
    +$FORUM_VIEWFORUM_TEMPLATE['start'] = ""; +$FORUM_VIEWFORUM_TEMPLATE['header'] = "

    {FORUMTITLE}

    {NEWTHREADBUTTONX}
    @@ -295,30 +295,30 @@ $FORUMVIEW_TEMPLATE['header'] = "
    \n"; -$FORUMVIEW_TEMPLATE['item-announce'] = $FORUMVIEW['item'] ; // "\n"; +$FORUM_VIEWFORUM_TEMPLATE['item'] = "\n"; +$FORUM_VIEWFORUM_TEMPLATE['item-sticky'] = $FORUMVIEW['item'] ; // "\n"; +$FORUM_VIEWFORUM_TEMPLATE['item-announce'] = $FORUMVIEW['item'] ; // "\n"; -$FORUMVIEW_TEMPLATE['sub-header'] = ""; -$FORUMVIEW_TEMPLATE['sub-item'] = " +$FORUM_VIEWFORUM_TEMPLATE['sub-header'] = ""; +$FORUM_VIEWFORUM_TEMPLATE['sub-item'] = "\n"; -$FORUMVIEW_TEMPLATE['sub-footer'] = ""; +$FORUM_VIEWFORUM_TEMPLATE['sub-footer'] = ""; -$FORUMVIEW_TEMPLATE['divider-important'] = ""; -$FORUMVIEW_TEMPLATE['divider-normal'] = ""; +$FORUM_VIEWFORUM_TEMPLATE['divider-important'] = ""; +$FORUM_VIEWFORUM_TEMPLATE['divider-normal'] = ""; -$FORUMVIEW_TEMPLATE['footer'] = "
    {THREADNAME}
    {THREADNAME}
    {ICON}{THREADNAME}
    by {POSTER} {THREADTIMELAPSE} {PAGESX}
    {REPLIESX}{VIEWSX}{LASTPOSTUSER} {LASTPOSTDATE}
    {ADMINOPTIONS}
    {THREADNAME}
    {THREADNAME}
    ".FORLAN_20."".LAN_55."".FORLAN_21."".FORLAN_22."
    {NEWFLAG}
    ".FORLAN_20."".LAN_55."".FORLAN_21."".FORLAN_22."
    {NEWFLAG}
    {SUB_FORUMTITLE}
    {SUB_DESCRIPTION}
    {SUB_REPLIESX} {SUB_THREADSX} {SUB_LASTPOSTUSER} {SUB_LASTPOSTDATE}
    ".LAN_411."".LAN_55."".LAN_56."".LAN_57."
    ".LAN_412."".LAN_55."".LAN_56."".LAN_57."
    ".LAN_411."".LAN_55."".LAN_56."".LAN_57."
    ".LAN_412."".LAN_55."".LAN_56."".LAN_57."
    +$FORUM_VIEWFORUM_TEMPLATE['footer'] = "
    {SEARCH}
    {NEWTHREADBUTTONX}
    "; -$FORUMVIEW_TEMPLATE['end'] = " \n"; +$FORUM_VIEWFORUM_TEMPLATE['end'] = " \n"; diff --git a/e107_plugins/forum/templates/forum_viewtopic_template.php b/e107_plugins/forum/templates/forum_viewtopic_template.php index 6530b2a4b..b1dbbc88d 100644 --- a/e107_plugins/forum/templates/forum_viewtopic_template.php +++ b/e107_plugins/forum/templates/forum_viewtopic_template.php @@ -305,7 +305,7 @@ $FORUM_CRUMB['forum']['value'] = "{FORU // {MODERATORS} {THREADSTATUS} -$FORUMTOPIC_TEMPLATE['start'] = " +$FORUM_VIEWTOPIC_TEMPLATE['start'] = "
    {BACKLINK}
    @@ -318,7 +318,7 @@ $FORUMTOPIC_TEMPLATE['start'] = " {MESSAGE} - +
    @@ -332,7 +332,7 @@ $FORUMTOPIC_TEMPLATE['start'] = " -$FORUMTOPIC_TEMPLATE['end'] = "
    +$FORUM_VIEWTOPIC_TEMPLATE['end'] = "
    {QUICKREPLY}
    @@ -350,15 +350,15 @@ $FORUMTOPIC_TEMPLATE['end'] = " "; -$FORUMTOPIC_TEMPLATE['thread'] =" +$FORUM_VIEWTOPIC_TEMPLATE['thread'] =" - {NEWFLAG} {USERCOMBO}{ANON_IP} - {THREADDATESTAMP} + {NEWFLAG} {USERCOMBO}{ANON_IP} + {THREADDATESTAMP=relative} {POSTOPTIONS} - + {CUSTOMTITLE} {AVATAR}
    @@ -366,6 +366,7 @@ $FORUMTOPIC_TEMPLATE['thread'] =" {LEVEL=badge} {LEVEL=pic}
    + {POLL} @@ -395,7 +396,7 @@ $FORUMTOPIC_TEMPLATE['thread'] =" "; - $FORUMTOPIC_TEMPLATE['replies'] = $FORUMTOPIC_TEMPLATE['thread']; + $FORUM_VIEWTOPIC_TEMPLATE['replies'] = $FORUM_VIEWTOPIC_TEMPLATE['thread'];