source: trunk/plugins/ImageManager/config.inc.php @ 1192

Last change on this file since 1192 was 1192, checked in by gogo, 10 years ago

Discussion in ticket #1478

Creating Sub Classes

Addition of method Xinha.extend. This method provides a means for more "classical" sub classing within javascript. Short story,

    var Vehicle = function() { }
    Vehicle.prototype.horn = function() { alert('Toot'); }
    var Car = function()
	{
		Car.parentConstructor.call(this); // If you want to call it.
	}
    Xinha.extend(Car, Vehicle);
    Car.prototype.horn = function()
	{
		alert('Toot');
		Car.superClass.horn.call(this);  // If you want to call it.
	}

remember the "call" method of javascript is .call(<on-this-object>, arg, arg, arg ..) and that you can also use the "apply" method to pass in arguments as an array which is .apply(<on this object>, [arg, arg, arg]), and that the arguments to your method are in the "arguments" array.

Dialog Modification

Split out the setting of the localizer from the translation of HTML in source:trunk/modules/Dialogs/XinhaDialog.js by introducing a new method Xinha.Dialog::setLocalizer(), Xinha.Dialog::translateHtml() remains compatible, the localizer is optional to it.

.htaccess Security

Further additions to the .htaccess files for the demo_images in ExtendedFileManager? and ImageManager?. I think we should give consideration to just deleting these folders totally, over the last year I've had a number of instances of people coming to me with these folders filled with various malware.

File-Picker on arbitrary fields outside Xinha (ExtendedFileManager?)

Addition of a source:trunk/plugins/ExtendedFileManager/file-picker.js hijacking of the ExtendedFileManager? in the same manner as the existing source:trunk/plugins/ImageManager/image-picker.js within ImageManager?. I'm putting this n there incase somebody finds it useful, but it may need some work as I don't use it myself any more. I am likely to come up with a way to replace both ExtendedFileManager? and ImageManager? with the "Mootools FileManager", this is a very nice file manager with a similar dialog "look" to our new dialogs, and the very VERY important bonus of it being easy to upload multiple files at once with a progress indicator (using a hidden flash component to do the hard work).

ImageManager? to use hspace and vspace attributes instead of margin.

The addition of a config option to ImageManager? "UseHSpaceVSpace" which swaps out the "margin" settings for the hspace and vspace attributes. The reason for this apparent "old fashioned-ness" is that margin is less reliably honoured when the HTML is put into an email.

YouTube and Flickr added to the ImageManager?

The addition of additional data sources (aka backends or choosers) to ImageManager?, specifically "YouTube" and "Flickr".

When one or both is enabled the user can use a selector in the image manager popup to choose from images on the local server, or search for videos on YouTube, or images on Flickr.

YouTube is enabled by setting $IMConfig['YouTube'] = TRUE; when the user selects a video the large format video still is inserted into the Xinha area, with extra information on the query string.

Flickr is enabled by setting $IMConfig['Flickr']['Key'] = 'your flickr api key here';, when the user selects an image, the image is inserted into the Xinha area.

For videos especially there needs to be some extra processing to turn that into a video when the end user sees this HTML, this is done by the "smart-image.js" script in combination with the (included) swfobject. In short, on the page WHERE YOU USE THE HTML (not where you are running Xinha to edit it) you will put this

   <script type="text/javascript" src="/path/to/xinha/plugins/ImageManager/smart-image.js"></script>
   <body onload="SmartImages.replace_all();">

it will replace the still image with the video (provided javascript is on).

Smart-image will also add a little hover attribution to Flickr sourced images (ie, hover over the image an attribution link appears). If you are going to use the Flickr source, then you must make sure you are legally permitted to do so, for one, your site can not be commercial. I've provided you with the tools, just try not to shoot yourself.

New Dialog Types

