Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2006-05-23 12:07:44

Pilly
New member
Registered: 2006-05-23
Posts: 3

ImageManager / Plugin Help

Hi,

Im using this with oscommerce, I was using HTML area 3, but have installed Xinha to replace it.
Ive got it installed and I can edit the text area, but my problem is I dont think the plugins are working. The one I really want to work is imagemanager.

When I click on insert image,  the popup appears
(www.domain.com)  /msdiscreet/admin/includes/javascript/xinha/popups/insert_image.html

But i was expecting the imagemanager to appear...!!!!


Can anyone, put me in the right direction



In the main page where i call it...

  <script type="text/javascript">
    _editor_url  = "includes/javascript/xinha/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = "en";      // And the language we need to use in the editor.
    _editor_skin = "xp-blue";
  </script>
  <script type="text/javascript" src="includes/javascript/xinha/htmlarea.js"></script>
<script type="text/javascript" src="includes/javascript/xinha/Xinha_config.js"></script>

Xinha.config.js

<script type="text/javascript">
    xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;

    // This contains the names of textareas we will make into Xinha editors
    xinha_init = xinha_init ? xinha_init : function()
    {
      /** STEP 1 ***************************************************************
       * First, what are the plugins you will be using in the editors on this
       * page.  List all the plugins you will need, even if not all the editors
       * will use all the plugins.
       *
       * The list of plugins below is a good starting point, but if you prefer
       * a must simpler editor to start with then you can use the following 
       * 
       * xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
       *
       * which will load no extra plugins at all.
       ************************************************************************/

      xinha_plugins = xinha_plugins ? xinha_plugins :
      [
       'CharacterMap',
       'ContextMenu',
       'FullScreen',
       'ListType',
       'SpellChecker',
       'Stylist',
       'SuperClean',
       'ImageManager',
       'InsertPicture',
       'TableOperations'

      ];
             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
             if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;

      /** STEP 2 ***************************************************************
       * Now, what are the names of the textareas you will be turning into
       * editors?
       ************************************************************************/

      xinha_editors = xinha_editors ? xinha_editors :
      [
        products_description[' . $languages[$i]['id'] . ']
      ];

      /** STEP 3 ***************************************************************
       * We create a default configuration to be used by all the editors.
       * If you wish to configure some of the editors differently this will be
       * done in step 5.
       *
       * If you want to modify the default config you might do something like this.
       *
       *   xinha_config = new HTMLArea.Config();
       *   xinha_config.width  = '640px';
       *   xinha_config.height = '420px';
       *
       *************************************************************************/

       xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config();

       <?php
        session_start();
        $IMConfig = array();
        $IMConfig['images_dir'] = '/home/phil/public_html/msdiscreet/images/htmlarea/';
        $IMConfig['images_url'] = 'http://www.philpearce.com/msdiscreet/images/htmlarea/';
        $IMConfig = serialize($IMConfig);
        if(!isset($_SESSION['Xinha:ImageManager'])) 
        {
          $_SESSION['Xinha:ImageManager'] = uniqid('secret_');
        }
               
       ?>

<?php
        function jsaddslashes($s)
        {
         $o="";
         $l=strlen($s);
         for($i=0;$i<$l;$i++)
         {
          $c=$s[$i];
          switch($c)
          {
           case '<': $o.='\\x3C'; break;
           case '>': $o.='\\x3E'; break;
           case '\'': $o.='\\\''; break;
           case '\\': $o.='\\\\'; break;
           case '"':  $o.='\\"'; break;
           case "\n": $o.='\\n'; break;
           case "\r": $o.='\\r'; break;
           default:
           $o.=$c;
          }
         }
         return $o;
        }
?>

       xinha_config.ImageManager.backend_config      
         = '<?php echo jsaddslashes($IMConfig)?>';
       xinha_config.ImageManager.backend_config_hash 
         = '<?php echo sha1($IMConfig . $_SESSION['Xinha:ImageManager'])?>';

      /** STEP 4 ***************************************************************
       * We first create editors for the textareas.
       *
       * You can do this in two ways, either
       *
       *   xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
       *
       * if you want all the editor objects to use the same set of plugins, OR;
       *
       *   xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config);
       *   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
       *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
       *
       * if you want to use a different set of plugins for one or more of the
       * editors.
       ************************************************************************/

      xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);

      /** STEP 5 ***************************************************************
       * If you want to change the configuration variables of any of the
       * editors,  this is the place to do that, for example you might want to
       * change the width and height of one of the editors, like this...
       *
       *   xinha_editors.myTextArea.config.width  = '640px';
       *   xinha_editors.myTextArea.config.height = '480px';
       *
       ************************************************************************/


      /** STEP 6 ***************************************************************
       * Finally we "start" the editors, this turns the textareas into
       * Xinha editors.
       ************************************************************************/

      HTMLArea.startEditors(xinha_editors);
    }

    window.onload = xinha_init;
