1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 12:41:51 +02:00

Shortcode tests for list_new, pm, rss_menu, signin and simpleParse()

This commit is contained in:
Cameron 2021-01-08 17:00:23 -08:00
parent d86d8d999f
commit c8ba5fe30a
11 changed files with 363 additions and 396 deletions

View File

@ -929,7 +929,7 @@ class e_parse extends e_parser
//return ($this->replaceVars[$key] !== null ? $this->replaceVars[$key]: $unset);
}
$key = $tmp[1]; // PHP7 fix.
return ($this->replaceVars->$key !== null ? $this->replaceVars->$key : $unset); // Doesn't work.
return (!empty($this->replaceVars) && ($this->replaceVars->$key !== null)) ? $this->replaceVars->$key : $unset; // Doesn't work.
}
@ -6060,12 +6060,19 @@ class e_emotefilter
class e_profanityFilter
{
protected $profanityList;
private $pref;
public function __construct()
{
global $pref;
$words = explode(',', $pref['profanity_words']);
$this->pref = e107::getPref();
if(empty($this->pref['profanity_words']))
{
return null;
}
$words = explode(',', $this->pref['profanity_words']);
$word_array = array();
foreach($words as $word)
{
@ -6089,14 +6096,15 @@ class e_profanityFilter
public function filterProfanities($text)
{
global $pref;
if (!$this->profanityList)
if (empty($this->profanityList))
{
return $text;
}
if ($pref['profanity_replace'])
if(!empty($this->pref['profanity_replace']))
{
return preg_replace("#\b".$this->profanityList."\b#is", $pref['profanity_replace'], $text);
return preg_replace("#\b".$this->profanityList."\b#is", $this->pref['profanity_replace'], $text);
}
return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text);

View File

@ -33,6 +33,8 @@ class listclass
var $list_pref;
var $mode;
var $shortcodes = FALSE;
private $pf; // profanity filter class.
public $data;
/**
* constructor
@ -180,7 +182,10 @@ class listclass
$arr[$s]['amount'] = vartrue($this->list_pref[$s."_".$mode."_amount"]);
$arr[$s]['order'] = vartrue($this->list_pref[$s."_".$mode."_order"]);
$arr[$s]['section'] = $s;
}
}
//sort array on order values set in preferences
usort($arr, function($e, $f)
@ -226,6 +231,8 @@ class listclass
return;
}
$content_name = '';
$content_types = array();
//get top level categories
@ -302,63 +309,63 @@ class listclass
{
if ($plugin_installed = isset($pref['plug_installed'][e107::getParser()->toDB($s, true)]))
{
$prf["$s_recent_menu_caption"] = $s;
$prf["$s_recent_page_caption"] = $s;
$prf["$s_new_menu_caption"] = $s;
$prf["$s_new_page_caption"] = $s;
$prf[$s."_recent_menu_caption"] = $s;
$prf[$s."_recent_page_caption"] = $s;
$prf[$s."_new_menu_caption"] = $s;
$prf[$s."_new_page_caption"] = $s;
}
}
else
{
$prf["$s_recent_menu_caption"] = $this->titles[$i];
$prf["$s_recent_page_caption"] = $this->titles[$i];
$prf["$s_new_menu_caption"] = $this->titles[$i];
$prf["$s_new_page_caption"] = $this->titles[$i];
$prf[$s."_recent_menu_caption"] = $this->titles[$i];
$prf[$s."_recent_page_caption"] = $this->titles[$i];
$prf[$s."_new_menu_caption"] = $this->titles[$i];
$prf[$s."_new_page_caption"] = $this->titles[$i];
}
}
else
{
$prf["$s_recent_menu_caption"] = $s;
$prf["$s_recent_page_caption"] = $s;
$prf["$s_new_menu_caption"] = $s;
$prf["$s_new_page_caption"] = $s;
$prf[$s."_recent_menu_caption"] = $s;
$prf[$s."_recent_page_caption"] = $s;
$prf[$s."_new_menu_caption"] = $s;
$prf[$s."_new_page_caption"] = $s;
}
$prf["$s_recent_menu_display"] = "1";
$prf["$s_recent_menu_open"] = "0";
$prf["$s_recent_menu_author"] = "0";
$prf["$s_recent_menu_category"] = "0";
$prf["$s_recent_menu_date"] = "1";
$prf["$s_recent_menu_amount"] = "5";
$prf["$s_recent_menu_order"] = ($i+1);
$prf["$s_recent_menu_icon"] = '';
$prf[$s."_recent_menu_display"] = "1";
$prf[$s."_recent_menu_open"] = "0";
$prf[$s."_recent_menu_author"] = "0";
$prf[$s."_recent_menu_category"] = "0";
$prf[$s."_recent_menu_date"] = "1";
$prf[$s."_recent_menu_amount"] = "5";
$prf[$s."_recent_menu_order"] = ($i+1);
$prf[$s."_recent_menu_icon"] = '';
$prf["$s_recent_page_display"] = "1";
$prf["$s_recent_page_open"] = "1";
$prf["$s_recent_page_author"] = "1";
$prf["$s_recent_page_category"] = "1";
$prf["$s_recent_page_date"] = "1";
$prf["$s_recent_page_amount"] = "10";
$prf["$s_recent_page_order"] = ($i+1);
$prf["$s_recent_page_icon"] = "1";
$prf[$s."_recent_page_display"] = "1";
$prf[$s."_recent_page_open"] = "1";
$prf[$s."_recent_page_author"] = "1";
$prf[$s."_recent_page_category"] = "1";
$prf[$s."_recent_page_date"] = "1";
$prf[$s."_recent_page_amount"] = "10";
$prf[$s."_recent_page_order"] = ($i+1);
$prf[$s."_recent_page_icon"] = "1";
$prf["$s_new_menu_display"] = "1";
$prf["$s_new_menu_open"] = "0";
$prf["$s_new_menu_author"] = "0";
$prf["$s_new_menu_category"] = "0";
$prf["$s_new_menu_date"] = "1";
$prf["$s_new_menu_amount"] = "5";
$prf["$s_new_menu_order"] = ($i+1);
$prf["$s_new_menu_icon"] = "1";
$prf[$s."_new_menu_display"] = "1";
$prf[$s."_new_menu_open"] = "0";
$prf[$s."_new_menu_author"] = "0";
$prf[$s."_new_menu_category"] = "0";
$prf[$s."_new_menu_date"] = "1";
$prf[$s."_new_menu_amount"] = "5";
$prf[$s."_new_menu_order"] = ($i+1);
$prf[$s."_new_menu_icon"] = "1";
$prf["$s_new_page_display"] = "1";
$prf["$s_new_page_open"] = "1";
$prf["$s_new_page_author"] = "1";
$prf["$s_new_page_category"] = "1";
$prf["$s_new_page_date"] = "1";
$prf["$s_new_page_amount"] = "10";
$prf["$s_new_page_order"] = ($i+1);
$prf["$s_new_page_icon"] = "1";
$prf[$s."_new_page_display"] = "1";
$prf[$s."_new_page_open"] = "1";
$prf[$s."_new_page_author"] = "1";
$prf[$s."_new_page_category"] = "1";
$prf[$s."_new_page_date"] = "1";
$prf[$s."_new_page_amount"] = "10";
$prf[$s."_new_page_order"] = ($i+1);
$prf[$s."_new_page_icon"] = "1";
}
//new menu preferences
@ -583,16 +590,15 @@ class listclass
if (e107::getPref('profanity_filter'))
{
$tp = e107::getParser();
if (!is_object($parser->e_pf))
if (!is_object($this->pf))
{
// require_once(e_HANDLER.'profanity_filter.php');
$parser->e_pf = new e_profanityFilter;
$this->pf = new e_profanityFilter;
}
foreach ($listArray as $k => $v)
{
if (isset($v['heading']))
{
$listArray[$k]['heading'] = $tp->e_pf->filterProfanities($v['heading']);
$listArray[$k]['heading'] = $this->pf->filterProfanities($v['heading']);
}
}
}
@ -781,6 +787,8 @@ class listclass
{
global $qs;
$text = '';
//get preferences
if(!isset($this->list_pref))
{

View File

@ -24,18 +24,12 @@ if (!defined('e107_INIT')) { exit; }
class list_shortcodes
{
var $rc;
var $rc; // list class.
var $e107;
var $row;
var $list_pref;
var $list_pref = array();
public $plugin;
function __construct()
{
$this->e107 = e107::getInstance();
$this->rc = '';
}
/*
function load_globals()
{
@ -90,37 +84,63 @@ class list_shortcodes
function sc_list_info()
{
if(empty($this->row['info']))
{
return null;
}
return e107::getParser()->toHTML($this->row['info'], true, "");
}
function sc_list_caption()
{
if(empty($this->rc->data) || empty($this->rc->data['caption']))
{
return null;
}
return e107::getParser()->toHTML($this->rc->data['caption'], true, "");
}
function sc_list_displaystyle()
{
//open sections if content exists ? yes if true, else use individual setting of section
return (vartrue($this->list_pref[$this->rc->mode."_openifrecords"]) && is_array($this->rc->data['records']) ? "" : $this->rc->data['display']);
$mode = $this->rc->mode."_openifrecords";
return (!empty($this->list_pref[$mode]) && isset($this->rc->data['records']) && is_array($this->rc->data['records'])) ? "" : varset($this->rc->data['display']);
}
function sc_list_col_cols()
{
if(empty($this->list_pref[$this->rc->mode."_colomn"]))
{
return null;
}
return $this->list_pref[$this->rc->mode."_colomn"];
}
function sc_list_col_welcometext()
{
if(empty($this->list_pref[$this->rc->mode."_welcometext"]))
{
return null;
}
return e107::getParser()->toHTML($this->list_pref[$this->rc->mode."_welcometext"], true, "");
}
function sc_list_col_cellwidth()
{
if(empty($this->list_pref[$this->rc->mode."_colomn"]))
{
return 25;
}
return round((100/$this->list_pref[$this->rc->mode."_colomn"]),0);
}
function sc_list_timelapse()
{
return $this->row['timelapse'];
return varset($this->row['timelapse']);
}
}

View File

@ -66,7 +66,7 @@ class pmbox_manager
{
$this->pmDB->gen($qry);
$pm_info[$which] = $this->pmDB->fetch();
if ($which == 'inbox' && ($this->pmPrefs['animate'] == 1 || $this->pmPrefs['popup'] == 1))
if ($which == 'inbox' && (!empty($this->pmPrefs['animate']) || !empty($this->pmPrefs['popup'])))
{
if($new = $this->pmDB->count('private_msg', '(*)', "WHERE pm_sent > '".USERLV."' AND pm_read = 0 AND pm_to = '".USERID."' AND pm_read_del != 1"))
{

View File

@ -115,7 +115,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
}
public function sc_pm_form_to($parm)
public function sc_pm_form_to($parm=null)
{
$userTo = $this->sc_pm_form_touser();
$classTo = $this->sc_pm_form_toclass();
@ -128,7 +128,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
if(deftrue('BOOTSTRAP'))
{
if(check_class($this->pmPrefs['opt_userclass']) )
if(isset($this->pmPrefs['opt_userclass']) && check_class($this->pmPrefs['opt_userclass']) )
{
$tab = array();
@ -168,7 +168,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
// $type = ($this->pmPrefs['dropdown'] == TRUE ? 'list' : 'popup');
if(check_class($this->pmPrefs['multi_class']))
if(isset($this->pmPrefs['multi_class']) && check_class($this->pmPrefs['multi_class']))
{
$ret = e107::getForm()->userpicker('pm_to', null, array('limit'=>10));
}
@ -198,7 +198,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
$ret = "";
if(check_class($this->pmPrefs['opt_userclass']) )
if(isset($this->pmPrefs['opt_userclass']) && check_class($this->pmPrefs['opt_userclass']) )
{
//$ret = "<input type='checkbox' name='to_userclass' value='1' />".LAN_PM_4." ";
@ -286,19 +286,19 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_post_button()
{
return "<input class='button btn btn-primary' type='submit' name='postpm' value='".LAN_PLUGIN_PM_NEW."' />";
return "<input class='button btn btn-primary' type='submit' name='postpm' value='".defset('LAN_PLUGIN_PM_NEW')."' />";
}
public function sc_pm_preview_button()
{
return "<input class='button btn' type='submit' name='postpm' value='".LAN_PM_3."' />";
return "<input class='button btn' type='submit' name='postpm' value='".defset('LAN_PM_3')."' />";
}
public function sc_pm_attachment()
{
if (check_class($this->pmPrefs['attach_class']))
if (isset($this->pmPrefs['attach_class']) && check_class($this->pmPrefs['attach_class']))
{
$ret = "
<div id='up_container' >
@ -322,9 +322,9 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_attachment_icon()
{
if($this->var['pm_attachments'] != "")
if(!empty($this->var['pm_attachments']))
{
return ATTACHMENT_ICON;
return defset('ATTACHMENT_ICON');
}
}
@ -333,7 +333,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
{
$tp = e107::getParser();
if($this->var['pm_attachments'] != '')
if(!empty($this->var['pm_attachments']))
{
$attachments = explode(chr(0), $this->var['pm_attachments']);
$i = 0;
@ -353,7 +353,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_receipt()
{
if (check_class($this->pmPrefs['receipt_class']))
if (isset($this->pmPrefs['receipt_class']) && check_class($this->pmPrefs['receipt_class']))
{
return "<input type='checkbox' name='receipt' value='1' />".LAN_PM_10;
}
@ -364,50 +364,50 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_inbox_total()
{
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
return (int) $pm_inbox['inbox']['total'];
return (int) varset($pm_inbox['inbox']['total']);
}
public function sc_pm_inbox_unread()
{
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
return (int) $pm_inbox['inbox']['unread'];
return (int) varset($pm_inbox['inbox']['unread']);
}
public function sc_pm_inbox_filled()
{
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
return ((int) $pm_inbox['inbox']['filled'] > 0 ? $pm_inbox['inbox']['filled'] : '');
return (isset($pm_inbox['inbox']['filled']) && ((int) $pm_inbox['inbox']['filled'] > 0)) ? $pm_inbox['inbox']['filled'] : '';
}
public function sc_pm_outbox_total()
{
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
return (int) $pm_outbox['outbox']['total'];
return (int) varset($pm_outbox['outbox']['total']);
}
public function sc_pm_outbox_unread()
{
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
return (int) $pm_outbox['outbox']['unread'];
return (int) varset($pm_outbox['outbox']['unread']);
}
public function sc_pm_outbox_filled()
{
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
return ((int) $pm_outbox['outbox']['filled'] > 0 ? $pm_outbox['outbox']['filled'] : '');
return (isset($pm_outbox['outbox']['filled']) && ((int) $pm_outbox['outbox']['filled'] > 0)) ? $pm_outbox['outbox']['filled'] : '';
}
public function sc_pm_date($parm = '')
public function sc_pm_date($parm = null)
{
$tp = e107::getParser();
if($parm)
if(!empty($parm))
{
return $tp->toDate($this->var['pm_sent'], $parm);
}
@ -468,14 +468,23 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
}
public function sc_pm_subject($parm = '')
public function sc_pm_subject($parm = null)
{
$tp = e107::getParser();
$ret = $tp->toHTML($this->var['pm_subject'], true, 'USER_TITLE');
$prm = explode(',',$parm);
if('link' === $prm[0])
if(is_string($parm))
{
$prm = explode(',', $parm);
}
else
{
$prm = $parm;
}
if('link' === varset($prm[0]))
{
$extra = '';
// TODO - go with only one route version - view/message ???
@ -522,11 +531,11 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
{
if($this->var['pm_read'] > 0 )
{
return PM_READ_ICON;
return defset('PM_READ_ICON');
}
else
{
return PM_UNREAD_ICON;
return defset('PM_UNREAD_ICON');
}
}
@ -545,7 +554,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
}
public function sc_pm_avatar($parm)
public function sc_pm_avatar($parm=null)
{
return e107::getParser()->toAvatar($this->var, $parm);
}
@ -661,7 +670,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_newpm_animate()
{
if($this->pmPrefs['animate'])
if(!empty($this->pmPrefs['animate']))
{
$pm_inbox = $this->pmManager->pm_getInfo('inbox');
if($pm_inbox['inbox']['new'] > 0)
@ -673,8 +682,13 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
}
public function sc_pm_nextprev($parm = '')
public function sc_pm_nextprev($parm = null)
{
if(empty($this->pmNextPrev['total']))
{
return null;
}
return e107::getParser()->parseTemplate("{NEXTPREV={$this->pmNextPrev['total']},{$this->pmPrefs['perpage']},{$this->pmNextPrev['start']},".e_SELF."?{$parm}.[FROM]}");
}
@ -690,15 +704,20 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_blocked_select()
{
if(!isset($this->pmBlocked['pm_block_from']))
{
return null;
}
return "<input type='checkbox' name='selected_pm[{$this->pmBlocked['pm_block_from']}]' value='1' />";
}
public function sc_pm_blocked_user($parm = '')
{
if (!$this->pmBlocked['user_name'])
if (empty($this->pmBlocked['user_name']))
{
$ret = LAN_PM_72;
$ret = defset('LAN_PM_72', "User deleted"); // define('LAN_PM_72', 'User deleted');
}
if('link' === $parm)
{
@ -708,7 +727,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
}
else
{
$ret = $this->pmBlocked['user_name'];
$ret = varset($this->pmBlocked['user_name']);
}
return $ret;
@ -717,12 +736,22 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_blocked_date($parm='')
{
if(empty($this->pmBlocked['pm_block_datestamp']))
{
return null;
}
return e107::getDate()->convert_date($this->pmBlocked['pm_block_datestamp'], $parm);
}
public function sc_pm_blocked_delete()
{
if(empty($this->pmBlocked['pm_block_from']))
{
return null;
}
return "<a href='".$this->url('action/delete-blocked', array('id' => $this->pmBlocked['pm_block_from']))."'><img src='".e_PLUGIN_ABS."pm/images/mail_delete.png' title='".LAN_DELETE."' alt='".LAN_DELETE."' class='icon S16' /></a>";
}
@ -740,7 +769,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
$class = (!empty($parm['class'])) ? $parm['class'] : 'btn btn-sm btn-primary btn-block-level';
return "<a class='".$class."' href='".$urlCompose."'>".$tp->toGlyph('fa-edit',' ')."".LAN_PLUGIN_PM_NEW."</a>";
return "<a class='".$class."' href='".$urlCompose."'>".$tp->toGlyph('fa-edit',' ')."".defset('LAN_PLUGIN_PM_NEW')."</a>";
}

View File

@ -159,10 +159,9 @@ class rss_ui extends e_admin_ui
global $i,$rss_shortcodes, $feed, $pref;
require_once(e_PLUGIN.'rss_menu/rss_shortcodes.php');
$rss_shortcodes = e107::getScBatch('rss_menu', true);
if(!isset($RSS_ADMIN_IMPORT_HEADER))
{
$RSS_ADMIN_IMPORT_HEADER = "
$RSS_ADMIN_IMPORT_HEADER = "
<form action='".e_SELF."' id='imlistform' method='post' >
<table class='table table-striped adminlist'>
<thead>
@ -175,10 +174,8 @@ class rss_ui extends e_admin_ui
<th>".RSS_LAN_ADMIN_12."</td>
</tr>
</thead><tbody>";
}
if(!isset($RSS_ADMIN_IMPORT_TABLE))
{
$RSS_ADMIN_IMPORT_TABLE = "
$RSS_ADMIN_IMPORT_TABLE = "
<tr>
<td class='first center'>{RSS_ADMIN_IMPORT_CHECK}</td>
<td>{RSS_ADMIN_IMPORT_NAME} - {RSS_ADMIN_IMPORT_TEXT}</td>
@ -187,85 +184,22 @@ class rss_ui extends e_admin_ui
<td>{RSS_ADMIN_IMPORT_URL}</td>
<td>{RSS_ADMIN_IMPORT_TOPICID}</td>
</tr>";
}
if(!isset($RSS_ADMIN_IMPORT_FOOTER))
{
$RSS_ADMIN_IMPORT_FOOTER = "</tbody>
$RSS_ADMIN_IMPORT_FOOTER = "</tbody>
</table>
<div class='buttons-bar center'>
".$frm->admin_button('import_rss',LAN_ADD,'submit')."
</div>
</form>
";
}
// global $RSS_ADMIN_IMPORT_HEADER, $RSS_ADMIN_IMPORT_TABLE, $RSS_ADMIN_IMPORT_FOOTER;
$sqli = new db;
$feedlist = array();
// @see e107_plugins/news/e_rss.php
/*
// News
$feed['name'] = ADLAN_0;
$feed['url'] = 'news'; // The identifier for the rss feed url
$feed['topic_id'] = ''; // The topic_id, empty on default (to select a certain category)
$feed['path'] = 'news'; // This is the plugin path location
$feed['text'] = RSS_PLUGIN_LAN_7;
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
// News categories
if($sqli ->select("news_category", "*","category_id!='' ORDER BY category_name "))
{
while($rowi = $sqli ->fetch())
{
$feed['name'] = ADLAN_0.' > '.$rowi['category_name'];
$feed['url'] = 'news';
$feed['topic_id'] = $rowi['category_id'];
$feed['path'] = 'news';
$feed['text'] = RSS_PLUGIN_LAN_10.' '.$rowi['category_name'];
$feed['class'] = '0';
$feed['limit'] = '9';
// $feed['exclude_class'] = '';
$feedlist[] = $feed;
}
}*/
/* // Download
$feed['name'] = ADLAN_24;
$feed['url'] = 'download';
$feed['topic_id'] = '';
$feed['path'] = 'download';
$feed['text'] = RSS_PLUGIN_LAN_8;
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
// Download categories
if($sqli ->select("download_category", "*","download_category_id!='' ORDER BY download_category_order "))
{
while($rowi = $sqli ->fetch())
{
$feed['name'] = ADLAN_24.' > '.$rowi['download_category_name'];
$feed['url'] = 'download';
$feed['topic_id'] = $rowi['download_category_id'];
$feed['path'] = 'download';
$feed['text'] = RSS_PLUGIN_LAN_11.' '.$rowi['download_category_name'];
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
}
}
*/
//
// Comments
$feed['name'] = LAN_COMMENTS;
$feed['url'] = 'comments';
@ -318,10 +252,12 @@ class rss_ui extends e_admin_ui
if(!$sql->select("rss", "*", "rss_path='".$feed['path']."' AND rss_url='".$feed['url']."' AND rss_topicid='".$feed['topic_id']."' "))
{
$render = TRUE;
$rss_shortcodes->setVars($feed);
$text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_TABLE, FALSE, $rss_shortcodes);
$i++;
}
}
$text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_FOOTER, FALSE, $rss_shortcodes);
if(!$render)
@ -330,7 +266,6 @@ class rss_ui extends e_admin_ui
}
else
{
// $ns->tablerender(RSS_LAN_ADMIN_11, $mes->render(). $text);
return $text;
}

