1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Cache added to newforumposts_menu.php. Fancybox 2.06b added to incompatible plugin list. (it loads an old version of jQuery) . Fix for BC replacement of newforumposts_main not rendering.

This commit is contained in:
Cameron
2020-05-06 13:33:01 -07:00
parent def50c174d
commit 8ac7f1fdf1
4 changed files with 66 additions and 41 deletions

View File

@@ -103,6 +103,7 @@ class admin_start
array('jshelpers', '0.3b'),
array('akismet', 7.0),
array('newforumposts_main', 1),
array('fancybox', '2.06b'),
);

View File

@@ -507,6 +507,7 @@ class e_plugin
if(version_compare($curVal,$version,"<")) // check pref version against file version.
{
e107::getDebug()->log($curVal." vs ".$version);
$needed[$path] = $version;
}
@@ -948,7 +949,7 @@ class e_plugin
$ret['@attributes']['name'] = varset($eplug_name);
$ret['@attributes']['lan'] = varset($eplug_name);
$ret['@attributes']['version'] = $this->_fixVersion($eplug_version);
$ret['@attributes']['version'] = $this->_fixVersion($eplug_version, true);
$ret['@attributes']['date'] = varset($eplug_date);
$ret['@attributes']['compatibility'] = $this->_fixCompat($eplug_compatible);
$ret['@attributes']['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest) ? 'true' : '';
@@ -1031,7 +1032,7 @@ class e_plugin
}
private function _fixVersion($ver)
private function _fixVersion($ver, $legacy=false)
{
if(empty($ver))
@@ -1041,8 +1042,9 @@ class e_plugin
$ver = str_replace('e107','',$ver);
$regex = ($legacy === true) ? '/([^\d\.ab])/' : '/([^\d\.])/';
return preg_replace('/([^\d\.])/','',$ver);
return preg_replace($regex,'',$ver); // eg. 2.0.1b okay for BC plugin.
}

View File

@@ -19,16 +19,18 @@ if(!class_exists('forum_newforumposts_menu'))
class forum_newforumposts_menu // plugin folder + menu name (without the .php)
{
private $plugPref = null;
private $menuPref = null;
private $forumObj = null;
private $plugPref;
private $menuPref;
private $forumObj;
private $total = array();
private $cacheTag = 'nfpCache';
private $cacheTime = 1; // cache time in minutes.
function __construct()
{
$this->forumObj = new e107forum;
$this->plugPref = e107::pref('forum'); // general forum preferences.
$this->menuPref = e107::getMenu()->pref();// ie. popup config details from within menu-manager.
$this->forumObj = new e107forum;
// Set some defaults ...
if (!isset($this->menuPref['title'])) $this->menuPref['title'] = "";
@@ -39,6 +41,16 @@ if(!class_exists('forum_newforumposts_menu'))
if (!isset($this->menuPref['scroll'])) $this->menuPref['scroll'] = "";
if (empty($this->menuPref['layout'])) $this->menuPref['layout'] = 'default';
$this->cacheTag .= "_".$this->menuPref['layout'];
if($text = e107::getCache()->retrieve($this->cacheTag, $this->cacheTime, true))
{
e107::getDebug()->log("New Forum Posts Menu Cache Rendered");
$caption = $this->getCaption();
e107::getRender()->tablerender($caption, $text, 'nfp_menu');
return null;
}
$sql = e107::getDb();
@@ -57,7 +69,7 @@ if(!class_exists('forum_newforumposts_menu'))
function getQuery()
private function getQuery()
{
$max_age = vartrue($this->menuPref['maxage'], 0);
$max_age = ($max_age == 0) ? '' : '(p.post_datestamp > '.(time()-(int)$max_age*86400).') AND ';
@@ -70,7 +82,6 @@ if(!class_exists('forum_newforumposts_menu'))
return false;
}
$qry = '';
$this->menuPref['layout'] = vartrue($this->menuPref['layout'], 'default');
switch($this->menuPref['layout'])
@@ -122,13 +133,11 @@ if(!class_exists('forum_newforumposts_menu'))
}
// TODO: cache menu.
function render()
private function render()
{
$tp = e107::getParser();
$sql = e107::getDb('nfp');
$pref = e107::getPref();
// $pref = e107::getPref();
$qry = $this->getQuery();
$ns = e107::getRender();
@@ -200,33 +209,7 @@ if(!class_exists('forum_newforumposts_menu'))
$text = LAN_FORUM_MENU_016;
}
if(!empty($this->menuPref['caption']))
{
if (array_key_exists(e_LANGUAGE, $this->menuPref['caption']))
{
// Language key exists
$caption = vartrue($this->menuPref['caption'][e_LANGUAGE], LAN_PLUGIN_FORUM_LATESTPOSTS);
}
elseif (is_array($this->menuPref['caption']))
{
// Language key not found
$keys = array_keys($caption = $this->menuPref['caption']);
// Just first language key from the list
$caption = vartrue($this->menuPref['caption'][$keys[0]], LAN_PLUGIN_FORUM_LATESTPOSTS);
}
else
{
// No multilan array, just plain text
$caption = vartrue($this->menuPref['caption'], LAN_PLUGIN_FORUM_LATESTPOSTS);
}
//$caption = !empty($this->menuPref['caption'][e_LANGUAGE]) ? $this->menuPref['caption'][e_LANGUAGE] : $this->menuPref['caption'];
}
if(empty($caption))
{
$caption = LAN_PLUGIN_FORUM_LATESTPOSTS;
}
$caption = $this->getCaption();
if(!empty($this->menuPref['scroll']))
{
@@ -234,11 +217,50 @@ if(!class_exists('forum_newforumposts_menu'))
}
// e107::debug('menuPref', $this->menuPref);
e107::getCache()->set($this->cacheTag, $text, true);
$ns->tablerender($caption, $text, 'nfp_menu');
}
private function getCaption()
{
if (!empty($this->menuPref['caption']))
{
if (array_key_exists(e_LANGUAGE, $this->menuPref['caption']))
{
// Language key exists
$caption = vartrue($this->menuPref['caption'][e_LANGUAGE], LAN_PLUGIN_FORUM_LATESTPOSTS);
}
elseif (is_array($this->menuPref['caption']))
{
// Language key not found
$keys = array_keys($caption = $this->menuPref['caption']);
// Just first language key from the list
$caption = vartrue($this->menuPref['caption'][$keys[0]], LAN_PLUGIN_FORUM_LATESTPOSTS);
}
else
{
// No multilan array, just plain text
$caption = vartrue($this->menuPref['caption'], LAN_PLUGIN_FORUM_LATESTPOSTS);
}
//$caption = !empty($this->menuPref['caption'][e_LANGUAGE]) ? $this->menuPref['caption'][e_LANGUAGE] : $this->menuPref['caption'];
}
if (empty($caption))
{
$caption = LAN_PLUGIN_FORUM_LATESTPOSTS;
}
return $caption;
}
}
}

View File

@@ -180,7 +180,7 @@ class news_front
*/
private function renderNewForumPosts()
{
if(e107::isInstalled('newforumposts_main') && !empty($this->pref['nfp_display']))
if(deftrue('THEME_LEGACY') && !empty($this->pref['nfp_display']))
{
$parms = array('layout'=>'main', 'display'=>$this->pref['nfp_amount']);