From 566613f050c3d990a95b02200d3814a6ad840bd3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 3 Jan 2021 08:45:18 -0800 Subject: [PATCH] Comment menu template now using v2.x wrappers. Template moved to templates folder. --- e107_plugins/comment_menu/comment_menu.php | 65 ++++++++++--------- .../comment_menu/comment_menu_shortcodes.php | 9 ++- .../comment_menu/comment_menu_template.php | 46 ------------- .../templates/comment_menu_template.php | 39 +++++++++++ 4 files changed, 82 insertions(+), 77 deletions(-) delete mode 100644 e107_plugins/comment_menu/comment_menu_template.php create mode 100644 e107_plugins/comment_menu/templates/comment_menu_template.php diff --git a/e107_plugins/comment_menu/comment_menu.php b/e107_plugins/comment_menu/comment_menu.php index ac70e394e..7d5f86d7c 100644 --- a/e107_plugins/comment_menu/comment_menu.php +++ b/e107_plugins/comment_menu/comment_menu.php @@ -34,26 +34,16 @@ if (!defined('e107_INIT')) } */ -require_once (e_PLUGIN."comment_menu/comment_menu_shortcodes.php"); -$cobj = e107::getObject('comment'); -if (file_exists(THEME."templates/comment_menu/comment_menu_template.php")) -{ - require_once (THEME."templates/comment_menu/comment_menu_template.php"); -} -elseif (file_exists(THEME."comment_menu_template.php")) -{ - require_once (THEME."comment_menu_template.php"); -} -else -{ - require_once(e_PLUGIN."comment_menu/comment_menu_template.php"); -} +// $cobj = e107::getObject('comment'); + + +$cobj = e107::getComment(); + global $menu_pref; - $data = $cobj->getCommentData(intval($menu_pref['comment_display'])); $text = ''; @@ -63,30 +53,47 @@ if (empty($data) || !is_array($data)) $text = CM_L1; } -if(!is_array($COMMENT_MENU_TEMPLATE)) // Convert to v2.x standard. +if(!$TEMPLATE = e107::getTemplate('comment_menu')) { - $TEMPLATE = array(); - $TEMPLATE['start'] = ""; - $TEMPLATE['item'] = $COMMENT_MENU_TEMPLATE; - $TEMPLATE['end'] = ""; -} -else -{ - $TEMPLATE = $COMMENT_MENU_TEMPLATE; + $COMMENT_MENU_TEMPLATE = null; + + if (file_exists(THEME."templates/comment_menu/comment_menu_template.php")) + { + require_once (THEME."templates/comment_menu/comment_menu_template.php"); + } + elseif (file_exists(THEME."comment_menu_template.php")) + { + require_once (THEME."comment_menu_template.php"); + } + + if(!is_array($COMMENT_MENU_TEMPLATE)) // Convert to v2.x standard. + { + $TEMPLATE = array(); + $TEMPLATE['start'] = ""; + $TEMPLATE['item'] = $COMMENT_MENU_TEMPLATE; + $TEMPLATE['end'] = ""; + } + else + { + $TEMPLATE = $COMMENT_MENU_TEMPLATE; + } + } -$comment_menu_shortcodes = new comment_menu_shortcodes; +require_once (e_PLUGIN."comment_menu/comment_menu_shortcodes.php"); +$sc = e107::getScBatch('comment_menu', true); +$sc->wrapper('comment_menu'); -$text .= $tp->parseTemplate($TEMPLATE['start'], true, $comment_menu_shortcodes); +$text .= $tp->parseTemplate($TEMPLATE['start'], true, $sc); foreach ($data as $row) { //e107::setRegistry('plugin/comment_menu/current', $row); - $comment_menu_shortcodes->setVars($row); - $text .= $tp->parseTemplate($TEMPLATE['item'], true, $comment_menu_shortcodes); + $sc->setVars($row); + $text .= $tp->parseTemplate($TEMPLATE['item'], true, $sc); } -$text .= $tp->parseTemplate($TEMPLATE['end'], true, $comment_menu_shortcodes); +$text .= $tp->parseTemplate($TEMPLATE['end'], true, $sc); //e107::setRegistry('plugin/comment_menu/current', null); diff --git a/e107_plugins/comment_menu/comment_menu_shortcodes.php b/e107_plugins/comment_menu/comment_menu_shortcodes.php index 6021677f0..3562e9c00 100644 --- a/e107_plugins/comment_menu/comment_menu_shortcodes.php +++ b/e107_plugins/comment_menu/comment_menu_shortcodes.php @@ -16,8 +16,6 @@ if (!defined('e107_INIT')) { exit; } -//$comment_menu_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__); -//e107::getRegistry('plugin/comment_menu/current'); class comment_menu_shortcodes extends e_shortcode { @@ -88,6 +86,13 @@ class comment_menu_shortcodes extends e_shortcode function sc_cm_author_avatar($parm=null) // new v2.1.5 { $data = array('user_id'=>$this->var['comment_author_id'], 'user_image'=>$this->var['comment_author_image']); + + if(!empty($parm['size'])) + { + $parm['w'] = $parm['size']; + $parm['h'] = $parm['size']; + } + return e107::getParser()->toAvatar($data, $parm); } diff --git a/e107_plugins/comment_menu/comment_menu_template.php b/e107_plugins/comment_menu/comment_menu_template.php deleted file mode 100644 index a76429565..000000000 --- a/e107_plugins/comment_menu/comment_menu_template.php +++ /dev/null @@ -1,46 +0,0 @@ -"; - - $COMMENT_MENU_TEMPLATE['item'] = "
  • - {CM_URL_PRE}{CM_TYPE} {CM_HEADING}{CM_URL_POST} -
    {CM_COMMENT}
    - {CM_AUTHOR} {CM_DATESTAMP} -
  • "; - - $COMMENT_MENU_TEMPLATE['end'] = ""; - - // {CM_AUTHOR_AVATAR: shape=circle} - - -} diff --git a/e107_plugins/comment_menu/templates/comment_menu_template.php b/e107_plugins/comment_menu/templates/comment_menu_template.php new file mode 100644 index 000000000..e10c1ddb7 --- /dev/null +++ b/e107_plugins/comment_menu/templates/comment_menu_template.php @@ -0,0 +1,39 @@ +{---}'; + + +// Template +$COMMENT_MENU_TEMPLATE['start'] = ""; +