1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Emoticons Administration ready, message handler multi-view in action

This commit is contained in:
secretr 2008-12-15 11:35:33 +00:00
parent 384cbbcf2c
commit 3a818d060b
3 changed files with 137 additions and 102 deletions

View File

@ -9,14 +9,14 @@
* Administration Area - Emotions Settings & Packs
*
* $Source: /cvs_backup/e107_0.8/e107_admin/emoticon.php,v $
* $Revision: 1.10 $
* $Date: 2008-12-14 21:01:58 $
* $Revision: 1.11 $
* $Date: 2008-12-15 11:35:33 $
* $Author: secretr $
*
*/
require_once("../class2.php");
if (!getperms("F"))
if (!getperms("F"))
{
header("location:".e_BASE."index.php");
exit;
@ -38,7 +38,7 @@ if(!$sql->db_Count("core", "(*)", "WHERE e107_name = 'emote_default'"))
// Change the active emote pack
if (isset($_POST['active']))
{
if ($pref['smiley_activate'] != $_POST['smiley_activate'])
if ($pref['smiley_activate'] != $_POST['smiley_activate'])
{
$pref['smiley_activate'] = $_POST['smiley_activate'];
$admin_log->log_event($pref['smiley_activate'] ? 'EMOTE_02' : 'EMOTE_03', $pref['emotepack'], E_LOG_INFORMATIVE, '');
@ -46,11 +46,11 @@ if (isset($_POST['active']))
$update = true;
$emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS);
}
else
else
{
$emessage->add(LAN_NO_CHANGE);
}
}
@ -67,22 +67,29 @@ foreach($_POST as $key => $value)
if(strstr($key, "subPack_"))
{
$subpack = str_replace("subPack_", "", $key);
$emote -> emoteConf($subpack);
$emote->emoteConf($subpack);
break;
}
if(strstr($key, "XMLPack_"))
{
$subpack = str_replace("XMLPack_", "", $key);
$emote -> emoteXML($subpack);
$emote->emoteXML($subpack);
break;
}
if(strstr($key, "defPack_"))
{
$pref['emotepack'] = str_replace("defPack_", "", $key);
save_prefs();
$admin_log->log_event('EMOTE_01',$pref['emotepack'],E_LOG_INFORMATIVE,'');
if(save_prefs())
{
$emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS);
}
else
{
$emessage->add(LAN_NO_CHANGE, E_MESSAGE_INFO);
}
$admin_log->log_event('EMOTE_01', $pref['emotepack'], E_LOG_INFORMATIVE, '');
break;
}
@ -128,6 +135,7 @@ class emotec
global $e107, $emessage, $fl, $pref;
$text = "
".$emessage->render()."
<div class='admintabs' id='tab-container'>
<ul class='e-tabs' id='core-emote-tabs'>
<li id='tab-activate'><a href='#emoticon-activate'>".EMOLAN_1."</a></li>
@ -144,7 +152,7 @@ class emotec
<tbody>
<tr>
<td class='label'>
".EMOLAN_4.":
".EMOLAN_4.":
</td>
<td class='control'>
<div class='auto-toggle-area autocheck'>
@ -159,15 +167,10 @@ class emotec
</div>
</fieldset>
</form>
";
//$e107->ns -> tablerender(EMOLAN_1, $text);
$text .= "
<form method='post' action='".e_SELF."?#etabTabContainer=emoticon-packages'>
<form method='post' action='".e_SELF."#etabTabContainer=emoticon-packages'>
<fieldset id='emoticon-packages'>
<legend class='e-hideme'>".EMOLAN_13."</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>
@ -202,8 +205,8 @@ class emotec
foreach($emoteArray as $emote)
{
if (strstr($emote['fname'], ".pak")
|| strstr($emote['fname'], ".xml")
if (strstr($emote['fname'], ".pak")
|| strstr($emote['fname'], ".xml")
|| strstr($emote['fname'], "phpBB"))
{
$can_scan = TRUE; // Allow re-scan of config files
@ -217,9 +220,9 @@ class emotec
$text .= "
</td>
<td class='center middle'>".($pref['emotepack'] == $pack ? EMOLAN_10 : "<button type='submit' name='defPack_".$pack."'><span>".EMOLAN_11."</span></button>")."</td>
<td class='center middle'>".($pref['emotepack'] == $pack ? EMOLAN_10 : "<button type='submit' name='defPack_".$pack."' value='".EMOLAN_11."'><span>".EMOLAN_11."</span></button>")."</td>
<td>
<button class='submit' type='submit' name='subPack_".$pack."'><span>".EMOLAN_12."</span></button>
<button class='edit' type='submit' name='subPack_".$pack."'><span>".EMOLAN_12."</span></button>
";
if ($can_scan && ($pack != 'default'))
{
@ -230,7 +233,7 @@ class emotec
}
$text .= "
<br /><br />
<button class='submit' type='submit' name='XMLPack_".$pack."'><span>".EMOLAN_28."</span></button>
<button class='create' type='submit' name='XMLPack_".$pack."'><span>".EMOLAN_28."</span></button>
";
$text .= "
</td>
@ -244,9 +247,9 @@ class emotec
</fieldset>
</form>
</div>
";
$e107->ns->tablerender(EMOLAN_13, $emessage->render().$text);
";
$e107->ns->tablerender(EMOLAN_PAGE_TITLE, $text);
}
@ -269,10 +272,10 @@ class emotec
//XXX Not sure if we need to know rhe number of files found - count($eArray) - <div class='info-bar'><strong>Total ".count($eArray)." files found</strong></div>
$text = "
<form method='post' action='".e_SELF."'>
<form method='post' action='".e_SELF."#etabTabContainer=emoticon-packages'>
<fieldset id='core-emoticon-configure'>
<legend class='e-hideme'>".EMOLAN_15."</legend>
<div class='info-bar'><strong>Total ".count($eArray)." files found</strong></div>
<div class='info-bar'><strong>".sprintf(EMOLAN_31, count($eArray))."</strong></div>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='3'>
<col style='width:20px' />
@ -298,45 +301,46 @@ class emotec
if (!isset($emotecode[$evalue]))
{
$file_back = '<span class="error">&nbsp;&nbsp;Emote not set</span>';
$file_back = '<span class="error">&nbsp;&nbsp;'.EMOLAN_37.'</span>';
}
elseif (!$emotecode[$evalue])
{
$text_back = '<span class="error">&nbsp;&nbsp;Empty value</span>';
$text_back = '<span class="error">&nbsp;&nbsp;'.EMOLAN_38.'</span>';
}
$text .= "
<tr>
<td class='center'><img src='".$emote['path'].$ename."' alt='' /></td>
<td>".$ename."{$file_back}</td>
<td>
<input class='tbox input-text' type='text' name='{$evalue}' value='".$tp -> toForm(varset($emotecode[$evalue],''))."' maxlength='200' />{$text_back}
<input class='tbox input-text' type='text' name='{$evalue}' value='".$tp->toForm(varset($emotecode[$evalue],''))."' maxlength='200' />{$text_back}
</td>
</tr>
";
}
$text .= "
</tbody>
</table>
<div class='buttons-bar center'>
<input type='hidden' name='packID' value='{$packID}' />
<button class='submit' type='submit' name='sub_conf' value='".EMOLAN_14."'><span>".EMOLAN_14."</span></button>
<button class='update' type='submit' name='sub_conf' value='".EMOLAN_14."'><span>".EMOLAN_14."</span></button>
<button class='cancel' type='submit' name='cancel' value='".LAN_CANCEL."'><span>".LAN_CANCEL."</span></button>
</div>
</fieldset>
</form>";
$e107->ns->tablerender(EMOLAN_15.": '".$packID."'", $text);
$e107->ns->tablerender(EMOLAN_PAGE_TITLE.' - '.EMOLAN_15.": '".$packID."'", $text);
}
// Generate an XML file - packname.xml in root emoticon directory
function emoteXML($packID, $strip_xtn = TRUE)
{
global $fl, $sysprefs, $tp;
global $emessage, $fl, $sysprefs, $tp;
$fname = e_IMAGE."emotes/".$packID."/emoticons.xml";
$backname = e_IMAGE."emotes/".$packID."/emoticons.bak";
$corea = "emote_".$packID;
$emotecode = $sysprefs -> getArray($corea);
@ -367,16 +371,16 @@ class emotec
$f_string .= "\n</messaging-emoticon-map>\n";
if (is_file($backname)) unlink($backname); // Delete any old backup
if (is_file($fname)) rename($fname,$backname);
//XXX message handler
if (file_put_contents($fname,$f_string) === FALSE)
{
echo "<br /><div style='text-align: center;'>".EMOLAN_30."<b>".$fname."</b></div><br />";
$emessage->add('<strong>'.EMOLAN_30.'</strong>'.str_replace(e_IMAGE, e_IMAGE_ABS, $fname), E_MESSAGE_WARNING);
}
else
{
echo "<br /><div style='text-align: center;'>".EMOLAN_29."<b>".$fname."</b></div><br />";
$emessage->add('<strong>'.EMOLAN_29.'</strong>'.str_replace(e_IMAGE, e_IMAGE_ABS, $fname), E_MESSAGE_SUCCESS);
}
}
@ -391,11 +395,11 @@ class emotec
$encoded_emotes = $tp->toDB($_POST);
$tmp = addslashes(serialize($encoded_emotes));
if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'"))
if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'"))
{
admin_update($sql->db_Update("core", "`e107_value`='{$tmp}' WHERE `e107_name`='emote_".$packID."' "), 'update', EMOLAN_16);
}
else
}
else
{
admin_update($sql->db_Insert("core", "'emote_".$packID."', '$tmp' "), 'insert', EMOLAN_16);
}
@ -406,37 +410,29 @@ class emotec
// Return false to disable listing of packs
function installCheck($do_one = FALSE)
{
global $sql, $fl;
global $e107, $emessage, $sql, $fl;
// Pick up a list of emote packs from the database
$pack_local = array();
if ($sql->db_Select("core","*","`e107_name` LIKE 'emote_%'",TRUE))
{
while ($row = $sql->db_Fetch())
{
$pack_local[substr($row['e107_name'],6)] = TRUE;
}
while ($row = $sql->db_Fetch())
{
$pack_local[substr($row['e107_name'],6)] = TRUE;
}
}
foreach($this -> packArray as $value)
{
if(strpos($value,' ')!==FALSE)
{ // Highlight any directory names containing spaces - not allowed
global $ns;
$msg = "
<div class='center'><strong>".EMOLAN_17."<br />".EMOLAN_18."</strong>
<table class='fborder'>
<tr>
<td class='fcaption'>".EMOLAN_19."</td>
<td class='fcaption'>".EMOLAN_20."</td>
</tr>
<tr>
<td class='forumheader3'>".$value."</td>
<td class='forumheader3'>".e_IMAGE_ABS."emotes/</td>
</tr>
</table>
</div>";
$ns->tablerender(EMOLAN_21, $msg);
<strong>".EMOLAN_17."</strong> ".EMOLAN_18."
<div>".EMOLAN_19.": {$value}</div>
<div>".EMOLAN_20.": ".e_IMAGE_ABS."emotes/</div>
";
$emessage->add($msg, E_MESSAGE_ERROR);
$e107->ns->tablerender(EMOLAN_PAGE_TITLE.' - '.EMOLAN_21, $emessage->render());
return FALSE;
}
@ -444,11 +440,11 @@ class emotec
{
unset($pack_local[$value]);
}
if (($do_one == $value) || !$do_one && (!$sql -> db_Select("core", "*", "e107_name='emote_".$value."' ")))
{ // Pack info not in DB, or to be re-scanned
$no_error = TRUE;
$File_type = 'Unknown';
$File_type = EMOLAN_32;
// Array of all files in the directory of the selected emote pack
$fileArray = $fl -> get_files(e_IMAGE."emotes/".$value); // We actually want all the files in the directory
$confFile = '';
@ -513,24 +509,24 @@ class emotec
<object mime="audio/x-wav">choir.wav</object>
</icon>*/
preg_match_all("#\<icon>(.*?)\<\/icon\>#si", $contents, $match);
$xml_type = 1;
// $match[0] - complete emoticon entry
// $match[1] - match string and object specification
// $match[1] - match string and object specification
$item_index = 1;
}
elseif (strpos($contents, "<emoticon") !== FALSE)
{ // "Original" E107 format (as used on KDE, although they may be changing to XEP-0038)
echo "Decoding standard XML file<br />";
//echo "Decoding standard XML file<br />";
preg_match_all("#\<emoticon file=\"(.*?)\"\>(.*?)\<\/emoticon\>#si", $contents, $match);
$xml_type = 2;
// $match[0] - complete emoticon entry
// $match[1] - filename (may or may not not have file extension/suffix)
// $match[2] - match string(s) representing emote
$item_index = 2;
}
if ($xml_type)
{
for($a=0; $a < count($match[0]); $a++)
@ -584,7 +580,7 @@ class emotec
}
}
// Only add if the file exists. OK if no definition - might want to be added
if ($file)
if ($file)
{
$confArray[$file] = $codet;
}
@ -592,7 +588,8 @@ class emotec
}
else
{
echo "Unsupported XML File Format<br /><br />";
//echo "Unsupported XML File Format<br /><br />";
$emessage->add(EMOLAN_33, E_MESSAGE_WARNING);
$no_error = FALSE;
}
@ -604,12 +601,13 @@ class emotec
if($confFile['type'] == "php")
{
echo EMOLAN_25."'".$value."'<br />";
include_once(e_IMAGE."emotes/".$value."/".$confFile['file']);
//$emessage->add(EMOLAN_25." '{$value}'", E_MESSAGE_INFO);
$File_type = EMOLAN_24;
$tmp = $_emoteconf; // Use consistent name
}
if ($no_error)
{
if ($do_one)
@ -620,25 +618,33 @@ class emotec
{ // Assume new pack
$sql->db_Insert("core", "'emote_".$value."', '{$tmp}' ");
}
echo "<div style='text-align: center;'><b>".$File_type." '</b> ".$value."'</div>";
//echo "<div style='text-align: center;'><b>".$File_type." '</b> ".$value."'</div>";
$emessage->add("<strong>{$File_type}</strong> '{$value}'", E_MESSAGE_INFO);
}
else
{ // Error occurred
echo "<div style='text-align: center;'><b>".EMOLAN_27." '</b> ".$value."'</div>";
//echo "<div style='text-align: center;'><b>".EMOLAN_27." '</b> ".$value."'</div>";
$emessage->add(EMOLAN_27." '{$value}'", E_MESSAGE_ERROR);
}
}
}
if (count($pack_local))
{
foreach ($pack_local as $p => $d)
if (count($pack_local))
{
echo "Missing files for pack: ".$p." - deleted in database<br />";
$sql->db_Delete("core","`e107_name` = 'emote_{$p}'");
foreach ($pack_local as $p => $d)
{
$emessage->add(EMOLAN_34.$p.EMOLAN_35, E_MESSAGE_INFO);
$sql->db_Delete("core","`e107_name` = 'emote_{$p}'");
}
}
}
return TRUE;
//echo $emessage->render();
return TRUE;
}
}
require_once("footer.php");
/**
@ -653,7 +659,6 @@ function headerjs()
$ret = "
<script type='text/javascript'>
//add required core lan - delete confirm message
(".e_jshelper::toString(IMALAN_67).").addModLan('core', 'delete_confirm');
</script>
<script type='text/javascript' src='".e_FILE_ABS."jslib/core/admin.js'></script>
";

View File

@ -1,10 +1,10 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_emoticon.php,v 1.5 2008-12-14 21:01:58 secretr Exp $
* $Id: lan_emoticon.php,v 1.6 2008-12-15 11:35:33 secretr Exp $
*
* Admin Language File
*
*
*/
define("EMOLAN_1", "Emote activation");
@ -27,16 +27,16 @@ define("EMOLAN_13", "Installed packs");
define("EMOLAN_14", "Save configuration");
define("EMOLAN_15", "Edit / configure emotes");
define("EMOLAN_16", "Emote configuration saved");
define("EMOLAN_17", "You have an emoticon pack present that contains spaces in the name, which are not allowed !");
define("EMOLAN_18", "please rename the instances listed below so they no longer contain spaces:");
define("EMOLAN_17", "You have an emoticon pack present that contains spaces in the name, which are not allowed!");
define("EMOLAN_18", "Please rename the instances listed below so they no longer contain spaces:");
define("EMOLAN_19", "Name");
define("EMOLAN_20", "Location");
define("EMOLAN_21", "Error");
define("EMOLAN_21", "Read Pack Error");
//define("EMOLAN_2", "Name");
define("EMOLAN_22", "New emote pak found:");
define("EMOLAN_23", "New emote xml pak found:");
define("EMOLAN_24", "New emote php found:");
define("EMOLAN_25", "Installing new PHP emotes: ");
define("EMOLAN_22", "New emote pack found:");
define("EMOLAN_23", "New emote xml pack found:");
define("EMOLAN_24", "New emote php pack found:");
//define("EMOLAN_25", "Installing new PHP emotes: ");
define("EMOLAN_26", "Re-scan pack");
define("EMOLAN_27", "Error occurred processing pack: ");
define("EMOLAN_28", "Generate XML");
@ -44,5 +44,13 @@ define("EMOLAN_29", "XML file generated: ");
define("EMOLAN_30", "Error writing XML file: ");
//0.8
define("EMOLAN_31", "Total %d files found");
define("EMOLAN_PAGE_TITLE", " Emoticons");
define("EMOLAN_31", "Total %u files found");
define("EMOLAN_32", "Unknown Pack detected : ");
define("EMOLAN_33", "Unsupported XML File Format!");
define("EMOLAN_34", "Missing files for pack: ");
define("EMOLAN_35", " - deleted in database");
define("EMOLAN_37", "Emote not set");
define("EMOLAN_38", "Empty emote value");
?>

