[ Index ]
 

Code source de FCKeditor 2.4

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

title

Body

[fermer]

/ -> fckeditor.pl (source)

   1  #####
   2  #  FCKeditor - The text editor for Internet - http://www.fckeditor.net
   3  #  Copyright (C) 2003-2007 Frederico Caldeira Knabben
   4  #  
   5  #  == BEGIN LICENSE ==
   6  #  
   7  #  Licensed under the terms of any of the following licenses at your
   8  #  choice:
   9  #  
  10  #   - GNU General Public License Version 2 or later (the "GPL")
  11  #     http://www.gnu.org/licenses/gpl.html
  12  #  
  13  #   - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14  #     http://www.gnu.org/licenses/lgpl.html
  15  #  
  16  #   - Mozilla Public License Version 1.1 or later (the "MPL")
  17  #     http://www.mozilla.org/MPL/MPL-1.1.html
  18  #  
  19  #  == END LICENSE ==
  20  #  
  21  #  File Name: fckeditor.pl
  22  #      This is the integration file for Perl.
  23  #  
  24  #  File Authors:
  25  #          Takashi Yamaguchi (jack@omakase.net)
  26  #####
  27  
  28  #my $InstanceName;
  29  #my $BasePath;
  30  #my $Width;
  31  #my $Height;
  32  #my $ToolbarSet;
  33  #my $Value;
  34  #my %Config;
  35  
  36  sub FCKeditor
  37  {
  38  
  39      local($instanceName) = @_;
  40      $InstanceName    = $instanceName;
  41      $BasePath        = '/fckeditor/';
  42      $Width            = '100%';
  43      $Height            = '200';
  44      $ToolbarSet        = 'Default';
  45      $Value            = '';
  46  }
  47  
  48  sub Create
  49  {
  50      print &CreateHtml();
  51  }
  52  
  53  sub specialchar_cnv
  54  {
  55  
  56      local($ch) = @_;
  57  
  58      $ch =~ s/&/&/g;        # &
  59      $ch =~ s/\"/"/g;    #"
  60      $ch =~ s/\'/'/g;    # '
  61      $ch =~ s/</&lt;/g;        # <
  62      $ch =~ s/>/&gt;/g;        # >
  63      return($ch);
  64  }
  65  
  66  sub CreateHtml
  67  {
  68  
  69      $HtmlValue = &specialchar_cnv($Value);
  70      $Html = '<div>' ;
  71      if(&IsCompatible()) {
  72          $Link = $BasePath . "editor/fckeditor.html?InstanceName=$InstanceName";
  73          if($ToolbarSet ne '') {
  74              $Link .= "&amp;Toolbar=$ToolbarSet";
  75          }
  76          #// Render the linked hidden field.
  77          $Html .= "<input type=\"hidden\" id=\"$InstanceName\" name=\"$InstanceName\" value=\"$HtmlValue\" style=\"display:none\" />" ;
  78  
  79          #// Render the configurations hidden field.
  80          $cfgstr = &GetConfigFieldString();
  81          $wk = $InstanceName."___Config";
  82          $Html .= "<input type=\"hidden\" id=\"$wk\" value=\"$cfgstr\" style=\"display:none\" />" ;
  83  
  84          #// Render the editor IFRAME.
  85          $wk = $InstanceName."___Frame";
  86          $Html .= "<iframe id=\"$wk\" src=\"$Link\" width=\"$Width\" height=\"$Height\" frameborder=\"0\" scrolling=\"no\"></iframe>";
  87      } else {
  88          if($Width =~ /\%/g){
  89              $WidthCSS = $Width;
  90          } else {
  91              $WidthCSS = $Width . 'px';
  92          }
  93          if($Height =~ /\%/g){
  94              $HeightCSS = $Height;
  95          } else {
  96              $HeightCSS = $Height . 'px';
  97          }
  98          $Html .= "<textarea name=\"$InstanceName\" rows=\"4\" cols=\"40\" style=\"width: $WidthCSS; height: $HeightCSS\">$HtmlValue</textarea>";
  99      }
 100      $Html .= '</div>';
 101      return($Html);
 102  }
 103  
 104  sub IsCompatible
 105  {
 106  
 107      $sAgent = $ENV{'HTTP_USER_AGENT'};
 108      if(($sAgent =~ /MSIE/i) && !($sAgent =~ /mac/i) && !($sAgent =~ /Opera/i)) {
 109          $iVersion = substr($sAgent,index($sAgent,'MSIE') + 5,3);
 110          return($iVersion >= 5.5) ;
 111      } elsif($sAgent =~ /Gecko\//i) {
 112          $iVersion = substr($sAgent,index($sAgent,'Gecko/') + 6,8);
 113          return($iVersion >= 20030210) ;
 114      } else {
 115          return(0);        # 2.0 PR fix
 116      }
 117  }
 118  
 119  sub GetConfigFieldString
 120  {
 121      $sParams = '';
 122      $bFirst = 0;
 123      foreach $sKey (keys %Config) {
 124          $sValue = $Config{$sKey};
 125          if($bFirst == 1) {
 126              $sParams .= '&amp;';
 127          } else {
 128              $bFirst = 1;
 129          }
 130          $k = &specialchar_cnv($sKey);
 131          $v = &specialchar_cnv($sValue);
 132          if($sValue eq "true") {
 133              $sParams .= "$k=true";
 134          } elsif($sValue eq "false") {
 135              $sParams .= "$k=false";
 136          } else {
 137              $sParams .= "$k=$v";
 138          }
 139      }
 140      return($sParams);
 141  }
 142  
 143  1;


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