diff --git a/e107_admin/admin.php b/e107_admin/admin.php index 5e5276417..c7041fb47 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -103,6 +103,7 @@ class admin_start array('jshelpers', '0.3b'), array('akismet', 7.0), array('newforumposts_main', 1), + array('fancybox', '2.06b'), ); diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index e9e3f33dd..ce2b8cab1 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -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. } diff --git a/e107_plugins/forum/newforumposts_menu.php b/e107_plugins/forum/newforumposts_menu.php index f19823060..89482a329 100755 --- a/e107_plugins/forum/newforumposts_menu.php +++ b/e107_plugins/forum/newforumposts_menu.php @@ -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; + } + + } + + } diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 0708b8941..90aae1973 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -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']);