View File

@ -53,7 +53,7 @@ input, select{ vertical-align:middle; }
textarea { overflow:auto; }
/* Table */
table { border:0; border-spacing:0; empty-cells:show; font-size:100%; }
table { border:0; border-spacing:0; empty-cells:show; font-size:100%; width: 100%; }
th { vertical-align:top; text-align:left; font-weight:normal; }
td { vertical-align:top; }
@ -110,6 +110,7 @@ select, .tbox, .helpbox {
background:#fff;
font:12px arial, helvetica, sans-serif;
}
option { padding-right: 10px;}
input.input-text, textarea, .tbox, .helpbox { padding:2px; }
select.tbox { min-height:17px; padding: 0px; /* to set the height for empty selects */ }
.select.order { width: 40px !important; }
@ -134,7 +135,7 @@ input.radio { margin-right: 3px; }
.adminform td.label { }
.adminform td.control { }
.field-help { width: 280px; line-height: 1.4em; padding-top: 3px; color:#333333 }
.field-help { width: 280px; line-height: 1.4em; padding-top: 3px; color:#333333; font-size: 11px; }
.label-note { font-style: italic; }
/* form used for content edit */
@ -177,12 +178,12 @@ input.radio { margin-right: 3px; }
/******** SyS Messages / Message text formatting */
/* message boxes */
#s-message {margin-bottom: 10px; }
#s-message { }
#s-message div.info,
#s-message div.error,
#s-message div.success,
#s-message div.warning { padding: 5px;}
#s-message div.warning { padding: 5px; margin-bottom: 10px; }
#s-message div.info { background-color:#C1E0FF; border: 1px solid #3399FF; }
@ -249,11 +250,13 @@ button.delete:hover span,
button.delete:focus span { background-image:url(images/btn_remove_over_left.gif) }
button.delete:active span { background-image:url(images/btn_remove_active_left.gif)}
/* Do we need this? Just no additional class?
button.submit span {}
button.submit span {}
button.submit:hover span,
button.submit:focus span {}
button.submit:active span {}
*/
button.update span { padding-left: 30px; }
button.update span { background-image:url(images/btn_update_left.gif); }
@ -273,6 +276,12 @@ button.edit:hover span,
button.edit:focus span {}
button.edit:active span {}
button.cancel span {}
button.cancel span {}
button.cancel:hover span,
button.cancel:focus span {}
button.cancel:active span {}
.buttons-bar { padding: 10px 0px; }
.buttons-bar button { margin-right: 10px; }
@ -325,13 +334,18 @@ 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-admin-log-config legend { font-weight: bold; }
#core-admin-log-options .checkbox,
#core-admin-log-filter .checkbox { margin-right: 5px; }
#core-admin-log-maintenance .select { width: 60px; }
#core-admin-log-maintenance button { margin-left: 10px; }
#core-frontpage-edit-home { width: 50%; float: left; }
#core-frontpage-edit-post-login { width: 50%; float: left; }
@ -343,6 +357,14 @@ ul.plugin-navigation ul.sub-nav a.link-active {font-weight: bold;}
#core-frontpage-edit .buttons-bar { clear: both; }
/******** Core Block IDs */
/* admin_log.php */
#core-admin-log-config {}
#core-admin-log-options {}
#core-admin-log-maintenance {}
#core-admin-log-filter {}
#core-admin-log-list {}
#core-admin-log-confirm-delete {}
/* cache.php */
#core-cache-settings {} /* General cache settings - Default front page */