Current File : /home/k/a/r/karenpetzb/www/items/category/JQuery.tar
View/Exception.php000060400000002133150712002450010114 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Exception.php 11941 2008-10-13 19:41:38Z matthew $
 */

require_once "ZendX/JQuery/Exception.php";

/**
 * jQuery Exception
 *
 * @package    ZendX_JQuery
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_View_Exception extends ZendX_JQuery_Exception { }View/Helper/ColorPicker.php000060400000004164150712002450011617 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: ColorPicker.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Color Picker View Helper
 *
 * @uses 	   Zend_View_Helper_FormText
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_ColorPicker extends ZendX_JQuery_View_Helper_UiWidget
{
	/**
	 * Render a Color Picker in an FormText field.
	 *
	 * @link   http://docs.jquery.com/UI/ColorPicker
	 * @param  string $id
	 * @param  string $value
	 * @param  array  $params
	 * @param  array  $attribs
	 * @return string
	 */
    public function colorPicker($id, $value='', array $params=array(), array $attribs=array())
    {
	    $attribs = $this->_prepareAttributes($id, $value, $attribs);

	    if(strlen($value) >= 6) {
	        $params['color'] = $value;
	    }

	    if(count($params) > 0) {
            $params = ZendX_JQuery::encodeJson($params);
	    } else {
	        $params = "{}";
	    }

        $js = sprintf('%s("#%s").colorpicker(%s);',
            ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
            $attribs['id'],
            $params
        );

        $this->jquery->addOnLoad($js);

	    return $this->view->formText($id, $value, $attribs);
    }
}View/Helper/Spinner.php000060400000004231150712002450011014 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Spinner.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Spinner View Helper
 *
 * @uses 	   Zend_Json
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_Spinner extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Create FormText field for numeric values that can be spinned through its values.
     *
     * @link   http://docs.jquery.com/UI/Spinner
     * @param  string $id
     * @param  string $value
     * @param  array  $params
     * @param  array  $attribs
     * @return string
     */
	public function spinner($id, $value="", array $params=array(), array $attribs=array())
	{
	    $attribs = $this->_prepareAttributes($id, $value, $attribs);

	    if(!isset($params['start']) && is_numeric($value)) {
	        $params['start'] = $value;
	    }

	    if(count($params)) {
	        $params = ZendX_JQuery::encodeJson($params);
	    } else {
	        $params = '{}';
	    }

        $js = sprintf('%s("#%s").spinner(%s);',
            ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
            $attribs['id'],
            $params
        );

        $this->jquery->addOnLoad($js);

	    return $this->view->formText($id, $value, $attribs);
	}
}View/Helper/JQuery/Container.php000060400000046306150712002450012550 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Container.php 20751 2010-01-29 11:14:09Z beberlei $
 */

/**
 * @see ZendX_JQuery
 */
require_once "ZendX/JQuery.php";

/**
 * jQuery View Helper. Transports all jQuery stack and render information across all views.
 *
 * @uses 	   ZendX_JQuery_View_Helper_JQuery_Container
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_JQuery_Container
{
    /**
     * Path to local webserver jQuery library
     *
     * @var String
     */
    protected $_jqueryLibraryPath = null;

    /**
     * Additional javascript files that for jQuery Helper components.
     *
     * @var Array
     */
    protected $_javascriptSources = array();

    /**
     * Indicates wheater the jQuery View Helper is enabled.
     *
     * @var Boolean
     */
    protected $_enabled = false;

    /**
     * Indicates if a capture start method for javascript or onLoad has been called.
     *
     * @var Boolean
     */
    protected $_captureLock = false;

    /**
     * Additional javascript statements that need to be executed after jQuery lib.
     *
     * @var Array
     */
    protected $_javascriptStatements = array();

    /**
     * Additional stylesheet files for jQuery related components.
     *
     * @var Array
     */
    protected $_stylesheets = array();

    /**
     * jQuery onLoad statements Stack
     *
     * @var Array
     */
    protected $_onLoadActions = array();

    /**
     * View is rendered in XHTML or not.
     *
     * @var Boolean
     */
    protected $_isXhtml = false;

    /**
     * Default CDN jQuery Library version
     *
     * @var String
     */
    protected $_version = ZendX_JQuery::DEFAULT_JQUERY_VERSION;

    /**
     * Default Render Mode (all parts)
     *
     * @var Integer
     */
    protected $_renderMode = ZendX_JQuery::RENDER_ALL;

    /**
     * jQuery UI Library Enabled
     *
     * @var Boolean
     */
    protected $_uiEnabled = false;

    /**
     * Local jQuery UI Path. Use Google CDN if
     * variable is null
     *
     * @var String
     */
    protected $_uiPath = null;

    /**
     * jQuery UI Google CDN Version
     *
     * @var String
     */
    protected $_uiVersion = ZendX_JQuery::DEFAULT_UI_VERSION;

    /**
     * Load CDN Path from SSL or Non-SSL?
     *
     * @var boolean
     */
    protected $_loadSslCdnPath = false;

    /**
     * View Instance
     *
     * @var Zend_View_Interface
     */
    public $view = null;

    /**
     * Set view object
     *
     * @param  Zend_View_Interface $view
     * @return void
     */
    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }

    /**
     * Enable jQuery
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function enable()
    {
        $this->_enabled = true;
        return $this;
    }

    /**
     * Disable jQuery
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function disable()
    {
        $this->uiDisable();
        $this->_enabled = false;
        return $this;
    }

    /**
     * Is jQuery enabled?
     *
     * @return boolean
     */
    public function isEnabled()
    {
        return $this->_enabled;
    }

    /**
     * Set the version of the jQuery library used.
     *
     * @param string $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setVersion($version)
    {
        $this->_version = $version;
        return $this;
    }

    /**
     * Get the version used with the jQuery library
     *
     * @return string
     */
    public function getVersion()
    {
        return $this->_version;
    }

    /**
     * Use CDN, using version specified. Currently supported
     * by Googles Ajax Library API are: 1.2.3, 1.2.6
     *
     * @deprecated As of version 1.8, use {@link setVersion()} instead.
     * @param  string $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setCdnVersion($version = null)
    {
        return $this->setVersion($version);
    }

    /**
     * Get CDN version
     *
     * @deprecated As of version 1.8, use {@link getVersion()} instead.
     * @return string
     */
    public function getCdnVersion()
    {
        return $this->getVersion();
    }

    /**
     * Set Use SSL on CDN Flag
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setCdnSsl($flag)
    {
        $this->_loadSslCdnPath = $flag;
        return $this;
    }

    /**
     * Are we using the CDN?
     *
     * @return boolean
     */
    public function useCdn()
    {
        return !$this->useLocalPath();
    }

    /**
     * Set path to local jQuery library
     *
     * @param  string $path
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setLocalPath($path)
    {
        $this->_jqueryLibraryPath = (string) $path;
        return $this;
    }

    /**
     * Enable jQuery UI Library Rendering
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function uiEnable()
    {
        $this->enable();
        $this->_uiEnabled = true;
        return $this;
    }

    /**
     * Disable jQuery UI Library Rendering
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function uiDisable()
    {
        $this->_uiEnabled = false;
        return $this;
    }

    /**
     * Check wheater currently the jQuery UI library is enabled.
     *
     * @return boolean
     */
    public function uiIsEnabled()
    {
         return $this->_uiEnabled;
    }

    /**
     * Set jQuery UI version used.
     * 
     * @param  string $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setUiVersion($version)
    {
        $this->_uiVersion = $version;
    	return $this;
    }

    /**
     * Get jQuery UI Version used.
     *
     * @return string
     */
    public function getUiVersion()
    {
        return $this->_uiVersion;
    }

    /**
     * Set jQuery UI CDN Version
     *
     * @deprecated As of 1.8 use {@link setUiVersion()}
     * @param String $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setUiCdnVersion($version="1.5.2")
    {
        return $this->setUiVersion($version);
    }

    /**
     * Return jQuery UI CDN Version
     *
     * @deprecated As of 1.8 use {@link getUiVersion()}
     * @return String
     */
    public function getUiCdnVersion()
    {
        return $this->getUiVersion();
    }

    /**
     * Set local path to jQuery UI library
     *
     * @param String $path
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setUiLocalPath($path)
    {
    	$this->_uiPath = (string) $path;
    	return $this;
    }

    /**
     * Return the local jQuery UI Path if set.
     *
     * @return string
     */
    public function getUiPath()
    {
    	return $this->_uiPath;
    }

    /**
     * Proxies to getUiPath() for consistency in function naming.
     *
     * @return string
     */
    public function getUiLocalPath()
    {
        return $this->getUiPath();
    }

    /**
     * Is the jQuery Ui loaded from local scope?
     *
     * @return boolean
     */
    public function useUiLocal()
    {
    	return (null===$this->_uiPath ? false : true);
    }

    /**
     * Is the jQuery Ui enabled and loaded from CDN?
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function useUiCdn()
    {
    	return !$this->useUiLocal();
    }

    /**
     * Get local path to jQuery
     *
     * @return string
     */
    public function getLocalPath()
    {
        return $this->_jqueryLibraryPath;
    }

    /**
     * Are we using a local path?
     *
     * @return boolean
     */
    public function useLocalPath()
    {
        return (null === $this->_jqueryLibraryPath) ? false : true;
    }

    /**
     * Start capturing routines to run onLoad
     *
     * @return boolean
     */
    public function onLoadCaptureStart()
    {
        if ($this->_captureLock) {
            require_once 'Zend/Exception.php';
            throw new Zend_Exception('Cannot nest onLoad captures');
        }

        $this->_captureLock = true;
        return ob_start();
    }

    /**
     * Stop capturing routines to run onLoad
     *
     * @return boolean
     */
    public function onLoadCaptureEnd()
    {
        $data               = ob_get_clean();
        $this->_captureLock = false;

        $this->addOnLoad($data);
        return true;
    }

    /**
     * Capture arbitrary javascript to include in jQuery script
     *
     * @return boolean
     */
    public function javascriptCaptureStart()
    {
        if ($this->_captureLock) {
            require_once 'Zend/Exception.php';
            throw new Zend_Exception('Cannot nest captures');
        }

        $this->_captureLock = true;
        return ob_start();
    }

    /**
     * Finish capturing arbitrary javascript to include in jQuery script
     *
     * @return boolean
     */
    public function javascriptCaptureEnd()
    {
        $data               = ob_get_clean();
        $this->_captureLock = false;

        $this->addJavascript($data);
        return true;
    }

    /**
     * Add a Javascript File to the include stack.
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addJavascriptFile($path)
    {
        $path = (string) $path;
        if (!in_array($path, $this->_javascriptSources)) {
            $this->_javascriptSources[] = (string) $path;
        }
        return $this;
    }

    /**
     * Return all currently registered Javascript files.
     *
     * This does not include the jQuery library, which is handled by another retrieval
     * strategy.
     *
     * @return Array
     */
    public function getJavascriptFiles()
    {
        return $this->_javascriptSources;
    }

    /**
     * Clear all currently registered Javascript files.
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function clearJavascriptFiles()
    {
        $this->_javascriptSources = array();
        return $this;
    }

    /**
     * Add arbitrary javascript to execute in jQuery JS container
     *
     * @param  string $js
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addJavascript($js)
    {
        $this->_javascriptStatements[] = $js;
        $this->enable();
        return $this;
    }

    /**
     * Return all registered javascript statements
     *
     * @return array
     */
    public function getJavascript()
    {
        return $this->_javascriptStatements;
    }

    /**
     * Clear arbitrary javascript stack
     *
	 * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function clearJavascript()
    {
        $this->_javascriptStatements = array();
        return $this;
    }

    /**
     * Add a stylesheet
     *
     * @param  string $path
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addStylesheet($path)
    {
        $path = (string) $path;
        if (!in_array($path, $this->_stylesheets)) {
            $this->_stylesheets[] = (string) $path;
        }
        return $this;
    }

    /**
     * Retrieve registered stylesheets
     *
     * @return array
     */
    public function getStylesheets()
    {
        return $this->_stylesheets;
    }

    /**
     * Add a script to execute onLoad
     *
     * @param  string $callback Lambda
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addOnLoad($callback)
    {
        if (!in_array($callback, $this->_onLoadActions, true)) {
            $this->_onLoadActions[] = $callback;
        }
        $this->enable();
        return $this;
    }

    /**
     * Retrieve all registered onLoad actions
     *
     * @return array
     */
    public function getOnLoadActions()
    {
        return $this->_onLoadActions;
    }

    /**
     * Clear the onLoadActions stack.
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function clearOnLoadActions()
    {
        $this->_onLoadActions = array();
        return $this;
    }

    /**
     * Set which parts of the jQuery enviroment should be rendered.
     *
     * This function allows for a gradual refactoring of the jQuery code
     * rendered by calling __toString(). Use ZendX_JQuery::RENDER_*
     * constants. By default all parts of the enviroment are rendered.
     *
     * @see    ZendX_JQuery::RENDER_ALL
     * @param  integer $mask
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setRenderMode($mask)
    {
        $this->_renderMode = $mask;
        return $this;
    }

    /**
     * Return bitmask of the current Render Mode
     * @return integer
     */
    public function getRenderMode()
    {
        return $this->_renderMode;
    }

    /**
     * String representation of jQuery environment
     *
     * @return string
     */
    public function __toString()
    {
        if (!$this->isEnabled()) {
            return '';
        }

        $this->_isXhtml = $this->view->doctype()->isXhtml();

        $html  = $this->_renderStylesheets() . PHP_EOL
               . $this->_renderScriptTags() . PHP_EOL
               . $this->_renderExtras();
        return $html;
    }

    /**
     * Render jQuery stylesheets
     *
     * @return string
     */
    protected function _renderStylesheets()
    {
    	if( ($this->getRenderMode() & ZendX_JQuery::RENDER_STYLESHEETS) == 0) {
            return '';
    	}

        foreach ($this->getStylesheets() as $stylesheet) {
            $stylesheets[] = $stylesheet;
        }

        if (empty($stylesheets)) {
            return '';
        }

        array_reverse($stylesheets);
        $style = "";
        foreach($stylesheets AS $stylesheet) {
            if ($this->view instanceof Zend_View_Abstract) {
                $closingBracket = ($this->view->doctype()->isXhtml()) ? ' />' : '>';
            } else {
                $closingBracket = ' />';
            }

            $style .= '<link rel="stylesheet" href="'.$stylesheet.'" '.
                      'type="text/css" media="screen"' . $closingBracket . PHP_EOL;
        }

        return $style;
    }

    /**
     * Renders all javascript file related stuff of the jQuery enviroment.
     *
     * @return string
     */
    protected function _renderScriptTags()
    {
        $scriptTags = '';
        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_LIBRARY) > 0) {
            $source = $this->_getJQueryLibraryPath();

            $scriptTags .= '<script type="text/javascript" src="' . $source . '"></script>'.PHP_EOL;

            if($this->uiIsEnabled()) {
                $uiPath = $this->_getJQueryUiLibraryPath();
                $scriptTags .= '<script type="text/javascript" src="'.$uiPath.'"></script>'.PHP_EOL;
            }

            if(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode() == true) {
                $scriptTags .= '<script type="text/javascript">var $j = jQuery.noConflict();</script>'.PHP_EOL;
            }
        }

        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_SOURCES) > 0) {
            foreach($this->getJavascriptFiles() AS $javascriptFile) {
                $scriptTags .= '<script type="text/javascript" src="' . $javascriptFile . '"></script>'.PHP_EOL;
            }
        }

        return $scriptTags;
    }

    /**
     * Renders all javascript code related stuff of the jQuery enviroment.
     *
     * @return string
     */
    protected function _renderExtras()
    {
        $onLoadActions = array();
        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_JQUERY_ON_LOAD) > 0) {
            foreach ($this->getOnLoadActions() as $callback) {
                $onLoadActions[] = $callback;
            }
        }

        $javascript = '';
        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_JAVASCRIPT) > 0) {
            $javascript = implode("\n    ", $this->getJavascript());
        }

        $content = '';

        if (!empty($onLoadActions)) {
            if(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode() == true) {
                $content .= '$j(document).ready(function() {'."\n    ";
            } else {
                $content .= '$(document).ready(function() {'."\n    ";
            }
            $content .= implode("\n    ", $onLoadActions) . "\n";
            $content .= '});'."\n";
        }

        if (!empty($javascript)) {
            $content .= $javascript . "\n";
        }

        if (preg_match('/^\s*$/s', $content)) {
            return '';
        }

        $html = '<script type="text/javascript">' . PHP_EOL
              . (($this->_isXhtml) ? '//<![CDATA[' : '//<!--') . PHP_EOL
              . $content
              . (($this->_isXhtml) ? '//]]>' : '//-->') . PHP_EOL
              . PHP_EOL . '</script>';
        return $html;
    }

    /**
     * @return string
     */
    protected function _getJQueryLibraryBaseCdnUri()
    {
        if($this->_loadSslCdnPath == true) {
            $baseUri = ZendX_JQuery::CDN_BASE_GOOGLE_SSL;
        } else {
            $baseUri = ZendX_JQuery::CDN_BASE_GOOGLE;
        }
        return $baseUri;
    }

    /**
     * @return string
     */
    protected function _getJQueryUiLibraryBaseCdnUri()
    {
        if($this->_loadSslCdnPath == true) {
            $baseUri = ZendX_JQuery::CDN_BASEUI_GOOGLE_SSL;
        } else {
            $baseUri = ZendX_JQuery::CDN_BASEUI_GOOGLE;
        }
        return $baseUri;
    }

	/**
	 * Internal function that constructs the include path of the jQuery library.
	 *
	 * @return string
	 */
    protected function _getJQueryLibraryPath()
    {
        if($this->_jqueryLibraryPath != null) {
            $source = $this->_jqueryLibraryPath;
        } else {
            $baseUri = $this->_getJQueryLibraryBaseCdnUri();
            $source = $baseUri .
                ZendX_JQuery::CDN_SUBFOLDER_JQUERY .
                $this->getCdnVersion() .
            	ZendX_JQuery::CDN_JQUERY_PATH_GOOGLE;
        }

        return $source;
    }

    /**
     * @return string
     */
    protected function _getJQueryUiLibraryPath()
    {
        if($this->useUiCdn()) {
            $baseUri = $this->_getJQueryLibraryBaseCdnUri();
            $uiPath = $baseUri.
                ZendX_JQuery::CDN_SUBFOLDER_JQUERYUI .
                $this->getUiCdnVersion() .
                "/jquery-ui.min.js";
        } else if($this->useUiLocal()) {
            $uiPath = $this->getUiPath();
        }
        return $uiPath;
    }
}View/Helper/UiWidget.php000060400000004456150712002450011130 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: UiWidget.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "Zend/View/Helper/HtmlElement.php";

