News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1255115930:v:use_geshi-1:v:type-xml

Started by Guest, Oct 09, 2009, 07:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Guest

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
   <id>groundup:Faster_parsesmileys</id>
   <name>Faster_parsesmileys</name>
   <version>1.0</version>
   <type>modification</type>
   <install>
      <modification type="inline">   
      <file name="$sourcedir/Subs.php">
      <operation>
         <search position="replace" whitespace="loose"><![CDATA[function parsesmileys(&$message)]]></search>
         <add><![CDATA[function parsesmileys(&$message)
{
   //parsesmileys_old($message);
   parse_smileys($message);
}

// Parse smileys in the passed message.
function parse_smileys(&$message)
{
   global $modSettings, $txt, $user_info, $context, $smcFunc;
   static $smileyarray = array();

   // No smiley set at all?!
   if ($user_info['smiley_set'] == 'none' || trim($message) == '')
      return;

   // If the smiley array hasn't been set, do it now.
   if (empty($smileyarray))
   {
      // Use the default smileys if it is disabled. (better for "portability" of smileys.)
      if (empty($modSettings['smiley_enable']))
      {
         $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
         $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
         $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
      }
      else
      {
         // Load the smileys in reverse order by length so they don't get parsed wrong.
         if (($temp = cache_get_data('parsing_smileys', 480)) == null)
         {
            $result = $smcFunc['db_query']('', '
               SELECT code, filename, description
               FROM {db_prefix}smileys',
               array(
               )
            );
            $smileysfrom = array();
            $smileysto = array();
            $smileysdescs = array();
            while ($row = $smcFunc['db_fetch_assoc']($result))
            {
               $smileysfrom[] = $row['code'];
               $smileysto[] = $row['filename'];
               $smileysdescs[] = $row['description'];
            }
            $smcFunc['db_free_result']($result);

            cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
         }
         else
            list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
      }

      foreach ($smileysfrom as $i => $from)
      {
         $smileyCode = '<img src="' . $modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i] . '" alt="' . htmlentities($from) . '" title="' . htmlentities($smileysdescs[$i]) . '" class="smiley" />';

         $smileyarray[$from] = $smileyCode;
         if ($from != ($specialChars = htmlspecialchars($from, ENT_QUOTES)))
            $smileyarray[$specialChars] = $smileyCode;
      }
   }

   // Replace away!
   $message = strtr($message, $smileyarray);
}

function parsesmileys_old(&$message)]]></add>
      </operation>
   </file>
   </modification>
   </install>
</package-info>