/[drupal]/contributions/modules/textimage/textimage.module
ViewVC logotype

Diff of /contributions/modules/textimage/textimage.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.23.4.15, Thu May 14 12:34:24 2009 UTC revision 1.23.4.16, Wed May 20 00:02:29 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: textimage.module,v 1.23.4.14 2009/05/14 03:55:13 deciphered Exp $  // $Id: textimage.module,v 1.23.4.15 2009/05/14 12:34:24 deciphered Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 613  function textimage_wrap_text($text, $fon Line 613  function textimage_wrap_text($text, $fon
613    // Note: we count in bytes for speed reasons, but maintain character boundaries.    // Note: we count in bytes for speed reasons, but maintain character boundaries.
614    while (true) {    while (true) {
615      // Find the next wrap point (always after trailing whitespace).      // Find the next wrap point (always after trailing whitespace).
616      if (preg_match('/['. PREG_CLASS_PUNCTUATION .']['. PREG_CLASS_SEPARATOR .']*|['. PREG_CLASS_SEPARATOR .']+/u', $text, $match, PREG_OFFSET_CAPTURE, $end)) {      if (drupal_preg_match('/['. PREG_CLASS_PUNCTUATION .']['. PREG_CLASS_SEPARATOR .']*|['. PREG_CLASS_SEPARATOR .']+/u', $text, $match, PREG_OFFSET_CAPTURE, $end)) {
617        $end = $match[0][1] + drupal_strlen($match[0][0]);        $end = $match[0][1] + drupal_strlen($match[0][0]);
618      }      }
619      else {      else {
# Line 656  function textimage_wrap_text($text, $fon Line 656  function textimage_wrap_text($text, $fon
656  }  }
657    
658  /**  /**
659     * Unicode-safe preg_match().
660     *
661     * Search subject for a match to the regular expression given in pattern,
662     * but return offsets in characters, where preg_match would return offsets
663     * in bytes.
664     *
665     * @see http://php.net/manual/en/function.preg-match.php
666     */
667    if (!function_exists('drupal_preg_match')) {
668      function drupal_preg_match($pattern, $subject, &$matches, $flags = NULL, $offset = 0) {
669        // Convert the offset value from characters to bytes.
670        $offset = strlen(drupal_substr($subject, 0, $offset, $encoding));
671    
672        $return_value = preg_match($pattern, $subject, $matches, $flags, $offset);
673    
674        if ($return_value && ($flags & PREG_OFFSET_CAPTURE)) {
675          foreach ($matches as &$match) {
676            // Convert the offset returned by preg_match from bytes back to characters.
677            $match[1] = drupal_strlen(substr($subject, 0, $match[1]));
678          }
679        }
680        return $return_value;
681      }
682    }
683    
684    /**
685   * Generate an image containing text with the given parameters.   * Generate an image containing text with the given parameters.
686   *   *
687   * @return $image   * @return $image

Legend:
Removed from v.1.23.4.15  
changed lines
  Added in v.1.23.4.16

  ViewVC Help
Powered by ViewVC 1.1.2