Viewing Paste 389

Formated Paste

  1. <?xml version="1.0"?>
  2. <!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
  3. <package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
  4. <id>groundup:Faster_parsesmileys</id>
  5. <name>Faster_parsesmileys</name>
  6. <version>1.0</version>
  7. <type>modification</type>
  8. <install>
  9. <modification type="inline">
  10. <file name="$sourcedir/Subs.php">
  11. <operation>
  12. <search position="replace" whitespace="loose"><![CDATA[function parsesmileys(&$message)]]></search>
  13. <add><![CDATA[function parsesmileys(&$message)
  14. {
  15. //parsesmileys_old($message);
  16. parse_smileys($message);
  17. }
  18.  
  19. // Parse smileys in the passed message.
  20. function parse_smileys(&$message)
  21. {
  22. global $modSettings, $txt, $user_info, $context, $smcFunc;
  23. static $smileyarray = array();
  24.  
  25. // No smiley set at all?!
  26. if ($user_info['smiley_set'] == 'none' || trim($message) == '')
  27. return;
  28.  
  29. // If the smiley array hasn't been set, do it now.
  30. if (empty($smileyarray))
  31. {
  32. // Use the default smileys if it is disabled. (better for "portability" of smileys.)
  33. if (empty($modSettings['smiley_enable']))
  34. {
  35. $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
  36. $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');
  37. $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'], '', '', '', '');
  38. }
  39. else
  40. {
  41. // Load the smileys in reverse order by length so they don't get parsed wrong.
  42. if (($temp = cache_get_data('parsing_smileys', 480)) == null)
  43. {
  44. $result = $smcFunc['db_query']('', '
  45. SELECT code, filename, description
  46. FROM {db_prefix}smileys',
  47. array(
  48. )
  49. );
  50. $smileysfrom = array();
  51. $smileysto = array();
  52. $smileysdescs = array();
  53. while ($row = $smcFunc['db_fetch_assoc']($result))
  54. {
  55. $smileysfrom[] = $row['code'];
  56. $smileysto[] = $row['filename'];
  57. $smileysdescs[] = $row['description'];
  58. }
  59. $smcFunc['db_free_result']($result);
  60.  
  61. cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
  62. }
  63. else
  64. list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
  65. }
  66.  
  67. foreach ($smileysfrom as $i => $from)
  68. {
  69. $smileyCode = '<img src="' . $modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i] . '" alt="' . htmlentities($from) . '" title="' . htmlentities($smileysdescs[$i]) . '" class="smiley" />';
  70.  
  71. $smileyarray[$from] = $smileyCode;
  72. if ($from != ($specialChars = htmlspecialchars($from, ENT_QUOTES)))
  73. $smileyarray[$specialChars] = $smileyCode;
  74. }
  75. }
  76.  
  77. // Replace away!
  78. $message = strtr($message, $smileyarray);
  79. }
  80.  
  81. function parsesmileys_old(&$message)]]></add>
  82. </operation>
  83. </file>
  84. </modification>
  85. </install>
  86. </package-info>
Name:
Email:
Code/text to paste:
  • Enable code highlighting
  • Code Language:
  • A duck, cat and a goose walk into a bar. How many animals walked into a bar?:
Highslide for Wordpress Plugin