1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-29 10:38:08 +01:00

New improved message handler - work in progress

This commit is contained in:
secretr 2008-12-11 18:13:10 +00:00
parent ca57d71401
commit 8d8be1b5cf
4 changed files with 403 additions and 82 deletions

View File

@ -1,32 +1,34 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| ©Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $
| $Revision: 1.4 $
| $Date: 2008-11-02 11:04:29 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Cache Administration Area
*
* $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $
* $Revision: 1.5 $
* $Date: 2008-12-11 18:13:10 $
* $Author: secretr $
*
*/
require_once("../class2.php");
if (!getperms("C"))
if (!getperms("C"))
{
header("location:".e_BASE."index.php");
exit;
}
$e_sub_cat = 'cache';
require_once("auth.php");
require_once(e_HANDLER."cache_handler.php");
$ec = new ecache;
if ($pref['cachestatus'] == '2')
$message = array();
if ($pref['cachestatus'] == '2')
{
$pref['cachestatus'] = '1';
save_prefs();
@ -39,37 +41,49 @@ if(!is_writable(e_CACHE))
exit;
}
/*
* XXX WORK IN PROGRESS - WAITING THE NEW MESSAGE HANDLER
*/
if (isset($_POST['submit_cache']))
{
if ($pref['cachestatus'] != $_POST['cachestatus'] || $pref['syscachestatus'] != $_POST['syscachestatus'])
{
$pref['cachestatus'] = $_POST['cachestatus'];
$pref['syscachestatus'] = $_POST['syscachestatus'];
$pref['cachestatus'] = $_POST['cachestatus'] ? '1' : '0';
$pref['syscachestatus'] = $_POST['syscachestatus'] ? '1' : '0';
save_prefs();
$admin_log->log_event('CACHE_01',$pref['syscachestatus'].', '.$pref['cachestatus'],E_LOG_INFORMATIVE,'');
$admin_log->log_event('CACHE_01', $pref['syscachestatus'].', '.$pref['cachestatus'], E_LOG_INFORMATIVE,'');
$ec->clear();
$ec->clear_sys();
$update = true;
admin_update($update, 'update', CACLAN_4);
//FIXME - admin_update - return formatted message instead tablerender & output, new message handler
//admin_update(true, 'update', CACLAN_4);
$message = array(LAN_UPDATE, CACLAN_4);
}
}
if (isset($_POST['empty_syscache']))
if (isset($_POST['empty_syscache']))
{
$ec->clear_sys();
$admin_log->log_event('CACHE_02',$pref['syscachestatus'].', '.$pref['cachestatus'],E_LOG_INFORMATIVE,'');
$ns->tablerender(LAN_UPDATE, "<div style='text-align:center'><b>".CACLAN_15."</b></div>");
$admin_log->log_event('CACHE_02', $pref['syscachestatus'].', '.$pref['cachestatus'], E_LOG_INFORMATIVE, '');
//$ns->tablerender(LAN_UPDATE, "<div style='text-align:center'><b>".CACLAN_15."</b></div>");
$message = array(LAN_UPDATE, CACLAN_15);
}
if (isset($_POST['empty_cache']))
if (isset($_POST['empty_cache']))
{
$ec->clear();
$admin_log->log_event('CACHE_03',$pref['syscachestatus'].', '.$pref['cachestatus'],E_LOG_INFORMATIVE,'');
$ns->tablerender(LAN_UPDATE, "<div style='text-align:center'><b>".CACLAN_6."</b></div>");
$admin_log->log_event('CACHE_03', $pref['syscachestatus'].', '.$pref['cachestatus'], E_LOG_INFORMATIVE, '');
//$ns->tablerender(LAN_UPDATE, "<div style='text-align:center'><b>".CACLAN_6."</b></div>");
$message = array(LAN_UPDATE, CACLAN_6);
}
$syscache_files = glob($e107->file_path.$FILES_DIRECTORY."cache/S_*.*");
$cache_files = glob($e107->file_path.$FILES_DIRECTORY."cache/C_*.*");
@ -107,7 +121,7 @@ $text = "<div style='text-align:center'>
</td>
</tr>
<tr style='vertical-align:top'>
<td colspan='3' style='text-align:center' class='forumheader'>
<input class='button' type='submit' name='submit_cache' value=\"".CACLAN_2."\" />
@ -116,8 +130,8 @@ $text = "<div style='text-align:center'>
</table>
</form>
</div>";
$ns->tablerender(CACLAN_3, $text);
require_once("footer.php");
?>

