Class mediaImageChooser

Description

This is an extension for developers that allows users of your application to choose images in HTML Forms with Joomla's Media Manager.

Installation:

  • install zoolJoomLibs.Base plugin and publish it
  • install zoolJoomLibs.mediaImageChooser plugin (publishing is not necessary)
Usage:

At first import zoolJoomLibs.Base plugin:

  1.  if (!JPluginHelper::importPlugin('zoolJoomLibs''base')) {
  2.      JError::raiseError(2001'Please, install and publish </b>zoolJoomLibs.Base</b> first.');
  3.  }

Import mediaImageChooser class:

  1.  if(!zjl_import('mediaImageChooser')) {
  2.      JError::raiseError(2001'Please, install <b>zoolJoomLibs.mediaImageChooser</b> first.');
  3.  }

Then add behavior for mediaImageChooser on your page:

  1. JHTML::_('mediaImageChooser.behavior.all');

or, with custom blank image:

  1. JHTML::_('mediaImageChooser.behavior.all''/path/to/blank/image.png');

Also don't forget to add "modal" behavior:

  1. JHTML::_('behavior.modal');

After that you are ready to use this class:

  1.  // ...
  2.  // Start of a form goes above
  3.  // ...
  4.  $image_chooser new mediaImageChooser('form_var_name''path/to/current/image.png');
  5.  // Show the inputbox
  6.  echo $image_chooser->inputBox();
  7.  // Show the "browse button"
  8.  echo $image_chooser->button();
  9.  // Show the image preview box
  10.  echo $image_chooser->preview();
  11.  // Output javascript that prepares all elements for work
  12.  echo $image_chooser->start();
  13.  //...
  14.  // The rest of a form goes below
  15.  // ...

Located in /mediaImageChooser.php (line 70)

JObject
   |
   --mediaImageChooser
Variable Summary
string $boxId
array $config
array $defAttrs
Method Summary
mediaImageChooser __construct (string $id, [string $mediaInitPath = null])
string button ([array $attr = array()], [numeric $winWidth = null], [numeric $winHeight = null])
string imagePreview ([array $attr = array()])
string inputBox ([array $attr = array()])
string preview ([array $attr = array()])
string start ()
string _getButtonId ()
string _getFolderValue ()
string _getPreviewId ()
boolean|integer _isAbsUrl (string $url)
Variables
string $boxId = '' (line 76)

Input box id.

  • access: protected
array $config = array(
'box' => array(),'btn'=>array('sfx'=>'_btn'),'win'=>array(),'prv'=>array('sfx'=>'_prv'))
(line 102)

Widget's config ('box', 'btn', 'win', 'prv')

  • access: public
array $defAttrs = array(
'box' => array ('class'=>'inputbox', 'type'=>'text', 'size'=>60, 'maxlength'=>255),'btn'=>array(),'win'=>array('width'=>570,'height'=>400),'prv'=>array('border'=>2,'alt'=>'Preview'))
(line 90)

Default html attributes for our widgets: input box('box'), button('btn'), modal window('win') and previewer('prv')

  • access: protected
string $mediaInitPath = '' (line 83)

Current path to choosen media file.

  • access: protected
Methods
Constructor __construct (line 113)
  • access: public
mediaImageChooser __construct (string $id, [string $mediaInitPath = null])
  • string $id: Chooser's id (your form's input box name and id)
  • string $mediaInitPath: Path to the image (empty by default). Should be relative to Joomla! root.
button (line 167)

Generates html for an image chooser button.

  • access: public
string button ([array $attr = array()], [numeric $winWidth = null], [numeric $winHeight = null])
  • array $attr: Any custom attributes to "a" element, except: class, href, id, name and rel
  • numeric $winWidth: Width of modal window which opens when the button clicked
  • numeric $winHeight: Height of modal window which opens when the button clicked
imagePreview (line 222)

Generates html for an image preview element.

Don't execute this if you don't need a previewer.

  • access: public
string imagePreview ([array $attr = array()])
  • array $attr: Any custom attributes to "img" element, except: id and name. The "alt" attribute passes through JText::_()
inputBox (line 144)

Generates html code for an inputbox.

  • access: public
string inputBox ([array $attr = array()])
  • array $attr: Any custom attributes to "input" element, except: onchange, id, name and value
preview (line 198)

Generates html for a preview element.

  • access: public
string preview ([array $attr = array()])
  • array $attr: Any custom attributes to "img" element, except: id and name. The "alt" attribute passes through JText::_()
start (line 232)

This method outputs javascript which prepares all elements for working together.

Run this after creating all needed elements.

  • access: public
string start ()
_getButtonId (line 311)

Generates button id.

  • access: protected
string _getButtonId ()
_getFolderValue (line 251)

Generates value for the "folder" com_media's parameter.

  • access: protected
string _getFolderValue ()
_getPreviewId (line 320)

Generates preview id.

  • access: protected
string _getPreviewId ()
_isAbsUrl (line 297)

Returns type of URL absoluteness:

  • return: "false" = not absolute, true = absolute URL, -1 = absolute-path reference
  • access: protected
boolean|integer _isAbsUrl (string $url)
  • string $url: URL to check

Documentation generated on Sun, 18 Jul 2010 22:35:39 +0300 by phpDocumentor 1.4.3