1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 21:21:54 +02:00

Comment menu template now using v2.x wrappers. Template moved to templates folder.

This commit is contained in:
Cameron 2021-01-03 08:45:18 -08:00
parent 3b0ff5d4ef
commit 566613f050
4 changed files with 82 additions and 77 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -1,46 +0,0 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Comment menu default template
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/comment_menu/comment_menu_template.php,v $
* $Revision$
* $Date$
* $Author$
*/
$sc_style['CM_TYPE']['pre'] = "[";
$sc_style['CM_TYPE']['post'] = "]";
$sc_style['CM_AUTHOR']['pre'] = CM_L13." ";
$sc_style['CM_AUTHOR']['post'] = "";
$sc_style['CM_DATESTAMP']['pre'] = " ";
$sc_style['CM_DATESTAMP']['post'] = "";
$sc_style['CM_COMMENT']['pre'] = "";
$sc_style['CM_COMMENT']['post'] = "";
// $SC_WRAPPER['CM_AUTHOR'] = CM_L13."{---}"; //XXX Not working as template is loaded the old way.
if (!isset($COMMENT_MENU_TEMPLATE))
{
$COMMENT_MENU_TEMPLATE['start'] = "<ul class='comment-menu'>";
$COMMENT_MENU_TEMPLATE['item'] = "<li>
{CM_URL_PRE}{CM_TYPE} {CM_HEADING}{CM_URL_POST}
<div>{CM_COMMENT}</div>
<small class='text-muted muted'> {CM_AUTHOR} {CM_DATESTAMP}</small>
</li>";
$COMMENT_MENU_TEMPLATE['end'] = "</ul>";
// {CM_AUTHOR_AVATAR: shape=circle}
}

View File

@ -0,0 +1,39 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Comment menu default template
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/comment_menu/comment_menu_template.php,v $
* $Revision$
* $Date$
* $Author$
*/
// Shortcode Wrappers
$COMMENT_MENU_WRAPPER['CM_DATESTAMP'] = ' {---}';
$COMMENT_MENU_WRAPPER['CM_AUTHOR'] = CM_L13.'{---}';
$COMMENT_MENU_WRAPPER['CM_TYPE'] = '<span class="label label-default badge badge-secondary bg-secondary ">{---}</span>';
// Template
$COMMENT_MENU_TEMPLATE['start'] = "<ul class='media-list list-unstyled comment-menu'>";
$COMMENT_MENU_TEMPLATE['item'] = "<li class='media d-flex mb-2' >
<div class='media-left mr-3 me-3'>{CM_AUTHOR_AVATAR: shape=circle&size=48&crop=1}</div>
<div class='media-body'>
{CM_TYPE} {CM_URL_PRE}{CM_HEADING}{CM_URL_POST}
<div>{CM_COMMENT}</div>
<small class='text-muted muted'> {CM_AUTHOR} {CM_DATESTAMP}</small>
</div>
</li>";
$COMMENT_MENU_TEMPLATE['end'] = "</ul>";