Subversion Repositories Applications.papyrus

Compare Revisions

No changes between revisions

Ignore whitespace Rev 830 → Rev 831

/trunk/client/phorum/bibliotheque/phorum/mods/smileys/smileys.php
New file
0,0 → 1,50
<?php
 
if(!defined("PHORUM")) return;
 
require_once("./mods/smileys/defaults.php");
 
function phorum_mod_smileys_after_header()
{
$PHORUM = $GLOBALS["PHORUM"];
 
// Return immediately if we have no active smiley replacements.
if (!isset($PHORUM["mod_smileys"])||!$PHORUM["mod_smileys"]["do_smileys"]){
return $data;
} ?>
 
<style type="text/css">
.mod_smileys_img {
vertical-align: bottom;
margin: 0px 3px 0px 3px;
}
</style> <?php
}
 
function phorum_mod_smileys_format($data)
{
$PHORUM = $GLOBALS["PHORUM"];
 
// Return immediately if we have no active smiley replacements.
if (!isset($PHORUM["mod_smileys"])||!$PHORUM["mod_smileys"]["do_smileys"]){
return $data;
}
 
// Run smiley replacements.
$replace = $PHORUM["mod_smileys"]["replacements"];
foreach ($data as $key => $message)
{
// Do subject replacements.
if (isset($replace["subject"]) && isset($message["subject"])) {
$data[$key]['subject'] = str_replace ($replace["subject"][0] , $replace["subject"][1], $message['subject'] );
}
// Do body replacements.
if (isset($replace["body"]) && isset($message["body"])) {
$data[$key]['body'] = str_replace ($replace["body"][0] , $replace["body"][1], $message['body'] );
}
}
 
return $data;
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/defaults.php
New file
0,0 → 1,14
<?php
// A simple helper script that will setup initial module
// settings in case one of these settings is missing.
 
if(!defined("PHORUM") && !defined("PHORUM_ADMIN")) return;
 
if (! isset($PHORUM['mod_smileys']) ||
! isset($PHORUM['mod_smileys']['prefix']) ||
! isset($PHORUM['mod_smileys']['smileys'])) {
require_once("./mods/smileys/smileyslib.php");
$PHORUM['mod_smileys'] = phorum_mod_smileys_initsettings();
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/smileyslib.php
New file
0,0 → 1,244
<?php
 
// A library of common functions and definitions for
// the smileys mod. This library is only loaded when
// initializing or saving module settings.
 
if(!defined("PHORUM") && !defined("PHORUM_ADMIN")) return;
 
// A match for filtering files that are accepted as smiley images.
define('MOD_SMILEYS_IMAGE_MATCH', '/^.+\.(gif|png|jpg|jpeg)$/i');
 
// A match for matching absolute file paths. Paths that I could think of:
// UNIX path /...
// URL proto://...
// Windows path X:\... or X:/...
// Windows net path \\...
define('MOD_SMILEYS_ABSPATH_MATCH', '!^/|^\w+://|^\w:[/\\\\]|^\\\\\\\\!i');
 
// The default smiley prefix path.
global $MOD_SMILEY_DEFAULT_PREFIX;
$MOD_SMILEY_DEFAULT_PREFIX = './mods/smileys/images/';
 
// The default list of smileys to install upon initial setup.
global $MOD_SMILEY_DEFAULT_SMILEYS;
$MOD_SMILEY_DEFAULT_SMILEYS = array(
"(:P)" => "smiley25.gif spinning smiley sticking its tongue out",
"(td)" => "smiley23.gif thumbs up",
"(tu)" => "smiley24.gif thumbs down",
":)-D" => "smiley15.gif smileys with beer",
">:D<" => "smiley14.gif the finger smiley",
"(:D" => "smiley12.gif smiling bouncing smiley",
"8-)" => "smilie8.gif eye rolling smiley",
":)o" => "smiley16.gif drinking smiley",
"::o" => "smilie10.gif eye popping smiley",
"B)-" => "smilie7.gif smoking smiley",
":(" => "smilie2.gif sad smiley",
":)" => "smilie1.gif smiling smiley",
":?" => "smiley17.gif moody smiley",
":D" => "smilie5.gif grinning smiley",
":P" => "smilie6.gif tongue sticking out smiley",
":S" => "smilie11.gif confused smiley",
":X" => "smilie9.gif angry smiley",
":o" => "smilie4.gif yawning smiley",
";)" => "smilie3.gif winking smiley",
"B)" => "cool.gif cool smiley",
"X(" => "hot.gif hot smiley",
);
 
/**
* Sets up initial settings for the smileys mod or upgrades
* the settings from old versions.
* @return modinfo - Updated module information.
*/
function phorum_mod_smileys_initsettings()
{
$PHORUM = $GLOBALS["PHORUM"];
global $MOD_SMILEY_DEFAULT_PREFIX;
global $MOD_SMILEY_DEFAULT_SMILEYS;
$modinfo = isset($PHORUM["mod_smileys"]) ? $PHORUM["mod_smileys"] : array();
 
// Keep track if we need to store settings in the database.
$do_db_update = false;
 
// Set default for the image prefix path.
if(! isset($modinfo['prefix'])) {
$modinfo['prefix'] = $MOD_SMILEY_DEFAULT_PREFIX;
// So phorum_mod_smileys_available() sees it right away.
$GLOBALS["PHORUM"]["mod_smileys"]["prefix"] = $MOD_SMILEY_DEFAULT_PREFIX;
$do_db_update = true;
}
 
// Set a default list of smileys or upgrade from existing smiley mod.
if (! isset($modinfo['smileys']))
{
$modinfo['smileys'] = array();
 
// Check if we have smileys from the previous version of the
// smiley mod. These were stored at the same level as the
// settings.
$upgrade_list = array();
if (isset($PHORUM["mod_smileys"])) {
foreach ($PHORUM["mod_smileys"] as $id => $smiley) {
if (is_numeric($id)) {
$upgrade_list[$id] = $smiley;
}
}
}
 
// We have an existing list of smileys to upgrade. Move the
// smileys to their new location.
if (count($upgrade_list)) {
foreach ($upgrade_list as $id => $smiley) {
unset($modinfo[$id]);
$modinfo["smileys"][$id] = $smiley;
}
$do_db_update = true;
}
// Set an initial list of smileys.
else {
foreach ($MOD_SMILEY_DEFAULT_SMILEYS as $search => $data) {
list($smiley, $alt) = preg_split('/\s+/', $data, 2);
$modinfo["smileys"][] = array(
"search" => $search,
"alt" => $alt,
"smiley" => $smiley,
"uses" => 2,
);
}
$do_db_update = true;
}
}
 
// Store the changed settings in the database. Errors are
// silently ignored here, to keep them away from end-users.
if ($do_db_update) {
list($modinfo, $message) = phorum_mod_smileys_store($modinfo);
$GLOBALS["PHORUM"]["mod_smileys"] = $modinfo;
return $modinfo;
}
}
 
/**
* Reads in the list of available smiley images.
* @return smileys - An array of smiley image filenames.
*/
function phorum_mod_smileys_available()
{
$PHORUM = $GLOBALS["PHORUM"];
 
$available_smileys = array();
if(file_exists($PHORUM['mod_smileys']['prefix'])){
$d = dir($PHORUM['mod_smileys']['prefix']);
while($entry=$d->read()) {
if(preg_match(MOD_SMILEYS_IMAGE_MATCH, $entry)) {
$available_smileys[$entry]=$entry;
}
}
}
asort($available_smileys);
return $available_smileys;
}
 
/**
* Compiles replacement arrays for the smileys mod and stores the
* data for the module in the database.
* @param modinfo - The configuration array for mod_smileys.
* @return result - An array containing two elements:
* updated module info or NULL on failure and
* a message that can be displayed to the user.
*/
function phorum_mod_smileys_store($modinfo)
{
// Get the current list of available smiley images.
$available_smileys = phorum_mod_smileys_available();
 
// Sort the smileys by length. We need to do this to replace the
// longest smileys matching strings first. Else for example the
// smiley ":)-D" could end up as (smileyimage)-D, because ":)"
// was replaced first.
uasort($modinfo["smileys"],'phorum_mod_smileys_sortbylength');
 
// Create and fill replacement arrays for subject and body.
$smiley_subject_key = array();
$smiley_subject_val = array();
$smiley_body_key = array();
$smiley_body_val = array();
$seen_images = array();
foreach ($modinfo["smileys"] as $id => $smiley)
{
// Check if the smiley image is available. Skip and keep track
// of missing smiley images.
$active = isset($available_smileys[$smiley["smiley"]]) ? true : false;
$modinfo["smileys"][$id]['active'] = $active;
if (! $active) continue;
 
// Check if the smiley image has been seen before. If is has, mark
// the current smiley as being an alias. This is used in the editor
// smiley help, to show only one version of a smiley image.
$is_alias = isset($seen_images[$smiley["smiley"]]) ? true : false;
$seen_images[$smiley["smiley"]] = 1;
$modinfo["smileys"][$id]["is_alias"] = $is_alias;
 
// Create HTML image code for the smiley.
$prefix = $modinfo["prefix"];
$src = htmlspecialchars("$prefix{$smiley['smiley']}");
$alttxt = empty($smiley['alt']) ? $smiley["search"] : $smiley["alt"];
$alt = htmlspecialchars($alttxt);
$img = "<img class=\"mod_smileys_img\" src=\"$src\" alt=\"$alt\" title=\"$alt\"/>";
 
// Below we use htmlspecialchars() on the search string.
// This is done, because the smiley mod is run after formatting
// by Phorum, so characters like < and > are HTML escaped.
 
// Body only replace (0) or subject and body replace (2).
if ($smiley['uses'] == 0 || $smiley['uses'] == 2) {
$smiley_body_key[] = htmlspecialchars($smiley['search']);
$smiley_body_val[] = $img;
}
 
// Subject only replace (1) or subject and body replace (2).
if ($smiley['uses'] == 1 || $smiley['uses'] == 2) {
$smiley_subject_key[] = htmlspecialchars($smiley['search']);
$smiley_subject_val[] = $img;
}
}
 
// Store replacement arrays in the module settings.
$modinfo["replacements"] = array(
"subject" => count($smiley_subject_key)
? array($smiley_subject_key, $smiley_subject_val)
: NULL,
"body" => count($smiley_body_key)
? array($smiley_body_key, $smiley_body_val)
: NULL
);
 
// For quickly determining if the smiley replacements must be run.
$modinfo["do_smileys"] = $modinfo["replacements"]["subject"] != NULL ||
$modinfo["replacements"]["body"] != NULL;
 
// Store the module settings in the database.
if (! phorum_db_update_settings(array("mod_smileys" => $modinfo))) {
return array(NULL, "Saving the smiley settings to the database failed.");
} else {
return array($modinfo, "The smiley settings were successfully saved.");
}
}
 
/**
* A callback function for sorting smileys by their search string length.
* usage: uasort($array_of_smileys, 'phorum_mod_smileys_sortbylength');
*/
function phorum_mod_smileys_sortbylength($a, $b) {
if (isset($a["search"]) && isset($b["search"])) {
if (strlen($a["search"]) == strlen($b["search"])) {
return strcmp($a["search"], $b["search"]);
} else {
return strlen($a["search"]) < strlen($b["search"]);
}
} else {
return 0;
}
}
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/laughing.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/laughing.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/rolleyes.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/rolleyes.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie1.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie1.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie2.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie2.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley12.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley12.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie3.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie3.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie4.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie4.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/confused.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/confused.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie5.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie5.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/kissing.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/kissing.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley14.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley14.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie6.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie6.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley15.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley15.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie7.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie7.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smile.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smile.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley16.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley16.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie8.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie8.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley17.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley17.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie9.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie9.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/footinmouth.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/footinmouth.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/lipsaresealed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/lipsaresealed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/undecided.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/undecided.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/embarrassed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/embarrassed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/frowning.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/frowning.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/crying.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/crying.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/baringteeth.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/baringteeth.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/suprised.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/suprised.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sleepy.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sleepy.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/tounge.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/tounge.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley23.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley23.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley24.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley24.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/wink.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/wink.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley25.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley25.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/thinking.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/thinking.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/innocent.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/innocent.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/angry.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/angry.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie10.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie10.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/disappointed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/disappointed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie11.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie11.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/nerd.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/nerd.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sick.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sick.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/hot.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/hot.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/cool.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/cool.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/settings.php
New file
0,0 → 1,349
<?php
 
if(!defined("PHORUM_ADMIN")) return;
 
require_once("./include/admin/PhorumInputForm.php");
require_once("./mods/smileys/smileyslib.php");
require_once("./mods/smileys/defaults.php");
 
// The definition of the possible uses for a smiley.
$PHORUM_MOD_SMILEY_USES = array(
0 => "Body",
1 => "Subject",
2 => "Body + Subject",
);
 
// ---------------------------------------------------------------------------
// Handle actions for sent form data.
// ---------------------------------------------------------------------------
 
// The action to perform.
$action = isset($_POST["action"]) ? $_POST["action"] : "";
 
// Keep track if the settings must be saved in the database.
$do_db_update = false;
 
// Keep track of error and success messages.
$error="";
$okmsg = "";
 
// Initialize smiley_id parameter.
$smiley_id = isset($_POST["smiley_id"]) ? $_POST["smiley_id"] : "NEW";
 
// ACTION: Changing the mod_smileys settings.
if (empty($error) && $action == "edit_settings") {
$_POST["prefix"] = trim($_POST["prefix"]);
// Is the field filled in?
if (empty($_POST["prefix"])) {
$error = "Please, fill in the smiley prefix path";
// Deny absolute paths.
} elseif (preg_match(MOD_SMILEYS_ABSPATH_MATCH, $_POST["prefix"])) {
$error = "The smiley path must be a path, relative to Phorum's " .
"installation directory";
// Is the specified prefix a directory?
} elseif (!is_dir($_POST["prefix"])) {
$error = "The smiley prefix path " .
'"' . htmlspecialchars($_POST["prefix"]) . '" ' .
" does not exist";
}
 
// All is okay. Set the prefix path in the config.
if (empty($error))
{
// Make sure the prefix path ends with a "/".
if (substr($_POST["prefix"], -1, 1) != '/') {
$_POST["prefix"] .= "/";
}
 
$PHORUM["mod_smileys"]["prefix"] = $_POST["prefix"];
 
$okmsg = "The smiley settings have been saved successfully";
$do_db_update = true;
}
}
 
// ACTION: Adding or updating smileys.
if (empty($error) && $action == "edit_smiley")
{
// Trim whitespace from form input fields.
foreach (array("search","smiley","alt") as $field) {
if (isset($_POST[$field])) $_POST[$field] = trim($_POST[$field]);
}
 
// Check if the search string is entered.
if (empty($_POST["search"]))
$error = "Please enter the string to match";
// Check if a replace smiley is selected.
elseif (empty($_POST["smiley"]))
$error = "Please, select a smiley to replace the string " .
htmlspecialchars($_POST["search"]) . " with";
// Check if the smiley doesn't already exist.
if (empty($error)) {
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
if ($smiley["search"] == $_POST["search"] &&
$_POST["smiley_id"] != $id) {
$error = "The smiley " .
'"' . htmlspecialchars($_POST["search"]) . '" ' .
"already exists";
break;
}
}
}
 
// All fields are okay. Update the smiley list.
if (empty($error))
{
$item = array(
"search" => $_POST["search"],
"smiley" => $_POST["smiley"],
"alt" => $_POST["alt"],
"uses" => $_POST['uses']
);
 
if ($smiley_id == "NEW") {
$PHORUM["mod_smileys"]["smileys"][]=$item;
$okmsg = "The smiley has been added successfully";
} else {
$PHORUM["mod_smileys"]["smileys"][$smiley_id]=$item;
$okmsg = "The smiley has been updated successfully";
}
 
$do_db_update = true;
}
}
 
// GET based actions.
if (empty($error) && isset($_GET["smiley_id"]))
{
// ACTION: Deleting a smiley from the list.
if (isset($_GET["delete"])) {
unset($PHORUM["mod_smileys"]["smileys"][$_GET["smiley_id"]]);
$do_db_update = true;
$okmsg = "The smiley has been deleted successfully";
}
 
// ACTION: Startup editing a smiley from the list.
if (isset($_GET["edit"])) {
$smiley_id = $_GET["smiley_id"];
}
}
 
 
// ---------------------------------------------------------------------------
// Do database updates.
// ---------------------------------------------------------------------------
 
// Changes have been made to the smileys configuration.
// Store these changes in the database.
if (empty($error) && $do_db_update)
{
list($modinfo, $message) = phorum_mod_smileys_store($PHORUM["mod_smileys"]);
if ($modinfo == NULL) {
$error = $message;
} else {
if (empty($okmsg)) $okmsg = $message;
$PHORUM["mod_smileys"] = $modinfo;
 
// Back to the startscreen
unset($_POST);
$smiley_id = 'NEW';
}
}
 
 
// ---------------------------------------------------------------------------
// Display the settings page
// ---------------------------------------------------------------------------
 
// Get the current list of available smiley images.
$available_smileys = phorum_mod_smileys_available();
 
// Javascript for displaying a smiley preview when a smiley image
// is selected from the drop down box.
?>
<script type="text/javascript">
function change_image(new_image) {
var div = document.getElementById("preview_div");
var img = document.getElementById("preview_image");
if (new_image.length == 0) {
new_image = "./images/trans.gif";
div.style.display = 'none';
} else {
new_image = "<?php print $PHORUM["mod_smileys"]["prefix"]?>" + new_image;
div.style.display = 'block';
}
img.src =new_image;
}
</script>
<?php
 
// Display the result message.
if (! empty($error)) {
phorum_admin_error($error);
} elseif (! empty($okmsg)) {
phorum_admin_okmsg($okmsg);
}
 
// Count things.
$total_smileys = 0;
$inactive_smileys = 0;
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
$total_smileys ++;
if (! $smiley["active"]) $inactive_smileys ++;
}
 
