Current File : /home/k/a/r/karenpetzb/www/items/category/ZendX.tar |
JQuery.php 0000604 00000011403 15071477167 0006506 0 ustar 00 <?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));
}
} Application/Resource/Jquery.php 0000604 00000012724 15071477167 0012607 0 ustar 00 <?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 Zend
* @package Zend_Application
* @subpackage Resource
* @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$
*/
/**
* Cache Manager resource
*
* Example configuration:
* <pre>
* resources.Jquery.noconflictmode = false ; default
* resources.Jquery.version = 1.7.1 ; <null>
* resources.Jquery.localpath = "/foo/bar"
* resources.Jquery.uienable = true;
* resources.Jquery.ui_enable = true;
* resources.Jquery.uiversion = 0.7.7;
* resources.Jquery.ui_version = 0.7.7;
* resources.Jquery.uilocalpath = "/bar/foo";
* resources.Jquery.ui_localpath = "/bar/foo";
* resources.Jquery.cdn_ssl = false
* resources.Jquery.render_mode = 255 ; default
* resources.Jquery.rendermode = 255 ; default
*
* resources.Jquery.javascriptfile = "/some/file.js"
* resources.Jquery.javascriptfiles.0 = "/some/file.js"
* resources.Jquery.stylesheet = "/some/file.css"
* resources.Jquery.stylesheets.0 = "/some/file.css"
* </pre>
*
* Resource for settings JQuery options
*
* @uses Zend_Application_Resource_ResourceAbstract
* @category ZendX
* @package ZendX_Application
* @subpackage Resource
* @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_Application_Resource_Jquery
extends Zend_Application_Resource_ResourceAbstract
{
/**
* @var ZendX_JQuery_View_Helper_JQuery_Container
*/
protected $_jquery;
/**
* @var Zend_View
*/
protected $_view;
/**
* Defined by Zend_Application_Resource_Resource
*
* @return ZendX_JQuery_View_Helper_JQuery_Container
*/
public function init()
{
return $this->getJquery();
}
/**
* Retrieve JQuery View Helper
*
* @return ZendX_JQuery_View_Helper_JQuery_Container
*/
public function getJquery()
{
if (null === $this->_jquery) {
$this->getBootstrap()->bootstrap('view');
$this->_view = $this->getBootstrap()->view;
ZendX_JQuery::enableView($this->_view);
$this->_parseOptions($this->getOptions());
$this->_jquery = $this->_view->jQuery();
}
return $this->_jquery;
}
/**
* Parse options to find those pertinent to jquery helper and invoke them
*
* @param array $options
* @return void
*/
protected function _parseOptions(array $options)
{
$options = array_merge($options, array('cdn_ssl' => false));
foreach ($options as $key => $value) {
switch($key) {
case 'noconflictmode':
if (!(bool)$value) {
ZendX_JQuery_View_Helper_JQuery::disableNoConflictMode();
} else {
ZendX_JQuery_View_Helper_JQuery::enableNoConflictMode();
}
break;
case 'version':
$this->_view->JQuery()->setVersion($value);
break;
case 'localpath':
$this->_view->JQuery()->setLocalPath($value);
break;
case 'uiversion':
case 'ui_version':
$this->_view->JQuery()->setUiVersion($value);
break;
case 'uilocalpath':
case 'ui_localpath':
$this->_view->JQuery()->setUiLocalPath($value);
break;
case 'cdn_ssl':
$this->_view->JQuery()->setCdnSsl($value);
break;
case 'render_mode':
case 'rendermode':
$this->_view->JQuery()->setRenderMode($value);
break;
case 'javascriptfile':
$this->_view->JQuery()->addJavascriptFile($value);
break;
case 'javascriptfiles':
foreach($options['javascriptfiles'] as $file) {
$this->_view->JQuery()->addJavascriptFile($file);
}
break;
case 'stylesheet':
$this->_view->JQuery()->addStylesheet($value);
break;
case 'stylesheets':
foreach ($value as $stylesheet) {
$this->_view->JQuery()->addStylesheet($stylesheet);
}
break;
}
}
if ((isset($key['uienable']) && (bool) $key['uienable'])
|| (isset($key['ui_enable']) && (bool) $key['ui_enable'])
|| (!isset($key['ui_enable']) && !isset($key['uienable'])))
{
$this->_view->JQuery()->uiEnable();
} else {
$this->_view->JQuery()->uiDisable();
}
}
}
Console/Exception.php 0000604 00000002214 15071477167 0010627 0 ustar 00 <?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_Whois
* @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 $
*/
/**
* @see ZendX_Exception
*/
require_once 'ZendX/Exception.php';
/**
* Exception class for ZendX_Console
*
* @category ZendX
* @package ZendX_Console
* @uses Zend_Exception
* @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_Console_Exception extends ZendX_Exception
{
}
Console/Process/Exception.php 0000604 00000002277 15071477167 0012256 0 ustar 00 <?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_Console
* @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 $
*/
/**
* @see ZendX_Console_Exception
*/
require_once 'ZendX/Console/Exception.php';
/**
* Exception class for ZendX_Console_Process
*
* @category ZendX
* @package ZendX_Console
* @uses ZendX_Console_Exception
* @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_Console_Process_Exception extends ZendX_Console_Exception
{
}
Console/Process/Unix.php 0000604 00000046655 15071477167 0011253 0 ustar 00 <?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_Console
* @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: Unix.php 20165 2010-01-09 18:57:56Z bkarwin $
*/
/**
* ZendX_Console_Process_Unix allows you to spawn a class as a separated process
*
* @category ZendX
* @package ZendX_Console
* @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_Console_Process_Unix
{
/**
* Void method
*/
const VOID_METHOD = 'void_method';
/**
* Return method
*/
const RETURN_METHOD = 'void_method';
/**
* Unique thread name
*
* @var string
*/
private $_name;
/**
* PID of the child process
*
* @var integer
*/
private $_pid = null;
/**
* UID of the child process owner
*
* @var integer
*/
private $_puid = null;
/**
* GUID of the child process owner
*
* @var integer
*/
private $_guid = null;
/**
* Whether the process is yet forked or not
*
* @var boolean
*/
private $_isRunning = false;
/**
* Wether we are into child process or not
*
* @var boolean
*/
private $_isChild = false;
/**
* A data structure to hold data for Inter Process Communications
*
* @var array
*/
private $_internalIpcData = array();
/**
* Key to access to Shared Memory Area.
*
* @var integer
*/
private $_internalIpcKey;
/**
* Key to access to Sync Semaphore.
*
* @var integer
*/
private $_internalSemKey;
/**
* Is Shared Memory Area OK? If not, the start() method will block.
* Otherwise we'll have a running child without any communication channel.
*
* @var boolean
*/
private $_ipcIsOkay;
/**
* Filename of the IPC segment file
*
* @var string
*/
private $_ipcSegFile;
/**
* Filename of the semaphor file
*
* @var string
*/
private $_ipcSemFile;
/**
* Constructor method
*
* Allocates a new pseudo-thread object. Optionally, set a PUID, a GUID and
* a UMASK for the child process. This also initialize Shared Memory
* Segments for process communications.
*
* @param integer $puid
* @param integer $guid
* @param integer $umask
* @throws ZendX_Console_Process_Exception When running on windows
* @throws ZendX_Console_Process_Exception When running in web enviroment
* @throws ZendX_Console_Process_Exception When shmop_* functions don't exist
* @throws ZendX_Console_Process_Exception When pcntl_* functions don't exist
* @throws ZendX_Console_Process_Exception When posix_* functions don't exist
*/
public function __construct($puid = null, $guid = null, $umask = null)
{
if (substr(PHP_OS, 0, 3) === 'WIN') {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Cannot run on windows');
} else if (!in_array(substr(PHP_SAPI, 0, 3), array('cli', 'cgi'))) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Can only run on CLI or CGI enviroment');
} else if (!function_exists('shmop_open')) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('shmop_* functions are required');
} else if (!function_exists('pcntl_fork')) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('pcntl_* functions are required');
} else if (!function_exists('posix_kill')) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('posix_* functions are required');
}
$this->_isRunning = false;
$this->_name = md5(uniqid(rand()));
$this->_guid = $guid;
$this->_puid = $puid;
if ($umask !== null) {
umask($umask);
}
// Try to create the shared memory segment. The variable
// $this->_ipcIsOkay contains the return code of this operation and must
// be checked before forking
if ($this->_createIpcSegment() && $this->_createIpcSemaphore()) {
$this->_ipcIsOkay = true;
} else {
$this->_ipcIsOkay = false;
}
}
/**
* Stop the child on destruction
*/
public function __destruct()
{
if ($this->isRunning()) {
$this->stop();
}
}
/**
* Causes this pseudo-thread to begin parallel execution.
*
* This method first checks of all the Shared Memory Segment. If okay, it
* forks the child process, attaches signal handler and returns immediatly.
* The status is set to running, and a PID is assigned. The result is that
* two pseudo-threads are running concurrently: the current thread (which
* returns from the call to the start() method) and the other thread (which
* executes its run() method).
*
* @throws ZendX_Console_Process_Exception When SHM segments can't be created
* @throws ZendX_Console_Process_Exception When process forking fails
* @return void
*/
public function start()
{
if (!$this->_ipcIsOkay) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Unable to create SHM segments for process communications');
}
// @see http://www.php.net/manual/en/function.pcntl-fork.php#41150
@ob_end_flush();
pcntl_signal(SIGCHLD, SIG_IGN);
$pid = @pcntl_fork();
if ($pid === -1) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Forking process failed');
} else if ($pid === 0) {
// This is the child
$this->_isChild = true;
// Sleep a second to avoid problems
sleep(1);
// Install the signal handler
pcntl_signal(SIGUSR1, array($this, '_sigHandler'));
// If requested, change process identity
if ($this->_guid !== null) {
posix_setgid($this->_guid);
}
if ($this->_puid !== null) {
posix_setuid($this->_puid);
}
// Run the child
try {
$this->_run();
} catch (Exception $e) {
// We have to catch any exceptions and clean up the process,
// else we will have a memory leak.
}
// Destroy the child after _run() execution. Required to avoid
// unuseful child processes after execution
exit(0);
} else {
// Else this is the parent
$this->_isChild = false;
$this->_isRunning = true;
$this->_pid = $pid;
}
}
/**
* Causes the current thread to die.
*
* The relative process is killed and disappears immediately from the
* processes list.
*
* @return boolean
*/
public function stop()
{
$success = false;
if ($this->_pid > 0) {
$status = 0;
posix_kill($this->_pid, 9);
pcntl_waitpid($this->_pid, $status, WNOHANG);
$success = pcntl_wifexited($status);
$this->_cleanProcessContext();
}
return $success;
}
/**
* Test if the pseudo-thread is already started.
*
* @return boolean
*/
public function isRunning()
{
return $this->_isRunning;
}
/**
* Set a variable into the shared memory segment, so that it can accessed
* both from the parent and from the child process. Variable names
* beginning with underlines are only permitted to interal functions.
*
* @param string $name
* @param mixed $value
* @throws ZendX_Console_Process_Exception When an invalid variable name is supplied
* @return void
*/
public function setVariable($name, $value)
{
if ($name[0] === '_') {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Only internal functions may use underline (_) as variable prefix');
}
$this->_writeVariable($name, $value);
}
/**
* Get a variable from the shared memory segment. Returns NULL if the
* variable doesn't exist.
*
* @param string $name
* @return mixed
*/
public function getVariable($name)
{
$this->_readFromIpcSegment();
if (isset($this->_internalIpcData[$name])) {
return $this->_internalIpcData[$name];
} else {
return null;
}
}
/**
* Read the time elapsed since the last child setAlive() call.
*
* This method is useful because often we have a pseudo-thread pool and we
* need to know each pseudo-thread status. If the child executes the
* setAlive() method, the parent with getLastAlive() can know that child is
* alive.
*
* @return integer
*/
public function getLastAlive()
{
$pingTime = $this->getVariable('_pingTime');
return ($pingTime === null ? 0 : (time() - $pingTime));
}
/**
* Returns the PID of the current pseudo-thread.
*
* @return integer
*/
public function getPid()
{
return $this->_pid;
}
/**
* Set a pseudo-thread property that can be read from parent process
* in order to know the child activity.
*
* Practical usage requires that child process calls this method at regular
* time intervals; parent will use the getLastAlive() method to know
* the elapsed time since the last pseudo-thread life signals...
*
* @return void
*/
protected function _setAlive()
{
$this->_writeVariable('_pingTime', time());
}
/**
* This is called from within the parent; all the communication stuff
* is done here.
*
* @param string $methodName
* @param array $argList
* @param string $type
* @return mixed
*/
protected function _callCallbackMethod($methodName, array $argList = array(), $type = self::VOID_METHOD)
{
// This is the parent, so we really cannot execute the method. Check
// arguments passed to the method.
if ($type === self::RETURN_METHOD) {
$this->_internalIpcData['_callType'] = self::RETURN_METHOD;
} else {
$this->_internalIpcData['_callType'] = self::VOID_METHOD;
}
// These setting are common to both the calling types
$this->_internalIpcData['_callMethod'] = $methodName;
$this->_internalIpcData['_callInput'] = $argList;
// Write the IPC data to the shared segment
$this->_writeToIpcSegment();
// Now we need to differentiate a bit.
switch ($this->_internalIpcData['_callType']) {
case VOID_METHOD:
// Notify the child so it can process the request
$this->_sendSigUsr1();
break;
case RETURN_METHOD:
// Set the semaphorew
shmop_write($this->_internalSemKey, 1, 0);
// Notify the child so it can process the request
$this->_sendSigUsr1();
// Block until the child process return
$this->_waitForIpcSemaphore();
// Read from the SHM segment. The result is stored into
// $this->_internalIpcData['_callOutput']
$this->_readFromIpcSegment();
// Data are returned. Now we can reset the semaphore
shmop_write($this->_internalSemKey, 0, 1);
// Return the result. Hence no break required here
return $this->_internalIpcData['_callOutput'];
}
}
/**
* This method actually implements the pseudo-thread logic.
*
* @return void
*/
abstract protected function _run();
/**
* Sends signal to the child process
*
* @return void
*/
private function _sendSigUsr1()
{
if ($this->_pid > 0) {
posix_kill($this->_pid, SIGUSR1);
}
}
/**
* Acutally Write a variable to the shared memory segment
*
* @param string $name
* @param mixed $value
* @return void
*/
private function _writeVariable($name, $value)
{
$this->_internalIpcData[$name] = $value;
$this->_writeToIpcSegment();
}
/**
* Destroy thread context and free relative resources.
*
* @return void
*/
private function _cleanProcessContext()
{
shmop_delete($this->_internalIpcKey);
shmop_delete($this->_internalSemKey);
shmop_close($this->_internalIpcKey);
shmop_close($this->_internalSemKey);
@unlink($this->_ipcSegFile);
@unlink($this->_ipcSemFile);
$this->_isRunning = false;
$this->_pid = null;
}
/**
* This is the signal handler that makes the communications between client
* and server possible.
*
* @param integer $signo
* @return void
*/
private function _sigHandler($signo)
{
switch ($signo) {
case SIGTERM:
// Handle shutdown tasks. Hence no break is require
exit;
case SIGUSR1:
// This is the User-defined signal we'll use. Read the SHM segment
$this->_readFromIpcSegment();
if (isset($this->_internalIpcData['_callType'])) {
$method = $this->_internalIpcData['_callMethod'];
$params = $this->_internalIpcData['_callInput'];
switch ($this->_internalIpcData['_callType']) {
case self::VOID_METHOD:
// Simple call the (void) method and return immediatly
// no semaphore is placed into parent, so the processing
// is async
call_user_func(array($this, $method), $params);
break;
case self::RETURN_METHOD:
// Process the request
$this->_internalIpcData['_callOutput'] = call_user_func(array($this, $method), $params);
// Write the result into IPC segment
$this->_writeToIPCsegment();
// Unlock the semaphore but block _writeToIpcSegment()
shmop_write($this->_internalSemKey, 0, 0);
shmop_write($this->_internalSemKey, 1, 1);
break;
}
}
break;
default:
// Ignore all other singals
break;
}
}
/**
* Wait for IPC Semaphore
*
* @return void
*/
private function _waitForIpcSemaphore()
{
while (true) {
$okay = shmop_read($this->_internalSemKey, 0, 1);
if ($okay === 0) {
break;
}
usleep(10);
}
}
/**
* Read data from IPC segment
*
* @throws ZendX_Console_Process_Exception When writing of SHM segment fails
* @return void
*/
private function _readFromIpcSegment()
{
$serializedIpcData = shmop_read($this->_internalIpcKey,
0,
shmop_size($this->_internalIpcKey));
if ($serializedIpcData === false) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Fatal error while reading SHM segment');
}
$data = @unserialize($serializedIpcData);
if ($data !== false) {
$this->_internalIpcData = $data;
}
}
/**
* Write data to IPC segment
*
* @throws ZendX_Console_Process_Exception When writing of SHM segment fails
* @return void
*/
private function _writeToIpcSegment()
{
// Read the transaction bit (2 bit of _internalSemKey segment). If it's
// value is 1, we're into the execution of a PHP_FORK_RETURN_METHOD, so
// we must not write to segment (data corruption)
if (shmop_read($this->_internalSemKey, 1, 1) === 1) {
return;
}
$serializedIpcData = serialize($this->_internalIpcData);
// Set the exchange array (IPC) into the shared segment
$shmBytesWritten = shmop_write($this->_internalIpcKey,
$serializedIpcData,
0);
// Check if lenght of SHM segment is enougth to contain data
if ($shmBytesWritten !== strlen($serializedIpcData)) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Fatal error while writing to SHM segment');
}
}
/**
* Create an IPC segment
*
* @throws ZendX_Console_Process_Exception When SHM segment can't be created
* @return boolean
*/
private function _createIpcSegment()
{
$this->_ipcSegFile = realpath(sys_get_temp_dir()) . '/' . rand() . $this->_name . '.shm';
touch($this->_ipcSegFile);
$shmKey = ftok($this->_ipcSegFile, 't');
if ($shmKey === -1) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Could not create SHM segment');
}
$this->_internalIpcKey = @shmop_open($shmKey, 'c', 0644, 10240);
if (!$this->_internalIpcKey) {
@unlink($this->_ipcSegFile);
return false;
}
return true;
}
/**
* Create IPC semaphore
*
* @throws ZendX_Console_Process_Exception When semaphore can't be created
* @return boolean
*/
private function _createIpcSemaphore()
{
$this->_ipcSemFile = realpath(sys_get_temp_dir()) . '/' . rand() . $this->_name . '.sem';
touch($this->_ipcSemFile);
$semKey = ftok($this->_ipcSemFile, 't');
if ($semKey === -1) {
require_once 'ZendX/Console/Process/Exception.php';
throw new ZendX_Console_Process_Exception('Could not create semaphore');
}
$this->_internalSemKey = @shmop_open($semKey, 'c', 0644, 10);
if (!$this->_internalSemKey) {
@unlink($this->_ipcSemFile);
return false;
}
return true;
}
}
Db/Adapter/Firebird/Exception.php 0000604 00000002226 15071477167 0012663 0 ustar 00 <?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 Zend
* @package ZendX_Db
* @subpackage Adapter
* @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: $
*/
/**
* @see Zend_Db_Adapter_Exception
*/
require_once 'Zend/Db/Adapter/Exception.php';
/**
* ZendX_Db_Adapter_Firebird_Exception
*
* @category ZendX
* @package ZendX_Db
* @subpackage Adapter
* @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_Db_Adapter_Firebird_Exception extends Zend_Db_Adapter_Exception
{
}
Db/Adapter/Firebird.php 0000604 00000046702 15071477167 0010734 0 ustar 00 <?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_Db
* @subpackage Adapter
* @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: $
*/
/**
* @see Zend_Db_Adapter_Abstract
*/
require_once 'Zend/Db/Adapter/Abstract.php';
/**
* @see Zend_Db_Profiler
*/
require_once 'Zend/Db/Profiler.php';
/**
* @see Zend_Db_Select
*/
require_once 'Zend/Db/Select.php';
/**
* @see Zend_Db_Statement_Firebird
*/
require_once 'ZendX/Db/Statement/Firebird.php';
/**
* @category ZendX
* @package ZendX_Db
* @subpackage Adapter
* @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_Db_Adapter_Firebird extends Zend_Db_Adapter_Abstract
{
/**
* Specifies whether the adapter automatically quotes identifiers.
* If true, most SQL generated by Zend_Db classes applies
* identifier quoting automatically.
* If false, developer must quote identifiers themselves
* by calling quoteIdentifier().
*
* @var bool
*/
protected $_autoQuoteIdentifiers = true;
/**
* The transaction resource.
*
* @var transaction
*/
protected $_transResource = null;
/**
* Return the status of current transaction.
* @return bool
*/
public function getTransaction()
{
return (is_resource($this->_transResource) ? $this->_transResource : null);
}
/**
* Keys are UPPERCASE SQL datatypes or the constants
* Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
*
* Values are:
* 0 = 32-bit integer
* 1 = 64-bit integer
* 2 = float or decimal
*
* @var array Associative array of datatypes to values 0, 1, or 2.
*/
protected $_numericDataTypes = array(
Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
'SMALLINT' => Zend_Db::INT_TYPE,
'INT' => Zend_Db::INT_TYPE,
'INTEGER' => Zend_Db::INT_TYPE,
'BIGINT' => Zend_Db::BIGINT_TYPE,
'INT64' => Zend_Db::BIGINT_TYPE,
'DECIMAL' => Zend_Db::FLOAT_TYPE,
'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
'DOUBLE' => Zend_Db::FLOAT_TYPE,
'NUMERIC' => Zend_Db::FLOAT_TYPE,
'FLOAT' => Zend_Db::FLOAT_TYPE
);
/**
* Quote a raw string.
*
* @param string $value Raw string
* @return string Quoted string
*/
protected function _quote($value)
{
if (is_int($value) || is_float($value)) {
return $value;
}
$value = str_replace("'", "''", $value);
return "'" . $value . "'";
}
/**
* Returns a list of the tables in the database.
*
* @return array
*/
public function listTables()
{
$data = $this->fetchCol('SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE RDB$SYSTEM_FLAG = 0');
foreach($data as &$v)
$v = trim($v);
return $data;
}
/**
* Returns the column descriptions for a table.
*
* The return value is an associative array keyed by the column name,
* as returned by the RDBMS.
*
* The value of each array element is an associative array
* with the following keys:
*
* SCHEMA_NAME => string; name of database or schema
* TABLE_NAME => string;
* COLUMN_NAME => string; column name
* COLUMN_POSITION => number; ordinal position of column in table
* DATA_TYPE => string; SQL datatype name of column
* DEFAULT => string; default expression of column, null if none
* NULLABLE => boolean; true if column can have nulls
* LENGTH => number; length of CHAR/VARCHAR
* SCALE => number; scale of NUMERIC/DECIMAL
* PRECISION => number; precision of NUMERIC/DECIMAL
* UNSIGNED => boolean; unsigned property of an integer type
* PRIMARY => boolean; true if column is part of the primary key
* PRIMARY_POSITION => integer; position of column in primary key
* IDENTITY => integer; true if column is auto-generated with unique values
*
* @param string $tableName
* @param string $schemaName OPTIONAL
* @return array
*/
public function describeTable($tableName, $schemaName = null)
{
$fieldMaps = array(
'TEXT' => 'CHAR',
'VARYING' => 'VARCHAR',
'SHORT' => 'SMALLINT',
'LONG' => 'INTEGER',
'FLOAT' => 'FLOAT',
'INT64' => array(0 => 'BIGINT', 'NUMERIC', 'DECIMAL'),
'DATE' => 'DATE',
'TIME' => 'TIME',
'BLOB' => 'BLOB',
'DOUBLE' => 'DOUBLE PRECISION',
'TIMESTAMP' => 'TIMESTAMP'
);
$sql = 'select
RF.RDB$RELATION_NAME, \'\', RF.RDB$FIELD_NAME, T.RDB$TYPE_NAME,
RF.RDB$DEFAULT_VALUE, RF.RDB$NULL_FLAG, RF.RDB$FIELD_POSITION,
F.RDB$CHARACTER_LENGTH, F.RDB$FIELD_SCALE, F.RDB$FIELD_PRECISION,
IXS.RDB$FIELD_POSITION, IXS.RDB$FIELD_POSITION, F.RDB$FIELD_SUB_TYPE
from RDB$RELATION_FIELDS RF
left join RDB$RELATION_CONSTRAINTS RC
on (RF.RDB$RELATION_NAME = RC.RDB$RELATION_NAME and RC.RDB$CONSTRAINT_TYPE = \'PRIMARY KEY\')
left join RDB$INDEX_SEGMENTS IXS
on (IXS.RDB$FIELD_NAME = RF.RDB$FIELD_NAME and RC.RDB$INDEX_NAME = IXS.RDB$INDEX_NAME)
inner join RDB$FIELDS F on (RF.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME)
inner join RDB$TYPES T on (T.RDB$TYPE = F.RDB$FIELD_TYPE and T.RDB$FIELD_NAME = \'RDB$FIELD_TYPE\')
where ' . $this->quoteInto('(UPPER(RF.RDB$RELATION_NAME) = UPPER(?)) ', $tableName) . '
order by RF.RDB$FIELD_POSITION';
$stmt = $this->query($sql);
/**
* Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$table_name = 0;
$owner = 1;
$column_name = 2;
$data_type = 3;
$data_default = 4;
$nullable = 5;
$column_id = 6;
$data_length = 7;
$data_scale = 8;
$data_precision = 9;
$constraint_type = 10;
$position = 11;
$sub_type = 12;
$desc = array();
foreach ($result as $key => $row) {
list ($primary, $primaryPosition, $identity) = array(false, null, false);
if (strlen($row[$constraint_type])) {
$primary = true;
$primaryPosition = $row[$position];
/**
* Firebird does not support auto-increment keys.
*/
$identity = false;
}
$dataType = trim($row[$data_type]);
$newType = $fieldMaps[$dataType];
if (is_array($newType) && $dataType == 'INT64')
$newType = $newType[$row[$sub_type]];
$row[$data_type] = $newType;
$desc[trim($row[$column_name])] = array(
'SCHEMA_NAME' => '',
'TABLE_NAME' => trim($row[$table_name]),
'COLUMN_NAME' => trim($row[$column_name]),
'COLUMN_POSITION' => $row[$column_id] +1,
'DATA_TYPE' => $row[$data_type],
'DEFAULT' => $row[$data_default],
'NULLABLE' => (bool) ($row[$nullable] != '1'),
'LENGTH' => $row[$data_length],
'SCALE' => ($row[$data_scale] == 0 ? null : $row[$data_scale]),
'PRECISION' => ($row[$data_precision] == 0 ? null : $row[$data_precision]),
'UNSIGNED' => false,
'PRIMARY' => $primary,
'PRIMARY_POSITION' => ($primary ? $primaryPosition+1 : null),
'IDENTITY' => $identity
);
}
return $desc;
}
/**
* Format a connection string to connect to database
*
* @return void
*/
protected function _formatDbConnString($host, $port, $dbname)
{
if (is_numeric($port))
$port = '/' . (integer) $port;
if ($dbname)
$dbname = ':' . $dbname;
return $host . $port . $dbname;
}
/**
* Creates a connection to the database.
*
* @return void
* @throws ZendX_Db_Adapter_Firebird_Exception
*/
protected function _connect()
{
if (isset($this->_connection) && is_resource($this->_connection)) {
return;
}
if (!extension_loaded('interbase')) {
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception('The Interbase extension is required for this adapter but the extension is not loaded');
}
// Suppress connection warnings here.
// Throw an exception instead.
$this->_connection = @ibase_connect(
$this->_formatDbConnString($this->_config['host'],$this->_config['port'] ,$this->_config['dbname']),
$this->_config['username'],
$this->_config['password'],
$this->_config['charset'],
$this->_config['buffers'],
$this->_config['dialect'],
$this->_config['role']
);
if ($this->_connection === false) {
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception(ibase_errmsg());
}
}
/**
* Force the connection to close.
*
* @return void
*/
public function closeConnection()
{
if (is_resource($this->_transResource)) {
ibase_rollback($this->_transResource);
}
$this->_transResource = null;
if (is_resource($this->_connection)) {
unset($this->_connection);
}
//$this->_connection = false;
}
/**
* Prepare a statement and return a Statement resource.
*
* @param string $sql SQL query
* @return ZendX_Db_Statement_Firebird
*/
public function prepare($sql)
{
$this->_connect();
$stmt = new ZendX_Db_Statement_Firebird($this, $sql);
if ($stmt === false) {
return false;
}
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
}
/**
* Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
*
* As a convention, on RDBMS brands that support sequences
* (e.g. Firebird, Oracle, PostgreSQL, DB2), this method forms the name of a sequence
* from the arguments and returns the last id generated by that sequence.
* On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
* returns the last value generated for such a column, and the table name
* argument is disregarded.
*
* Firebird does not support IDENTITY columns, so if the sequence is not
* specified, this method returns null.
*
* @param string $tableName OPTIONAL Name of table.
* @param string $primaryKey OPTIONAL Name of primary key column.
* @return string
* @throws ZendX_Db_Adapter_Firebird_Exception
*/
public function lastInsertId($tableName = null, $primaryKey = null)
{
if ($tableName !== null) {
$sequenceName = $tableName;
if ($primaryKey) {
$sequenceName .= "_$primaryKey";
}
$sequenceName .= '_seq';
return $this->lastSequenceId($sequenceName);
}
// No support for IDENTITY columns; return null
return null;
}
/**
* Begin a transaction.
*
* @return void
*/
protected function _beginTransaction()
{
$this->_connect();
if (is_resource($this->_transResource)){
return;
}
$this->_transResource = ibase_trans(IBASE_DEFAULT, $this->_connection);
}
/**
* Commit a transaction.
*
* @return void
*/
protected function _commit()
{
if (false === ibase_commit(is_resource($this->_transResource) ? $this->_transResource : $this->_connection)) {
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception(ibase_errmsg());
}
$this->_transResource = null;
}
/**
* Roll-back a transaction.
*
* @return void
*/
protected function _rollBack()
{
if (false === ibase_rollback(is_resource($this->_transResource) ? $this->_transResource : $this->_connection)) {
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception(ibase_errmsg());
}
$this->_transResource = null;
}
/**
* Set the fetch mode.
*
* @param int $mode
* @return void
*/
public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_LAZY:
case Zend_Db::FETCH_ASSOC:
case Zend_Db::FETCH_NUM:
case Zend_Db::FETCH_BOTH:
case Zend_Db::FETCH_NAMED:
case Zend_Db::FETCH_OBJ:
case Zend_Db::FETCH_BOUND: // bound to PHP variable
$this->_fetchMode = $mode;
break;
default:
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception("Invalid fetch mode '$mode' specified");
}
}
/**
* Adds an adapter-specific LIMIT clause to the SELECT statement.
*
* @param string $sql
* @param integer $count
* @param integer $offset
* @throws Zend_Db_Adapter_Exception
* @return string
*/
public function limit($sql, $count, $offset = 0)
{
$count = intval($count);
if ($count <= 0) {
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception("LIMIT argument count=$count is not valid");
}
$offset = intval($offset);
if ($offset < 0) {
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Adapter/Firebird/Exception.php';
throw new ZendX_Db_Adapter_Firebird_Exception("LIMIT argument offset=$offset is not valid");
}
if (trim($sql) == ''){
//Only compatible with FB 2.0 or newer
//ZF 1.5.0 don't support limit sql syntax that don't only append texto to sql, fixed in 1.5.1
$sql .= " rows $count";
if ($offset > 0)
$sql .= " to $offset";
}
else
$sql = substr_replace($sql, "select first $count skip $offset ", stripos($sql, 'select'), 6);
return $sql;
}
/**
* Quote a table identifier and alias.
*
* @param string|array|Zend_Db_Expr $ident The identifier or expression.
* @param string $alias An alias for the table.
* @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
* @return string The quoted identifier and alias.
*/
public function quoteTableAs($ident, $alias = null, $auto=false)
{
// Firebird doesn't allow the 'AS' keyword between the table identifier/expression and alias.
return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
}
/**
* Return the most recent value from the specified sequence in the database.
* This is supported only on RDBMS brands that support sequences
* (e.g. Firebird, Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
*
* @param string $sequenceName
* @return string
*/
public function lastSequenceId($sequenceName)
{
$this->_connect();
$sql = 'SELECT GEN_ID('.$this->quoteIdentifier($sequenceName).', 0) FROM RDB$DATABASE';
$value = $this->fetchOne($sql);
return $value;
}
/**
* Generate a new value from the specified sequence in the database, and return it.
* This is supported only on RDBMS brands that support sequences
* (e.g. Firebird, Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
*
* @param string $sequenceName
* @return integer
*/
public function nextSequenceId($sequenceName)
{
$this->_connect();
$sql = 'SELECT GEN_ID('.$this->quoteIdentifier($sequenceName).', 1) FROM RDB$DATABASE';
$value = $this->fetchOne($sql);
return $value;
}
/**
* Check if the adapter supports real SQL parameters.
*
* @param string $type 'positional' or 'named'
* @return bool
*/
public function supportsParameters($type)
{
switch ($type) {
case 'positional':
return true;
case 'named':
default:
return false;
}
}
/**
* Test if a connection is active
*
* @return boolean
*/
public function isConnected()
{
return ((bool) (is_resource($this->_connection)
&& get_resource_type($this->_connection) == 'Firebird/InterBase link'));
}
/**
* Retrieve server version in PHP style
*
* @return string
*/
public function getServerVersion()
{
$this->_connect();
$service = ibase_service_attach($this->_formatDbConnString($this->_config['host'], $this->_config['port'], ''), $this->_config['username'], $this->_config['password']);
if ($service != FALSE) {
$server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
ibase_service_detach($service);
$matches = null;
if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $server_info, $matches)) {
return $matches[1];
} else {
return null;
}
} else {
return null;
}
}
} Db/Statement/Firebird.php 0000604 00000025413 15071477167 0011314 0 ustar 00 <?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_Db
* @subpackage Statement
* @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: $
*/
/**
* @see Zend_Db_Statement
*/
require_once 'Zend/Db/Statement.php';
/**
* Extends for Firebird
*
* @category ZendX
* @package ZendX_Db
* @subpackage Statement
* @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_Db_Statement_Firebird extends Zend_Db_Statement
{
/**
* The firebird_stmtPrepared resource.
*
* @var firebird_stmtPrepared
*/
protected $_stmtPrepared = null;
/**
* The firebird_stmtResult resource.
*
* @var firebird_result
*/
protected $_stmtResult = null;
/**
* The firebird_stmtResult resource.
*
* @var firebird_result
*/
protected $_stmtRowCount = 0;
/**
* The firebird_stmtResult resource.
*
* @var firebird_result
*/
protected $_stmtColumnCount = 0;
/**
* Column names.
*
* @var array
*/
protected $_keys = array();
/**
* Fetched result values.
*
* @var array
*/
protected $_values = array();
/**
* @var array
*/
protected $_meta = null;
/**
* @param string $sql
* @return void
* @throws ZendX_Db_Statement_Firebird_Exception
*/
public function _prepare($sql)
{
$this->_stmtRowCount = 0;
$this->_stmtColumnCount = 0;
$connection = $this->_adapter->getConnection();
if ($trans = $this->_adapter->getTransaction())
$this->_stmtPrepared = @ibase_prepare($connection, $trans, $sql);
else
$this->_stmtPrepared = @ibase_prepare($connection, $sql);
if ($this->_stmtPrepared === false) {
/**
* @see ZendX_Db_Statement_Firebird_Exception
*/
require_once 'ZendX/Db/Statement/Firebird/Exception.php';
throw new ZendX_Db_Statement_Firebird_Exception("Firebird prepare error: " . ibase_errmsg());
}
}
/**
* Binds a parameter to the specified variable name.
*
* @param mixed $parameter Name the parameter, either integer or string.
* @param mixed $variable Reference to PHP variable containing the value.
* @param mixed $type OPTIONAL Datatype of SQL parameter.
* @param mixed $length OPTIONAL Length of SQL parameter.
* @param mixed $options OPTIONAL Other options.
* @return bool
* @throws ZendX_Db_Statement_Firebird_Exception
*/
protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
return true;
}
/**
* Closes the cursor and the statement.
*
* @return bool
*/
public function close()
{
if ($stmt = $this->_stmtResult) {
@ibase_free_result($this->_stmtResult);
$this->_stmtResult = null;
}
if ($this->_stmtPrepared) {
$r = @ibase_free_query($this->_stmtPrepared);
$this->_stmtPrepared = null;
return $r;
}
return false;
}
/**
* Closes the cursor, allowing the statement to be executed again.
*
* @return bool
*/
public function closeCursor()
{
if ($stmt = $this->_stmtResult) {
return @ibase_free_result($this->_stmtResult);
}
return false;
}
/**
* Returns the number of columns in the result set.
* Returns null if the statement has no result set metadata.
*
* @return int The number of columns.
*/
public function columnCount()
{
return $this->_stmtColumnCount ? $this->_stmtColumnCount : 0;
}
/**
* Retrieves the error code, if any, associated with the last operation on
* the statement handle.
*
* @return string error code.
*/
public function errorCode()
{
if ($this->_stmtPrepared || $this->_stmtResult) {
return ibase_errcode();
}
return false;
}
/**
* Retrieves an array of error information, if any, associated with the
* last operation on the statement handle.
*
* @return array
*/
public function errorInfo()
{
if (!$this->_stmtPrepared) {
return false;
}
return array(
ibase_errcode(),
ibase_errmsg()
);
}
/**
* Executes a prepared statement.
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws ZendX_Db_Statement_Firebird_Exception
*/
public function _execute(array $params = null)
{
if (!$this->_stmtPrepared) {
return false;
}
// if no params were given as an argument to execute(),
// then default to the _bindParam array
if ($params === null) {
$params = $this->_bindParam;
}
// send $params as input parameters to the statement
if ($params) {
array_unshift($params, $this->_stmtPrepared);
$retval = @call_user_func_array(
'ibase_execute',
$params
);
} else
// execute the statement
$retval = @ibase_execute($this->_stmtPrepared);
$this->_stmtResult = $retval;
if ($retval === false) {
$last_error = ibase_errmsg();
$this->_stmtRowCount = 0;
}
//Firebird php ibase extension, auto-commit is not after each call, but at
//end of script. Disabled when transaction is active
if (!$this->_adapter->getTransaction())
ibase_commit_ret();
if ($retval === false) {
/**
* @see ZendX_Db_Statement_Firebird_Exception
*/
require_once 'ZendX/Db/Statement/Firebird/Exception.php';
throw new ZendX_Db_Statement_Firebird_Exception("Firebird statement execute error : " . $last_error);
}
// statements that have no result set do not return metadata
if (is_resource($this->_stmtResult)) {
// get the column names that will result
$this->_keys = array();
$coln = ibase_num_fields($this->_stmtResult);
$this->_stmtColumnCount = $coln;
for ($i = 0; $i < $coln; $i++) {
$col_info = ibase_field_info($this->_stmtResult, $i);
$this->_keys[] = $this->_adapter->foldCase($col_info['name']);
}
// set up a binding space for result variables
$this->_values = array_fill(0, count($this->_keys), null);
// set up references to the result binding space.
// just passing $this->_values in the call_user_func_array()
// below won't work, you need references.
$refs = array();
foreach ($this->_values as $i => &$f) {
$refs[$i] = &$f;
}
}
if ($trans = $this->_adapter->getTransaction())
$this->_stmtRowCount = ibase_affected_rows($trans);
else
$this->_stmtRowCount = ibase_affected_rows($this->_adapter->getConnection());
return true;
}
/**
* Fetches a row from the result set.
*
* @param int $style OPTIONAL Fetch mode for this fetch operation.
* @param int $cursor OPTIONAL Absolute, relative, or other.
* @param int $offset OPTIONAL Number for absolute or relative cursors.
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws Zend_Db_Statement_Exception
*/
public function fetch($style = null, $cursor = null, $offset = null)
{
if (!$this->_stmtResult) {
return false;
}
if ($style === null) {
$style = $this->_fetchMode;
}
switch ($style) {
case Zend_Db::FETCH_NUM:
$row = ibase_fetch_row($this->_stmtResult, IBASE_TEXT);
break;
case Zend_Db::FETCH_ASSOC:
$row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
break;
case Zend_Db::FETCH_BOTH:
$row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
if ($row !== false)
$row = array_merge($row, array_values($row));
break;
case Zend_Db::FETCH_OBJ:
$row = ibase_fetch_object($this->_stmtResult, IBASE_TEXT);
break;
case Zend_Db::FETCH_BOUND:
$row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
if ($row !== false){
$row = array_merge($row, array_values($row));
$row = $this->_fetchBound($row);
}
break;
default:
/**
* @see ZendX_Db_Adapter_Firebird_Exception
*/
require_once 'ZendX/Db/Statement/Firebird/Exception.php';
throw new ZendX_Db_Statement_Firebird_Exception(
"Invalid fetch mode '$style' specified"
);
break;
}
return $row;
}
/**
* Retrieves the next rowset (result set) for a SQL statement that has
* multiple result sets. An example is a stored procedure that returns
* the results of multiple queries.
*
* @return bool
* @throws ZendX_Db_Statement_Firebird_Exception
*/
public function nextRowset()
{
/**
* @see ZendX_Db_Statement_Firebird_Exception
*/
require_once 'ZendX/Db/Statement/Firebird/Exception.php';
throw new ZendX_Db_Statement_Firebird_Exception(__FUNCTION__.'() is not implemented');
}
/**
* Returns the number of rows affected by the execution of the
* last INSERT, DELETE, or UPDATE statement executed by this
* statement object.
*
* @return int The number of rows affected.
* @throws Zend_Db_Statement_Exception
*/
public function rowCount()
{
return $this->_stmtRowCount ? $this->_stmtRowCount : 0;
}
}
Db/Statement/Firebird/Exception.php 0000604 00000002244 15071477167 0013247 0 ustar 00 <?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 Zend
* @package ZendX_Db
* @subpackage Statement
* @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: $
*/
/**
* @see Zend_Db_Statement_Exception
*/
require_once 'Zend/Db/Statement/Exception.php';
/**
* ZendX_Db_Adapter_Firebird_Exception
*
* @category ZendX
* @package ZendX_Db
* @subpackage Statement
* @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_Db_Statement_Firebird_Exception extends Zend_Db_Statement_Exception
{
}
Exception.php 0000604 00000002161 15071477167 0007226 0 ustar 00 <?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_Whois
* @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 $
*/
/**
* @see Zend_Exception
*/
require_once 'Zend/Exception.php';
/**
* Exception class for ZendX
*
* @category ZendX
* @package ZendX
* @uses Zend_Exception
* @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_Exception extends Zend_Exception
{
}
JQuery/View/Exception.php 0000604 00000002133 15071477167 0011356 0 ustar 00 <?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 { } JQuery/View/Helper/ColorPicker.php 0000604 00000004164 15071477167 0013061 0 ustar 00 <?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);
}
} JQuery/View/Helper/Spinner.php 0000604 00000004231 15071477167 0012256 0 ustar 00 <?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);
}
} JQuery/View/Helper/JQuery/Container.php 0000604 00000046306 15071477167 0014012 0 ustar 00 <?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;
}
} JQuery/View/Helper/UiWidget.php 0000604 00000004456 15071477167 0012372 0 ustar 00 <?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;
}
} JQuery/View/Helper/TabPane.php 0000604 00000004353 15071477167 0012157 0 ustar 00 <?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);
}
} JQuery/View/Helper/AccordionContainer.php 0000604 00000012341 15071477167 0014405 0 ustar 00 <?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;
}
} JQuery/View/Helper/DialogContainer.php 0000604 00000004240 15071477167 0013702 0 ustar 00 <?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;
}
} JQuery/View/Helper/DatePicker.php 0000604 00000011156 15071477167 0012657 0 ustar 00 <?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;
}
} JQuery/View/Helper/TabContainer.php 0000604 00000010255 15071477167 0013214 0 ustar 00 <?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;
}
} JQuery/View/Helper/Slider.php 0000604 00000013271 15071477167 0012066 0 ustar 00 <?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;
}
} JQuery/View/Helper/AutoComplete.php 0000604 00000006313 15071477167 0013244 0 ustar 00 <?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);
}
} JQuery/View/Helper/AccordionPane.php 0000604 00000005072 15071477167 0013351 0 ustar 00 <?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);
}
} JQuery/View/Helper/AjaxLink.php 0000604 00000030523 15071477167 0012344 0 ustar 00 <?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;
}
} JQuery/View/Helper/UiWidgetPane.php 0000604 00000006125 15071477167 0013171 0 ustar 00 <?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());
} JQuery/View/Helper/JQuery.php 0000604 00000010415 15071477167 0012060 0 ustar 00 <?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':'$');
}
}
JQuery/Form.php 0000604 00000004403 15071477167 0007413 0 ustar 00 <?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);
}
} JQuery/Exception.php 0000604 00000002106 15071477167 0010444 0 ustar 00 <?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 { } JQuery/Form/Decorator/UiWidgetElementMarker.php 0000604 00000002050 15071477167 0015526 0 ustar 00 <?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 {
} JQuery/Form/Decorator/TabContainer.php 0000604 00000002421 15071477167 0013704 0 ustar 00 <?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";
} JQuery/Form/Decorator/UiWidgetElement.php 0000604 00000011601 15071477167 0014366 0 ustar 00 <?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;
}
}
} JQuery/Form/Decorator/UiWidgetContainer.php 0000604 00000007706 15071477167 0014732 0 ustar 00 <?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);
}
} JQuery/Form/Decorator/AccordionContainer.php 0000604 00000002450 15071477167 0015101 0 ustar 00 <?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";
} JQuery/Form/Decorator/UiWidgetPane.php 0000604 00000011517 15071477167 0013666 0 ustar 00 <?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);
}
} JQuery/Form/Decorator/TabPane.php 0000604 00000002374 15071477167 0012654 0 ustar 00 <?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";
} JQuery/Form/Decorator/DialogContainer.php 0000604 00000004241 15071477167 0014377 0 ustar 00 <?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);
}
} JQuery/Form/Decorator/AccordionPane.php 0000604 00000002424 15071477167 0014043 0 ustar 00 <?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";
} JQuery/Form/Exception.php 0000604 00000000237 15071477167 0011352 0 ustar 00 <?php
/**
* @see ZendX_JQuery_Exception
*/
require_once "ZendX/JQuery/Exception.php";
class ZendX_JQuery_Form_Exception extends ZendX_JQuery_Exception
{
} JQuery/Form/Element/ColorPicker.php 0000604 00000002357 15071477167 0013226 0 ustar 00 <?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";
} JQuery/Form/Element/UiWidget.php 0000604 00000012473 15071477167 0012533 0 ustar 00 <?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;
}
} JQuery/Form/Element/AutoComplete.php 0000604 00000002363 15071477167 0013410 0 ustar 00 <?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";
} JQuery/Form/Element/Spinner.php 0000604 00000002337 15071477167 0012426 0 ustar 00 <?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";
} JQuery/Form/Element/DatePicker.php 0000604 00000002353 15071477167 0013021 0 ustar 00 <?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";
} JQuery/Form/Element/Slider.php 0000604 00000002333 15071477167 0012226 0 ustar 00 <?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";
} JQuery/Controller/Action/Helper/AutoComplete.php 0000604 00000004070 15071477167 0015670 0 ustar 00 <?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;
}
}