</script>

In plugin/imagemanager/config.inc.php

<?php
/**
 * Image Manager configuration file.
 * @author $Author: Wei Zhuo $
 * @version $Id: config.inc.php 27 2004-04-01 08:31:57Z Wei Zhuo $
 * @package ImageManager
 *
 * @todo change all these config values to defines()
 */

// REVISION HISTORY:
//
// 2005-03-20 Yermo Lamers (www.formvista.com):
//    . unified backend.
// . created a set of defaults that make sense for bundling with Xinha.

// -------------------------------------------------------------------------

require_once("../../../../configure.php");
/**
* Default backend URL
*
* URL to use for unified backend.
*
* The ?__plugin=ImageManager& is required. 
*/

//$IMConfig['backend_url'] = "backend.php?__plugin=ImageManager&";

/**
* Backend Installation Directory
*
* location of backend install; these are used to link to css and js
* assets because we may have the front end installed in a different
* directory than the backend. (i.e. nothing assumes that the frontend
* and the backend are in the same directory)
*/


// ------------------------------------------------------------

/**
* Path to directory containing images.
*
* File system path to the directory you want to manage the images
* for multiple user systems, set it dynamically.
*
* NOTE: This directory requires write access by PHP. That is, 
* PHP must be able to create files in this directory.
* Able to create directories is nice, but not necessary.
*
* CHANGE THIS: for out-of-the-box demo purposes we're setting this to ./demo_images
* which has some graphics in it.
*/

// $IMConfig['images_dir'] = "/some/path/to/images/directory;

$IMConfig['images_dir'] =  '/home/phil/public_html/msdiscreet/images/htmlarea/';

// -------------------------------------------------------------------------

/**
* URL of directory containing images.
*
* The URL to the above path, the web browser needs to be able to see it.
* It can be protected via .htaccess on apache or directory permissions on IIS,
* check you web server documentation for futher information on directory protection
* If this directory needs to be publicly accessiable, remove scripting capabilities
* for this directory (i.e. disable PHP, Perl, CGI). We only want to store assets
* in this directory and its subdirectories.
*
* CHANGE THIS: You need to change this to match the url where you have Xinha
* installed. If the images show up blank chances are this is not set correctly.
*/

// $IMConfig['images_url'] = "/url/to/above";

// try to figure out the URL of the sample images directory. For your installation
// you will probably want to keep images in another directory.

$IMConfig['images_url'] = 'http://www.xxxxxx.com/msdiscreet/images/htmlarea/';

// -------------------------------------------------------------------------

/**
* PHP Safe Mode?
*
* Possible values: true, false
*
* TRUE - If PHP on the web server is in safe mode, set this to true.
* SAFE MODE restrictions: directory creation will not be possible,
* only the GD library can be used, other libraries require
* Safe Mode to be off.
*
* FALSE - Set to false if PHP on the web server is not in safe mode.
*/

$IMConfig['safe_mode'] = false;

// -------------------------------------------------------------------------

/**
* Image Library to use.
*
* Possible values: 'GD', 'IM', or 'NetPBM'
*
* The image manipulation library to use, either GD or ImageMagick or NetPBM.
* If you have safe mode ON, or don't have the binaries to other packages, 
* your choice is 'GD' only. Other packages require Safe Mode to be off.
*
* DEFAULT: GD is probably the most likely to be available. 
*/

$IMConfig['IMAGE_CLASS'] = 'GD';


// -------------------------------------------------------------------------

/**
* NetPBM or IM binary path.
*
* After defining which library to use, if it is NetPBM or IM, you need to
* specify where the binary for the selected library are. And of course
* your server and PHP must be able to execute them (i.e. safe mode is OFF).
* GD does not require the following definition.
*/

$IMConfig['IMAGE_TRANSFORM_LIB_PATH'] ='/usr/bin/';

// For windows, something like
// C:/"Program Files"/ImageMagick-5.5.7-Q16/