/**
 * @see ZendX_JQuery
 */
require_once "ZendX/JQuery.php";

/**
 * jQuery Ui Widget Base class
 *
 * @uses 	   ZendX_JQuery_View_Helper_JQuery_Container
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class ZendX_JQuery_View_Helper_UiWidget extends Zend_View_Helper_HtmlElement
{
    /**
     * Contains reference to the jQuery view helper
     *
     * @var ZendX_JQuery_View_Helper_JQuery_Container
     */
    protected $jquery;

    /**
     * Set view and enable jQuery Core and UI libraries
     *
     * @param  Zend_View_Interface $view
     * @return ZendX_JQuery_View_Helper_Widget
     */
    public function setView(Zend_View_Interface $view)
    {
        parent::setView($view);
        $this->jquery = $this->view->jQuery();
        $this->jquery->enable()
                     ->uiEnable();
        return $this;
    }

    /**
     * Helps with building the correct Attributes Array structure.
     *
     * @param String $id
     * @param String $value
     * @param Array $attribs
     * @return Array $attribs
     */
	protected function _prepareAttributes($id, $value, $attribs)
	{
        if(!isset($attribs['id'])) {
            $attribs['id'] = $id;
        }
        $attribs['name']  = $id;
        $attribs['value'] = (string) $value;

        return $attribs;
	}
}View/Helper/TabPane.php000060400000004353150712002450010715 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: TabPane.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

require_once "UiWidgetPane.php";

/**
 * jQuery Tabs Pane View Helper, goes with Tab Container
 *
 * @uses 	   Zend_Json, ZendX_JQuery_View_Helper_TabContainer
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_TabPane extends ZendX_JQuery_View_Helper_UiWidgetPane
{
    /**
     * Add a tab pane to the tab container with the given $id.
     *
     * @param  string $id
     * @param  string $content
     * @param  array  $options
     * @return string always empty
     */
    public function tabPane($id=null, $content='', array $options=array())
    {
        if(0 === func_num_args()) {
            return $this;
        }

        $name = '';
        if(isset($options['title'])) {
            $name = $options['title'];
            unset($options['title']);
        }

        $this->_addPane($id, $name, $content, $options);
        return '';
    }

    /**
     * Register new tab pane with tabContainer view helper.
     *
     * @see    ZendX_JQuery_View_Helper_TabContainer::addPane
     * @param  string $id
     * @param  string $name
     * @param  string $content
     * @param  array  $options
     * @return void
     */
    protected function _addPane($id, $name, $content, array $options=array())
    {
        $this->view->tabContainer()->addPane($id, $name, $content, $options);
    }
}View/Helper/AccordionContainer.php000060400000012341150712002450013143 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AccordionContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Accordion View Helper
 *
 * @uses 	   Zend_Json
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_View_Helper_AccordionContainer extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * @var array
     */
    protected $_panes = array();

    /**
     * @var string
     */
    protected $_elementHtmlTemplate = null;

    /**
     * Add Accordion Pane for the Accordion-Id
     *
     * @param  string $id
     * @param  string $name
     * @param  string $content
     * @return ZendX_JQuery_View_Helper_AccordionContainer
     */
    public function addPane($id, $name, $content, array $options=array())
    {
        if(!isset($this->_panes[$id])) {
            $this->_panes[$id] = array();
        }
        if(strlen($name) == 0 && isset($options['title'])) {
            $name = $options['title'];
        }
        $this->_panes[$id][] = array('name' => $name, 'content' => $content, 'options' => $options);
        return $this;
    }

    /**
     * Render Accordion with the currently registered elements.
     *
     * If no arguments are given, the accordion object is returned so that
     * chaining the {@link addPane()} function allows to register new elements
     * for an accordion.
     *
     * @link   http://docs.jquery.com/UI/Accordion
     * @param  string $id
     * @param  array  $params
     * @param  array  $attribs
     * @return string|ZendX_JQuery_View_Helper_AccordionContainer
     */
    public function accordionContainer($id=null, array $params=array(), array $attribs=array())
    {
        if(0 === func_num_args()) {
            return $this;
        }

        if(!isset($attribs['id'])) {
            $attribs['id'] = $id;
        }

        $html = "";
        if(isset($this->_panes[$id])) {
            foreach($this->_panes[$id] AS $element) {
                $html .= sprintf($this->getElementHtmlTemplate(), $element['name'], $element['content']).PHP_EOL;
            }

            if(count($params) > 0) {
                $params = ZendX_JQuery::encodeJson($params);
            } else {
                $params = "{}";
            }

            $js = sprintf('%s("#%s").accordion(%s);',
                ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
                $attribs['id'],
                $params
            );
            $this->jquery->addOnLoad($js);

            $html = $this->getAccordionTemplate($attribs, $html);
        }
        return $html;
    }

    /**
     * @param  array $attribs
     * @param  string $html
     * @return string
     */
    protected function getAccordionTemplate($attribs, $html)
    {
        if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
            $html = '<div'
                  . $this->_htmlAttribs($attribs)
                  . '>'.PHP_EOL
                  . $html
                  . '</div>'.PHP_EOL;
        } else {
            $html = '<ul'
                  . $this->_htmlAttribs($attribs)
                  . '>'.PHP_EOL
                  . $html
                  . '</ul>'.PHP_EOL;
        }
        return $html;
    }

    /**
     * @return string
     */
    protected function getElementHtmlTemplate()
    {
        if($this->_elementHtmlTemplate == null) {
            if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
                $this->_elementHtmlTemplate = '<h3><a href="#">%s</a></h3><div>%s</div>';
            } else {
                $this->_elementHtmlTemplate = '<li class="ui-accordion-group"><a href="#" class="ui-accordion-header">%s</a><div class="ui-accordion-content">%s</div></li>';
            }
        }
        return $this->_elementHtmlTemplate;
    }

    /**
     * Set the accordion element template
     *
     * @param  string $htmlTemplate
     * @return ZendX_JQuery_View_Helper_AccordionContainer
     */
    public function setElementHtmlTemplate($htmlTemplate)
    {
        if(substr_count($htmlTemplate, '%s') != 2) {
            require_once "ZendX/JQuery/View/Exception.php";
            throw new ZendX_JQuery_View_Exception(
                "Accordion Container HTML Template requires two sprintf() string replace markers '%s'."
            );
        }
        $this->_elementHtmlTemplate = $htmlTemplate;
        return $this;
    }
}View/Helper/DialogContainer.php000060400000004240150712002450012440 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: DialogContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Dialog View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_DialogContainer extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Create a jQuery UI Dialog filled with the given content
     *
     * @link   http://docs.jquery.com/UI/Dialog
     * @param  string $id
     * @param  string $content
     * @param  array $params
     * @param  array $attribs
     * @return string
     */
	public function dialogContainer($id, $content, $params=array(), $attribs=array())
	{
        if (!array_key_exists('id', $attribs)) {
            $attribs['id'] = $id;
        }

        if(count($params) > 0) {
            $params = ZendX_JQuery::encodeJson($params);
        } else {
            $params = "{}";
        }

        $js = sprintf('%s("#%s").dialog(%s);',
            ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
            $attribs['id'],
            $params
        );
        $this->jquery->addOnLoad($js);

        $html = '<div'
              . $this->_htmlAttribs($attribs)
              . '>'
              . $content
              . '</div>';
        return $html;
	}
}View/Helper/DatePicker.php000060400000011156150712002450011415 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: DatePicker.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see Zend_Registry
 */
