mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 17:14:42 +02:00
Linkwords - add caching
This commit is contained in:
@@ -11,23 +11,23 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/admin_config.php,v $
|
||||
| $Revision: 1.7 $
|
||||
| $Revision: 1.8 $
|
||||
|
|
||||
| ***** START OF VERSION WHICH ALLOWS TOOLTIPS (also order of forms changed )
|
||||
|
|
||||
| $Date: 2008-12-07 21:55:01 $
|
||||
| $Date: 2008-12-13 18:04:52 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
require_once("../../class2.php");
|
||||
if (!plugInstalled('linkwords')) header("Location: ".e_BASE."index.php");
|
||||
if (!getperms("P"))
|
||||
if (!getperms("P") || !plugInstalled('linkwords'))
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
exit ;
|
||||
}
|
||||
require_once(e_ADMIN."auth.php");
|
||||
@include_lan(e_PLUGIN."linkwords/languages/".e_LANGUAGE."_admin_linkwords.php");
|
||||
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
||||
|
||||
$lw_context_areas = array(
|
||||
'TITLE' => LWLAN_33,
|
||||
@@ -69,6 +69,7 @@ if(isset($deltest[LWLAN_17]))
|
||||
{
|
||||
$sql->db_Delete("linkwords", "linkword_id=".$delete_id);
|
||||
$admin_log->log_event('LINKWD_03','ID: '.$delete_id,'');
|
||||
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
||||
$message = LWLAN_19;
|
||||
}
|
||||
}
|
||||
@@ -114,6 +115,7 @@ if (isset($_POST['saveopts_linkword']))
|
||||
$pref['lw_ajax_enable'] = isset($_POST['lw_ajax_enable']);
|
||||
save_prefs();
|
||||
$logString = implode(', ',$pref['lw_context_visibility']).'[!br!]'.$pref['lw_page_visibility'].'[!br!]'.$pref['lw_ajax_enable'];
|
||||
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
||||
$admin_log->log_event('LINKWD_04',$logString,'');
|
||||
}
|
||||
|
||||
@@ -160,6 +162,7 @@ if (isset($_POST['submit_linkword']) || isset($_POST['update_linkword']))
|
||||
$message = LWLAN_57;
|
||||
}
|
||||
}
|
||||
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/e_tohtml.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2008-12-07 21:55:01 $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-12-13 18:04:52 $
|
||||
| $Author: e107steved $
|
||||
|
|
||||
| *utf - flags functions which need utf-8-aware code
|
||||
@@ -27,6 +27,8 @@ TODO:
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
if (!plugInstalled('linkwords')) exit;
|
||||
|
||||
define('LW_CACHE_ENABLE', TRUEE);
|
||||
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
||||
|
||||
class e_tohtml_linkwords
|
||||
{
|
||||
@@ -37,19 +39,19 @@ class e_tohtml_linkwords
|
||||
var $link_list = array(); // Corresponding list of links to apply
|
||||
var $ext_list = array(); // Flags to determine 'open in new window' for link
|
||||
var $tip_list = array(); // Store for tooltips
|
||||
var $LinkID = array(); // Unique ID for each linkword
|
||||
var $area_opts = array(); // Process flags for the various contexts
|
||||
var $block_list = array(); // Array of 'blocked' pages
|
||||
var $LinkID = array(); // Unique ID for each linkword
|
||||
|
||||
|
||||
/* constructor */
|
||||
function e_tohtml_linkwords()
|
||||
{
|
||||
global $pref, $tp;
|
||||
global $pref, $tp, $e107;
|
||||
// See whether they should be active on this page - if not, no point doing anything!
|
||||
if ((strpos(e_SELF, ADMINDIR) !== FALSE) || (strpos(e_PAGE, "admin_") !== FALSE)) return; // No linkwords on admin directories
|
||||
|
||||
// Now see if disabled on specific pages
|
||||
// Now see if disabled on specific pages
|
||||
$check_url = e_SELF.(e_QUERY ? "?".e_QUERY : '');
|
||||
$this->block_list = explode("|",substr(varset($pref['lw_page_visibility'],''),2)); // Knock off the 'show/hide' flag
|
||||
foreach ($this->block_list as $p)
|
||||
@@ -69,6 +71,21 @@ class e_tohtml_linkwords
|
||||
}
|
||||
|
||||
// Will probably need linkwords on this page - so get the info
|
||||
if (LW_CACHE_ENABLE && ($temp = $e107->ecache->retrieve_sys(LW_CACHE_TAG)))
|
||||
{
|
||||
$ret = eval($temp);
|
||||
if ($ret)
|
||||
{
|
||||
echo "Error reading linkwords cache: {$ret}<br />";
|
||||
$temp = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->lw_enabled = TRUE;
|
||||
}
|
||||
}
|
||||
if (!$temp)
|
||||
{ // Either cache disabled, or no info in cache (or error reading/processing cache)
|
||||
$link_sql = new db;
|
||||
if($link_sql -> db_Select("linkwords", "*", "linkword_active!=1"))
|
||||
{
|
||||
@@ -76,7 +93,6 @@ class e_tohtml_linkwords
|
||||
while ($row = $link_sql->db_Fetch())
|
||||
{
|
||||
extract($row);
|
||||
// $lw = strtolower($linkword_word); // It was trimmed when saved *utf
|
||||
$lw = $tp->uStrToLower($linkword_word); // It was trimmed when saved *utf
|
||||
if ($linkword_active == 2) $linkword_link = ''; // Make sure linkword disabled
|
||||
if ($linkword_active < 2) $linkword_tooltip = ''; // Make sure tooltip disabled
|
||||
@@ -102,6 +118,16 @@ class e_tohtml_linkwords
|
||||
$this->LinkID[] = $lwID;
|
||||
}
|
||||
}
|
||||
if (LW_CACHE_ENABLE)
|
||||
{ // Write to file for next time
|
||||
$temp = '';
|
||||
foreach (array('word_list', 'link_list', 'tip_list', 'ext_list', 'LinkID') as $var)
|
||||
{
|
||||
$temp .= '$this->'.$var.'='.var_export($this->$var, TRUE).";\n";
|
||||
}
|
||||
$e107->ecache->set_sys(LW_CACHE_TAG,$temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->area_opts = $pref['lw_context_visibility'];
|
||||
$this->utfMode = (strtolower(CHARSET) == 'utf-8') ? 'u' : ''; // Flag to enable utf-8 on regex
|
||||
|
Reference in New Issue
Block a user