Added a new Dialog type "DetachedDialog?". This "faked" dialog extends the Xinha.Dialog and is a "drop in" replacement for it, the difference is the DetachedDialog? is not associated to any instance of Xinha. No Xinha needs to be instantiated for a "plugin" to use a DetachedDialog?. Where this is useful is in leveraging off plugins to provide functionality outside of Xinha, see link-picker.js below (in Linker).

Also added a new Dialog type "DivDialog?". Similar to the DetachedDialog?, except the dialog HTML is written directly into an html element supplied to the dialog. The use of this is similar to the above, providing a means for getting a plugin "away" from Xinha to provide it's services for other things. This Dialog may need some work since it was written before the new Xinha.Dialog was created, in brief test it worked mostly. Worth keeping around as it's a pretty simple example of how a new Dialog type can be constructed by extending the existing one.

Added a "Link Picker" to leverage the Linker plugin for providing a "Browse" button next to normal input fields in order to select a link which is written into the field.

This is the initial usage of the DetachedDialog?, the basic usage of this is described in the comments in that file source:trunk/plugins/Linker/link-picker.js

Hid all dotfiles from the Linker scanner, the linker shouldn't be showing "hidden" files.

CSS fix to dTree in linker, just to make sure it's styles were not getting clobbered.

Stylist Duplicate Stylesheet Fix

Stop the Stylist from possibly adding a duplicate stylesheet into pageStyleSheets, this was creating a subtle problem in certain circumstances.

New Plugin: WysiwygWrap?

Added a new plugin WysiwygWrap, basically this wraps the content of your Xinha with some specific elements you tell it, when in Wysiwyg mode, and strips them out again when you go back to code (or submit). The idea is to make it so that, combined with an appropriate pageStyleSheet(s) you can more easily simulate in Xinha what it will "look like" when that HTML is "published" wherever it's getting published.

It takes a simple configuration of xinha.config.WysiwygWrap = { elements: [ list of the ancestor elements to insert, in order top down ] }
Example:

  xinha.config.WysiwygWrap = { elements: ['div#outer', 'div.inner'] }

will produce this in your Xinha Wysiwyg mode html

	<div id="outer">
		<div class="inner">
			** Original Xinha Content For Editing Here **
		</div>
	</div>

so your pageStyleSheet would just make nice CSS for those outer and inner to make the html in the Wysiwyg mode look closer to how it would look "on the site".