require_once "Zend/Registry.php";

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Date Picker View Helper
 *
 * @uses 	   Zend_View_Helper_FormText
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_DatePicker extends ZendX_JQuery_View_Helper_UiWidget
{
	/**
	 * Create a jQuery UI Widget Date Picker
	 *
	 * @link   http://docs.jquery.com/UI/Datepicker
	 * @param  string $id
	 * @param  string $value
	 * @param  array  $params jQuery Widget Parameters
	 * @param  array  $attribs HTML Element Attributes
	 * @return string
	 */
	public function datePicker($id, $value = null, array $params = array(), array $attribs = array())
	{
		$attribs = $this->_prepareAttributes($id, $value, $attribs);

		//
		// Prepare params
		//
		if(!isset($params['dateFormat']) && Zend_Registry::isRegistered('Zend_Locale')) {
		    $params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat();
		}

		// TODO: Allow translation of DatePicker Text Values to get this action from client to server

		if(count($params) > 0) {
            $params = ZendX_JQuery::encodeJson($params);
		} else {
		    $params = "{}";
		}

		$js = sprintf('%s("#%s").datepicker(%s);',
		    ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
		    $attribs['id'],
		    $params
		);

		//
		// Add DatePicker callup to onLoad Stack
		//
		$this->jquery->addOnLoad($js);

		return $this->view->formText($id, $value, $attribs);
	}

	/**
	 * A Check for Zend_Locale existance has already been done in {@link datePicker()}
	 * this function only resolves the default format from Zend Locale to
	 * a jQuery Date Picker readable format. This function can be potentially buggy
	 * because of its easy nature and is therefore stripped from the core functionality
	 * to be easily overriden.
	 *
	 * @return string
	 */
	public static function resolveZendLocaleToDatePickerFormat($format=null)
	{
        if($format == null) {
            $locale = Zend_Registry::get('Zend_Locale');
            if( !($locale instanceof Zend_Locale) ) {
                require_once "ZendX/JQuery/Exception.php";
                throw new ZendX_JQuery_Exception("Cannot resolve Zend Locale format by default, no application wide locale is set.");
            }
            /**
             * @see Zend_Locale_Format
             */
            require_once "Zend/Locale/Format.php";
            $format = Zend_Locale_Format::getDateFormat($locale);
        }

        $dateFormat = array(
            'EEEEE' => 'D', 'EEEE' => 'DD', 'EEE' => 'D', 'EE' => 'D', 'E' => 'D',
            'MMMM' => 'MM', 'MMM' => 'M', 'MM' => 'mm', 'M' => 'm',
            'YYYYY' => 'yy', 'YYYY' => 'yy', 'YYY' => 'yy', 'YY' => 'y', 'Y' => 'y',
            'yyyyy' => 'yy', 'yyyy' => 'yy', 'yyy' => 'yy', 'yy' => 'y',
            'G' => '', 'e' => '', 'a' => '', 'h' => '', 'H' => '', 'm' => '',
            's' => '', 'S' => '', 'z' => '', 'Z' => '', 'A' => '',
        );

        $newFormat = "";
        $isText = false;
        $i = 0;
        while($i < strlen($format)) {
            $chr = $format[$i];
            if($chr == '"' || $chr == "'") {
                $isText = !$isText;
            }
            $replaced = false;
            if($isText == false) {
                foreach($dateFormat AS $zl => $jql) {
                    if(substr($format, $i, strlen($zl)) == $zl) {
                        $chr = $jql;
                        $i += strlen($zl);
                        $replaced = true;
                    }
                }
            }
            if($replaced == false) {
                $i++;
            }
            $newFormat .= $chr;
        }

	    return $newFormat;
	}
}View/Helper/TabContainer.php000060400000010255150712002450011752 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: TabContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Tabs Container View Helper
 *
 * @uses 	   Zend_Json
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_TabContainer extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Save all the pre-rendered tab panes to each tab container
     *
     * @var array
     */
    protected $_tabs = array();

    /**
     * Add Tab to TabsContainer
     *
     * @param  string $id
     * @param  string $name
     * @param  string $content
     * @param  array  $options
     * @return ZendX_JQuery_View_Helper_TabsContainer
     */
    public function addPane($id, $name, $content, array $options=array())
    {
        if(!isset($this->_tabs[$id])) {
            $this->_tabs[$id] = array();
        }
        if(strlen($name) == 0 && isset($options['title'])) {
            $name = $options['title'];
        }

        $this->_tabs[$id][] = array('name' => $name, 'content' => $content, 'options' => $options);
        return $this;
    }

    /**
     * Render TabsContainer with all the currently registered tabs.
     *
     * Render all tabs to the given $id. If no arguments are given the
     * tabsContainer view helper object is returned and can be used
     * for chaining {@link addPane()} for tab pane adding.
     *
     * @link   http://docs.jquery.com/UI/Tabs
     * @param  string $id
     * @param  array  $params
     * @param  array  $attribs
     * @return string|ZendX_JQuery_View_Helper_TabsContainer
     */
    public function tabContainer($id=null, $params=array(), $attribs=array())
    {
        if(func_num_args() === 0) {
            return $this;
        }

        if(!isset($attribs['id'])) {
            $attribs['id'] = $id;
        }

        $content = "";
        if(isset($this->_tabs[$id])) {
            $list = '<ul class="ui-tabs-nav">'.PHP_EOL;
            $html = '';
            $fragment_counter = 1;
            foreach($this->_tabs[$id] AS $k => $v) {
                $frag_name = sprintf('%s-frag-%d', $attribs['id'], $fragment_counter++);
                $opts = $v['options'];
                if(isset($opts['contentUrl'])) {
                    $list .= '<li class="ui-tabs-nav-item"><a href="'.$opts['contentUrl'].'"><span>'.$v['name'].'</span></a></li>'.PHP_EOL;
                } else {
                    $list .= '<li class="ui-tabs-nav-item"><a href="#'.$frag_name.'"><span>'.$v['name'].'</span></a></li>'.PHP_EOL;
                    $html .= '<div id="'.$frag_name.'" class="ui-tabs-panel">'.$v['content'].'</div>'.PHP_EOL;
                }
            }
            $list .= '</ul>'.PHP_EOL;

            $content = $list.$html;
            unset($this->_tabs[$id]);
        }

        if(count($params)) {
            $params = ZendX_JQuery::encodeJson($params);
        } else {
            $params = '{}';
        }

        $js = sprintf('%s("#%s").tabs(%s);',
            ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
            $attribs['id'],
            $params
        );
        $this->jquery->addOnLoad($js);

        $html = '<div'
              . $this->_htmlAttribs($attribs)
              . '>'.PHP_EOL
              . $content
              . '</div>'.PHP_EOL;
        return $html;
    }
}View/Helper/Slider.php000060400000013271150712002450010624 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Slider.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Slider View Helper
 *
 * @uses 	   Zend_Json
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_Slider extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Create jQuery slider that updates its values into a hidden form input field.
     *
     * @link   http://docs.jquery.com/UI/Slider
     * @param  string $id
     * @param  string $value
     * @param  array  $params
     * @param  array  $attribs
     * @return string
     */
    public function slider($id, $value = null, array $params = array(), array $attribs = array())
    {
        if(!isset($attribs['id'])) {
            $attribs['id'] = $id;
        }

        $jqh = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();

        $params = $this->initializeStartingValues($value, $params);
        $handleCount = $this->getHandleCount($params);

        // Build the Change/Update functionality of the Slider via javascript, updating hidden fields. aswell as hidden fields
        $hidden = "";
        if(!isset($params['change'])) {
            $sliderUpdateFn = 'function(e, ui) {'.PHP_EOL;
            for($i = 0; $i < $handleCount; $i++) {
                // Js Func
                if($i === 0) {
                    $sliderHiddenId = $attribs['id'];
                } else {
                    $sliderHiddenId = $attribs['id']."-".$i;
                }
                $sliderUpdateFn .= $this->getChangeCallback($jqh, $sliderHiddenId, $attribs['id'], $i);

                // Hidden Fields
                $startValue = $this->getHandleValue($i, $params);
                $hiddenAttribs = array('type' => 'hidden', 'id' => $sliderHiddenId, 'name' => $sliderHiddenId, 'value' => $startValue);
                $hidden .= '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket(). PHP_EOL;
            }
            $sliderUpdateFn .= "}".PHP_EOL;
            $params['change'] = new Zend_Json_Expr($sliderUpdateFn);
        }

        $attribs['id'] .= "-slider";

        if(count($params) > 0) {
            $params = ZendX_JQuery::encodeJson($params);
        } else {
            $params = '{}';
        }

        $js = sprintf('%s("#%s").slider(%s);', $jqh, $attribs['id'], $params);
        $this->jquery->addOnLoad($js);

        $html = '<div' . $this->_htmlAttribs($attribs) . '>';
        for($i = 0; $i < $handleCount; $i++) {
            $html .= '<div class="ui-slider-handle"></div>';
        }
        $html .= '</div>';

        return $hidden.$html;
    }

    protected function getChangeCallback($jqh, $sliderHiddenId, $elementId, $handlerNum)
    {
        if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
            return sprintf('    %s("#%s").attr("value", %s("#%s-slider").slider("values", %d));'.PHP_EOL,
                $jqh, $sliderHiddenId, $jqh, $elementId, $handlerNum
            );
        } else {
            return sprintf('    %s("#%s").attr("value", %s("#%s-slider").slider("value", %d));'.PHP_EOL,
                $jqh, $sliderHiddenId, $jqh, $elementId, $handlerNum
            );
        }
    }

    protected function getHandleCount($params)
    {
        if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
            return count($params['values']);
        } else {
            return count($params['handles']);
        }
    }

    protected function getHandleValue($handleNum, $params)
    {
        if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
            return $params['values'][$handleNum];
        } else {
            return $params['handles'][$handleNum]['start'];
        }
    }

    protected function initializeStartingValues($value, $params)
    {
        $values = array();
        if(isset($params['value'])) {
            $values[] = $params['value'];
            unset($params['value']);
        } else if(isset($params['values'])) {
            $values = $params['values'];
            unset($params['values']);
        } else if(isset($params['handles'])) {
            for($i = 0; $i < count($params['handles']); $i++) {
                $values[] = $params['handles'][$i]['start'];
            }
            unset($params['handles']);
        } else if(isset($params['startValue'])) {
            $values[] = $params['startValue'];
            unset($params['startValue']);
        } else if(is_numeric($value)) {
            $values[] = $value;
        }

        if(version_compare($this->jquery->getUiVersion(), "1.7.0") >= 0) {
            $params['values'] = $values;
        } else {
            $params['handles'] = array();
            for($i = 0; $i < count($values); $i++) {
                $params['handles'][$i]['start'] = $values[$i];
            }
        }
        return $params;
    }
}View/Helper/AutoComplete.php000060400000006313150712002450012002 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AutoComplete.php 20754 2010-01-29 11:42:43Z beberlei $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * jQuery Autocomplete View Helper
 *
 * @uses 	   Zend_Json, Zend_View_Helper_FormText
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_AutoComplete extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Builds an AutoComplete ready input field.
     *
     * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText
     * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete
     * field. Make sure you have set one out of the two following options: $params['data'] or
     * $params['url']. The first one accepts an array as data input to the autoComplete, the
     * second accepts an url, where the autoComplete content is returned from. For the format
     * see jQuery documentation.
     *
     * @link   http://docs.jquery.com/UI/Autocomplete
     * @throws ZendX_JQuery_Exception
     * @param  String $id
     * @param  String $value
     * @param  array $params
     * @param  array $attribs
     * @return String
     */
    public function autoComplete($id, $value = null, array $params = array(), array $attribs = array())
    {
        $attribs = $this->_prepareAttributes($id, $value, $attribs);

        if (!isset($params['source'])) {
            if (isset($params['url'])) {
                $params['source'] = $params['url'];
                unset($params['url']);
            } else if (isset($params['data'])) {
                $params['source'] = $params['data'];
                unset($params['data']);
            } else {
                require_once "ZendX/JQuery/Exception.php";
                throw new ZendX_JQuery_Exception(
                    "Cannot construct AutoComplete field without specifying 'source' field, ".
                    "either an url or an array of elements."
                );
            }
        }

        $params = ZendX_JQuery::encodeJson($params);

        $js = sprintf('%s("#%s").autocomplete(%s);',
                ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
                $attribs['id'],
                $params
        );

        $this->jquery->addOnLoad($js);

        return $this->view->formText($id, $value, $attribs);
    }
}View/Helper/AccordionPane.php000060400000005072150712002450012107 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AccordionPane.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidgetPane
 */
