Current File : /home/k/a/r/karenpetzb/www/items/category/JQuery.php.tar
home/karenpetzb/library/ZendX/JQuery.php000060400000011403150711570650014267 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 20165 2010-01-09 18:57:56Z bkarwin $
 */

/**
 * @see Zend_Json
 */
require_once "Zend/Json.php";

/**
 * jQuery Global Class holding constants and static convienience methods.
 *
 * @todo       Offer convenience methods to add a tab or accordion container/pane combination.
 * @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
{
    /**
     * Current default supported jQuery library version with ZendX_JQuery
     * 
     * @const string
     */
    const DEFAULT_JQUERY_VERSION = "1.3.2";

    /**
     * Currently supported jQuery UI library version with ZendX_JQuery
     *
     * @const string
     */
    const DEFAULT_UI_VERSION = "1.7.1";

    /**
     * @see http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery
     * @const string Base path to CDN
     */
    const CDN_BASE_GOOGLE = 'http://ajax.googleapis.com/ajax/libs/';

    /**
     * @see http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery
     * @const string Base path to CDN
     */
    const CDN_BASE_GOOGLE_SSL = 'https://ajax.googleapis.com/ajax/libs/';

    /**
     * @const string
     */
    const CDN_SUBFOLDER_JQUERY = 'jquery/';

    /**
     * @const string
     */
    const CDN_SUBFOLDER_JQUERYUI = 'jqueryui/';

    /**
     * Always uses compressed version, because this is assumed to be the use case
     * in production enviroment. An uncompressed version has to included manually.
     *
     * @see http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery
     * @const string File path after base and version
     */
    const CDN_JQUERY_PATH_GOOGLE = '/jquery.min.js';

    /**
     * Which parts of the the jQuery library should be rendered on echo'ing
     * the jQuery library to the View. The constants act as bit-mask. This
     * way the jQuery autogenerated code can be refactored based on personal needs.
     *
     * @see ZendX_JQuery_Helper_JQuery::setRenderMode
     * @const Integer
     */
    const RENDER_LIBRARY         = 1;
    const RENDER_SOURCES         = 2;
    const RENDER_STYLESHEETS     = 4;
    const RENDER_JAVASCRIPT      = 8;
    const RENDER_JQUERY_ON_LOAD  = 16;
    const RENDER_ALL             = 255;

    /**
     * jQuery-enable a view instance
     *
     * @param  Zend_View_Interface $view
     * @return void
     */
    public static function enableView(Zend_View_Interface $view)
    {
        if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
            $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
        }
    }

    /**
     * jQuery-enable a form instance
     *
     * @param  Zend_Form $form
     * @return void
     */
    public static function enableForm(Zend_Form $form)
    {
        $form->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');

        foreach ($form->getSubForms() as $subForm) {
            self::enableForm($subForm);
        }

        if (null !== ($view = $form->getView())) {
            self::enableView($view);
        }
    }

    /**
     * Encode Json that may include javascript expressions.
     *
     * Take care of using the Zend_Json_Encoder to alleviate problems with the json_encode
     * magic key mechanism as of now.
     *
     * @see Zend_Json::encode
     * @param  mixed $value
     * @return mixed
     */
    public static function encodeJson($value)
    {
        if(!class_exists('Zend_Json')) {
            /**
             * @see Zend_Json
             */
            require_once "Zend/Json.php";
        }
        return Zend_Json::encode($value, false, array('enableJsonExprFinder' => true));
    }
}home/karenpetzb/library/ZendX/JQuery/View/Helper/JQuery.php000060400000010415150715323430017635 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':'$');
    }
}