[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/common/ -> ezautolinkoperator.php (source)

   1  <?php
   2  //
   3  // Definition of eZAutoLinkOperator class
   4  //
   5  // Created on: <07-Feb-2003 09:39:55 bf>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  class eZAutoLinkOperator
  30  {
  31      /*!
  32       */
  33      function eZAutoLinkOperator( $name = 'autolink' )
  34      {
  35          $this->Operators = array( $name );
  36      }
  37  
  38      /*!
  39       Returns the operators in this class.
  40      */
  41      function &operatorList()
  42      {
  43          return $this->Operators;
  44      }
  45  
  46      /*!
  47       See eZTemplateOperator::namedParameterList()
  48      */
  49      function namedParameterList()
  50      {
  51          return array( 'max_chars' => array( 'type' => 'integer',
  52                                              'required' => false,
  53                                              'default' => null ) );
  54      }
  55  
  56      function formatUri( $url, $max )
  57      {
  58          $text = $url;
  59          if (strlen($text) > $max)
  60          {
  61              $text = substr($text, 0, ($max / 2) - 3). '...'. substr($text, strlen($text) - ($max / 2));
  62          }
  63          return "<a href=\"$url\" title=\"$url\">$text</a>";
  64      }
  65  
  66      /*!
  67       \static
  68      */
  69      function addURILinks( $text, $max, $methods = 'http|https|ftp' )
  70      {
  71          return preg_replace(
  72              "!($methods):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:\/~\+#;*\(\)\!]*[\w\-\@?^=%&\/~\+#;*\(\)\!])?!e",
  73              'eZAutoLinkOperator::formatUri("$0", '. $max. ')',
  74              $text
  75          );
  76      }
  77  
  78  
  79      /*!
  80       \reimp
  81      */
  82      function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
  83      {
  84          $ini =& $tpl->ini();
  85          $max = $ini->variable( 'AutoLinkOperator', 'MaxCharacters' );
  86          if ( $namedParameters['max_chars'] !== null )
  87          {
  88              $max = $namedParameters['max_chars'];
  89          }
  90  
  91          $methods = $ini->variable( 'AutoLinkOperator', 'Methods' );
  92          $methodText = implode( '|', $methods );
  93  
  94          // Replace mail
  95          $operatorValue = preg_replace( "#(([a-zA-Z0-9_-]+\\.)*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+\\.)*[a-zA-Z0-9_-]+)#", "<a href='mailto:\\1'>\\1</a>", $operatorValue );
  96  
  97          // Replace http/ftp etc. links
  98          $operatorValue = eZAutoLinkOperator::addURILinks($operatorValue, $max, $methodText);
  99      }
 100  
 101      /// \privatesection
 102      var $Operators;
 103  };
 104  
 105  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7