require_once "UiWidgetPane.php";

/**
 * jQuery Accordion Pane, goes with Accordion Container
 *
 * @uses 	   ZendX_JQuery_View_Helper_AccordionContainer
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_View_Helper_AccordionPane extends ZendX_JQuery_View_Helper_UiWidgetPane
{
    /**
     * Add accordion pane to the accordion with $id
     *
     * Directly add an additional pane to the accordion with $id. The title
     * is to be given in the $options array as 'title' key. Additionally when
     * specified with no arguments, the helper returns itsself as object making
     * it possible to use {@link captureStart()} and {@link captureEnd()} methods.
     *
     * @param  string $id
     * @param  string $content
     * @param  array  $options
     * @return string|ZendX_JQuery_View_Helper_AccordionPane
     */
    public function accordionPane($id=null, $content='', array $options=array())
    {
        if(0 === func_num_args()) {
            return $this;
        }

        $name = '';
        if(isset($options['title'])) {
            $name = $options['title'];
            unset($options['title']);
        }

        $this->_addPane($id, $name, $content, $options);
        return '';
    }

    /**
     * Method hooks into Accordion Container and registeres new pane
     *
     * @param string $id
     * @param string $name
     * @param string $content
     * @param array  $options
     */
    protected function _addPane($id, $name, $content, array $options=array())
    {
        $this->view->accordionContainer()->addPane($id, $name, $content, $options);
    }
}View/Helper/AjaxLink.php000060400000030523150712002450011102 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AjaxLink.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see Zend_View_Helper_HtmlElement
 */
include_once "Zend/View/Helper/HtmlElement.php";

/**
 * jQuery Accordion Pane, goes with Accordion Container
 *
 * @uses 	   Zend_Json
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_AjaxLink extends Zend_View_Helper_HtmlElement
{
    /**
     * Static because multiple instances accross views of AjaxLink could reset the counter and a
     * subcontainer because of this single private class variable seems too much overhead.
     *
     * @staticvar Integer
     */
    private static $currentLinkCallbackId = 1;

    /**
     * Create an anchor that enables ajax-based requests and handling of the response.
     *
     * This helper creates links that make XmlHttpRequests to the server. It allows to
     * inject the response into the DOM. Fancy effects going with the links can be enabled
     * via simple callback shortnames. The functionality is mostly controlled by the $options
     * array:
     *
     * $options
     *  Key				Behaviour
     *  =================================================================================
     *  'update'        Update a container with the content fetched from $url
     *  'method'        Explicit Requesting method mimicing the jQuery functionality: GET, POST
     *  'inline'        True or false, wheater to inline the javascript in onClick=""
     * 					atttribute or append it to jQuery onLoad Stack.
     *  'complete'      String specifies javascript called after successful request or a
     * 					shortname of a jQuery effect that should be applied to the 'update' element.
     *  'beforeSend'	String specifies javascript called before the request is sent, or a
     * 					shortname of a jQuery effect that should be applied to the link clicked.
     *  'noscript'		True/false, include a noscript variant that directly requests
     * 					the given $url (make sure to check $request->isXmlHttpRequest())
     *  'dataType'		What type of data is the response returning? text, html, json?
     *  'title'			HTML Attribute title of the Anchor
     *  'class'			HTML Attribute class of the Anchor
     *  'id'			HTML Attribute id of the Anchor
     *  'attribs'		Array of Key-Value pairs with HTML Attribute names and their content.
     *
     * BeforeSend Callback:
     * Can include shortcuts as a string assignment to fire of effects before sending of request.
     * Possible shortcuts are 'fadeOut', 'fadeOutSlow', 'hide', 'hideSlow', 'slideUp', 'flash',
     * @example $options = array('beforeSend' => 'hideSlow', 'complete' => 'show');
     *
     * @link   http://docs.jquery.com/Ajax
     * @param  String $label Urls Title
     * @param  String $url Link to Point to
     * @param  Array $options
     * @param  Array $params Key Value Pairs of GET/POST Parameters
     * @return String
     */
    public function ajaxLink($label, $url, $options=null, $params=null)
    {
        $jquery = $this->view->jQuery();
        $jquery->enable();

        $jqHandler = (ZendX_JQuery_View_Helper_JQuery::getNoConflictMode()==true)?'$j':'$';

        $attribs = array();
        if(isset($options['attribs']) && is_array($options['attribs'])) {
            $attribs = $options['attribs'];
        }

        //
        // The next following 4 conditions check for html attributes that the link might need
        //
        if(empty($options['noscript']) || $options['noscript'] == false) {
            $attribs['href'] = "#";
        } else {
            $attribs['href'] = $url;
        }

        if(!empty($options['title'])) {
            $attribs['title'] = $options['title'];
        }

        // class value is an array because the jQuery CSS selector
        // click event needs its own classname later on
        if(!isset($attribs['class'])) {
            $attribs['class'] = array();
        } elseif(is_string($attribs['class'])) {
            $attribs['class'] = explode(" ", $attribs['class']);
        }
        if(!empty($options['class'])) {
            $attribs['class'][] = $options['class'];
        }

        if(!empty($options['id'])) {
            $attribs['id'] = $options['id'];
        }

        //
        // Execute Javascript inline?
        //
        $inline = false;
        if(!empty($options['inline']) && $options['inline'] == true) {
            $inline = true;
        }

        //
        // Detect the callbacks:
        // Just those two callbacks, beforeSend and complete can be defined for the $.get and $.post options.
        // Pick all the defined callbacks and put them on their respective stacks.
        //
        $callbacks = array('beforeSend' => null, 'complete' => null);
        if(isset($options['beforeSend'])) {
            $callbacks['beforeSend'] = $options['beforeSend'];
        }
        if(isset($options['complete'])) {
            $callbacks['complete'] = $options['complete'];
        }

        $updateContainer = false;
        if(!empty($options['update']) && is_string($options['update'])) {
            $updateContainer = $options['update'];

            // Additionally check if there is a callback complete that is a shortcut to be executed
            // on the specified update container
            if(!empty($callbacks['complete'])) {
                switch(strtolower($callbacks['complete'])) {
                    case 'show':
                        $callbacks['complete'] = sprintf("%s('%s').show();", $jqHandler, $updateContainer);
                        break;
                    case 'showslow':
                        $callbacks['complete'] = sprintf("%s('%s').show('slow');", $jqHandler, $updateContainer);
                        break;
                    case 'shownormal':
                        $callbacks['complete'] = sprintf("%s('%s').show('normal');", $jqHandler, $updateContainer);
                        break;
                    case 'showfast':
                        $callbacks['complete'] = sprintf("%s('%s').show('fast');", $jqHandler, $updateContainer);
                        break;
                    case 'fadein':
                        $callbacks['complete'] = sprintf("%s('%s').fadeIn('normal');", $jqHandler, $updateContainer);
                        break;
                    case 'fadeinslow':
                        $callbacks['complete'] = sprintf("%s('%s').fadeIn('slow');", $jqHandler, $updateContainer);
                        break;
                    case 'fadeinfast':
                        $callbacks['complete'] = sprintf("%s('%s').fadeIn('fast');", $jqHandler, $updateContainer);
                        break;
                    case 'slidedown':
                        $callbacks['complete'] = sprintf("%s('%s').slideDown('normal');", $jqHandler, $updateContainer);
                        break;
                    case 'slidedownslow':
                        $callbacks['complete'] = sprintf("%s('%s').slideDown('slow');", $jqHandler, $updateContainer);
                        break;
                    case 'slidedownfast':
                        $callbacks['complete'] = sprintf("%s('%s').slideDown('fast');", $jqHandler, $updateContainer);
                        break;
                }
            }
        }

        if(empty($options['dataType'])) {
            $options['dataType'] = "html";
        }

        $requestHandler = $this->_determineRequestHandler($options, (count($params)>0)?true:false);

        $callbackCompleteJs = array();
        if($updateContainer != false) {
            if($options['dataType'] == "text") {
                $callbackCompleteJs[] = sprintf("%s('%s').text(data);", $jqHandler, $updateContainer);
            } else {
                $callbackCompleteJs[] = sprintf("%s('%s').html(data);", $jqHandler, $updateContainer);
            }
        }
        if($callbacks['complete'] != null) {
            $callbackCompleteJs[] = $callbacks['complete'];
        }

        if(isset($params) && count($params) > 0) {
            $params = ZendX_JQuery::encodeJson($params);
        } else {
            $params = '{}';
        }

        $js = array();
        if($callbacks['beforeSend'] != null) {
            switch(strtolower($callbacks['beforeSend'])) {
                case 'fadeout':
                    $js[] = sprintf("%s(this).fadeOut();", $jqHandler);
                    break;
                case 'fadeoutslow':
                    $js[] = sprintf("%s(this).fadeOut('slow');", $jqHandler);
                    break;
                case 'fadeoutfast':
                    $js[] = sprintf("%s(this).fadeOut('fast');", $jqHandler);
                    break;
                case 'hide':
                    $js[] = sprintf("%s(this).hide();", $jqHandler);
                    break;
                case 'hideslow':
                    $js[] = sprintf("%s(this).hide('slow');", $jqHandler);
                    break;
                case 'hidefast':
                    $js[] = sprintf("%s(this).hide('fast');", $jqHandler);
                    break;
                case 'slideup':
                    $js[] = sprintf("%s(this).slideUp(1000);", $jqHandler);
                    break;
                default:
                    $js[] = $callbacks['beforeSend'];
                    break;
            }
        }

        switch($requestHandler) {
            case 'GET':
                $js[] = sprintf("%s.get('%s', %s, function(data, textStatus) { %s }, '%s');return false;",
                    $jqHandler, $url, $params, implode(" ", $callbackCompleteJs), $options['dataType']);
                break;
            case 'POST':
                $js[] = sprintf("%s.post('%s', %s, function(data, textStatus) { %s }, '%s');return false;",
                    $jqHandler, $url, $params, implode(" ", $callbackCompleteJs), $options['dataType']);
                break;
        }

        $js = implode($js);

        if($inline == true) {
            $attribs['onClick'] = $js;
        } else {
            if(!isset($attribs['id'])) {
                $clickClass = sprintf("ajaxLink%d", ZendX_JQuery_View_Helper_AjaxLink::$currentLinkCallbackId);
                ZendX_JQuery_View_Helper_AjaxLink::$currentLinkCallbackId++;

                $attribs['class'][] = $clickClass;
                $onLoad = sprintf("%s('a.%s').click(function() { %s });", $jqHandler, $clickClass, $js);
            } else {
                $onLoad = sprintf("%s('a#%s').click(function() { %s });", $jqHandler, $attribs['id'], $js);
            }

            $jquery->addOnLoad($onLoad);
        }

        if(count($attribs['class']) > 0) {
            $attribs['class'] = implode(" ", $attribs['class']);
        } else {
            unset($attribs['class']);
        }

        $html = '<a'
            . $this->_htmlAttribs($attribs)
            . '>'
            . $label
            . '</a>';
        return $html;
    }

    /**
     * Determine which request method (GET or POST) should be used.
     *
     * Normally the request method is determined implicitly by the rule,
     * if addiotional params are sent, POST, if not GET. You can overwrite
     * this behaviiour by implicitly setting $options['method'] = "POST|GET";
     *
     * @param  Array   $options
     * @param  Boolean $hasParams
     * @return String
     */
    protected function _determineRequestHandler($options, $hasParams)
    {
        if(isset($options['method']) && in_array(strtoupper($options['method']), array('GET', 'POST'))) {
            return strtoupper($options['method']);
        }
        $requestHandler = "GET";
        if($hasParams == true) {
            $requestHandler = "POST";
        }
        return $requestHandler;
    }
}View/Helper/UiWidgetPane.php000060400000006125150712002450011727 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: UiWidgetPane.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "UiWidget.php";