// Display a warning in case there are no smiley images available.
if (! count($available_smileys)) {
phorum_admin_error(
"<strong>Warning:</strong><br/>" .
"No smiley images were found in your current smiley prefix " .
"path. Please place some smileys in the directory " .
htmlspecialchars($PHORUM["mod_smileys"]["prefix"]) .
" or change your prefix path to point to a directory " .
"containing smiley images.");
} elseif ($inactive_smileys) {
phorum_admin_error(
"<strong>Warning:</strong><br/>" .
"You have $inactive_smileys smiley(s) configured for which the " .
"image file was not found (marked as \"UNAVAILBLE\" in the list " .
"below). Delete the smiley(s) from the list or place the missing " .
"images in the directory \"" .
htmlspecialchars($PHORUM["mod_smileys"]["prefix"]) . "\". After " .
"placing new smiley images, click \"Save settings\" to update " .
"the smiley settings.");
}
 
// Create the smiley settings form.
if ($smiley_id == "NEW")
{
$frm = new PhorumInputForm ("", "post", 'Save settings');
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "smileys");
$frm->hidden("action", "edit_settings");
$frm->addbreak("Smiley Settings");
$row = $frm->addrow("Smiley Prefix Path", $frm->text_box("prefix", $PHORUM["mod_smileys"]["prefix"], 50));
$frm->addhelp($row,
"Set the smiley image prefix path",
"This option can be used to set the path to the directory where
you have stored your smileys. This path must be relative to the
directory in which you installed the Phorum software. Absolute
paths cannot be used here.");
$frm->show();
}
 