View File

@ -112,14 +112,15 @@ if (empty($rss_type))
}
}
$text = $tp->parseTemplate($RSS_LIST_HEADER);
$text = $tp->parseTemplate($RSS_LIST_HEADER, true);
while($row = $sql->fetch())
{
$sc->setVars($row);
$text .= $tp->parseTemplate($RSS_LIST_TABLE, false, $sc);
}
$text .= $tp->parseTemplate($RSS_LIST_FOOTER);
$text .= $tp->parseTemplate($RSS_LIST_FOOTER, true);
$ns->tablerender(RSS_MENU_L2, $text);
}

View File

@ -11,279 +11,108 @@
*/
if (!defined('e107_INIT')) { exit; }
include_once(e_HANDLER.'shortcode_handler.php');
// $rss_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
class rss_menu_shortcodes extends e_shortcode
{
private $tp;
function __construct()
{
$this->tp = e107::getParser();
}
function sc_rss_feed()
{
global $row, $tp;
// $url2 = e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e107::url('rss_menu','rss', $row);
return "<a href='".$url2."'>".$tp->toHTML($row['rss_name'], TRUE)."</a>";
$url2 = e107::url('rss_menu','rss', $this->var);
return "<a href='".$url2."'>".$this->tp->toHTML($this->var['rss_name'], TRUE)."</a>";
}
function sc_rss_icon()
{
global $row, $tp;
// $url2 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e107::url('rss_menu','rss', $row);
return "<a href='".$url2."'>".RSS_ICON."</a>";
$url2 = e107::url('rss_menu','rss', $this->var);
return "<a href='".$url2."'>".defset('RSS_ICON')."</a>";
}
function sc_rss_text()
{
global $row, $tp;
return $tp->toHTML($row['rss_text'], TRUE, "defs");
return $this->tp->toHTML($this->var['rss_text'], TRUE, "defs");
}
function sc_rss_types()
{
global $row, $tp;
// $url1 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".1".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
// $url2 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
// $url3 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".3".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
// $url4 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".4".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e107::url('rss_menu','rss', $row);
$url4 = e107::url('rss_menu','atom', $row);
$url2 = e107::url('rss_menu','rss', $this->var);
$url4 = e107::url('rss_menu','atom', $this->var);
if(deftrue('BOOTSTRAP')) // v2.x
{
$text = "
<div>
<a class='btn btn-sm btn-default' href='".e107::url('rss_menu', 'rss', $row)."' title='RSS 2.0'>".$tp->toGlyph('fa-rss')." RSS</a>
<a class='btn btn-sm btn-default' href='".e107::url('rss_menu', 'atom', $row)."' title='ATOM'>".$tp->toGlyph('fa-rss')." Atom</a>
<a class='btn btn-sm btn-default' href='".$url2."' title='RSS 2.0'>".$this->tp->toGlyph('fa-rss')." RSS</a>
<a class='btn btn-sm btn-default' href='".$url4."' title='ATOM'>".$this->tp->toGlyph('fa-rss')." Atom</a>
</div>";
return $text;
}
$text = "";
// $text .= "<a href='".$url1."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss1.png' class='icon' alt='RSS 0.92' /></a>";
$text .= "<a href='".$url2."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss2.png' class='icon' alt='RSS 2.0' /></a>";
// $text .= "<a href='".$url3."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss3.png' class='icon' alt='RDF' /></a>";
$text .= "<a href='".$url4."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss4.png' class='icon' alt='ATOM' /></a>";
return $text;
}
//##### ADMIN --------------------------------------------------
function sc_rss_admin_caption($parm='')
{
global $sort;
list($field,$txt) = explode(",",$parm);
$txt = constant($txt);
return "<a href='".e_SELF."?list.{$field}.".($sort == "desc" ? "asc" : "desc")."'>".$txt."</a>\n";
}
function sc_rss_admin_id()
{
global $row;
return $row['rss_id'];
}
function sc_rss_admin_name()
{
global $row;
return $row['rss_name'];
}
function sc_rss_admin_path()
{
global $row;
return $row['rss_path'];
}
function sc_rss_admin_url()
{
global $row;
return "<a href='".e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$row['rss_url']."'>".$row['rss_url']."</a>";
}
function sc_rss_admin_topicid()
{
global $row;
return $row['rss_topicid'];
}
function sc_rss_admin_limit()
{
global $row, $rs;
$id = $row['rss_id'];
$frm = e107::getForm();
return $frm->number("limit[$id]",$row['rss_limit']);
return "<input class='tbox' type='text' name=\"limit[$id]\" title=\"".RSS_LAN05."\" value='".intval($row['rss_limit'])."' size='3' maxlength='3' />";
}
function sc_rss_admin_limitbutton()
{
$frm = e107::getForm();
return $frm->admin_button('update_limit',LAN_UPDATE,'update');
}
function sc_rss_admin_options()
{
global $row, $tp;
$delname = $row['rss_name'];
$delid = $row['rss_id'];
$options = "
<a href='".e_SELF."?create.edit.".$row['rss_id']."' >".ADMIN_EDIT_ICON."</a>
<input type='image' title=\"".LAN_DELETE."\" name='delete[{$delid}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(LAN_CONFIRMDEL ." [".LAN_ID.": ".$delid." : ".$delname."]\\n\\n")."')\"/>";
return $options;
}
function sc_rss_admin_form_name()
{
global $row;
return "<input class='tbox' type='text' name='rss_name' size='74' value=\"".$row['rss_name']."\" />\n";
}
function sc_rss_admin_form_url()
{
global $row,$PLUGINS_DIRECTORY;
return SITEURL.$PLUGINS_DIRECTORY."rss_menu/rss.php?".e_LANQRY." <input class='tbox' type='text' name='rss_url' size='10' value=\"".$row['rss_url']."\" maxlength='50' /> .{".LAN_TYPE."}.{".RSS_LAN_ADMIN_12."}";
}
function sc_rss_admin_form_topicid()
{
global $row;
return "<input class='tbox' type='text' name='rss_topicid' size='74' value=\"".$row['rss_topicid']."\" maxlength='250' />";
}
function sc_rss_admin_form_path()
{
global $row;
return "<input class='tbox' type='text' name='rss_path' size='74' value=\"".$row['rss_path']."\" maxlength='250' />";
}
function sc_rss_admin_form_text()
{
global $row;
return "<textarea class='tbox' name='rss_text' cols='74' rows='5' >".$row['rss_text']."</textarea>\n";
}
function sc_rss_admin_form_class()
{
global $row;
$vals = array(RSS_LAN_ADMIN_21,RSS_LAN_ADMIN_22,RSS_LAN_ADMIN_23);
$text = "<select class='tbox' name='rss_class'>";
foreach($vals as $key=>$val)
{
$sel = ($row['rss_class'] == $key) ? " selected='selected'" : "";
$text .= "<option value='{$key}'{$sel}>$val</option>\n";
}
$text .= "</select>";
return $text;
}
function sc_rss_admin_form_limit()
{
global $row;
$frm = e107::getForm();
return $frm->number('rss_limit',$row['rss_limit'],3);
return "<input class='tbox' name='rss_limit' size='3' title=\"".RSS_LAN05."\" value='".intval($row['rss_limit'])."' maxlength='3' />";
}
function sc_rss_admin_form_createbutton()
{
global $row;
$qs = explode(".", e_QUERY);
$frm = e107::getForm();
if(isset($qs[1]) && $qs[1] == "edit" && isset($qs[2]) && is_numeric($qs[2]) )
{
$text = "<input type='hidden' name='rss_datestamp' value='".$row['rss_datestamp']."' />
<input type='hidden' name='rss_id' value='".$row['rss_id']."' />";
$text .= $frm->admin_button('update_rss',LAN_UPDATE,'update');
}
else
{
$text = $frm->admin_button('create_rss',LAN_CREATE,'submit');
}
return $text;
}
function sc_rss_admin_import_check()
{
global $feed, $rs, $tp, $i;
if($feed['description'])
global $rs, $i;
if(!empty($this->var['description']))
{
$feed['text'] = $feed['description'];
$this->var['text'] = $this->var['description'];
}
$text = "<input id='import-".$i."' type='checkbox' name='importid[$i]' value='1' />";
$text .= "<input type='hidden' name='name[$i]' value='".$tp->toForm($feed['name'])."' />";
$text .= "<input type='hidden' name='url[$i]' value='".$tp->toForm($feed['url'])."' />";
$text .= "<input type='hidden' name='topic_id[$i]' value='".$tp->toForm($feed['topic_id'])."' />";
$text .= "<input type='hidden' name='path[$i]' value='".$tp->toForm($feed['path'])."' />";
$text .= "<input type='hidden' name='text[$i]' value='".$tp->toForm($feed['text'])."' />";
$text .= "<input type='hidden' name='class[$i]' value='".$tp->toForm($feed['class'])."' />";
$text .= "<input type='hidden' name='limit[$i]' value='".intval($feed['limit'])."' />";
$text .= "<input type='hidden' name='name[$i]' value='".$this->tp->toForm($this->var['name'])."' />";
$text .= "<input type='hidden' name='url[$i]' value='".$this->tp->toForm($this->var['url'])."' />";
$text .= "<input type='hidden' name='topic_id[$i]' value='".$this->tp->toForm($this->var['topic_id'])."' />";
$text .= "<input type='hidden' name='path[$i]' value='".$this->tp->toForm($this->var['path'])."' />";
$text .= "<input type='hidden' name='text[$i]' value='".$this->tp->toForm($this->var['text'])."' />";
$text .= "<input type='hidden' name='class[$i]' value='".$this->tp->toForm($this->var['class'])."' />";
$text .= "<input type='hidden' name='limit[$i]' value='".intval($this->var['limit'])."' />";
return $text;
}
function sc_rss_admin_import_path()
{
global $feed, $i;
return "<label for='import-".$i."'>".$feed['path']."</label>";
global $i;
return "<label for='import-".$i."'>".$this->var['path']."</label>";
}
function sc_rss_admin_import_name()
{
global $feed, $i;
return "<label for='import-".$i."'>".$feed['name']."</label>";
global $i;
return "<label for='import-".$i."'>".$this->var['name']."</label>";
}
function sc_rss_admin_import_text()
{
global $feed;
return ($feed['description']) ? $feed['description'] : $feed['text'];
return !empty($this->var['description']) ? $this->var['description'] : $this->var['text'];
}
function sc_rss_admin_import_url()
{
global $feed;
return $feed['url'];
return $this->var['url'];
}
function sc_rss_admin_import_topicid()
{
global $feed;
return $feed['topic_id'];
return $this->var['topic_id'];
}
}

