From dc1c46acc1bb21e99f2a392d4ae1fb8f83afd091 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 27 Apr 2016 14:37:43 -0700 Subject: [PATCH] Forum Post BC-Fixes. Renamed forum-post shortcodes to avoid name conflicts. --- e107_handlers/shortcode_handler.php | 9 +- e107_plugins/forum/forum_post.php | 244 +++++++++++++++++- .../shortcodes/batch/post_shortcodes.php | 40 +-- .../forum/templates/forum_post_template.php | 242 +---------------- e107_plugins/poll/poll_class.php | 22 +- 5 files changed, 291 insertions(+), 266 deletions(-) diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index dd2db5e43..033093973 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -426,14 +426,11 @@ class e_parse_shortcode } elseif(E107_DBG_BBSC || E107_DBG_SC) { - echo "

Couldn't Find Class '".$className."' in ".$path."

"; + // echo "

Couldn't Find Class '".$className."' in ".$path."

"; + echo "
Couldn't Load: ".$path." with class-name: {$className} and pluginName {$pluginName}
"; } } - elseif(E107_DBG_BBSC || E107_DBG_SC) - { - echo "
Couldn't Load: ".$path." with class-name: {$className} and pluginName {$pluginName}
"; - - } + // TODO - throw exception? return null; diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 2c6d59662..8c048e5b1 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -353,6 +353,7 @@ class forum_post_handler */ function getTemplate($type = 'post') { + $pref = e107::pref('core'); global $FORUMPOST, $subjectbox, $userbox, $poll_form, $fileattach, $fileattach_alert; // needed for BC. @@ -380,9 +381,217 @@ class forum_post_handler } } + // ----------------- Legacy ------------------------- + + if(!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); } + + if(empty($userbox)) + { + $userbox = " + ".LAN_FORUM_3010." + + + + "; + } + + if(empty($subjectbox)) + { + $subjectbox = " + ".LAN_FORUM_3011." + + + + "; + } + + if(empty($fileattach)) + { + $fileattach = " + + ".($pref['image_post'] ? LAN_FORUM_3012 : LAN_FORUM_3013)." + + + ".LAN_FORUM_3014." + ".str_replace(array('[', ']'), array('', ''), LAN_FORUM_3015)."
".LAN_FORUM_3016.": ".vartrue($allowed_filetypes)."
".LAN_FORUM_3017."
".LAN_FORUM_3018.": ".(vartrue($max_upload_size) ? $max_upload_size." ".LAN_FORUM_3019 : ini_get('upload_max_filesize'))." +
+
+ + + +
+ + + + "; + + } + // If the upload directory is not writable, we need to alert the user about this. + if(empty($fileattach_alert)) + { + $fileattach_alert = " + + ".($pref['image_post'] ? LAN_FORUM_3012 : LAN_FORUM_3013)." + + + ".str_replace('[x]', e_FILE."public", LAN_FORUM_3021)." + \n"; + } + // ------------ + + if(empty($FORUMPOST)) + { + $FORUMPOST = " +
+
+ {FORMSTART} + + + + + {USERBOX} + {SUBJECTBOX} + + + + + {POLL} + {FILEATTACH} + + + + +
{BACKLINK} +
{POSTTYPE} + {POSTBOX}
+ {EMAILNOTIFY}
+ {NOEMOTES}
+ {POSTTHREADAS} +
+ {BUTTONS} +
+ {FORMEND} + + + + + +
+ {FORUMJUMP} +
+
+ "; + } + + if(empty($FORUMPOST_REPLY)) + { + $FORUMPOST_REPLY = " +
+
+ {FORMSTART} + + + + + {USERBOX} + {SUBJECTBOX} + + + + + + {POLL} + + {FILEATTACH} + + + + +
{BACKLINK} +
{POSTTYPE} + {POSTBOX}
+ {EMAILNOTIFY}
+ {NOEMOTES}
+ {POSTTHREADAS} +
+ {BUTTONS} +
+ {FORMEND} + + + + + +
+ {FORUMJUMP} +
+
+
+ {THREADTOPIC} + {LATESTPOSTS} +
+ "; + } + + if(empty($LATESTPOSTS_START)) + { + $LATESTPOSTS_START = " + + + + "; + } + + if(empty($LATESTPOSTS_POST)) + { + $LATESTPOSTS_POST = " + + + + + "; + } + + if(empty($LATESTPOSTS_END)) + { + $LATESTPOSTS_END = " +
".str_replace('[y]', "{LATESTPOSTSCOUNT}", LAN_FORUM_3022)."
{POSTER} +
".IMAGE_post2." {THREADDATESTAMP}
+ {POST} +
+ "; + } + + if(empty($THREADTOPIC_REPLY)) + { + $THREADTOPIC_REPLY = " + + + + + + + + +
".LAN_FORUM_1003."
{POSTER} +
".IMAGE_post2." {THREADDATESTAMP}
+ {POST} +
+ "; + } + + + // -------------------------------- End Legacy Code ----------------------------------// + + + + + if($type == 'post') { - return (deftrue('BOOTSTRAP')) ? $FORUM_POST_TEMPLATE : array('form'=>$FORUMPOST); + $template= (deftrue('BOOTSTRAP')) ? $FORUM_POST_TEMPLATE : array('form'=>$FORUMPOST); + // print_a($template); + return $this->upgradeTemplate($template); } else { @@ -408,6 +617,39 @@ class forum_post_handler } + private function upgradeTemplate($template) + { + $arr = array( + 'POSTOPTIONS' => "FORUM_POST_OPTIONS", + 'POSTOPTIONS_LABEL' => "FORUM_POST_OPTIONS_LABEL", + 'POLL' => 'FORUM_POST_POLL', + 'FORUM_AUTHOR' => 'FORUM_POST_AUTHOR', + 'FORUM_SUBJECT' => 'FORUM_POST_SUBJECT', + 'BUTTONS' => 'FORUM_POST_BUTTONS', + 'FORMSTART' => 'FORUM_POST_FORM_START', + 'FORMEND' => 'FORUM_POST_FORM_END', + 'POSTBOX' => 'FORUM_POST_TEXTAREA', + 'EMAILNOTIFY' => 'FORUM_POST_EMAIL_NOTIFY', + 'BACKLINK' => 'FORUM_POST_BREADCRUMB', + 'POSTTYPE' => 'FORUM_POST_TEXTAREA_LABEL' + ); + + foreach($arr as $old => $new) + { + //$template = str_replace("{".$old."}", "{".$new."}", $template); + $reg = '/\{'.$old.'((?:=|:)?[^\}]*)\}/'; // handle variations. + $repl = '{'.$new.'$1}'; + $template = preg_replace($reg,$repl, $template); + + } + + // print_a($template); + + return $template; + + } + + function renderFormMove() { if(!deftrue('MODERATOR')) diff --git a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php index bfe6dfa0b..91df5147a 100644 --- a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php @@ -18,7 +18,7 @@ class plugin_forum_post_shortcodes extends e_shortcode $this->e107 = e107::getInstance(); } - function sc_latestposts($parm) + function sc_latestposts($parm) //TODO move elsewhere? { $parm = ($parm ? $parm : 10); global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST; @@ -48,12 +48,12 @@ class plugin_forum_post_shortcodes extends e_shortcode return e107::getParser()->parseTemplate($THREADTOPIC_REPLY, true); } - function sc_formstart() + function sc_forum_post_form_start() { return "
"; } - function sc_formend() + function sc_forum_post_form_end() { $frm = e107::getForm(); return $frm->hidden('action',$this->var['action']).$frm->close(); @@ -81,7 +81,7 @@ class plugin_forum_post_shortcodes extends e_shortcode return (USER == false ? $userbox : ''); } - function sc_forum_author() + function sc_forum_post_author() { $opts = array('size' => 'xlarge'); $tp = e107::getParser(); @@ -110,7 +110,7 @@ class plugin_forum_post_shortcodes extends e_shortcode return ($this->var['action'] == 'nt' ? $subjectbox : ''); } - function sc_forum_subject() + function sc_forum_post_subject() { $opts = array('size' => 'xlarge'); @@ -144,12 +144,12 @@ class plugin_forum_post_shortcodes extends e_shortcode } - function sc_posttype() + function sc_forum_post_textarea_label() { return ($this->var['action'] == 'nt' ? LAN_FORUM_2015 : LAN_FORUM_2006); } - function sc_postbox() + function sc_forum_post_textarea() { $tp = e107::getParser(); @@ -181,7 +181,7 @@ class plugin_forum_post_shortcodes extends e_shortcode } - function sc_buttons() + function sc_forum_post_buttons() { $ret = " "; @@ -272,10 +272,10 @@ class plugin_forum_post_shortcodes extends e_shortcode } - function sc_postoptions_label() + function sc_forum_post_options_label() { $type = $this->sc_postthreadas(); - $poll = $this->sc_poll('front'); + $poll = $this->sc_forum_post_poll('front'); $attach = $this->sc_forumattachment(); if(empty($type) && empty($poll) && empty($attach)) @@ -288,10 +288,10 @@ class plugin_forum_post_shortcodes extends e_shortcode - function sc_postoptions($parm='') + function sc_forum_post_options($parm='') { $type = $this->sc_postthreadas(); - $poll = $this->sc_poll('front'); + $poll = $this->sc_forum_post_poll('front'); $attach = $this->sc_forumattachment(); $tabs = array(); @@ -369,7 +369,7 @@ class plugin_forum_post_shortcodes extends e_shortcode } - function sc_poll($parm='') + function sc_forum_post_poll($parm=null) { if(!e107::isInstalled('poll')) @@ -390,11 +390,13 @@ class plugin_forum_post_shortcodes extends e_shortcode return $poll_form; } - - return "".LAN_FORUM_3028." + //BC Code below. + return "".LAN_FORUM_3028." + "; + ".$poll_form."
"; } + return ''; } @@ -416,7 +418,7 @@ class plugin_forum_post_shortcodes extends e_shortcode return ''; } - function sc_backlink() + function sc_forum_post_breadcrumb() { global $forum, $threadInfo, $eaction, $action,$forumInfo; @@ -432,11 +434,11 @@ class plugin_forum_post_shortcodes extends e_shortcode function sc_noemotes() { - if(vartrue($eaction) == true) { return ; } + if(vartrue($eaction) == true) { return null; } return " ".LAN_FORUM_3039.''; } - function sc_emailnotify() + function sc_forum_post_email_notify() { diff --git a/e107_plugins/forum/templates/forum_post_template.php b/e107_plugins/forum/templates/forum_post_template.php index f2d2e5f76..f5e4838a5 100644 --- a/e107_plugins/forum/templates/forum_post_template.php +++ b/e107_plugins/forum/templates/forum_post_template.php @@ -9,264 +9,47 @@ */ if (!defined('e107_INIT')) { exit; } -if(!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); } - -// the user box and subject box are not always displayed, therefore we need to define them /in case/ they are, if not they'll be ignored. - -if(!vartrue($userbox)) -{ -$userbox = " -".LAN_FORUM_3010." - - - -"; -} - -if(!vartrue($subjectbox)) -{ -$subjectbox = " -".LAN_FORUM_3011." - - - -"; -} - -// the poll is optional, be careful when changing the values here, only change if you know what you're doing ... -if(!vartrue($poll_form)) -{ - if(is_readable(e_PLUGIN.'poll/poll_class.php')) { - require_once(e_PLUGIN.'poll/poll_class.php'); - $pollo = new poll; - $poll_form = $pollo -> renderPollForm('forum'); - } -} - -// finally, file attach is optional, again only change this if you know what you're doing ... -if(!vartrue($fileattach)) -{ -$fileattach = " - - ".($pref['image_post'] ? LAN_FORUM_3012 : LAN_FORUM_3013)." - - - ".LAN_FORUM_3014." - ".str_replace(array('[', ']'), array('', ''), LAN_FORUM_3015)."
".LAN_FORUM_3016.": ".vartrue($allowed_filetypes)."
".LAN_FORUM_3017."
".LAN_FORUM_3018.": ".(vartrue($max_upload_size) ? $max_upload_size." ".LAN_FORUM_3019 : ini_get('upload_max_filesize'))." -
-
- - - -
- - - -"; -// -// -} -// If the upload directory is not writable, we need to alert the user about this. -if(!vartrue($fileattach_alert)) -{ - $fileattach_alert = " - - ".($pref['image_post'] ? LAN_FORUM_3012 : LAN_FORUM_3013)." - - - ".str_replace('[x]', e_FILE."public", LAN_FORUM_3021)." - \n"; -} -// ------------ - -if(!$FORUMPOST) -{ -$FORUMPOST = " -
-
-{FORMSTART} - - - - -{USERBOX} -{SUBJECTBOX} - - - - -{POLL} -{FILEATTACH} - - - - -
{BACKLINK} -
{POSTTYPE} -{POSTBOX}
-{EMAILNOTIFY}
-{NOEMOTES}
-{POSTTHREADAS} -
-{BUTTONS} -
-{FORMEND} - - - - - -
-{FORUMJUMP} -
-
-"; -} - -if(!vartrue($FORUMPOST_REPLY)) -{ -$FORUMPOST_REPLY = " -
-
-{FORMSTART} - - - - -{USERBOX} -{SUBJECTBOX} - - - - - -{POLL} - -{FILEATTACH} - - - - -
{BACKLINK} -
{POSTTYPE} -{POSTBOX}
-{EMAILNOTIFY}
-{NOEMOTES}
-{POSTTHREADAS} -
-{BUTTONS} -
-{FORMEND} - - - - - -
-{FORUMJUMP} -
-
-
-{THREADTOPIC} -{LATESTPOSTS} -
-"; -} - -if(!vartrue($LATESTPOSTS_START)) -{ -$LATESTPOSTS_START = " - - - -"; -} - -if(!vartrue($LATESTPOSTS_POST)) -{ -$LATESTPOSTS_POST = " - - - - -"; -} - -if(!vartrue($LATESTPOSTS_END)) -{ -$LATESTPOSTS_END = " -
".str_replace('[y]', "{LATESTPOSTSCOUNT}", LAN_FORUM_3022)."
{POSTER} -
".IMAGE_post2." {THREADDATESTAMP}
- {POST} -
-"; -} - -if(!vartrue($THREADTOPIC_REPLY)) -{ -$THREADTOPIC_REPLY = " - - - - - - - - -
".LAN_FORUM_1003."
{POSTER} -
".IMAGE_post2." {THREADDATESTAMP}
- {POST} -
-"; -} - // New in v2.x - requires a bootstrap theme be loaded. - $FORUM_POST_TEMPLATE['form'] = " - {FORMSTART} +$FORUM_POST_TEMPLATE['form'] = " + {FORUM_POST_FORM_START}
-
{BACKLINK}
+
{FORUM_POST_BREADCRUMB}
-
{FORUM_AUTHOR}
+
{FORUM_POST_AUTHOR}
-
{FORUM_SUBJECT}
+
{FORUM_POST_SUBJECT}
- +
- {POSTBOX} - {EMAILNOTIFY} + {FORUM_POST_TEXTAREA} + {FORUM_POST_EMAIL_NOTIFY}
- -
{POSTOPTIONS}
+ +
{FORUM_POST_OPTIONS}
- {BUTTONS} + {FORUM_POST_BUTTONS}
- {FORMEND} + {FORUM_POST_FORM_END} "; -$js = << \ No newline at end of file diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index c725f412e..51a4a717c 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -626,6 +626,8 @@ class poll //XXX New v2.x default for front-end. Currently used by forum-post in bootstrap mode. // TODO LAN - Needs a more generic LAN rewrite when used on another area than forum + + if ($mode == 'front') { @@ -722,22 +724,22 @@ class poll //TODO Hardcoded FORUM code needs to be moved somewhere. - if ($mode == 'forum') + if ($mode == 'forum') // legacy code. { $text = " - ".LAN_FORUM_3029." + ".LAN_FORUM_3029." -
".LAN_FORUM_3030.":
- +
".LAN_FORUM_3030.":
+ "; $option_count = (count(vartrue($_POST['poll_option'])) ? count($_POST['poll_option']) : 1); $text .= " - ".LAN_FORUM_3031." - + ".LAN_FORUM_3031." +
"; for($count = 1; $count <= $option_count; $count++) @@ -758,15 +760,15 @@ class poll - ".LAN_FORUM_3033." - + ".LAN_FORUM_3033." + ".LAN_YES."   ".LAN_NO." - ".LAN_FORUM_3034." - + ".LAN_FORUM_3034." + ".LAN_FORUM_3035."
".LAN_FORUM_3036."
".LAN_FORUM_3037."