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).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/admin_config.php,v $
|
| $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 )
|
| ***** 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 $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
require_once("../../class2.php");
|
require_once("../../class2.php");
|
||||||
if (!plugInstalled('linkwords')) header("Location: ".e_BASE."index.php");
|
if (!getperms("P") || !plugInstalled('linkwords'))
|
||||||
if (!getperms("P"))
|
|
||||||
{
|
{
|
||||||
header("location:".e_BASE."index.php");
|
header("location:".e_BASE."index.php");
|
||||||
exit ;
|
exit ;
|
||||||
}
|
}
|
||||||
require_once(e_ADMIN."auth.php");
|
require_once(e_ADMIN."auth.php");
|
||||||
@include_lan(e_PLUGIN."linkwords/languages/".e_LANGUAGE."_admin_linkwords.php");
|
@include_lan(e_PLUGIN."linkwords/languages/".e_LANGUAGE."_admin_linkwords.php");
|
||||||
|
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
||||||
|
|
||||||
$lw_context_areas = array(
|
$lw_context_areas = array(
|
||||||
'TITLE' => LWLAN_33,
|
'TITLE' => LWLAN_33,
|
||||||
@@ -69,6 +69,7 @@ if(isset($deltest[LWLAN_17]))
|
|||||||
{
|
{
|
||||||
$sql->db_Delete("linkwords", "linkword_id=".$delete_id);
|
$sql->db_Delete("linkwords", "linkword_id=".$delete_id);
|
||||||
$admin_log->log_event('LINKWD_03','ID: '.$delete_id,'');
|
$admin_log->log_event('LINKWD_03','ID: '.$delete_id,'');
|
||||||
|
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
||||||
$message = LWLAN_19;
|
$message = LWLAN_19;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,23 +98,24 @@ if (isset($_POST['saveopts_linkword']))
|
|||||||
'LINKTEXT' => FALSE,
|
'LINKTEXT' => FALSE,
|
||||||
'RAWTEXT' => FALSE
|
'RAWTEXT' => FALSE
|
||||||
);
|
);
|
||||||
foreach ($_POST['lw_visibility_area'] as $can_see)
|
foreach ($_POST['lw_visibility_area'] as $can_see)
|
||||||
{
|
|
||||||
if (key_exists($can_see,$lw_context_areas))
|
|
||||||
{
|
{
|
||||||
$pref['lw_context_visibility'][$can_see] = TRUE;
|
if (key_exists($can_see,$lw_context_areas))
|
||||||
|
{
|
||||||
|
$pref['lw_context_visibility'][$can_see] = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// Text area for 'exclude' pages - use same method as for menus
|
||||||
// Text area for 'exclude' pages - use same method as for menus
|
$pagelist = explode("\r\n", $_POST['linkword_omit_pages']);
|
||||||
$pagelist = explode("\r\n", $_POST['linkword_omit_pages']);
|
for ($i = 0 ; $i < count($pagelist) ; $i++)
|
||||||
for ($i = 0 ; $i < count($pagelist) ; $i++)
|
{
|
||||||
{
|
$pagelist[$i] = trim($pagelist[$i]);
|
||||||
$pagelist[$i] = trim($pagelist[$i]);
|
}
|
||||||
}
|
$pref['lw_page_visibility'] = '2-'.implode("|", $pagelist); // '2' for 'hide on specified pages'
|
||||||
$pref['lw_page_visibility'] = '2-'.implode("|", $pagelist); // '2' for 'hide on specified pages'
|
$pref['lw_ajax_enable'] = isset($_POST['lw_ajax_enable']);
|
||||||
$pref['lw_ajax_enable'] = isset($_POST['lw_ajax_enable']);
|
save_prefs();
|
||||||
save_prefs();
|
$logString = implode(', ',$pref['lw_context_visibility']).'[!br!]'.$pref['lw_page_visibility'].'[!br!]'.$pref['lw_ajax_enable'];
|
||||||
$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,'');
|
$admin_log->log_event('LINKWD_04',$logString,'');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +162,7 @@ if (isset($_POST['submit_linkword']) || isset($_POST['update_linkword']))
|
|||||||
$message = LWLAN_57;
|
$message = LWLAN_57;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/e_tohtml.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/e_tohtml.php,v $
|
||||||
| $Revision: 1.3 $
|
| $Revision: 1.4 $
|
||||||
| $Date: 2008-12-07 21:55:01 $
|
| $Date: 2008-12-13 18:04:52 $
|
||||||
| $Author: e107steved $
|
| $Author: e107steved $
|
||||||
|
|
|
|
||||||
| *utf - flags functions which need utf-8-aware code
|
| *utf - flags functions which need utf-8-aware code
|
||||||
@@ -27,6 +27,8 @@ TODO:
|
|||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
if (!plugInstalled('linkwords')) exit;
|
if (!plugInstalled('linkwords')) exit;
|
||||||
|
|
||||||
|
define('LW_CACHE_ENABLE', TRUEE);
|
||||||
|
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
||||||
|
|
||||||
class e_tohtml_linkwords
|
class e_tohtml_linkwords
|
||||||
{
|
{
|
||||||
@@ -37,72 +39,96 @@ class e_tohtml_linkwords
|
|||||||
var $link_list = array(); // Corresponding list of links to apply
|
var $link_list = array(); // Corresponding list of links to apply
|
||||||
var $ext_list = array(); // Flags to determine 'open in new window' for link
|
var $ext_list = array(); // Flags to determine 'open in new window' for link
|
||||||
var $tip_list = array(); // Store for tooltips
|
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 $area_opts = array(); // Process flags for the various contexts
|
||||||
var $block_list = array(); // Array of 'blocked' pages
|
var $block_list = array(); // Array of 'blocked' pages
|
||||||
var $LinkID = array(); // Unique ID for each linkword
|
|
||||||
|
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
function e_tohtml_linkwords()
|
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!
|
// 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
|
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 : '');
|
$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
|
$this->block_list = explode("|",substr(varset($pref['lw_page_visibility'],''),2)); // Knock off the 'show/hide' flag
|
||||||
foreach ($this->block_list as $p)
|
foreach ($this->block_list as $p)
|
||||||
{
|
|
||||||
if ($p=trim($p))
|
|
||||||
{
|
{
|
||||||
if(substr($p, -1) == '!')
|
if ($p=trim($p))
|
||||||
{
|
{
|
||||||
$p = substr($p, 0, -1);
|
if(substr($p, -1) == '!')
|
||||||
if(substr($check_url, strlen($p)*-1) == $p) return;
|
{
|
||||||
}
|
$p = substr($p, 0, -1);
|
||||||
else
|
if(substr($check_url, strlen($p)*-1) == $p) return;
|
||||||
{
|
}
|
||||||
if(strpos($check_url, $p) !== FALSE) return;
|
else
|
||||||
}
|
{
|
||||||
}
|
if(strpos($check_url, $p) !== FALSE) return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Will probably need linkwords on this page - so get the info
|
// Will probably need linkwords on this page - so get the info
|
||||||
$link_sql = new db;
|
if (LW_CACHE_ENABLE && ($temp = $e107->ecache->retrieve_sys(LW_CACHE_TAG)))
|
||||||
if($link_sql -> db_Select("linkwords", "*", "linkword_active!=1"))
|
{
|
||||||
{
|
$ret = eval($temp);
|
||||||
$this->lw_enabled = TRUE;
|
if ($ret)
|
||||||
while ($row = $link_sql->db_Fetch())
|
{
|
||||||
{
|
echo "Error reading linkwords cache: {$ret}<br />";
|
||||||
extract($row);
|
$temp = '';
|
||||||
// $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
|
|
||||||
$lwID = max($row['linkword_tip_id'], $row['linkword_id']); // If no specific ID defined, use the DB record ID
|
|
||||||
if (strpos($lw,','))
|
|
||||||
{ // Several words to same link
|
|
||||||
$lwlist = explode(',',$lw);
|
|
||||||
foreach ($lwlist as $lw)
|
|
||||||
{
|
|
||||||
$this->word_list[] = trim($lw);
|
|
||||||
$this->link_list[] = $linkword_link;
|
|
||||||
$this->tip_list[] = $linkword_tooltip;
|
|
||||||
$this->ext_list[] = $linkword_newwindow;
|
|
||||||
$this->LinkID[] = $lwID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->word_list[] = $lw;
|
$this->lw_enabled = TRUE;
|
||||||
$this->link_list[] = $linkword_link;
|
|
||||||
$this->tip_list[] = $linkword_tooltip;
|
|
||||||
$this->ext_list[] = $linkword_newwindow;
|
|
||||||
$this->LinkID[] = $lwID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
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"))
|
||||||
|
{
|
||||||
|
$this->lw_enabled = TRUE;
|
||||||
|
while ($row = $link_sql->db_Fetch())
|
||||||
|
{
|
||||||
|
extract($row);
|
||||||
|
$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
|
||||||
|
$lwID = max($row['linkword_tip_id'], $row['linkword_id']); // If no specific ID defined, use the DB record ID
|
||||||
|
if (strpos($lw,','))
|
||||||
|
{ // Several words to same link
|
||||||
|
$lwlist = explode(',',$lw);
|
||||||
|
foreach ($lwlist as $lw)
|
||||||
|
{
|
||||||
|
$this->word_list[] = trim($lw);
|
||||||
|
$this->link_list[] = $linkword_link;
|
||||||
|
$this->tip_list[] = $linkword_tooltip;
|
||||||
|
$this->ext_list[] = $linkword_newwindow;
|
||||||
|
$this->LinkID[] = $lwID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->word_list[] = $lw;
|
||||||
|
$this->link_list[] = $linkword_link;
|
||||||
|
$this->tip_list[] = $linkword_tooltip;
|
||||||
|
$this->ext_list[] = $linkword_newwindow;
|
||||||
|
$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->area_opts = $pref['lw_context_visibility'];
|
||||||
$this->utfMode = (strtolower(CHARSET) == 'utf-8') ? 'u' : ''; // Flag to enable utf-8 on regex
|
$this->utfMode = (strtolower(CHARSET) == 'utf-8') ? 'u' : ''; // Flag to enable utf-8 on regex
|
||||||
$this->lwAjaxEnabled = varset($pref['lw_ajax_enable'],0);
|
$this->lwAjaxEnabled = varset($pref['lw_ajax_enable'],0);
|
||||||
|
Reference in New Issue
Block a user