/**
 * jQuery Pane Base class, adds captureStart/captureEnd functionality for panes.
 *
 * @uses 	   ZendX_JQuery_View_Helper_JQuery_Container
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class ZendX_JQuery_View_Helper_UiWidgetPane extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Capture Lock information
     *
     * @var array
     */
    protected $_captureLock = array();

    /**
     * Current capture additional information
     *
     * @var array
     */
    protected $_captureInfo = array();

    /**
     * Begin capturing content for layout container
     *
     * @param  string $id
     * @param  string $name
     * @param  array  $options
     * @return void
     */
    public function captureStart($id, $name, array $options=array())
    {
        if (array_key_exists($id, $this->_captureLock)) {
            require_once 'ZendX/JQuery/View/Exception.php';
            throw new ZendX_JQuery_View_Exception(sprintf('Lock already exists for id "%s"', $id));
        }

        $this->_captureLock[$id] = true;
        $this->_captureInfo[$id] = array(
            'name'  => $name,
            'options' => $options,
        );

        return ob_start();
    }

    /**
     * Finish capturing content for layout container
     *
     * @param  string $id
     * @return string
     */
    public function captureEnd($id)
    {
        if (!array_key_exists($id, $this->_captureLock)) {
            require_once 'ZendX/JQuery/View/Exception.php';
            throw new ZendX_JQuery_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
        }

        $content = ob_get_clean();
        extract($this->_captureInfo[$id]);
        unset($this->_captureLock[$id], $this->_captureInfo[$id]);
        return $this->_addPane($id, $name, $content, $options);
    }

    /**
     * Add an additional pane to the current Widget Container
     *
     * @param string $id
     * @param string $name
     * @param string $content
     * @param array  $options
     */
    abstract protected function _addPane($id, $name, $content, array $options=array());
}View/Helper/JQuery.php000060400000010415150712002450010616 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: JQuery.php 20184 2010-01-10 21:22:54Z freak $
 */

/**
 * @see ZendX_JQuery
 */
require_once "ZendX/JQuery.php";

/**
 * @see Zend_Registry
 */
require_once 'Zend/Registry.php';

/**
 * @see Zend_View_Helper_Abstract
 */
require_once 'Zend/View/Helper/Abstract.php';

/**
 * @see ZendX_JQuery_View_Helper_JQuery_Container
 */
require_once "ZendX/JQuery/View/Helper/JQuery/Container.php";

/**
 * jQuery Helper. Functions as a stack for code and loads all jQuery dependencies.
 *
 * @uses 	   Zend_Json
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_JQuery extends Zend_View_Helper_Abstract
{
    /**
     * @var Zend_View_Interface
     */
    public $view;

	/**
	 * jQuery no Conflict Mode
	 *
	 * @see	      http://docs.jquery.com/Using_jQuery_with_Other_Libraries
	 * @staticvar Boolean Status of noConflict Mode
	 */
    private static $noConflictMode = false;

   /**
     * Initialize helper
     *
     * Retrieve container from registry or create new container and store in
     * registry.
     *
     * @return void
     */
    public function __construct()
    {
        $registry = Zend_Registry::getInstance();
        if (!isset($registry[__CLASS__])) {
            require_once 'ZendX/JQuery/View/Helper/JQuery/Container.php';
            $container = new ZendX_JQuery_View_Helper_JQuery_Container();
            $registry[__CLASS__] = $container;
        }
        $this->_container = $registry[__CLASS__];
    }

	/**
	 * Return jQuery View Helper class, to execute jQuery library related functions.
	 *
	 * @return ZendX_JQuery_View_Helper_JQuery_Container
	 */
    public function jQuery()
    {
        return $this->_container;
    }

    /**
     * Set view object
     *
     * @param  Zend_View_Interface $view
     * @return void
     */
    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
        $this->_container->setView($view);
    }

    /**
     * Proxy to container methods
     *
     * @param  string $method
     * @param  array  $args
     * @return mixed
     * @throws Zend_View_Exception For invalid method calls
     */
    public function __call($method, $args)
    {
        if (!method_exists($this->_container, $method)) {
            require_once 'Zend/View/Exception.php';
            throw new Zend_View_Exception(sprintf('Invalid method "%s" called on jQuery view helper', $method));
        }

        return call_user_func_array(array($this->_container, $method), $args);
    }

	/**
	 * Enable the jQuery internal noConflict Mode to work with
	 * other Javascript libraries. Will setup jQuery in the variable
	 * $j instead of $ to overcome conflicts.
	 *
	 * @link http://docs.jquery.com/Using_jQuery_with_Other_Libraries
	 */
    public static function enableNoConflictMode()
    {
    	self::$noConflictMode = true;
    }

	/**
	 * Disable noConflict Mode of jQuery if this was previously enabled.
	 *
	 * @return void
	 */
    public static function disableNoConflictMode()
    {
    	self::$noConflictMode = false;
    }

	/**
	 * Return current status of the jQuery no Conflict Mode
	 *
	 * @return Boolean
	 */
    public static function getNoConflictMode()
    {
    	return self::$noConflictMode;
    }

    /**
     * Return current jQuery handler based on noConflict mode settings.
     *
     * @return String
     */
    public static function getJQueryHandler()
    {
        return ((self::getNoConflictMode()==true)?'$j':'$');
    }
}
Form.php000060400000004403150712002450006151 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Form.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

require_once "Zend/Form.php";

/**
 * Form Wrapper for jQuery-enabled forms
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Form extends Zend_Form
{
    /**
     * Constructor
     *
     * @param  array|Zend_Config|null $options
     * @return void
     */
    public function __construct($options = null)
    {
        $this->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
             ->addPrefixPath('ZendX_JQuery_Form_Element', 'ZendX/JQuery/Form/Element', 'element')
             ->addElementPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
             ->addDisplayGroupPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator');
        parent::__construct($options);
    }

    /**
     * Set the view object
     *
     * Ensures that the view object has the jQuery view helper path set.
     *
     * @param  Zend_View_Interface $view
     * @return ZendX_JQuery_Form
     */
    public function setView(Zend_View_Interface $view = null)
    {
        if (null !== $view) {
            if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
                $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
            }
        }
        return parent::setView($view);
    }
}Exception.php000060400000002106150712002450007202 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Exception.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

require_once "Zend/Exception.php";

/**
 * jQuery Exception
 *
 * @package    ZendX_JQuery
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Exception extends Zend_Exception { }Form/Decorator/UiWidgetElementMarker.php000060400000002050150712002450014264 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id$
 */

/**
 * Marking UiWidgetElement rendering decorator.
 *
 * Marker Interface to make sure that programmer using ZendX_JQuery is not
 * switching ZendX_JQuery_Form_Decorator_UiWidgetElement with Zend_Form_Decorator_ViewHelper
 * without noticing that this is not possible.
 */
interface ZendX_JQuery_Form_Decorator_UiWidgetElementMarker {
}Form/Decorator/TabContainer.php000060400000002421150712002450012442 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: TabContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
 */
require_once "UiWidgetContainer.php";

/**
 * Form Decorator for jQuery Tabs View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Decorator_TabContainer extends ZendX_JQuery_Form_Decorator_UiWidgetContainer
{
    protected $_helper = "tabContainer";
}Form/Decorator/UiWidgetElement.php000060400000011601150712002450013124 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: UiWidgetElement.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see Zend_Form_Decorator_ViewHelper
 */
require_once "Zend/Form/Decorator/ViewHelper.php";

/**
 * @see ZendX_JQuery_Form_Decorator_UiWidgetElementMarker
 */
require_once "ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php";