// -------------------------------------------------------------------------
//                OPTIONAL SETTINGS 
// -------------------------------------------------------------------------

/**
* Thumbnail prefix
*
* The prefix for thumbnail files, something like .thumb will do. The
* thumbnails files will be named as "prefix_imagefile.ext", that is,
*  prefix + orginal filename.
*/

$IMConfig['thumbnail_prefix'] = '.';

// -------------------------------------------------------------------------

/**
* Thumbnail Directory
*
* Thumbnail can also be stored in a directory, this directory
* will be created by PHP. If PHP is in safe mode, this parameter
*  is ignored, you can not create directories. 
*
*  If you do not want to store thumbnails in a directory, set this
*  to false or empty string '';
*/

$IMConfig['thumbnail_dir'] = '.';

// -------------------------------------------------------------------------

/**
* Resized prefix
*
* The prefix for resized files, something like .resized will do.  The
* resized files will be named <prefix>_<width>x<height>_<original>
* resized files are created when one changes the dimensions of an image
* in the image manager selection dialog - the image is scaled when the
* user clicks the ok button.
*/

$IMConfig['resized_prefix'] = '.resized';

// -------------------------------------------------------------------------

/**
* Resized Directory
*
* Resized images may also be stored in a directory, except in safe mode.
*/

$IMConfig['resized_dir'] = '.resized';

// -------------------------------------------------------------------------

/**
* Allow New Directories
*
*
* Possible values: true, false
*
* TRUE -  Allow the user to create new sub-directories in the
*        $IMConfig['base_dir'].
*
* FALSE - No directory creation.
*
* NOTE: If $IMConfig['safe_mode'] = true, this parameter
*     is ignored, you can not create directories
*
* DEFAULT: for demo purposes we turn this off.
*/

$IMConfig['allow_new_dir'] = true;

// -------------------------------------------------------------------------

/**
* Allow Uploads
*
*  Possible values: true, false
*
*  TRUE - Allow the user to upload files.
*
*  FALSE - No uploading allowed.
*
* DEFAULT: for demo purposes we turn this off.
*/

$IMConfig['allow_upload'] = true;

// -------------------------------------------------------------------------

/**
* Validate Images
*
* Possible values: true, false
*
* TRUE - If set to true, uploaded files will be validated based on the 
*        function getImageSize, if we can get the image dimensions then 
*        I guess this should be a valid image. Otherwise the file will be rejected.
*
* FALSE - All uploaded files will be processed.
*
* NOTE: If uploading is not allowed, this parameter is ignored.
*/

$IMConfig['validate_images'] = true;

// -------------------------------------------------------------------------

/**
* Default Thumnail.
*
* The default thumbnail if the thumbnails can not be created, either
* due to error or bad image file.
*/

$IMConfig['default_thumbnail'] = 'img/default.gif';

// -------------------------------------------------------------------------

/**
*  Thumbnail dimensions.
*/

$IMConfig['thumbnail_width'] = 96;
$IMConfig['thumbnail_height'] = 96;

// -------------------------------------------------------------------------

/**
* Editor Temporary File Prefix.
*
* Image Editor temporary filename prefix.
*/

$IMConfig['tmp_prefix'] = '.editor_';


$IMConfig['ViewMode'] = 'thumbs';




////////////////////////////////////////////////////////////////////////////////
//       ================== END OF CONFIGURATION =======================      //
////////////////////////////////////////////////////////////////////////////////





// If config specified from front end, merge it
if(isset($_REQUEST['backend_config']))
{
  if(get_magic_quotes_gpc()) {
    $_REQUEST['backend_config'] = stripslashes($_REQUEST['backend_config']);
  }
  
  // Config specified from front end, check that it's valid
  session_start();
  $secret = $_SESSION[$_REQUEST['backend_config_secret_key_location']];

  if($_REQUEST['backend_config_hash'] !== sha1($_REQUEST['backend_config'] . $secret))
  {
    die("Backend security error.");
  }

  $to_merge = unserialize($_REQUEST['backend_config']);
  if(!is_array($to_merge))
  {
    die("Backend config syntax error.");
  }

  $IMConfig = array_merge($IMConfig, $to_merge);
  $IMConfig['backend_url'] .= "backend_config=" . rawurlencode($_REQUEST['backend_config']) . '&';
  $IMConfig['backend_url'] .= "backend_config_hash=" . rawurlencode($_REQUEST['backend_config_hash']) . '&';
  $IMConfig['backend_url'] .= "backend_config_secret_key_location=" . rawurlencode($_REQUEST['backend_config_secret_key_location']) . '&';

}

