[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/includes/ -> fckeditor.php (source)

   1  <?php
   2  /**

   3   * @package htmleditors

   4   * @copyright Copyright 2003-2006 Zen Cart Development Team

   5   * @copyright Portions Copyright 2003 osCommerce

   6   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   7   * @version $Id: fckeditor.php 4245 2006-08-24 14:07:50Z drbyte $

   8   */
   9  
  10  /**

  11   * Customizations for Zen Cart based on FCKeditor v2.3.1

  12   */
  13  
  14  class FCKeditor
  15  {
  16      var $InstanceName ;
  17      var $BasePath ;
  18      var $Width ;
  19      var $Height ;
  20      var $ToolbarSet ;
  21      var $Value ;
  22      var $Config ;
  23  
  24      // PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>)

  25  	function __construct( $instanceName )
  26      {
  27          $this->InstanceName    = $instanceName ;
  28          $this->BasePath = DIR_WS_CATALOG.'editors/fckeditor/' ;
  29          $this->Width        = '100%' ;
  30          $this->Height        = '250' ;
  31          $this->ToolbarSet    = 'Default' ;  // 'Default'/blank or "Basic"

  32          $this->Value = '' ;           // default text

  33      $this->EditorAreaCSS = DIR_WS_CATALOG . 'includes/templates/template_default/css/stylesheet.css';
  34      $this->AutoDetectLanguage = true ;
  35      $this->DefaultLanguage    = strtolower($_SESSION['languages_code']);
  36  
  37  //        $this->CanUpload = 'true' ;   // true or none

  38  //        $this->CanBrowse = 'true' ;   // true or none

  39  
  40          $this->Config        = array() ;
  41      }
  42      
  43      // PHP 4 Contructor

  44  	function FCKeditor( $instanceName )
  45      {
  46          $this->__construct( $instanceName ) ;
  47      }
  48      
  49  	function Create()
  50      {
  51          echo $this->CreateHtml() ;
  52      }
  53  
  54  	function CreateHtml()
  55      {
  56          $HtmlValue = htmlspecialchars( $this->Value ) ;
  57  
  58          $Html = '<div>' ;
  59          
  60          if ( $this->IsCompatible() )
  61          {
  62              if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
  63                  $File = 'fckeditor.original.html' ;
  64              else
  65                  $File = 'fckeditor.html' ;
  66  
  67              $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
  68  
  69              if ( $this->ToolbarSet != '' )
  70                  $Link .= "&amp;Toolbar={$this->ToolbarSet}" ;
  71  
  72              // Render the linked hidden field.

  73              $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
  74  
  75              // Render the configurations hidden field.

  76              $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
  77  
  78              // Render the editor IFRAME.

  79              $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
  80          }
  81          else
  82              {
  83              if ( strpos( $this->Width, '%' ) === false )
  84                  $WidthCSS = $this->Width . 'px' ;
  85                  else
  86                  $WidthCSS = $this->Width ;
  87  
  88              if ( strpos( $this->Height, '%' ) === false )
  89                  $HeightCSS = $this->Height . 'px' ;
  90                  else
  91                  $HeightCSS = $this->Height ;
  92  
  93              $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
  94              }
  95  
  96          $Html .= '</div>' ;
  97          
  98          return $Html ;
  99          }
 100  
 101  	function IsCompatible()
 102      {
 103          global $HTTP_USER_AGENT ;
 104  
 105          if ( isset( $HTTP_USER_AGENT ) )
 106              $sAgent = $HTTP_USER_AGENT ;
 107          else
 108              $sAgent = $_SERVER['HTTP_USER_AGENT'] ;
 109  
 110          if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
 111          {
 112              $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
 113              return ($iVersion >= 5.5) ;
 114          }
 115          else if ( strpos($sAgent, 'Gecko/') !== false )
 116          {
 117              $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
 118              return ($iVersion >= 20030210) ;
 119          }
 120          else
 121              return false ;
 122      }
 123      
 124  	function GetConfigFieldString()
 125      {
 126          $sParams = '' ;
 127          $bFirst = true ;
 128  
 129          foreach ( $this->Config as $sKey => $sValue )
 130          {
 131              if ( $bFirst == false )
 132                  $sParams .= '&amp;' ;
 133              else
 134                  $bFirst = false ;
 135              
 136              if ( $sValue === true )
 137                  $sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
 138              else if ( $sValue === false )
 139                  $sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
 140              else
 141                  $sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
 142          }
 143          
 144          return $sParams ;
 145          }
 146  
 147  	function EncodeConfig( $valueToEncode )
 148      {
 149          $chars = array( 
 150              '&' => '%26', 
 151              '=' => '%3D', 
 152              '"' => '%22' ) ;
 153  
 154          return strtr( $valueToEncode,  $chars ) ;
 155      }
 156  }
 157  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics