From 010ba14c739395bbf0a510a94708614b2c4b1c0b Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 5 Apr 2016 13:15:58 -0700 Subject: [PATCH] Forum view-topic template wrapper fix. Custom-title styling subject to change. Default SEF-URL format now separates thread_id into 'folder'. (backward compat.) --- e107_admin/users.php | 2 +- e107_handlers/e107_class.php | 8 +++ e107_handlers/shortcode_handler.php | 5 ++ e107_plugins/forum/e_url.php | 4 +- e107_plugins/forum/forum.css | 11 +++ e107_plugins/forum/forum_viewtopic.php | 67 ++++++++++++------- .../templates/forum_viewtopic_template.php | 4 +- 7 files changed, 72 insertions(+), 29 deletions(-) diff --git a/e107_admin/users.php b/e107_admin/users.php index a312ee465..d24990fbf 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -272,7 +272,7 @@ class users_admin_ui extends e_admin_ui 'user_name' => array('title' => LAN_USER_01, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto','thclass' => 'left first'), // Display name 'user_loginname' => array('title' => LAN_USER_02, 'tab'=>0, 'type' => 'text', 'data'=>'str', 'width' => 'auto'), // User name 'user_login' => array('title' => LAN_USER_03, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto'), // Real name (no real vetting) - 'user_customtitle' => array('title' => LAN_USER_04, 'tab'=>0, 'type' => 'text', 'data'=>'str', 'width' => 'auto'), // No real vetting + 'user_customtitle' => array('title' => LAN_USER_04, 'tab'=>0, 'type' => 'text', 'inline'=>true, 'data'=>'str', 'width' => 'auto'), // No real vetting 'user_password' => array('title' => LAN_PASSWORD, 'tab'=>0, 'type' => 'method', 'data'=>'str', 'width' => 'auto'), //TODO add md5 option to form handler? 'user_sess' => array('title' => 'Session', 'tab'=>0, 'noedit'=>true, 'type' => 'text', 'width' => 'auto'), // Photo 'user_image' => array('title' => LAN_USER_07, 'tab'=>0, 'type' => 'dropdown', 'data'=>'str', 'width' => 'auto'), // Avatar diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index e670e2c8f..5279d154c 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2541,12 +2541,20 @@ class e107 { if(isset($SC_WRAPPER)) { + if(E107_DBG_BBSC) + { + e107::getMessage()->addDebug("Found wrapper: ".$SC_WRAPPER); + } self::scStyle($SC_WRAPPER); } // ID_WRAPPER support if(isset($$wrapper) && !empty($$wrapper) && is_array($$wrapper)) { + if(E107_DBG_BBSC) + { + e107::getMessage()->addDebug("Found ID wrapper: ".$wrapper); + } self::setRegistry($wrapperRegPath, $$wrapper); } } diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index c5414ca56..7d3243f95 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -762,6 +762,7 @@ class e_parse_shortcode { // $cname = get_class($this->addedCodes); + $tmpWrap = e107::templateWrapper($this->addedCodes->wrapper()); if(!empty($tmpWrap)) // FIX for #3 above. { @@ -769,6 +770,10 @@ class e_parse_shortcode $this->wrapper = $this->addedCodes->getWrapperID(); } + elseif(E107_DBG_BBSC) + { + // e107::getMessage()->addDebug("Wrapper Empty: ".$this->addedCodes->wrapper()); + } } diff --git a/e107_plugins/forum/e_url.php b/e107_plugins/forum/e_url.php index 986bde8c3..de4e24da0 100644 --- a/e107_plugins/forum/e_url.php +++ b/e107_plugins/forum/e_url.php @@ -55,8 +55,8 @@ class forum_url // plugin-folder + '_url' ); $config['topic'] = array( - 'regex' => '^forum/(.*)/(\d*)-([\w-]*)/?\??(.*)', - 'sef' => 'forum/{forum_sef}/{thread_id}-{thread_sef}/', + 'regex' => '^forum/(.*)/(\d*)(?:-|/)([\w-]*)/?\??(.*)', + 'sef' => 'forum/{forum_sef}/{thread_id}/{thread_sef}/', 'redirect' => '{e_PLUGIN}forum/forum_viewtopic.php?id=$2&$4' ); /* diff --git a/e107_plugins/forum/forum.css b/e107_plugins/forum/forum.css index b14b252a8..264a703a0 100644 --- a/e107_plugins/forum/forum.css +++ b/e107_plugins/forum/forum.css @@ -18,6 +18,17 @@ ul.newforumposts-menu { padding-left: 10px; } ul.newforumposts-menu li { margin-bottom: 15px; } div.forum-poll-results { padding-left:0 } +.forum-viewtopic-customtitle { +display: block; +background-color: #E0E0E0; +border-bottom-left-radius: 5px; +border-bottom-right-radius: 5px; +margin-top: -3px; +border: 1px solid #ccc; +padding: 5px 15px; +text-align: center; + } + @media all and (min-height: 800px) { #forum, #forum-stats, #forum-rules { min-height: 500px; } diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 7ab06061d..08b618b80 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -199,36 +199,44 @@ if(file_exists(THEME.'forum_design.php')) // legacy file include_once (THEME.'forum_design.php'); } -if (!vartrue($FORUMSTART)) -{ - if(file_exists(THEME.'forum_viewtopic_template.php')) - { - require_once(THEME.'forum_viewtopic_template.php'); - } - elseif(file_exists(THEME.'templates/forum/forum_viewtopic_template.php')) - { - require_once(THEME.'templates/forum/forum_viewtopic_template.php'); - } - elseif(file_exists(THEME.'forum_template.php')) - { - require_once(THEME.'forum_template.php'); - } - else - { - require_once(e_PLUGIN.'forum/templates/forum_viewtopic_template.php'); - } -} // New in v2.x -if(is_array($FORUM_VIEWTOPIC_TEMPLATE) && deftrue('BOOTSTRAP',false)) +if(deftrue('BOOTSTRAP',false)) { + $FORUM_VIEWTOPIC_TEMPLATE = e107::getTemplate('forum','forum_viewtopic'); + + // print_a($FORUM_VIEWTOPIC_TEMPLATE); + $FORUMSTART = $FORUM_VIEWTOPIC_TEMPLATE['start']; $FORUMTHREADSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['thread']; $FORUMEND = $FORUM_VIEWTOPIC_TEMPLATE['end']; $FORUMREPLYSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['replies']; $FORUMDELETEDSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['deleted']; } +else +{ + if (!vartrue($FORUMSTART)) + { + if(file_exists(THEME.'forum_viewtopic_template.php')) + { + require_once(THEME.'forum_viewtopic_template.php'); + } + elseif(file_exists(THEME.'templates/forum/forum_viewtopic_template.php')) + { + require_once(THEME.'templates/forum/forum_viewtopic_template.php'); + } + elseif(file_exists(THEME.'forum_template.php')) + { + require_once(THEME.'forum_template.php'); + } + else + { + require_once(e_PLUGIN.'forum/templates/forum_viewtopic_template.php'); + } + } + +} //TODO Clean up this mess!! @@ -441,6 +449,9 @@ if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE; $alt = false; $i = $thread->page; + +$sc = e107::getScBatch('view', 'forum'); + foreach ($postList as $postInfo) { if($postInfo['post_options']) @@ -462,23 +473,29 @@ foreach ($postList as $postInfo) $postInfo['thread_start'] = false; $alt = !$alt; + $sc->setScVar('postInfo', $postInfo); + if($postInfo['post_status']) { $_style = (isset($FORUMDELETEDSTYLE_ALT) && $alt ? $FORUMDELETEDSTYLE_ALT : $FORUMDELETEDSTYLE); + $sc->wrapper('forum_viewtopic/deleted'); } else { $_style = (isset($FORUMREPLYSTYLE_ALT) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE); + $sc->wrapper('forum_viewtopic/replies'); } - - $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo); - $forrep .= $tp->parseTemplate($_style, true, $forum_shortcodes) . "\n"; + + // $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic'); + $forrep .= $tp->parseTemplate($_style, true, $sc) . "\n"; } else { $postInfo['thread_start'] = true; - $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo); - $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, vartrue($forum_shortcodes)) . "\n"; + $sc->setScVar('postInfo', $postInfo); + $sc->wrapper('forum_viewtopic/thread'); + // $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic'); + $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, vartrue($sc)) . "\n"; } } unset($loop_uid); diff --git a/e107_plugins/forum/templates/forum_viewtopic_template.php b/e107_plugins/forum/templates/forum_viewtopic_template.php index 089fbbc87..26ef029b3 100644 --- a/e107_plugins/forum/templates/forum_viewtopic_template.php +++ b/e107_plugins/forum/templates/forum_viewtopic_template.php @@ -474,7 +474,9 @@ $FORUM_VIEWTOPIC_TEMPLATE['deleted'] = " -$FORUM_VIEWTOPIC_WRAPPER['ATTACHMENTS'] = "
{---}
"; +$FORUM_VIEWTOPIC_WRAPPER['thread']['ATTACHMENTS'] = "
{---}
"; +$FORUM_VIEWTOPIC_WRAPPER['thread']['CUSTOMTITLE'] = "{---}"; + //$FORUMDELETEDSTYLE = "
DELETED";