define('IMAGE_CLASS', $IMConfig['IMAGE_CLASS']);
define('IMAGE_TRANSFORM_LIB_PATH', $IMConfig['IMAGE_TRANSFORM_LIB_PATH']);
define( "IM_CONFIG_LOADED", "yes" );

// bring in the debugging library

include_once( "ddt.php" );

// uncomment to send debug messages to a local file
// _setDebugLog( "/tmp/debug_log.txt" );

// turn debugging on everywhere.
// _ddtOn();

// END

?>

Offline

#2 2006-05-24 03:55:12

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: ImageManager / Plugin Help

Install the LiveHeaders plugin for Firefox and try it (and look at the headers to see if everything loads properly), chances are there is some permission problem or something and ImageManager is not getting installed.


James Sleeman

Offline

#3 2006-05-24 06:13:45

Pilly
New member
Registered: 2006-05-23
Posts: 3

Re: ImageManager / Plugin Help

ok,

Ive installed the liveheaders for firefox.

I can assume from the 404 error file isnt found. But ive tried loads of methods to select the directories / urls within imagemananger...

Can anyone see the error in my config.inc.php above??? I assume thats where the error lies..


http://www.xxx.com/msdiscreet/admin/inc … e/skin.css

GET /msdiscreet/admin/includes/javascript/xinha/popups/includes/javascript/xinha/skins/xp-blue/skin.css HTTP/1.1
Host: www.xxx.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
Accept: text/css,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.xxx.com/msdiscreet/admin/inc … image.html

HTTP/1.x 404 Not Found
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Transfer-Encoding: chunked
Via: 1.1 UK-PROXY-SERVER
Date: Wed, 24 May 2006 10:16:15 GMT
Content-Type: text/html; charset=iso-8859-1
Server: Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.2 FrontPage/5.0.2.2634a mod_ssl/2.8.21 OpenSSL/0.9.6b
Keep-Alive: timeout=15, max=99

Last edited by Pilly (2006-05-24 06:18:52)

Offline

#4 2006-05-25 07:01:32

Pilly
New member
Registered: 2006-05-23
Posts: 3

Re: ImageManager / Plugin Help

I got it working with the full_example.html in the examples dir...

so as its visible and working just the plugins not working, the error must be in this.. Can anyone see the error??

  <script type="text/javascript">
    _editor_url  = "includes/javascript/xinha/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = "en";      // And the language we need to use in the editor.
    _editor_skin = "xp-blue";
  </script>
  <script type="text/javascript" src="includes/javascript/xinha/htmlarea.js"></script>
  <script type="text/javascript" src="includes/javascript/xinha/Xinha_config.js">
 <script type="text/javascript">
    xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;


    // This contains the names of textareas we will make into Xinha editors
    xinha_init = xinha_init ? xinha_init : function()
    {


      xinha_plugins = xinha_plugins ? xinha_plugins :
      [
       'CharacterMap',
       'ContextMenu',
       'FullScreen',
       'ListType',
       'SpellChecker',
       'Stylist',
       'SuperClean',
       'ImageManager',
       'TableOperations'
      ];

             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
             if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;


      xinha_editors = xinha_editors ? xinha_editors :
      [
        products_description[' . $languages[$i]['id'] . ']
      ];


       xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config();



      xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);



      HTMLArea.startEditors(xinha_editors);
    }

    window.onload = xinha_init;
  </script>

Last edited by Pilly (2006-05-25 10:53:23)

Offline

#5 2006-05-26 08:55:20

steveo125
Xinha Community Member
Registered: 2006-04-04
Posts: 24

Re: ImageManager / Plugin Help

Your _editor_url is relative.  It needs to start with a / to make it absolute - Xinha tries to work with relative paths, but an absolute one is more reliable. - as it says at the end of the line.....

try
_editor_url= "/msdiscreet/admin/includes/javascript/xinha/";

Offline

#6 2006-06-02 20:12:30

NotSteve
New member
Registered: 2006-06-02
Posts: 3

Re: ImageManager / Plugin Help

That's interesting. I had some trouble getting the Image Manager to work in osCommerce, but finally got it. Let me know if you're still having a problem; I'll post my config settings.

Bill

Offline

Board footer

Powered by FluxBB