/**
 * Abstract Form Decorator for all jQuery UI Form Elements
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Decorator_UiWidgetElement
    extends Zend_Form_Decorator_ViewHelper
    implements ZendX_JQuery_Form_Decorator_UiWidgetElementMarker
{
    /**
     * Element attributes
     *
     * @var array
     */
    protected $_attribs;

    /**
     * jQuery UI View Helper
     *
     * @var ZendX_JQuery_View_Helper_UiWidget
     */
    public $helper;

    /**
     * jQuery related attributes/options
     *
     * @var array
     */
    protected $_jQueryParams = array();

    /**
     * Get element attributes
     *
     * @return array
     */
    public function getElementAttribs()
    {
        if (null === $this->_attribs) {
            if($this->_attribs = parent::getElementAttribs()) {
                if (array_key_exists('jQueryParams', $this->_attribs)) {
                    $this->setJQueryParams($this->_attribs['jQueryParams']);
                    unset($this->_attribs['jQueryParams']);
                }
            }
        }

        return $this->_attribs;
    }

    /**
     * Set a single jQuery option parameter
     *
     * @param  string $key
     * @param  mixed $value
     * @return ZendX_JQuery_Form_Decorator_UiWidgetElement
     */
    public function setJQueryParam($key, $value)
    {
        $this->_jQueryParams[(string) $key] = $value;
        return $this;
    }

    /**
     * Set jQuery option parameters
     *
     * @param  array $params
     * @return ZendX_JQuery_Form_Decorator_UiWidgetElement
     */
    public function setJQueryParams(array $params)
    {
        $this->_jQueryParams = array_merge($this->_jQueryParams, $params);
        return $this;
    }

    /**
     * Retrieve a single jQuery option parameter
     *
     * @param  string $key
     * @return mixed|null
     */
    public function getJQueryParam($key)
    {
        $this->getElementAttribs();
        $key = (string) $key;
        if (array_key_exists($key, $this->_jQueryParams)) {
            return $this->_jQueryParams[$key];
        }

        return null;
    }

    /**
     * Get jQuery option parameters
     *
     * @return array
     */
    public function getJQueryParams()
    {
        $this->getElementAttribs();
        return $this->_jQueryParams;
    }

    /**
     * Render an jQuery UI Widget element using its associated view helper
     *
     * @param  string $content
     * @return string
     * @throws Zend_Form_Decorator_Exception if element or view are not registered
     */
    public function render($content)
    {
        $element = $this->getElement();
        $view = $element->getView();
        if (null === $view) {
            require_once 'Zend/Form/Decorator/Exception.php';
            throw new Zend_Form_Decorator_Exception('UiWidgetElement decorator cannot render without a registered view object');
        }

        if(method_exists($element, 'getJQueryParams')) {
            $this->setJQueryParams($element->getJQueryParams());
        }
        $jQueryParams = $this->getJQueryParams();

        $helper    = $this->getHelper();
        $separator = $this->getSeparator();
        $value     = $this->getValue($element);
        $attribs   = $this->getElementAttribs();
        $name      = $element->getFullyQualifiedName();

        $id = $element->getId();
        $attribs['id'] = $id;

        $elementContent = $view->$helper($name, $value, $jQueryParams, $attribs);
        switch ($this->getPlacement()) {
            case self::APPEND:
                return $content . $separator . $elementContent;
            case self::PREPEND:
                return $elementContent . $separator . $content;
            default:
                return $elementContent;
        }
    }
}Form/Decorator/UiWidgetContainer.php000060400000007706150712002450013470 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: UiWidgetContainer.php 20746 2010-01-29 10:36:35Z beberlei $
 */

require_once "Zend/Form/Decorator/Abstract.php";

/**
 * Abstract Form Decorator for all jQuery UI Widget Containers
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class ZendX_JQuery_Form_Decorator_UiWidgetContainer extends Zend_Form_Decorator_Abstract
{
    /**
     * View helper
     * @var string
     */
    protected $_helper;

    /**
     * Element attributes
     * @var array
     */
    protected $_attribs;

    /**
     * jQuery option parameters
     * @var array
     */
    protected $_jQueryParams;

    /**
     * Get view helper for rendering container
     *
     * @return string
     */
    public function getHelper()
    {
        if (null === $this->_helper) {
            require_once 'Zend/Form/Decorator/Exception.php';
            throw new Zend_Form_Decorator_Exception('No view helper specified fo DijitContainer decorator');
        }
        return $this->_helper;
    }

    /**
     * Get element attributes
     *
     * @return array
     */
    public function getAttribs()
    {
        if (null === $this->_attribs) {
            $attribs = $this->getElement()->getAttribs();
            if (array_key_exists('jQueryParams', $attribs)) {
                $this->getJQueryParams();
                unset($attribs['jQueryParams']);
            }
            $this->_attribs = $attribs;
        }
        return $this->_attribs;
    }

    /**
     * Get jQuery option parameters
     *
     * @return array
     */
    public function getJQueryParams()
    {
        if (null === $this->_jQueryParams) {
            $this->_jQueryParams = array();
            if($attribs = $this->getElement()->getAttribs()) {
                if (array_key_exists('jQueryParams', $attribs)) {
                    $this->_jQueryParams = $attribs['jQueryParams'];
                }
            }

            if($options = $this->getOptions()) {
                if (array_key_exists('jQueryParams', $options)) {
                    $this->_jQueryParams = array_merge($this->_jQueryParams, $options['jQueryParams']);
                    $this->removeOption('jQueryParams');
                }
            }
        }

        return $this->_jQueryParams;
    }

    /**
     * Render an jQuery UI Widget element using its associated view helper
     *
     * Determine view helper from 'helper' option, or, if none set, from
     * the element type. Then call as
     * helper($element->getName(), $element->getValue(), $element->getAttribs())
     *
     * @param  string $content
     * @return string
     * @throws Zend_Form_Decorator_Exception if element or view are not registered
     */
    public function render($content)
    {
        $element = $this->getElement();
        $view    = $element->getView();
        if (null === $view) {
            return $content;
        }

        $jQueryParams = $this->getJQueryParams();
        $attribs     = $this->getOptions();

        $helper      = $this->getHelper();
        $id          = $element->getId() . '-container';

        return $view->$helper($id, $jQueryParams, $attribs);
    }
}Form/Decorator/AccordionContainer.php000060400000002450150712002450013637 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AccordionContainer.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
 */
require_once "UiWidgetContainer.php";

/**
 * Form Decorator for jQuery Accordion View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Decorator_AccordionContainer extends ZendX_JQuery_Form_Decorator_UiWidgetContainer
{
    protected $_helper = "accordionContainer";
}Form/Decorator/UiWidgetPane.php000060400000011517150712002450012424 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: UiWidgetPane.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

require_once "Zend/Form/Decorator/Abstract.php";

/**
 * Abstract Form Decorator for all jQuery UI Pane View Helpers
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class ZendX_JQuery_Form_Decorator_UiWidgetPane extends Zend_Form_Decorator_Abstract
{
    /**
     * View helper
     * @var string
     */
    protected $_helper;

    /**
     * Element attributes
     * @var array
     */
    protected $_attribs;

    /**
     * jQuery option parameters
     * @var array
     */
    protected $_jQueryParams;

    /**
     * Container title
     * @var string
     */
    protected $_title;

    /**
     * Get view helper for rendering container
     *
     * @return string
     */
    public function getHelper()
    {
        if (null === $this->_helper) {
            require_once 'Zend/Form/Decorator/Exception.php';
            throw new Zend_Form_Decorator_Exception('No view helper specified fo UiWidgetContainer decorator');
        }
        return $this->_helper;
    }

    /**
     * Get element attributes
     *
     * @return array
     */
    public function getAttribs()
    {
        if (null === $this->_attribs) {
            $attribs = $this->getElement()->getAttribs();
            if (array_key_exists('jQueryParams', $attribs)) {
                $this->getJQueryParams();
                unset($attribs['jQueryParams']);
            }
            $this->_attribs = $attribs;
        }
        return $this->_attribs;
    }

    /**
     * Get jQuery option parameters
     *
     * @return array
     */
    public function getJQueryParams()
    {
        if (null === $this->_jQueryParams) {
            $attribs = $this->getElement()->getAttribs();
            $this->_jQueryParams = array();
            if (array_key_exists('jQueryParams', $attribs)) {
                $this->_jQueryParams = $attribs['jQueryParams'];
            }

            $options = $this->getOptions();
            if (array_key_exists('jQueryParams', $options)) {
                $this->_jQueryParams = array_merge($this->_jQueryParams, $options['jQueryParams']);
                $this->removeOption('jQueryParams');
            }
        }

        // Ensure we have a title param
        if (!array_key_exists('title', $this->_jQueryParams)) {
            require_once "Zend/Form/Decorator/Exception.php";
            throw new Zend_Form_Decorator_Exception("UiWidgetPane Decorators have to have a jQueryParam 'title' to render. This title can been set via setJQueryParam('title') on the parent element.");
        }

        return $this->_jQueryParams;
    }

    /**
     * Render an jQuery UI Widget Pane using its associated view helper
     *
     * @throws Zend_Form_Decorator_Exception
     * @param  string $content
     * @return string
     * @throws Zend_Form_Decorator_Exception if element or view are not registered
     */
    public function render($content)
    {
        $element = $this->getElement();
        $view    = $element->getView();
        if (null === $view) {
            return $content;
        }

        $jQueryParams = $this->getJQueryParams();
        $attribs     = array_merge($this->getAttribs(), $this->getOptions());

        if(isset($jQueryParams['title']) && !empty($jQueryParams['title'])) {
            if (null !== ($translator = $element->getTranslator())) {
                $jQueryParams['title'] = $translator->translate($jQueryParams['title']);
            }
        }

        if(isset($jQueryParams['containerId'])) {
            $id = $jQueryParams['containerId']."-container";
        } else {
            require_once "Zend/Form/Decorator/Exception.php";
            throw new Zend_Form_Decorator_Exception("UiWidgetPane Decorators have to have a jQueryParam 'containerId', to point at their parent container. This containerId has been set via setAttrib('id') on the parent element.");
        }

        $helper = $this->getHelper();

        return $view->$helper($id, $content, $jQueryParams, $attribs);
    }
}Form/Decorator/TabPane.php000060400000002374150712002450011412 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: TabPane.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
 */
require_once "UiWidgetPane.php";

/**
 * Form Decorator for jQuery Tab Pane View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Decorator_TabPane extends ZendX_JQuery_Form_Decorator_UiWidgetPane
{
    protected $_helper = "tabPane";
}Form/Decorator/DialogContainer.php000060400000004241150712002450013135 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: DialogContainer.php 20746 2010-01-29 10:36:35Z beberlei $
 */

/**
 * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
 */
require_once "UiWidgetContainer.php";

/**
 * Form Decorator for jQuery Dialog View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Decorator_DialogContainer extends ZendX_JQuery_Form_Decorator_UiWidgetContainer
{
    protected $_helper = "dialogContainer";

    /**
     * Render an jQuery UI Widget element using its associated view helper
     *
     * Determine view helper from 'helper' option, or, if none set, from
     * the element type. Then call as
     * helper($element->getName(), $element->getValue(), $element->getAttribs())
     *
     * @param  string $content
     * @return string
     * @throws Zend_Form_Decorator_Exception if element or view are not registered
     */
    public function render($content)
    {
        $element = $this->getElement();
        $view    = $element->getView();
        if (null === $view) {
            return $content;
        }

        $jQueryParams = $this->getJQueryParams();
        $attribs     = $this->getOptions();

        $helper      = $this->getHelper();
        $id          = $element->getId() . '-container';

        return $view->$helper($id, $content, $jQueryParams, $attribs);
    }
}Form/Decorator/AccordionPane.php000060400000002424150712002450012601 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AccordionPane.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Decorator_UiWidgetContainer
 */
require_once "UiWidgetPane.php";

/**
 * Form Decorator for jQuery Accordion Pane View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Decorator_AccordionPane extends ZendX_JQuery_Form_Decorator_UiWidgetPane
{
    protected $_helper = "accordionPane";
}Form/Exception.php000060400000000237150712002450010110 0ustar00<?php

/**
 * @see ZendX_JQuery_Exception
 */