In practice, I'm not sure this works that well, it seemed a good idea at the time, but it can be a bit fragile.

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 11.9 KB
Line 
1<?php
2/**
3 * Image Manager configuration file.
4 * @author $Author:gogo $
5 * @version $Id:config.inc.php 830 2007-05-09 13:27:34Z gogo $
6 * @package ImageManager
7 *
8 * @todo change all these config values to defines()
9 */
10
11// REVISION HISTORY:
12//
13// 2005-03-20 Yermo Lamers (www.formvista.com):
14//      . unified backend.
15// . created a set of defaults that make sense for bundling with Xinha.
16
17// -------------------------------------------------------------------------
18
19/**
20* Default backend URL
21*
22* URL to use for unified backend.
23*
24* The ?__plugin=ImageManager& is required.
25*/
26
27$IMConfig['backend_url'] = "backend.php?__plugin=ImageManager&";
28
29/**
30* Backend Installation Directory
31*
32* location of backend install; these are used to link to css and js
33* assets because we may have the front end installed in a different
34* directory than the backend. (i.e. nothing assumes that the frontend
35* and the backend are in the same directory)
36*/
37
38$IMConfig['base_dir'] = getcwd();
39$IMConfig['base_url'] = '';
40
41// ------------------------------------------------------------
42
43/**
44* Path to directory containing images.
45*
46* File system path to the directory you want to manage the images
47* for multiple user systems, set it dynamically.
48*
49* NOTE: This directory requires write access by PHP. That is,
50* PHP must be able to create files in this directory.
51* Able to create directories is nice, but not necessary.
52*
53* CHANGE THIS: for out-of-the-box demo purposes we're setting this to ./demo_images
54* which has some graphics in it.
55*/
56
57// $IMConfig['images_dir'] = "/some/path/to/images/directory;
58
59$IMConfig['images_dir'] = "demo_images";
60
61// -------------------------------------------------------------------------
62
63/**
64* URL of directory containing images.
65*
66* The URL to the above path, the web browser needs to be able to see it.
67* It can be protected via .htaccess on apache or directory permissions on IIS,
68* check you web server documentation for futher information on directory protection
69* If this directory needs to be publicly accessiable, remove scripting capabilities
70* for this directory (i.e. disable PHP, Perl, CGI). We only want to store assets
71* in this directory and its subdirectories.
72*
73* CHANGE THIS: You need to change this to match the url where you have Xinha
74* installed. If the images show up blank chances are this is not set correctly.
75*/
76
77// $IMConfig['images_url'] = "/url/to/above";
78
79// try to figure out the URL of the sample images directory. For your installation
80// you will probably want to keep images in another directory.
81
82$IMConfig['images_url'] = str_replace( "backend.php", "", $_SERVER["PHP_SELF"] ) . "demo_images";
83
84// -------------------------------------------------------------------------
85
86/**
87* PHP Safe Mode?
88*
89* Possible values: true, false
90*
91* TRUE - If PHP on the web server is in safe mode, set this to true.
92* SAFE MODE restrictions: directory creation will not be possible,
93* only the GD library can be used, other libraries require
94* Safe Mode to be off.
95*
96* FALSE - Set to false if PHP on the web server is not in safe mode.
97*/
98
99$IMConfig['safe_mode'] = false;
100
101// -------------------------------------------------------------------------
102
103/**
104* Image Library to use.
105*
106* Possible values: 'GD', 'IM', or 'NetPBM'
107*
108* The image manipulation library to use, either GD or ImageMagick or NetPBM.
109* If you have safe mode ON, or don't have the binaries to other packages,
110* your choice is 'GD' only. Other packages require Safe Mode to be off.
111*
112* DEFAULT: GD is probably the most likely to be available.
113*/
114
115$IMConfig['IMAGE_CLASS'] = 'GD';
116
117
118// -------------------------------------------------------------------------
119
120/**
121* NetPBM or IM binary path.
122*
123* After defining which library to use, if it is NetPBM or IM, you need to
124* specify where the binary for the selected library are. And of course
125* your server and PHP must be able to execute them (i.e. safe mode is OFF).
126* GD does not require the following definition.
127*/
128
129$IMConfig['IMAGE_TRANSFORM_LIB_PATH'] ='/usr/bin/';
130
131// For windows, something like
132// C:/"Program Files"/ImageMagick-5.5.7-Q16/
133
134// -------------------------------------------------------------------------
135//                OPTIONAL SETTINGS
136// -------------------------------------------------------------------------
137
138/**
139* Thumbnail prefix
140*
141* The prefix for thumbnail files, something like .thumb will do. The
142* thumbnails files will be named as "prefix_imagefile.ext", that is,
143*  prefix + orginal filename.
144*/
145
146$IMConfig['thumbnail_prefix'] = '.';
147
148// -------------------------------------------------------------------------
149
150/**
151* Thumbnail Directory
152*
153* Thumbnail can also be stored in a directory, this directory
154* will be created by PHP. If PHP is in safe mode, this parameter
155*  is ignored, you can not create directories.
156*
157*  If you do not want to store thumbnails in a directory, set this
158*  to false or empty string '';
159*/
160
161$IMConfig['thumbnail_dir'] = '.thumbs';
162
163// -------------------------------------------------------------------------
164
165/**
166* Resized prefix
167*
168* The prefix for resized files, something like .resized will do.  The
169* resized files will be named <prefix>_<width>x<height>_<original>
170* resized files are created when one changes the dimensions of an image
171* in the image manager selection dialog - the image is scaled when the
172* user clicks the ok button.
173*/
174
175$IMConfig['resized_prefix'] = '.resized';
176
177// -------------------------------------------------------------------------
178
179/**
180* Resized Directory
181*
182* Resized images may also be stored in a directory, except in safe mode.
183*/
184
185$IMConfig['resized_dir'] = '.resized';
186
187/**
188 * Full options
189 *
190 * Determines whether the user is given options for padding,
191 * background/padding colour, margin, border and border colour.
192 */
193
194$IMConfig['show_full_options'] = true;
195 
196// -------------------------------------------------------------------------
197
198/**
199* Allow New Directories
200*
201*
202* Possible values: true, false
203*
204* TRUE -  Allow the user to create new sub-directories in the
205*        $IMConfig['base_dir'].
206*
207* FALSE - No directory creation.
208*
209* NOTE: If $IMConfig['safe_mode'] = true, this parameter
210*     is ignored, you can not create directories
211*
212* DEFAULT: for demo purposes we turn this off.
213*/
214
215$IMConfig['allow_new_dir'] = true;
216
217// -------------------------------------------------------------------------
218
219/**
220* Allow Uploads
221*
222*  Possible values: true, false
223*
224*  TRUE - Allow the user to upload files.
225*
226*  FALSE - No uploading allowed.
227*
228* DEFAULT: for demo purposes we turn this off.
229*/
230
231$IMConfig['allow_upload'] = false;
232
233// -------------------------------------------------------------------------
234
235/**
236* Validate Images
237*
238* Possible values: true, false
239*
240* TRUE - If set to true, uploaded files will be validated based on the
241*        function getImageSize, if we can get the image dimensions then
242*        I guess this should be a valid image. Otherwise the file will be rejected.
243*
244* FALSE - All uploaded files will be processed.
245*
246* NOTE: If uploading is not allowed, this parameter is ignored.
247*/
248
249$IMConfig['validate_images'] = true;
250
251$IMConfig['allowed_image_extensions'] = array("jpg","gif","png","jpeg");
252
253// -------------------------------------------------------------------------
254
255/**
256* Default Thumnail.
257*
258* The default thumbnail if the thumbnails can not be created, either
259* due to error or bad image file.
260*/
261
262$IMConfig['default_thumbnail'] = 'img/default.gif';
263
264// -------------------------------------------------------------------------
265
266/**
267*  Thumbnail dimensions.
268*/
269
270$IMConfig['thumbnail_width'] = 96;
271$IMConfig['thumbnail_height'] = 96;
272
273// -------------------------------------------------------------------------
274
275/**
276* Editor Temporary File Prefix.
277*
278* Image Editor temporary filename prefix.
279*/
280
281$IMConfig['tmp_prefix'] = '.editor_';
282
283
284$IMConfig['ViewMode'] = 'thumbs';
285
286// -------------------------------------------------------------------------
287
288/** Margin Types
289 *  If your HTML will be used in an email, then using CSS type "margin"
290 *  is not so reliable and you should set UseHSpaceVSpace to be true
291 *  to go back to the old fashioned hspace="" and vspace="" attributes on
292 *  images.
293 */
294$IMConfig['UseHSpaceVSpace'] = false;
295
296// -------------------------------------------------------------------------
297
298/**
299 * ImageManager/Picker can provide selection interfaces for more than just
300 * images on the server ("Pictures").
301 *
302 *  Local - the classical ImageManager for images stored on this server.
303 *
304 *  YouTube  - provides selection (but not upload etc) of videos on YouTube
305 *    see smart-image.js for how to make the videos work as videos instead of
306 *    static images.
307 *
308 *  Flickr   - provides selection (but not upload etc) of public images on Flickr
309 *    Set
310 *       $IMConfig['Flickr'] = array('Key' => 'yourkeyhere');
311 *    to turn on Flickr support.
312 *
313 *    To get a key: http://www.flickr.com/services/api/keys/
314 *
315 *    WARNING: Flickr restricts commercial use of the API.  If your site is in any way even
316 *     remotely commercial you need to ask for a commercial key from flickr.
317 *
318 *    ADDITIONAL WARNING: Flickr requires that you provide a link back to them, preferably
319 *     on the image itself (linking to the image) - you can use smart-image.js to do
320 *     something like this.
321 *
322 *    ADDITIONAL ADDITIONAL WARNING: It's up to you to comply with the image's license!!
323 */
324 
325$IMConfig['Local'] = TRUE;
326$IMConfig['YouTube']  = FALSE;
327$IMConfig['Flickr']   = FALSE;
328
329// These are some configurable defaults for Flickr, to override
330//  $IMConfig['Flickr'] = array('Whatever' => 'You Want');
331$FlickrDefaults = array
332(
333  // This is the URL as flickr provides it for the licence which you wish
334  // to search on by default.  The default here is the least restrictive one.
335  'Default License' => 'http://creativecommons.org/licenses/by/2.0/',
336   
337); 
338
339
340////////////////////////////////////////////////////////////////////////////////
341//       ================== END OF CONFIGURATION =======================      //
342////////////////////////////////////////////////////////////////////////////////
343
344
345// Standard PHP Backend Data Passing
346//  if data was passed using xinha_pass_to_php_backend() we merge the items
347//  provided into the Config
348require_once(realpath(dirname(__FILE__) . '/../../contrib/php-xinha.php'));
349if($passed_data = xinha_read_passed_data())
350{
351  $IMConfig = array_merge($IMConfig, $passed_data);
352  $IMConfig['backend_url'] .= xinha_passed_data_querystring() . '&';
353 
354  if($IMConfig['Flickr'])
355  {
356    foreach($FlickrDefaults as $k => $v)
357    {
358      if(!isset($IMConfig['Flickr'][$k]))
359      {
360        $IMConfig['Flickr'][$k] = $v;
361      }
362    }
363  }
364}
365// Deprecated config passing, don't use this way any more!
366elseif(isset($_REQUEST['backend_config']))
367{
368  if(get_magic_quotes_gpc()) {
369    $_REQUEST['backend_config'] = stripslashes($_REQUEST['backend_config']);
370  }
371 
372  // Config specified from front end, check that it's valid
373  session_start();
374  $secret = $_SESSION[$_REQUEST['backend_config_secret_key_location']];
375
376  if($_REQUEST['backend_config_hash'] !== sha1($_REQUEST['backend_config'] . $secret))
377  {
378    die("Backend security error.");
379  }
380
381  $to_merge = unserialize($_REQUEST['backend_config']);
382  if(!is_array($to_merge))
383  {
384    die("Backend config syntax error.");
385  }
386
387  $IMConfig = array_merge($IMConfig, $to_merge);
388  $IMConfig['backend_url'] .= "backend_config=" . rawurlencode($_REQUEST['backend_config']) . '&';
389  $IMConfig['backend_url'] .= "backend_config_hash=" . rawurlencode($_REQUEST['backend_config_hash']) . '&';
390  $IMConfig['backend_url'] .= "backend_config_secret_key_location=" . rawurlencode($_REQUEST['backend_config_secret_key_location']) . '&';
391
392}
393
394define('IMAGE_CLASS', $IMConfig['IMAGE_CLASS']);
395define('IMAGE_TRANSFORM_LIB_PATH', $IMConfig['IMAGE_TRANSFORM_LIB_PATH']);
396define( "IM_CONFIG_LOADED", "yes" );
397
398// bring in the debugging library
399
400include_once( "ddt.php" );
401
402// uncomment to send debug messages to a local file
403// _setDebugLog( "/tmp/debug_log.txt" );
404
405// turn debugging on everywhere.
406// _ddtOn();
407
408// END
409
410?>
Note: See TracBrowser for help on using the repository browser.