[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/Text/Filter/ -> emoticons.php (source)

   1  <?php
   2  
   3  require_once  'Horde.php';
   4  
   5  /**
   6   * The Text_Filter_emoticons:: class finds emoticon strings ( :), etc.) in a
   7   * block of text and turns them into image links.
   8   *
   9   * Parameters:
  10   * <pre>
  11   * entities -- If true the html entity versions of the patterns will be used.
  12   * </pre>
  13   *
  14   * $Horde: framework/Text_Filter/Filter/emoticons.php,v 1.17.10.10 2006/07/24 04:48:17 slusarz Exp $
  15   *
  16   * Copyright 2003-2006 Marko Djukic <marko@oblo.com>
  17   *
  18   * See the enclosed file COPYING for license information (LGPL). If you did not
  19   * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  20   *
  21   * @author  Marko Djukic <marko@oblo.com>
  22   * @package Horde_Text
  23   */
  24  class Text_Filter_emoticons extends Text_Filter {
  25  
  26      /**
  27       * Filter parameters.
  28       *
  29       * @var array
  30       */
  31      var $_params = array('entities' => false);
  32  
  33      /**
  34       * Returns a hash with replace patterns.
  35       *
  36       * @return array  Patterns hash.
  37       */
  38      function getPatterns()
  39      {
  40          $regexp = array();
  41          $iconpath = $GLOBALS['registry']->getImageDir('horde') . '/emoticons';
  42  
  43          /* Loop through possible string emoticons and convert to graphics. */
  44          foreach ($this->getIcons() as $string => $icon) {
  45              $beg_pattern = '(^|\s)';
  46              $end_pattern = '(?=\s)';
  47              if ($this->_params['entities']) {
  48                  $string = htmlspecialchars($string);
  49                  $beg_pattern = '(^|\s|<br />|&nbsp;)';
  50                  $end_pattern = '(?=\s|<br />|&nbsp;)';
  51              }
  52  
  53              /* Check for a smiley either immediately at the start of a line or
  54               * following a space. Use {} as the preg delimiters as this is not
  55               * found in any smiley. */
  56              $regexp['{' . $beg_pattern . preg_quote($string) . $end_pattern . '}'] = '\\1' . Horde::img($icon . '.png', $string, array('align' => 'middle', 'title' => $string), $iconpath) . (($this->_params['entities']) ? '\\2' : '');
  57          }
  58  
  59          return array('regexp' => $regexp);
  60      }
  61  
  62      /**
  63       * Returns a hash with emoticons and names.
  64       *
  65       * @return array  Patterns hash.
  66       */
  67      function getIcons()
  68      {
  69          /* List complex strings before simpler ones, otherwise for example :((
  70           * would be matched against :( before :(( is found. */
  71          return array(
  72              ':/' => 'frustrated', ':-/' => 'frustrated',
  73              // ':*>' => 'blush',
  74              ':e' => 'disappointed',
  75              '=:)$' => 'mrt',
  76              '#|' => 'hangover', '#-|' => 'hangover',
  77              ':-@' => 'shout',
  78              ':((' => 'bigfrown', ':C' => 'bigfrown',
  79              ':S' => 'dazed', ':-S' => 'dazed',
  80              'X@' => 'angry',
  81              'X(' => 'mad',
  82              // '>:)' => 'devil', '>:-)' => 'devil',
  83              // '>:p' => 'deviltongue', '>:-p' => 'deviltongue',
  84              // '>:p' => 'raspberry', '>:P' => 'raspberry',
  85              // '&)' => 'punk',
  86              // '&p' => 'punktongue',
  87              // '=&)' => 'punkmohawk',
  88              ':]' => 'grin',
  89              '#[' => 'hurt', '#(' => 'hurt', '#-[' => 'hurt', '#-(' => 'hurt',
  90              ':O' => 'embarrassed', ':-O' => 'embarrassed',
  91              ':[' => 'sad',
  92              // '>:@' => 'enraged',
  93              // ':&' => 'annoyed',
  94              '=(' => 'worried', '=-(' => 'worried',
  95              ':|=' => 'vampire',
  96              ':-(' => 'frown',
  97              ':D' => 'biggrin',
  98              '8)' => 'cool',
  99              // In English, 8PM occurs sufficiently often to specifically
 100              // search for and exclude
 101              '8p(?<![Mm]\s+)' => 'cooltongue', // '8Þ' => 'cooltongue',
 102              '8D' => 'coolgrin',
 103              ':p' => 'tongueout', ':P' => 'tongueout', // ':Þ' => 'tongueout',
 104              '?:(' => 'confused', '%-(' => 'confused',
 105              // ':)&' => 'love',
 106              'O;-)' => 'angelwink',
 107              ';]' => 'winkgrin',
 108              ';p' => 'winktongue', ';P' => 'winktongue', // ';Þ' => 'winktongue',
 109              ':|' => 'indifferent', ':-|' => 'indifferent',
 110              '!|' => 'tired', '!-I' => 'tired',
 111              '|I' => 'asleep', '|-I' => 'asleep',
 112              'O:)' => 'angel', 'O:-)' => 'angel',
 113              'O;)' => 'angelwink',
 114              ';-)' => 'wink',
 115              ':#)' => 'clown', ':o)' => 'clown',
 116              ':)' => 'smile',
 117              ';)' => 'wink',
 118              ':-)' => 'smile',
 119              ':@' => 'shout',
 120              ':(' => 'frown',
 121          );
 122      }
 123  
 124  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7