require_once "ZendX/JQuery/Exception.php";

class ZendX_JQuery_Form_Exception extends ZendX_JQuery_Exception
{

}Form/Element/ColorPicker.php000060400000002357150712002450011764 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: ColorPicker.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Element_UiWidget
 */
require_once "UiWidget.php";

/**
 * Form Element for jQuery ColorPicker View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Form_Element_ColorPicker extends ZendX_JQuery_Form_Element_UiWidget
{
    public $helper = "colorPicker";
}Form/Element/UiWidget.php000060400000012473150712002450011271 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: UiWidget.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

require_once "Zend/Form/Element.php";

/**
 * Base Form Element for jQuery View Helpers
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_Form_Element_UiWidget extends Zend_Form_Element
{
    /**
     * jQuery related parameters of this form element.
     *
     * @var array
     */
    public $jQueryParams = array();

    /**
     * Just here to prevent errors.
     *
     * @var array
     */
    public $options = array();

    /**
     * Constructor
     *
     * @param  mixed $spec
     * @param  mixed $options
     * @return void
     */
    public function __construct($spec, $options = null)
    {
        $this->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator');
        parent::__construct($spec, $options);
    }

    /**
     * Get jQuery related parameter of this form element
     *
     * @param  string $key
     * @return string
     */
    public function getJQueryParam($key)
    {
        $key = (string) $key;
        return $this->jQueryParams[$key];
    }

    /**
     * Get all currently known jQuery related parameters of this element
     *
     * @return array
     */
    public function getJQueryParams()
    {
        return $this->jQueryParams;
    }

    /**
     * Set a jQuery related parameter of this form element.
     *
     * @param  string $key
     * @param  string $value
     * @return ZendX_JQuery_Form_Element_UiWidget
     */
    public function setJQueryParam($key, $value)
    {
        $key = (string) $key;
        $this->jQueryParams[$key] = $value;
        return $this;
    }

    /**
     * Set an array of jQuery related options for this element (merging with old options).
     *
     * @param  Array $params
     * @return ZendX_JQuery_Form_Element_UiWidget
     */
    public function setJQueryParams($params)
    {
        $this->jQueryParams = array_merge($this->jQueryParams, $params);
        return $this;
    }

    /**
     * Load default decorators
     *
     * @return void
     */
    public function loadDefaultDecorators()
    {
        if ($this->loadDefaultDecoratorsIsDisabled()) {
            return;
        }

        $decorators = $this->getDecorators();
        if (empty($decorators)) {
            $this->addDecorator('UiWidgetElement')
                 ->addDecorator('Errors')
                 ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
                 ->addDecorator('HtmlTag', array('tag' => 'dd'))
                 ->addDecorator('Label', array('tag' => 'dt'));
        }
    }

    /**
     * Set the view object
     *
     * Ensures that the view object has the jQuery view helper path set.
     *
     * @param  Zend_View_Interface $view
     * @return ZendX_JQuery_Form_Element_UiWidget
     */
    public function setView(Zend_View_Interface $view = null)
    {
        if (null !== $view) {
            if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
                $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
            }
        }
        return parent::setView($view);
    }

    /**
     * Retrieve all decorators
     *
     * @throws ZendX_JQuery_Form_Exception
     * @return array
     */
    public function getDecorators()
    {
        $decorators = parent::getDecorators();
        if(count($decorators) > 0) {
            // Only check this if there are decorators present, otherwise it could
            // be that the decorators have not been initialized yet.
            $foundUiWidgetElementMarker = false;
            foreach($decorators AS $decorator) {
                if($decorator instanceof ZendX_JQuery_Form_Decorator_UiWidgetElementMarker) {
                    $foundUiWidgetElementMarker = true;
                }
            }
            if($foundUiWidgetElementMarker === false) {
                require_once "ZendX/JQuery/Form/Exception.php";
                throw new ZendX_JQuery_Form_Exception(
                    "Cannot render jQuery form element without at least one decorator ".
                    "implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface. ".
                    "Default decorator for this marker interface is the 'ZendX_JQuery_Form_Decorator_UiWidgetElement'. ".
                    "Hint: The ViewHelper decorator does not render jQuery elements correctly."
                );
            }
        }

        return $decorators;
    }
}Form/Element/AutoComplete.php000060400000002363150712002450012146 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AutoComplete.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Element_UiWidget
 */
require_once "UiWidget.php";

/**
 * Form Element for jQuery Autocomplete View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Form_Element_AutoComplete extends ZendX_JQuery_Form_Element_UiWidget
{
    public $helper = "autoComplete";
}Form/Element/Spinner.php000060400000002337150712002450011164 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Spinner.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Element_UiWidget
 */
require_once "UiWidget.php";

/**
 * Form Element for jQuery Spinner View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Form_Element_Spinner extends ZendX_JQuery_Form_Element_UiWidget
{
    public $helper = "spinner";
}Form/Element/DatePicker.php000060400000002353150712002450011557 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: DatePicker.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Element_UiWidget
 */
require_once "UiWidget.php";

/**
 * Form Element for jQuery DatePicker View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Form_Element_DatePicker extends ZendX_JQuery_Form_Element_UiWidget
{
    public $helper = "datePicker";
}Form/Element/Slider.php000060400000002333150712002450010764 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Slider.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see ZendX_JQuery_Form_Element_UiWidget
 */
require_once "UiWidget.php";

/**
 * Form Element for jQuery Slider View Helper
 *
 * @package    ZendX_JQuery
 * @subpackage Form
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
class ZendX_JQuery_Form_Element_Slider extends ZendX_JQuery_Form_Element_UiWidget
{
    public $helper = "slider";
}Controller/Action/Helper/AutoComplete.php000060400000004070150712002450014426 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: AutoComplete.php 20165 2010-01-09 18:57:56Z bkarwin $
 */

require_once "Zend/Controller/Action/Helper/AutoComplete/Abstract.php";

class ZendX_JQuery_Controller_Action_Helper_AutoComplete
extends Zend_Controller_Action_Helper_AutoComplete_Abstract
{
    /**
     * Validate autocompletion data
     *
     * @param  mixed $data
     * @return boolean
     */
    public function validateData($data)
    {
        if (!is_array($data)) {
            return false;
        }

        return true;
    }

    /**
     * Prepare autocompletion data
     *
     * @param  mixed   $data
     * @param  boolean $keepLayouts
     * @return mixed
     */
    public function prepareAutoCompletion($data, $keepLayouts = false)
    {
        if (!$this->validateData($data)) {
            /**
             * @see Zend_Controller_Action_Exception
             */
            require_once 'Zend/Controller/Action/Exception.php';
            throw new Zend_Controller_Action_Exception('Invalid data passed for autocompletion');
        }

        $data = (array) $data;
        $output = "";
        foreach($data AS $k => $v) {
            if(is_numeric($k)) {
                $output .= $v."\n";
            } else {
                $output .= $k."|".$v."\n";
            }
        }

        if (!$keepLayouts) {
            $this->disableLayouts();
        }

        return $output;
    }
}Container.php000060400000046306150715322710007207 0ustar00<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category    ZendX
 * @package     ZendX_JQuery
 * @subpackage  View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license     http://framework.zend.com/license/new-bsd     New BSD License
 * @version     $Id: Container.php 20751 2010-01-29 11:14:09Z beberlei $
 */

/**
 * @see ZendX_JQuery
 */
require_once "ZendX/JQuery.php";

/**
 * jQuery View Helper. Transports all jQuery stack and render information across all views.
 *
 * @uses 	   ZendX_JQuery_View_Helper_JQuery_Container
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class ZendX_JQuery_View_Helper_JQuery_Container
{
    /**
     * Path to local webserver jQuery library
     *
     * @var String
     */
    protected $_jqueryLibraryPath = null;

    /**
     * Additional javascript files that for jQuery Helper components.
     *
     * @var Array
     */
    protected $_javascriptSources = array();

    /**
     * Indicates wheater the jQuery View Helper is enabled.
     *
     * @var Boolean
     */
    protected $_enabled = false;

    /**
     * Indicates if a capture start method for javascript or onLoad has been called.
     *
     * @var Boolean
     */
    protected $_captureLock = false;

    /**
     * Additional javascript statements that need to be executed after jQuery lib.
     *
     * @var Array
     */
    protected $_javascriptStatements = array();

    /**
     * Additional stylesheet files for jQuery related components.
     *
     * @var Array
     */
    protected $_stylesheets = array();

    /**
     * jQuery onLoad statements Stack
     *
     * @var Array
     */
    protected $_onLoadActions = array();

    /**
     * View is rendered in XHTML or not.
     *
     * @var Boolean
     */
    protected $_isXhtml = false;

    /**
     * Default CDN jQuery Library version
     *
     * @var String
     */
    protected $_version = ZendX_JQuery::DEFAULT_JQUERY_VERSION;

    /**
     * Default Render Mode (all parts)
     *
     * @var Integer
     */
    protected $_renderMode = ZendX_JQuery::RENDER_ALL;

    /**
     * jQuery UI Library Enabled
     *
     * @var Boolean
     */
    protected $_uiEnabled = false;

    /**
     * Local jQuery UI Path. Use Google CDN if
     * variable is null
     *
     * @var String
     */
    protected $_uiPath = null;

    /**
     * jQuery UI Google CDN Version
     *
     * @var String
     */
    protected $_uiVersion = ZendX_JQuery::DEFAULT_UI_VERSION;

    /**
     * Load CDN Path from SSL or Non-SSL?
     *
     * @var boolean
     */
    protected $_loadSslCdnPath = false;

    /**
     * View Instance
     *
     * @var Zend_View_Interface
     */
    public $view = null;

    /**
     * Set view object
     *
     * @param  Zend_View_Interface $view
     * @return void
     */
    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }

    /**
     * Enable jQuery
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function enable()
    {
        $this->_enabled = true;
        return $this;
    }

    /**
     * Disable jQuery
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function disable()
    {
        $this->uiDisable();
        $this->_enabled = false;
        return $this;
    }

    /**
     * Is jQuery enabled?
     *
     * @return boolean
     */
    public function isEnabled()
    {
        return $this->_enabled;
    }

    /**
     * Set the version of the jQuery library used.
     *
     * @param string $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setVersion($version)
    {
        $this->_version = $version;
        return $this;
    }

    /**
     * Get the version used with the jQuery library
     *
     * @return string
     */
    public function getVersion()
    {
        return $this->_version;
    }

    /**
     * Use CDN, using version specified. Currently supported
     * by Googles Ajax Library API are: 1.2.3, 1.2.6
     *
     * @deprecated As of version 1.8, use {@link setVersion()} instead.
     * @param  string $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setCdnVersion($version = null)
    {
        return $this->setVersion($version);
    }

    /**
     * Get CDN version
     *
     * @deprecated As of version 1.8, use {@link getVersion()} instead.
     * @return string
     */
    public function getCdnVersion()
    {
        return $this->getVersion();
    }

    /**
     * Set Use SSL on CDN Flag
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setCdnSsl($flag)
    {
        $this->_loadSslCdnPath = $flag;
        return $this;
    }

    /**
     * Are we using the CDN?
     *
     * @return boolean
     */
    public function useCdn()
    {
        return !$this->useLocalPath();
    }

    /**
     * Set path to local jQuery library
     *
     * @param  string $path
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setLocalPath($path)
    {
        $this->_jqueryLibraryPath = (string) $path;
        return $this;
    }

    /**
     * Enable jQuery UI Library Rendering
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function uiEnable()
    {
        $this->enable();
        $this->_uiEnabled = true;
        return $this;
    }

    /**
     * Disable jQuery UI Library Rendering
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function uiDisable()
    {
        $this->_uiEnabled = false;
        return $this;
    }

    /**
     * Check wheater currently the jQuery UI library is enabled.
     *
     * @return boolean
     */
    public function uiIsEnabled()
    {
         return $this->_uiEnabled;
    }

    /**
     * Set jQuery UI version used.
     * 
     * @param  string $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setUiVersion($version)
    {
        $this->_uiVersion = $version;
    	return $this;
    }

    /**
     * Get jQuery UI Version used.
     *
     * @return string
     */
    public function getUiVersion()
    {
        return $this->_uiVersion;
    }

    /**
     * Set jQuery UI CDN Version
     *
     * @deprecated As of 1.8 use {@link setUiVersion()}
     * @param String $version
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setUiCdnVersion($version="1.5.2")
    {
        return $this->setUiVersion($version);
    }

    /**
     * Return jQuery UI CDN Version
     *
     * @deprecated As of 1.8 use {@link getUiVersion()}
     * @return String
     */
    public function getUiCdnVersion()
    {
        return $this->getUiVersion();
    }

    /**
     * Set local path to jQuery UI library
     *
     * @param String $path
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setUiLocalPath($path)
    {
    	$this->_uiPath = (string) $path;
    	return $this;
    }

    /**
     * Return the local jQuery UI Path if set.
     *
     * @return string
     */
    public function getUiPath()
    {
    	return $this->_uiPath;
    }

    /**
     * Proxies to getUiPath() for consistency in function naming.
     *
     * @return string
     */
    public function getUiLocalPath()
    {
        return $this->getUiPath();
    }

    /**
     * Is the jQuery Ui loaded from local scope?
     *
     * @return boolean
     */
    public function useUiLocal()
    {
    	return (null===$this->_uiPath ? false : true);
    }

    /**
     * Is the jQuery Ui enabled and loaded from CDN?
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function useUiCdn()
    {
    	return !$this->useUiLocal();
    }

    /**
     * Get local path to jQuery
     *
     * @return string
     */
    public function getLocalPath()
    {
        return $this->_jqueryLibraryPath;
    }

    /**
     * Are we using a local path?
     *
     * @return boolean
     */
    public function useLocalPath()
    {
        return (null === $this->_jqueryLibraryPath) ? false : true;
    }

    /**
     * Start capturing routines to run onLoad
     *
     * @return boolean
     */
    public function onLoadCaptureStart()
    {
        if ($this->_captureLock) {
            require_once 'Zend/Exception.php';
            throw new Zend_Exception('Cannot nest onLoad captures');
        }

        $this->_captureLock = true;
        return ob_start();
    }

    /**
     * Stop capturing routines to run onLoad
     *
     * @return boolean
     */
    public function onLoadCaptureEnd()
    {
        $data               = ob_get_clean();
        $this->_captureLock = false;

        $this->addOnLoad($data);
        return true;
    }

    /**
     * Capture arbitrary javascript to include in jQuery script
     *
     * @return boolean
     */
    public function javascriptCaptureStart()
    {
        if ($this->_captureLock) {
            require_once 'Zend/Exception.php';
            throw new Zend_Exception('Cannot nest captures');
        }

        $this->_captureLock = true;
        return ob_start();
    }

    /**
     * Finish capturing arbitrary javascript to include in jQuery script
     *
     * @return boolean
     */
    public function javascriptCaptureEnd()
    {
        $data               = ob_get_clean();
        $this->_captureLock = false;

        $this->addJavascript($data);
        return true;
    }

    /**
     * Add a Javascript File to the include stack.
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addJavascriptFile($path)
    {
        $path = (string) $path;
        if (!in_array($path, $this->_javascriptSources)) {
            $this->_javascriptSources[] = (string) $path;
        }
        return $this;
    }

    /**
     * Return all currently registered Javascript files.
     *
     * This does not include the jQuery library, which is handled by another retrieval
     * strategy.
     *
     * @return Array
     */
    public function getJavascriptFiles()
    {
        return $this->_javascriptSources;
    }

    /**
     * Clear all currently registered Javascript files.
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function clearJavascriptFiles()
    {
        $this->_javascriptSources = array();
        return $this;
    }

    /**
     * Add arbitrary javascript to execute in jQuery JS container
     *
     * @param  string $js
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addJavascript($js)
    {
        $this->_javascriptStatements[] = $js;
        $this->enable();
        return $this;
    }

    /**
     * Return all registered javascript statements
     *
     * @return array
     */
    public function getJavascript()
    {
        return $this->_javascriptStatements;
    }

    /**
     * Clear arbitrary javascript stack
     *
	 * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function clearJavascript()
    {
        $this->_javascriptStatements = array();
        return $this;
    }

    /**
     * Add a stylesheet
     *
     * @param  string $path
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addStylesheet($path)
    {
        $path = (string) $path;
        if (!in_array($path, $this->_stylesheets)) {
            $this->_stylesheets[] = (string) $path;
        }
        return $this;
    }

    /**
     * Retrieve registered stylesheets
     *
     * @return array
     */
    public function getStylesheets()
    {
        return $this->_stylesheets;
    }

    /**
     * Add a script to execute onLoad
     *
     * @param  string $callback Lambda
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function addOnLoad($callback)
    {
        if (!in_array($callback, $this->_onLoadActions, true)) {
            $this->_onLoadActions[] = $callback;
        }
        $this->enable();
        return $this;
    }

    /**
     * Retrieve all registered onLoad actions
     *
     * @return array
     */
    public function getOnLoadActions()
    {
        return $this->_onLoadActions;
    }

    /**
     * Clear the onLoadActions stack.
     *
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function clearOnLoadActions()
    {
        $this->_onLoadActions = array();
        return $this;
    }

    /**
     * Set which parts of the jQuery enviroment should be rendered.
     *
     * This function allows for a gradual refactoring of the jQuery code
     * rendered by calling __toString(). Use ZendX_JQuery::RENDER_*
     * constants. By default all parts of the enviroment are rendered.
     *
     * @see    ZendX_JQuery::RENDER_ALL
     * @param  integer $mask
     * @return ZendX_JQuery_View_Helper_JQuery_Container
     */
    public function setRenderMode($mask)
    {
        $this->_renderMode = $mask;
        return $this;
    }

    /**
     * Return bitmask of the current Render Mode
     * @return integer
     */
    public function getRenderMode()
    {
        return $this->_renderMode;
    }

    /**
     * String representation of jQuery environment
     *
     * @return string
     */
    public function __toString()
    {
        if (!$this->isEnabled()) {
            return '';
        }

        $this->_isXhtml = $this->view->doctype()->isXhtml();

        $html  = $this->_renderStylesheets() . PHP_EOL
               . $this->_renderScriptTags() . PHP_EOL
               . $this->_renderExtras();
        return $html;
    }

    /**
     * Render jQuery stylesheets
     *
     * @return string
     */
    protected function _renderStylesheets()
    {
    	if( ($this->getRenderMode() & ZendX_JQuery::RENDER_STYLESHEETS) == 0) {
            return '';
    	}

        foreach ($this->getStylesheets() as $stylesheet) {
            $stylesheets[] = $stylesheet;
        }

        if (empty($stylesheets)) {
            return '';
        }

        array_reverse($stylesheets);
        $style = "";
        foreach($stylesheets AS $stylesheet) {
            if ($this->view instanceof Zend_View_Abstract) {
                $closingBracket = ($this->view->doctype()->isXhtml()) ? ' />' : '>';
            } else {
                $closingBracket = ' />';
            }

            $style .= '<link rel="stylesheet" href="'.$stylesheet.'" '.
                      'type="text/css" media="screen"' . $closingBracket . PHP_EOL;
        }

        return $style;
    }

    /**
     * Renders all javascript file related stuff of the jQuery enviroment.
     *
     * @return string
     */
    protected function _renderScriptTags()
    {
        $scriptTags = '';
        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_LIBRARY) > 0) {
            $source = $this->_getJQueryLibraryPath();

            $scriptTags .= '<script type="text/javascript" src="' . $source . '"></script>'.PHP_EOL;

            if($this->uiIsEnabled()) {
                $uiPath = $this->_getJQueryUiLibraryPath();
                $scriptTags .= '<script type="text/javascript" src="'.$uiPath.'"></script>'.PHP_EOL;
            }

            if(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode() == true) {
                $scriptTags .= '<script type="text/javascript">var $j = jQuery.noConflict();</script>'.PHP_EOL;
            }
        }

        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_SOURCES) > 0) {
            foreach($this->getJavascriptFiles() AS $javascriptFile) {
                $scriptTags .= '<script type="text/javascript" src="' . $javascriptFile . '"></script>'.PHP_EOL;
            }
        }

        return $scriptTags;
    }

    /**
     * Renders all javascript code related stuff of the jQuery enviroment.
     *
     * @return string
     */
    protected function _renderExtras()
    {
        $onLoadActions = array();
        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_JQUERY_ON_LOAD) > 0) {
            foreach ($this->getOnLoadActions() as $callback) {
                $onLoadActions[] = $callback;
            }
        }

        $javascript = '';
        if( ($this->getRenderMode() & ZendX_JQuery::RENDER_JAVASCRIPT) > 0) {
            $javascript = implode("\n    ", $this->getJavascript());
        }

        $content = '';

        if (!empty($onLoadActions)) {
            if(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode() == true) {
                $content .= '$j(document).ready(function() {'."\n    ";
            } else {
                $content .= '$(document).ready(function() {'."\n    ";
            }
            $content .= implode("\n    ", $onLoadActions) . "\n";
            $content .= '});'."\n";
        }

        if (!empty($javascript)) {
            $content .= $javascript . "\n";
        }

        if (preg_match('/^\s*$/s', $content)) {
            return '';
        }

        $html = '<script type="text/javascript">' . PHP_EOL
              . (($this->_isXhtml) ? '//<![CDATA[' : '//<!--') . PHP_EOL
              . $content
              . (($this->_isXhtml) ? '//]]>' : '//-->') . PHP_EOL
              . PHP_EOL . '</script>';
        return $html;
    }

    /**
     * @return string
     */
    protected function _getJQueryLibraryBaseCdnUri()
    {
        if($this->_loadSslCdnPath == true) {
            $baseUri = ZendX_JQuery::CDN_BASE_GOOGLE_SSL;
        } else {
            $baseUri = ZendX_JQuery::CDN_BASE_GOOGLE;
        }
        return $baseUri;
    }

    /**
     * @return string
     */
    protected function _getJQueryUiLibraryBaseCdnUri()
    {
        if($this->_loadSslCdnPath == true) {
            $baseUri = ZendX_JQuery::CDN_BASEUI_GOOGLE_SSL;
        } else {
            $baseUri = ZendX_JQuery::CDN_BASEUI_GOOGLE;
        }
        return $baseUri;
    }

	/**
	 * Internal function that constructs the include path of the jQuery library.
	 *
	 * @return string
	 */
    protected function _getJQueryLibraryPath()
    {
        if($this->_jqueryLibraryPath != null) {
            $source = $this->_jqueryLibraryPath;
        } else {
            $baseUri = $this->_getJQueryLibraryBaseCdnUri();
            $source = $baseUri .
                ZendX_JQuery::CDN_SUBFOLDER_JQUERY .
                $this->getCdnVersion() .
            	ZendX_JQuery::CDN_JQUERY_PATH_GOOGLE;
        }

        return $source;
    }

    /**
     * @return string
     */
    protected function _getJQueryUiLibraryPath()
    {
        if($this->useUiCdn()) {
            $baseUri = $this->_getJQueryLibraryBaseCdnUri();
            $uiPath = $baseUri.
                ZendX_JQuery::CDN_SUBFOLDER_JQUERYUI .
                $this->getUiCdnVersion() .
                "/jquery-ui.min.js";
        } else if($this->useUiLocal()) {
            $uiPath = $this->getUiPath();
        }
        return $uiPath;
    }
}