View File

@ -19,6 +19,7 @@ if (!defined('e107_INIT'))
exit();
}
e107::plugLan('login_menu', null);
class plugin_signin_signin_shortcodes extends e_shortcode
{
@ -166,7 +167,7 @@ class plugin_signin_signin_shortcodes extends e_shortcode
{
return "<input type='hidden' name='autologin' id='autologin' value='1' />";
}
if ($pref['user_tracking'] !== "session")
if (varset($pref['user_tracking']) !== "session")
{
return "<input type='checkbox' name='autologin' id='autologin' value='1' checked='checked' />" . ($parm ? $parm : "" . LAN_LOGINMENU_6 );
}

View File

@ -710,12 +710,25 @@ while(&#036;row = &#036;sql-&gt;fetch())
{
}
*/
public function testSimpleParse()
{
$vars = array(
'CONTACT_SUBJECT'=> "My Subject",
'CONTACT_PERSON' => "My Name"
);
$template = "{CONTACT_SUBJECT} <b>{CONTACT_PERSON}</b>{MISSING_SHORTCODE}";
$result = $this->tp->simpleParse($template, $vars);
$this->assertEquals("My Subject <b>My Name</b>", $result);
$result = $this->tp->simpleParse($template, null);
$this->assertEquals(" <b></b>", $result);
}
*/
public function testToText()
{
$arr = array(

View File

@ -1222,6 +1222,146 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
}
public function testPMShortcodes()
{
require_once(e_PLUGIN."pm/pm_shortcodes.php");
try
{
/** @var plugin_pm_pm_shortcodes $sc */
$sc = $this->make('plugin_pm_pm_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$sc->__construct();
$vars = array(
'pm_id' => 5,
'pm_sent' => time(),
'pm_read' => 0,
'pm_from' => 1,
'from_name' => 'admin',
'pm_to' => 1,
'pm_block_datestamp' => time(),
'pm_block_from'=> 2,
);
$sc->setVars($vars);
$this->processShortcodeMethods($sc);
}
public function testRSSShortcodes()
{
require_once(e_PLUGIN."rss_menu/rss_shortcodes.php");
try
{
/** @var rss_menu_shortcodes $sc */
$sc = $this->make('rss_menu_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$sc->__construct();
$vars = array(
'rss_id' => '1',
'rss_name' => 'News',
'rss_url' => 'news',
'rss_topicid' => '0',
'rss_path' => '0',
'rss_text' => 'The rss feed of the news',
'rss_datestamp' => '1456448477',
'rss_class' => '0',
'rss_limit' => '10',
// import shortcodes.
'name' => "Comments",
'url' => 'comments',
'topic_id' => '',
'path' => 'comments',
'text' => 'the rss feed of comments',
'class' => '0',
'limit' => '9',
);
$sc->setVars($vars);
$this->processShortcodeMethods($sc);
}
public function testSigninShortcodes()
{
require_once(e_PLUGIN."signin/signin_shortcodes.php");
try
{
/** @var plugin_signin_signin_shortcodes $sc */
$sc = $this->make('plugin_signin_signin_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$sc->__construct();
$this->processShortcodeMethods($sc);
}
public function testListShortcodes()
{
require_once(e_PLUGIN."list_new/list_shortcodes.php");
require_once(e_PLUGIN."list_new/list_class.php");
try
{
/** @var list_shortcodes $sc */
$sc = $this->make('list_shortcodes');
}
catch (Exception $e)
{
$this->fail($e->getMessage());
}
$sc->rc = new listclass;
$vars = array (
'caption' => 'My Caption',
'display' => '1',
'open' => '1',
'author' => '',
'category' => '1',
'date' => '',
'icon' => '',
'amount' => '1',
'order' => '1',
'section' => 'news',
);
$sc->row = $vars;
$exclude = array('sc_list_category'); // unknown issue.
$this->processShortcodeMethods($sc, $exclude);
}
/*
@ -1229,24 +1369,7 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
e107_plugins\links_page (1 usage found)
links_page_shortcodes.php (1 usage found)
1 <?php
e107_plugins\list_new (1 usage found)
list_shortcodes.php (1 usage found)
1 <?php
e107_plugins\login_menu (1 usage found)
login_menu_shortcodes.php (1 usage found)
1 <?php
e107_plugins\online (1 usage found)
online_shortcodes.php (1 usage found)
1 <?php
e107_plugins\pm (1 usage found)
pm_shortcodes.php (1 usage found)
1 <?php
e107_plugins\rss_menu (1 usage found)
rss_shortcodes.php (1 usage found)
1 <?php
e107_plugins\signin (1 usage found)
signin_shortcodes.php (1 usage found)
1 <?php
*/