Dieser Commit ist enthalten in:
Ursprung
2b21070b1a
Commit
f7a7c71f86
1583 geänderte Dateien mit 454759 neuen und 0 gelöschten Zeilen
171
library/ZendX/JQuery/View/Helper/AccordionContainer.php
Normale Datei
171
library/ZendX/JQuery/View/Helper/AccordionContainer.php
Normale Datei
|
|
@ -0,0 +1,171 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
80
library/ZendX/JQuery/View/Helper/AccordionPane.php
Normale Datei
80
library/ZendX/JQuery/View/Helper/AccordionPane.php
Normale Datei
|
|
@ -0,0 +1,80 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
308
library/ZendX/JQuery/View/Helper/AjaxLink.php
Normale Datei
308
library/ZendX/JQuery/View/Helper/AjaxLink.php
Normale Datei
|
|
@ -0,0 +1,308 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
89
library/ZendX/JQuery/View/Helper/AutoComplete.php
Normale Datei
89
library/ZendX/JQuery/View/Helper/AutoComplete.php
Normale Datei
|
|
@ -0,0 +1,89 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
73
library/ZendX/JQuery/View/Helper/ColorPicker.php
Normale Datei
73
library/ZendX/JQuery/View/Helper/ColorPicker.php
Normale Datei
|
|
@ -0,0 +1,73 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
135
library/ZendX/JQuery/View/Helper/DatePicker.php
Normale Datei
135
library/ZendX/JQuery/View/Helper/DatePicker.php
Normale Datei
|
|
@ -0,0 +1,135 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
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
|
||||
$params = ZendX_JQuery::encodeJson($params);
|
||||
|
||||
$js = sprintf('%s("#%s").datepicker(%s);',
|
||||
ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
|
||||
$attribs['id'],
|
||||
$params
|
||||
);
|
||||
|
||||
$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' => 'yy',
|
||||
'yyyyy' => 'yy', 'yyyy' => 'yy', 'yyy' => 'yy', 'yy' => 'y', 'y' => 'yy',
|
||||
'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;
|
||||
}
|
||||
}
|
||||
74
library/ZendX/JQuery/View/Helper/DialogContainer.php
Normale Datei
74
library/ZendX/JQuery/View/Helper/DialogContainer.php
Normale Datei
|
|
@ -0,0 +1,74 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
167
library/ZendX/JQuery/View/Helper/JQuery.php
Normale Datei
167
library/ZendX/JQuery/View/Helper/JQuery.php
Normale Datei
|
|
@ -0,0 +1,167 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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':'$');
|
||||
}
|
||||
}
|
||||
832
library/ZendX/JQuery/View/Helper/JQuery/Container.php
Normale Datei
832
library/ZendX/JQuery/View/Helper/JQuery/Container.php
Normale Datei
|
|
@ -0,0 +1,832 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
164
library/ZendX/JQuery/View/Helper/Slider.php
Normale Datei
164
library/ZendX/JQuery/View/Helper/Slider.php
Normale Datei
|
|
@ -0,0 +1,164 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
73
library/ZendX/JQuery/View/Helper/Spinner.php
Normale Datei
73
library/ZendX/JQuery/View/Helper/Spinner.php
Normale Datei
|
|
@ -0,0 +1,73 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
132
library/ZendX/JQuery/View/Helper/TabContainer.php
Normale Datei
132
library/ZendX/JQuery/View/Helper/TabContainer.php
Normale Datei
|
|
@ -0,0 +1,132 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
74
library/ZendX/JQuery/View/Helper/TabPane.php
Normale Datei
74
library/ZendX/JQuery/View/Helper/TabPane.php
Normale Datei
|
|
@ -0,0 +1,74 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
84
library/ZendX/JQuery/View/Helper/UiWidget.php
Normale Datei
84
library/ZendX/JQuery/View/Helper/UiWidget.php
Normale Datei
|
|
@ -0,0 +1,84 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
105
library/ZendX/JQuery/View/Helper/UiWidgetPane.php
Normale Datei
105
library/ZendX/JQuery/View/Helper/UiWidgetPane.php
Normale Datei
|
|
@ -0,0 +1,105 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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());
|
||||
}
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren