$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;
/** * 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) { global $PHORUM; // 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'); $prefix = $GLOBALS["PHORUM"]["http_path"] . "/" . $modinfo["prefix"]; $prefix = preg_replace('/\\/\\.\\//', '/', $prefix); // 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. $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."); } }