// No smiley images in the current prefix path? Then do not show the
// rest of the forms. Let the admin fix this issue first.
if (!count($available_smileys)) return;
 
// Create the smiley adding and editing form.
if (isset($_POST["smiley_id"])) {
$search = $_POST["search"];
$smiley = $_POST["smiley"];
$alt = $_POST["alt"];
$uses = $_POST["uses"];
}
if ($smiley_id == "NEW") {
$title = "Add a new smiley";
$submit = "Add smiley";
 
// Fill initial form data for creating smileys.
if (! isset($_POST["smiley_id"])) {
$search = "";
$smiley = "";
$alt = "";
$uses = 2;
}
} else {
$title = "Update a smiley";
$submit = "Update smiley";
 
// Fill initial form data for editing smileys.
if (! isset($_POST["smiley_id"])) {
$smileydata = $PHORUM["mod_smileys"]["smileys"][$smiley_id];
$search = $smileydata["search"];
$smiley = $smileydata["smiley"];
$alt = $smileydata["alt"];
$uses = $smileydata["uses"];
}
}
$frm = new PhorumInputForm ("", "post", $submit);
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "smileys");
$frm->hidden("smiley_id", $smiley_id);
$frm->hidden("action", "edit_smiley");
$frm->addbreak($title);
$frm->addrow("Smiley string to match", $frm->text_box("search", $search, 20));
$row = $frm->addrow("Image to replace the string with", $frm->select_tag("smiley", array_merge(array(''=>'Select smiley ...'),$available_smileys), $smiley, "onChange=\"change_image(this.options[this.selectedIndex].value);\"") . "&nbsp;&nbsp;<div style=\"display:none;margin-top:5px\" id=\"preview_div\"><strong>Preview: </strong><img src=\"images/trans.gif\" id=\"preview_image\" /></div>");
$frm->addhelp($row,
"Smiley replacement image",
"The drop down list shows all images that were found in your
smiley prefix path. If you want to add your own smileys, simply place
them in \"" . htmlspecialchars($PHORUM["mod_smileys"]["prefix"]) . "\"
and reload this page.");
$frm->addrow("ALT tag for the image", $frm->text_box("alt", $alt, 40));
$frm->addrow("Used for", $frm->select_tag("uses", $PHORUM_MOD_SMILEY_USES, $uses));
$frm->show();
 
// Make the preview image visible in case a $smiley is set.
if (!empty($smiley)) {?>
<script type="text/javascript">
change_image('<?php print addslashes($smiley) ?>');
</script><?php
}
 
// Show the configured list of smileys.
if ($smiley_id == "NEW")
{
print "<hr class=\"PhorumAdminHR\" />";
 
if (count($PHORUM["mod_smileys"]["smileys"]))
{ ?>
<table cellspacing="1" class="PhorumAdminTable" width="100%">
<tr>
<td class="PhorumAdminTableHead">String</td>
<td class="PhorumAdminTableHead">Image file</td>
<td class="PhorumAdminTableHead">Image</td>
<td class="PhorumAdminTableHead">ALT tag</td>
<td class="PhorumAdminTableHead">Used for</td>
<td class="PhorumAdminTableHead">&nbsp;</td>
</tr>
<?php
 
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $item)
{
$used_for_txt = $PHORUM_MOD_SMILEY_USES[$item['uses']];
foreach ($item as $key => $val) {
$item[$key] = htmlspecialchars($val);
}
$action_url = "$_SERVER[PHP_SELF]?module=modsettings&mod=smileys&smiley_id=$id";
 
print "<tr>\n";
print " <td class=\"PhorumAdminTableRow\">{$item["search"]}</td>\n";
print " <td class=\"PhorumAdminTableRow\">{$item["smiley"]}</td>\n";
print " <td class=\"PhorumAdminTableRow\" align=\"center\">";
if ($item["active"]) {
print "<img src=\"{$PHORUM["mod_smileys"]["prefix"]}{$item["smiley"]}\"/></td>\n";
} else {
print "<div style=\"color:red\">UNAVAILBLE</div>";
}
print " <td class=\"PhorumAdminTableRow\">{$item["alt"]}</td>\n";
print " <td class=\"PhorumAdminTableRow\" style=\"white-space:nowrap\">$used_for_txt</td>\n";
print " <td class=\"PhorumAdminTableRow\">" .
"<a href=\"$action_url&edit=1\">Edit</a>&nbsp;&#149;&nbsp;" .
"<a href=\"$action_url&delete=1\">Delete</a></td>\n";
print "</tr>\n";
}
 
print "</table>\n";
 
} else {
 
print "Currently, you have no smiley replacements configured.";
 
}
 
// For a more clear end of page.
print "<br/><br/><br/>";
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/info.txt
New file
0,0 → 1,4
hook: after_header|phorum_mod_smileys_after_header
hook: format|phorum_mod_smileys_format
title: Smiley Replacement Mod
desc: This module allows admins to define smiley replacements in messages.