View File

@ -1,24 +1,311 @@
<?php
/*
+ ----------------------------------------------------------------------------+
e107 website system
|
| ©Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
| $Revision: 1.3 $
| $Date: 2008-08-08 20:16:12 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Message Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
* $Revision: 1.4 $
* $Date: 2008-12-11 18:13:10 $
* $Author: secretr $
*
*/
if (!defined('e107_INIT')) { exit; }
/*
* Type defines
*/
define('E_MESSAGE_INFO', 'info');
define('E_MESSAGE_SUCCESS', 'success');
define('E_MESSAGE_WARNING', 'warning');
define('E_MESSAGE_ERROR', 'error');
//FIXME - language file! new?
class eMessage
{
/**
* System Message Array
*
* @var array
* @access private
*/
var $_sysmsg = array();
/**
* Constructor
*
* @param string $php4_check PHP4 singleton fix
* @return eMessage
*
* @access protected
*/
function eMessage($php4_check)
{
if($php4_check !== 'e107_emessage_php4_very_long_hard_to_remember_check')
{
exit('Fatal error! You are not allowed to direct instantinate an object for singleton class! Please use eMessage::getInstance()');
}
if(!session_id()) session_start();
if(isset($_SESSION['e107_system_messages']) && is_array($_SESSION['e107_system_messages']))
{
$this->_sysmsg = $_SESSION['e107_system_messages'];
return $this->resetSession();
}
return $this->reset();
}
/**
* Get singleton instance
*
* @return object eMessage instance
* @access public static
*/
function &getInstance()
{
static $instance = array();
if(empty($instance))
{
$instance[0] = new eMessage('e107_emessage_php4_very_long_hard_to_remember_check');
}
return $instance[0];
}
/**
* Add message to a type stack
*
* @param string $message
* @param string $type
* @param bool $session
* @return eMessage
*/
function add($message, $type = E_MESSAGE_INFO, $session = false)
{
if(!$session)
{
if($this->isType($type)) $this->_sysmsg[$type][] = $message;
return $this;
}
return $this->addSession($message, $type);
}
/**
* Add message to a _SESSION type stack
*
* @param string $message
* @param string $type
* @return eMessage
*/
function addSession($message, $type = E_MESSAGE_INFO)
{
if($this->isType($type)) $_SESSION['e107_system_messages'][$type][] = $message;
return $this;
}
/**
* Get type title (multi-language)
*
* @param string $type
* @return string title
*
* @access public static
*/
function getTitle($type)
{
return defsettrue('EMESSLAN_TITLE_'.strtoupper($type), '');
}
/**
* Message getter
*
* @param string $type valid type
* @param bool $raw force array return
* @param bool $reset reset message type stack
* @return string|array message
*/
function get($type, $raw = false, $reset = true)
{
$message = varsettrue($this->_sysmsg[$type], array());
if($reset) $this->reset($type);
return (true === $raw ? $message : eMessage::formatMessage($type, $message));
}
/**
* Session message getter
*
* @param string $type valid type
* @param bool $raw force array return
* @param bool $reset reset session message type stack
* @return string|array session message
*/
function getSession($type, $raw = false, $reset = true)
{
$message = varsettrue($_SESSION['e107_system_messages'][$type], array());
if($reset) $this->resetSession($type);
return (true === $raw ? $message : eMessage::formatMessage($type, $message));
}
/**
* Output all accumulated messages
*
* @param bool $raw force return type array
* @param bool $reset reset all messages
* @param bool $session merge with session messages
* @return array|string messages
*/
function render($raw = true, $reset = true, $session = true)
{
if($session)
{
$this->_merge();
}
$ret = array();
foreach ($this->_get_types() as $type)
{
$message = $this->get($type, $raw);
if(!empty($message))
{
$ret[$type] = (true === $raw) ? $message : eMessage::formatMessage($type, $message);
}
}
if($reset) $this->reset(false);
if(true === $raw || empty($ret)) return ($raw ? $ret : '');
//XXX keep it id (once per page) instead class for now, ask for feedback
return "
<div id='s-message'>
".implode("\n", $ret)."
</div>
";
}
/**
* Create message block markup based on its type.
*
* @param string $type
* @param array|string $message
* @return string formated message
*
* @access public static
*/
function formatMessage($type, $message)
{
if (empty($message)) return '';
elseif (is_array($message))
{
$message = "<div class='message-item'>\n".implode("</div>\n<div class='message-item'>", $message)."</div>";
}
return "
<div class='{$type}'>
<div class='message-title'>".eMessage::getTitle($type)."</div>
<div class='message-body'>
{$message}
<div>
</div>
";
}
/**
* Reset message array
*
* @param mixed $type false for reset all, or type constant
* @param bool $session reset session messages as well
* @return eMessage
*/
function reset($type, $session = false)
{
if(false === $type) $this->_sysmsg = $this->_type_map();
elseif(isset($this->_sysmsg[$type])) $this->_sysmsg[$type] = array();
if($session) $this->resetSession($type);
return $this;
}
/**
* Reset _SESSION message array
*
* @param mixed $type false for reset all, or valid type constant
* @return eMessage
*/
function resetSession($type)
{
if(!$type) $_SESSION['e107_system_messages'] = $this->_type_map();
elseif(isset($_SESSION['e107_system_messages'][$type])) $_SESSION['e107_system_messages'][$type] = array();
return $this;
}
/**
* Merge _SESSION message array with the current messages
*
* @param bool $reset
* @return eMessage
*/
function _merge($reset = true)
{
foreach (array_keys($_SESSION['e107_system_messages']) as $type)
{
if(!$this->isType($type)) continue;
$this->_sysmsg[$type] = array_merge($this->_sysmsg[$type], $_SESSION['e107_system_messages'][$type]);
}
if($reset) $this->resetSession();
return $this;
}
/**
* Check passed type against the type map
*
* @param mixed $type
* @return bool
*/
function isType($type)
{
return (array_key_exists($type, $this->_type_map()));
}
/**
* Balnk type array structure
*
* @return array type map
*/
function _type_map()
{
//show them in this order!
return array(
E_MESSAGE_ERROR => array(),
E_MESSAGE_WARNING => array(),
E_MESSAGE_SUCCESS => array(),
E_MESSAGE_INFO => array()
);
}
/**
* Get all valid message types
*
* @return array valid message types
*/
function _get_types()
{
return array_keys($this->_type_map());
}
}
function show_emessage($mode, $message, $line = 0, $file = "") {
global $tp;
if(is_numeric($message))
@ -45,11 +332,11 @@ function show_emessage($mode, $message, $line = 0, $file = "") {
</div>";
}
if (class_exists('e107table'))
if (class_exists('e107table'))
{
$ns = new e107table;
}
switch($mode)
switch($mode)
{
case "CRITICAL_ERROR" :
$message = $emessage[$message] ? $emessage[$message] : $message;

View File

@ -1,13 +1,10 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_cache.php,v $
| $Revision: 1.2 $
| $Date: 2007-02-04 17:36:16 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_cache.php,v 1.3 2008-12-11 18:13:10 secretr Exp $
*
* Admin Language File
*
*/
define("CACLAN_1", "Cache System Status");
define("CACLAN_2", "Set cache status");

View File

@ -1,7 +1,6 @@
/* E107 CORE CSS *********************************************************************************************/
.searchhighlight{text-decoration: underline; color:#FF0000; font-weight:bold; }
/*
* e107 v0.800 - new class definitions
*/
@ -104,22 +103,20 @@ ul,ol { list-style:none; }
/* Form elements */
input.input-text,
textarea,
select, .tbox {
select, .tbox, .helpbox {
border-width:1px;
border-style:solid;
border-color:#aaa #c8c8c8 #c8c8c8 #aaa;
background:#fff;
font:12px arial, helvetica, sans-serif;
}
input.input-text, textarea, .tbox { padding:2px; }
input.input-text, textarea, .tbox, .helpbox { padding:2px; }
select.tbox { min-height:17px; padding: 0px; /* to set the height for empty selects */ }
/* custom fields CSS */
#core-emoticon-configure input.input-text { width: 300px; }
.select.order { width: 40px; }
.select.order { width: 40px !important; }
.select.time-offset { width: 60px !important; }
input.radio { margin-right: 3px; }
/* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
.inline-help { width: 280px; }
.auto-toggle-area { width: 280px; }
/* form used for settings */
@ -137,7 +134,7 @@ select.tbox { min-height:17px; padding: 0px; /* to set the height for empty sel
.adminform td.label { }
.adminform td.control { }
.field-help { width: 280px; }
.field-help { width: 280px; line-height: 1.4em; padding-top: 3px; }
.label-note { font-style: italic; }
/* form used for content edit */
@ -179,13 +176,21 @@ select.tbox { min-height:17px; padding: 0px; /* to set the height for empty sel
.admintabs ul.e-tabs li.active { border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF}
/******** SyS Messages / Message text formatting */
.s-message {}
.s-message .error-box {}
.warning { color: #FF6600}
/* message boxes */
#s-message {}
#s-message div.info, #s-message div.error, #s-message div.success, #s-message div.warning {}
.message-title {}
.message-body {}
.message-item ()
/* validate result inline message */
.validate-result {}
/* message text (overall) */
.warning { color: #FF6600 }
.success {}
.error { color: #FF0000}
.error { color: #FF0000 }
.info {}
.validate-result {} /* validate result inline message */
/******** Tooltip info */
.e-info {}
@ -202,7 +207,7 @@ button span {
position:relative;
display:block;
white-space:nowrap;
padding:0 0 0 11px;
padding:0 0 0 13px;
height:22px; line-height:22px; color:#0b333c;
}
@ -303,20 +308,23 @@ ul.plugin-navigation ul.sub-nav a.link-active {font-weight: bold;}
.page-info { border: 1px solid #DDDDDD; margin-bottom: 10px; }
.page-info p { padding: 10px; }
#core-prefs-main .col-label {}
#core-emoticon-configure input.input-text { width: 300px; }
#core-links-edit textarea { width: 390px !important; }
#core-links-edit .helpbox { width: 390px !important; margin: 5px 0px; }
#core-links-edit .field-help { width: 390px; }
#core-frontpage-edit-home { width: 50%; float: left; }
#core-frontpage-edit-post-login { width: 50%; float: left; }
#core-frontpage-edit-home .adminlist { width: 99%; }
#core-frontpage-edit-post-login .adminlist { width: 99%; float: right; }
#core-frontpage-edit .tbox { width: 80%;}
#core-frontpage-edit select.tbox { width: 50%;}
#core-frontpage-edit .buttons-bar select.tbox { width: 140px; }
#core-frontpage-edit .buttons-bar { clear: both; }
/******** Core Block IDs */
/* cache.php */
#core-cache-settings {} /* General cache settings - Default front page */
@ -336,17 +344,32 @@ ul.plugin-navigation ul.sub-nav a.link-active {font-weight: bold;}
#core-image-check-avatar {} /* Check avatar sizes table */
#core-image-settings {} /* General image settings - Default front page */
/* links.php */
#core-links-list-1 {} /* Display list of current links - Default front page */
#core-links-list-2 {} /* Display list of current links - Default front page */
#core-links-list-3 {} /* Display list of current links - Default front page */
#core-links-list-4 {} /* Display list of current links - Default front page */
/* lancheck.php */
#core-lancheck-edit {} /* Edid language file */
/* language.php */
#core-language-settings {} /* Language Preferences - Default front page */
#core-language-list {} /* Multi-language DB tables list */
#core-language-edit {} /* Edit Multi-language DB tables */
#core-language-lancheck {} /* Language Tools - Verify/Edit Language Files */
#core-language-package {} /* Language Tools - Create Language-Pack (zip) */
/* links.php */
#core-links-list-1 {} /* Display list of current links - Links Front Page */
#core-links-list-2 {} /* Display list of current links - Links Front Page */
#core-links-list-3 {} /* Display list of current links - Links Front Page */
#core-links-list-4 {} /* Display list of current links - Links Front Page */
#core-links-create {} /* Create or edit link - Create New Link*/
#core-links-options {} /* Links general settins - Options */
#core-links-generator {} /* Sublink Generator */
/* meta.php */
#core-dataform {} /* Form tag ID - Default front page - old core definition */
#dataform {} /* Form tag ID - Default front page - old core definition */
#core-meta-settings {} /* General meta settings - Default front page */
/* prefs.php */
#core-prefs {} /* Main continer - contains all block lemenst from bewlow */
/* search.php */
#core-search-configuration-main {} /* Search Configuration for Searchable Areas - Default front page */
#core-search-configuration-comm {} /* Search Configuration for Searchable Comments Areas - Default front page */