Changes between Version 2 and Version 3 of Documentation/Plugins/ImageManager


Ignore:
Timestamp:
09/13/06 16:04:08 (13 years ago)
Author:
gogo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/Plugins/ImageManager

    v2 v3  
    2020}}} 
    2121 
    22 Now we configure the PHP, because we are passing this through javascript we have to have a "secret" key so we know it hasn't been tampered with... 
     22Now we configure the PHP, (for a full list of options you can use here, see the config.inc.php in the ImageManager directory, any you don't provide here will revert to the defaults shown in that file)... 
     23 
    2324{{{ 
    24       <?php 
    25         session_start(); 
    26         $IMConfig = array(); 
    27         $IMConfig['images_dir'] = '/full/path/to/images/'; 
    28         $IMConfig['images_url'] = '/url/to/images/'; 
    29         $IMConfig = serialize($IMConfig); 
    30         if(!isset($_SESSION['Xinha:ImageManager']))  
    31         { 
    32           $_SESSION['Xinha:ImageManager'] = uniqid('secret_'); 
    33         }         
    34        ?> 
     25 with(xinha_config.ImageManager) 
     26 { 
     27  <?php 
     28     require_once('/path/to/xinha/contrib/php-xinha.php'); 
     29     xinha_pass_to_php_backend( 
     30       array( 
     31         'images_dir' => '/path/to/images',  
     32         'images_url' => '/images' 
     33       ) 
     34     );  
     35   ?> 
     36 } 
    3537}}} 
    3638 
    37 And finally configure the client side... 
    38 {{{  
    39   xinha_config.ImageManager.backend_config       
    40     = '<?php echo jsaddslashes($IMConfig)?>'; 
    41   xinha_config.ImageManager.backend_config_hash  
    42     = '<?php echo sha1($IMConfig . $_SESSION['Xinha:ImageManager'])?>'; 
    43 }}} 
    44  
    45  
    46  
     39Fairly obviously, you need to change the paths above to suit your installation. 
    4740 
    4841== Complete Example == 
     
    5144    xinha_init = xinha_init ? xinha_init : function() 
    5245    { 
    53       /** STEP 1 *************************************************************** 
     46      /** STE      P 1 *************************************************************** 
    5447       * First, what are the plugins you will be using in the editors on this 
    5548       * page.  List all the plugins you will need, even if not all the editors 
     
    8982       xinha_config = xinha_config ? xinha_config : new HTMLArea.Config(); 
    9083 
    91        <?php 
    92         session_start(); 
    93         $IMConfig = array(); 
    94         $IMConfig['images_dir'] = '/full/path/to/images/'; 
    95         $IMConfig['images_url'] = '/url/to/images/'; 
    96         $IMConfig = serialize($IMConfig); 
    97         if(!isset($_SESSION['Xinha:ImageManager']))  
    98         { 
    99           $_SESSION['Xinha:ImageManager'] = uniqid('secret_'); 
    100         } 
    101                 
    102        ?> 
    103  
    104        xinha_config.ImageManager.backend_config       
    105          = '<?php echo jsaddslashes($IMConfig)?>'; 
    106        xinha_config.ImageManager.backend_config_hash  
    107          = '<?php echo sha1($IMConfig . $_SESSION['Xinha:ImageManager'])?>'; 
    108  
     84       with(xinha_config.ImageManager) 
     85       { 
     86        <?php 
     87          require_once('/path/to/xinha/contrib/php-xinha.php'); 
     88          xinha_pass_to_php_backend( 
     89            array( 
     90              'images_dir' => '/path/to/images',  
     91              'images_url' => '/images' 
     92            ) 
     93          );  
     94        ?> 
     95       } 
    10996      /** STEP 4 *************************************************************** 
    11097       * We first create editors for the textareas. 
     
    147134 
    148135}}} 
    149  
    150 == jsaddslashes == 
    151 The PHP code above uses a function called jsaddslashes() to escape characters that are special within javascript strings.  Here is a suitable function if you do not have one in your collection already. 
    152  
    153 {{{ 
    154 <?php 
    155         function jsaddslashes($s) 
    156         { 
    157          $o=""; 
    158          $l=strlen($s); 
    159          for($i=0;$i<$l;$i++) 
    160          { 
    161           $c=$s[$i]; 
    162           switch($c) 
    163           { 
    164            case '<': $o.='\\x3C'; break; 
    165            case '>': $o.='\\x3E'; break; 
    166            case '\'': $o.='\\\''; break; 
    167            case '\\': $o.='\\\\'; break; 
    168            case '"':  $o.='\\"'; break; 
    169            case "\n": $o.='\\n'; break; 
    170            case "\r": $o.='\\r'; break; 
    171            default: 
    172            $o.=$c; 
    173           } 
    174          } 
    175          return $o; 
    176         } 
    177 ?> 
    178 }}}