Current File : /home/k/a/r/karenpetzb/www/items/category/View.tar |
Stream.php 0000604 00000011124 15071177274 0006516 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_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Stream wrapper to convert markup of mostly-PHP templates into PHP prior to
* include().
*
* Based in large part on the example at
* http://www.php.net/manual/en/function.stream-wrapper-register.php
*
* As well as the example provided at:
* http://mikenaberezny.com/2006/02/19/symphony-templates-ruby-erb/
* written by
* Mike Naberezny (@link http://mikenaberezny.com)
* Paul M. Jones (@link http://paul-m-jones.com)
*
* @category Zend
* @package Zend_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Stream
{
/**
* Current stream position.
*
* @var int
*/
protected $_pos = 0;
/**
* Data for streaming.
*
* @var string
*/
protected $_data;
/**
* Stream stats.
*
* @var array
*/
protected $_stat;
/**
* Opens the script file and converts markup.
*/
public function stream_open($path, $mode, $options, &$opened_path)
{
// get the view script source
$path = str_replace('zend.view://', '', $path);
$this->_data = file_get_contents($path);
/**
* If reading the file failed, update our local stat store
* to reflect the real stat of the file, then return on failure
*/
if ($this->_data === false) {
$this->_stat = stat($path);
return false;
}
/**
* Convert <?= ?> to long-form <?php echo ?> and <? ?> to <?php ?>
*
*/
$this->_data = preg_replace('/\<\?\=/', "<?php echo ", $this->_data);
$this->_data = preg_replace('/<\?(?!xml|php)/s', '<?php ', $this->_data);
/**
* file_get_contents() won't update PHP's stat cache, so we grab a stat
* of the file to prevent additional reads should the script be
* requested again, which will make include() happy.
*/
$this->_stat = stat($path);
return true;
}
/**
* Included so that __FILE__ returns the appropriate info
*
* @return array
*/
public function url_stat()
{
return $this->_stat;
}
/**
* Reads from the stream.
*/
public function stream_read($count)
{
$ret = substr($this->_data, $this->_pos, $count);
$this->_pos += strlen($ret);
return $ret;
}
/**
* Tells the current position in the stream.
*/
public function stream_tell()
{
return $this->_pos;
}
/**
* Tells if we are at the end of the stream.
*/
public function stream_eof()
{
return $this->_pos >= strlen($this->_data);
}
/**
* Stream statistics.
*/
public function stream_stat()
{
return $this->_stat;
}
/**
* Seek to a specific point in the stream.
*/
public function stream_seek($offset, $whence)
{
switch ($whence) {
case SEEK_SET:
if ($offset < strlen($this->_data) && $offset >= 0) {
$this->_pos = $offset;
return true;
} else {
return false;
}
break;
case SEEK_CUR:
if ($offset >= 0) {
$this->_pos += $offset;
return true;
} else {
return false;
}
break;
case SEEK_END:
if (strlen($this->_data) + $offset >= 0) {
$this->_pos = strlen($this->_data) + $offset;
return true;
} else {
return false;
}
break;
default:
return false;
}
}
}
Helper/FormPassword.php 0000604 00000005464 15071177274 0011142 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "password" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormPassword extends Zend_View_Helper_FormElement
{
/**
* Generates a 'password' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formPassword($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
if ($disable) {
// disabled
$disabled = ' disabled="disabled"';
}
// determine the XHTML value
$valueString = ' value=""';
if (array_key_exists('renderPassword', $attribs)) {
if ($attribs['renderPassword']) {
$valueString = ' value="' . $this->view->escape($value) . '"';
}
unset($attribs['renderPassword']);
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// render the element
$xhtml = '<input type="password"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $valueString
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
}
Helper/FormSubmit.php 0000604 00000004734 15071177274 0010602 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "submit" button
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormSubmit extends Zend_View_Helper_FormElement
{
/**
* Generates a 'submit' button.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formSubmit($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// check if disabled
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// Render the button.
$xhtml = '<input type="submit"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. ' value="' . $this->view->escape($value) . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
}
Helper/FormImage.php 0000604 00000005775 15071177274 0010367 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate an "image" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormImage extends Zend_View_Helper_FormElement
{
/**
* Generates an 'image' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The source ('src="..."') for the image.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formImage($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// Determine if we should use the value or the src attribute
if (isset($attribs['src'])) {
$src = ' src="' . $this->view->escape($attribs['src']) . '"';
unset($attribs['src']);
} else {
$src = ' src="' . $this->view->escape($value) . '"';
unset($value);
}
// Do we have a value?
if (isset($value) && !empty($value)) {
$value = ' value="' . $this->view->escape($value) . '"';
} else {
$value = '';
}
// Disabled?
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// build the element
$xhtml = '<input type="image"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $src
. $value
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
}
Helper/DeclareVars.php 0000604 00000005703 15071177274 0010703 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: DeclareVars.php 10664 2008-08-05 10:56:06Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for declaring default values of template variables
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_DeclareVars extends Zend_View_Helper_Abstract
{
/**
* The view object that created this helper object.
* @var Zend_View
*/
public $view;
/**
* Declare template vars to set default values and avoid notices when using strictVars
*
* Primarily for use when using {@link Zend_View_Abstract::strictVars() Zend_View strictVars()},
* this helper can be used to declare template variables that may or may
* not already be set in the view object, as well as to set default values.
* Arrays passed as arguments to the method will be used to set default
* values; otherwise, if the variable does not exist, it is set to an empty
* string.
*
* Usage:
* <code>
* $this->declareVars(
* 'varName1',
* 'varName2',
* array('varName3' => 'defaultValue',
* 'varName4' => array()
* )
* );
* </code>
*
* @param string|array variable number of arguments, all string names of variables to test
* @return void
*/
public function declareVars()
{
$args = func_get_args();
foreach($args as $key) {
if (is_array($key)) {
foreach ($key as $name => $value) {
$this->_declareVar($name, $value);
}
} else if (!isset($view->$key)) {
$this->_declareVar($key);
}
}
}
/**
* Set a view variable
*
* Checks to see if a $key is set in the view object; if not, sets it to $value.
*
* @param string $key
* @param string $value Defaults to an empty string
* @return void
*/
protected function _declareVar($key, $value = '')
{
if (!isset($this->view->$key)) {
$this->view->$key = $value;
}
}
}
Helper/PartialLoop.php 0000604 00000006144 15071177274 0010736 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: PartialLoop.php 13032 2008-12-05 02:43:17Z sidhighwind $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Partial */
require_once 'Zend/View/Helper/Partial.php';
/**
* Helper for rendering a template fragment in its own variable scope; iterates
* over data provided and renders for each iteration.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_PartialLoop extends Zend_View_Helper_Partial
{
/**
* Marker to where the pointer is at in the loop
* @var integer
*/
protected $partialCounter = 0;
/**
* Renders a template fragment within a variable scope distinct from the
* calling View object.
*
* If no arguments are provided, returns object instance.
*
* @param string $name Name of view script
* @param string|array $module If $model is empty, and $module is an array,
* these are the variables to populate in the
* view. Otherwise, the module in which the
* partial resides
* @param array $model Variables to populate in the view
* @return string
*/
public function partialLoop($name = null, $module = null, $model = null)
{
if (0 == func_num_args()) {
return $this;
}
if ((null === $model) && (null !== $module)) {
$model = $module;
$module = null;
}
if (!is_array($model)
&& (!$model instanceof Traversable)
&& (is_object($model) && !method_exists($model, 'toArray'))
) {
require_once 'Zend/View/Helper/Partial/Exception.php';
throw new Zend_View_Helper_Partial_Exception('PartialLoop helper requires iterable data');
}
if (is_object($model)
&& (!$model instanceof Traversable)
&& method_exists($model, 'toArray')
) {
$model = $model->toArray();
}
$content = '';
// reset the counter if it's call again
$this->partialCounter = 0;
foreach ($model as $item) {
// increment the counter variable
$this->partialCounter++;
$content .= $this->partial($name, $module, $item);
}
return $content;
}
}
Helper/Partial/Exception.php 0000604 00000002264 15071177274 0012041 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Exception */
require_once 'Zend/View/Exception.php';
/**
* Exception for Zend_View_Helper_Partial class.
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Partial_Exception extends Zend_View_Exception
{
}
Helper/Form.php 0000604 00000005023 15071177274 0007406 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Form.php 10196 2008-07-18 22:01:18Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo Form dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_Form extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.Form';
/**
* Module being used
* @var string
*/
protected $_module = 'dijit.form.Form';
/**
* @var Zend_View_Helper_Form
*/
protected $_helper;
/**
* dijit.form.Form
*
* @param string $id
* @param null|array $attribs HTML attributes
* @param false|string $content
* @return string
*/
public function form($id, $attribs = null, $content = false)
{
if (!is_array($attribs)) {
$attribs = (array) $attribs;
}
if (array_key_exists('id', $attribs)) {
$attribs['name'] = $id;
} else {
$attribs['id'] = $id;
}
if (false === $content) {
$content = '';
}
$attribs = $this->_prepareDijit($attribs, array(), 'layout');
return $this->getFormHelper()->form($id, $attribs, $content);
}
/**
* Get standard form helper
*
* @return Zend_View_Helper_Form
*/
public function getFormHelper()
{
if (null === $this->_helper) {
require_once 'Zend/View/Helper/Form.php';
$this->_helper = new Zend_View_Helper_Form;
$this->_helper->setView($this->view);
}
return $this->_helper;
}
}
Helper/FormLabel.php 0000604 00000004144 15071177274 0010351 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_FormElement **/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Form label helper
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormLabel extends Zend_View_Helper_FormElement
{
/**
* Generates a 'label' element.
*
* @param string $name The form element name for which the label is being generated
* @param string $value The label text
* @param array $attribs Form element attributes (used to determine if disabled)
* @return string The element XHTML.
*/
public function formLabel($name, $value = null, array $attribs = array())
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable, escape
// build the element
if ($disable) {
// disabled; display nothing
$xhtml = '';
} else {
$value = ($escape) ? $this->view->escape($value) : $value;
// enabled; display label
$xhtml = '<label'
. ' for="' . $this->view->escape($id) . '"'
. $this->_htmlAttribs($attribs)
. '>' . $value . '</label>';
}
return $xhtml;
}
}
Helper/Interface.php 0000604 00000002526 15071177274 0010410 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 10664 2008-08-05 10:56:06Z matthew $
*/
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_View_Helper_Interface
{
/**
* Set the View object
*
* @param Zend_View_Interface $view
* @return Zend_View_Helper_Interface
*/
public function setView(Zend_View_Interface $view);
/**
* Strategy pattern: helper method to invoke
*
* @return mixed
*/
public function direct();
}
Helper/Action.php 0000604 00000011263 15071177274 0007723 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Action.php 10664 2008-08-05 10:56:06Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for rendering output of a controller action
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Action extends Zend_View_Helper_Abstract
{
/**
* @var string
*/
public $defaultModule;
/**
* @var Zend_Controller_Dispatcher_Interface
*/
public $dispatcher;
/**
* @var Zend_Controller_Request_Abstract
*/
public $request;
/**
* @var Zend_Controller_Response_Abstract
*/
public $response;
/**
* Constructor
*
* Grab local copies of various MVC objects
*
* @return void
*/
public function __construct()
{
$front = Zend_Controller_Front::getInstance();
$modules = $front->getControllerDirectory();
if (empty($modules)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Action helper depends on valid front controller instance');
}
$request = $front->getRequest();
$response = $front->getResponse();
if (empty($request) || empty($response)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Action view helper requires both a registered request and response object in the front controller instance');
}
$this->request = clone $request;
$this->response = clone $response;
$this->dispatcher = clone $front->getDispatcher();
$this->defaultModule = $front->getDefaultModule();
}
/**
* Reset object states
*
* @return void
*/
public function resetObjects()
{
$params = $this->request->getUserParams();
foreach (array_keys($params) as $key) {
$this->request->setParam($key, null);
}
$this->response->clearBody();
$this->response->clearHeaders()
->clearRawHeaders();
}
/**
* Retrieve rendered contents of a controller action
*
* If the action results in a forward or redirect, returns empty string.
*
* @param string $action
* @param string $controller
* @param string $module Defaults to default module
* @param array $params
* @return string
*/
public function action($action, $controller, $module = null, array $params = array())
{
$this->resetObjects();
if (null === $module) {
$module = $this->defaultModule;
}
// clone the view object to prevent over-writing of view variables
$viewRendererObj = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
Zend_Controller_Action_HelperBroker::addHelper(clone $viewRendererObj);
$this->request->setParams($params)
->setModuleName($module)
->setControllerName($controller)
->setActionName($action)
->setDispatched(true);
$this->dispatcher->dispatch($this->request, $this->response);
// reset the viewRenderer object to it's original state
Zend_Controller_Action_HelperBroker::addHelper($viewRendererObj);
if (!$this->request->isDispatched()
|| $this->response->isRedirect())
{
// forwards and redirects render nothing
return '';
}
$return = $this->response->getBody();
$this->resetObjects();
return $return;
}
/**
* Clone the current View
*
* @return Zend_View_Interface
*/
public function cloneView()
{
$view = clone $this->view;
$view->clearVars();
return $view;
}
}
Helper/FormHidden.php 0000604 00000004027 15071177274 0010525 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "hidden" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormHidden extends Zend_View_Helper_FormElement
{
/**
* Generates a 'hidden' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
* @param mixed $value The element value.
* @param array $attribs Attributes for the element tag.
* @return string The element XHTML.
*/
public function formHidden($name, $value = null, array $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
if (isset($id)) {
if (isset($attribs) && is_array($attribs)) {
$attribs['id'] = $id;
} else {
$attribs = array('id' => $id);
}
}
return $this->_hidden($name, $value, $attribs);
}
}
Helper/HeadScript.php 0000604 00000034651 15071177274 0010542 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 7078 2007-12-11 14:29:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/**
* Helper for setting and retrieving script elements for HTML head section
*
* @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container_Standalone
{
/**#@+
* Script type contants
* @const string
*/
const FILE = 'FILE';
const SCRIPT = 'SCRIPT';
/**#@-*/
/**
* Registry key for placeholder
* @var string
*/
protected $_regKey = 'Zend_View_Helper_HeadScript';
/**
* Are arbitrary attributes allowed?
* @var bool
*/
protected $_arbitraryAttributes = false;
/**#@+
* Capture type and/or attributes (used for hinting during capture)
* @var string
*/
protected $_captureLock;
protected $_captureScriptType = null;
protected $_captureScriptAttrs = null;
protected $_captureType;
/**#@-*/
/**
* Optional allowed attributes for script tag
* @var array
*/
protected $_optionalAttributes = array(
'charset', 'defer', 'language', 'src'
);
/**
* Required attributes for script tag
* @var string
*/
protected $_requiredAttributes = array('type');
/**
* Whether or not to format scripts using CDATA; used only if doctype
* helper is not accessible
* @var bool
*/
public $useCdata = false;
/**
* Constructor
*
* Set separator to PHP_EOL.
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->setSeparator(PHP_EOL);
}
/**
* Return headScript object
*
* Returns headScript helper object; optionally, allows specifying a script
* or script file to include.
*
* @param string $mode Script or file
* @param string $spec Script/url
* @param string $placement Append, prepend, or set
* @param array $attrs Array of script attributes
* @param string $type Script type and/or array of script attributes
* @return Zend_View_Helper_HeadScript
*/
public function headScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
{
if ((null !== $spec) && is_string($spec)) {
$action = ucfirst(strtolower($mode));
$placement = strtolower($placement);
switch ($placement) {
case 'set':
case 'prepend':
case 'append':
$action = $placement . $action;
break;
default:
$action = 'append' . $action;
break;
}
$this->$action($spec, $type, $attrs);
}
return $this;
}
/**
* Start capture action
*
* @param mixed $captureType
* @param string $typeOrAttrs
* @return void
*/
public function captureStart($captureType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $type = 'text/javascript', $attrs = array())
{
if ($this->_captureLock) {
require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headScript captures');
}
$this->_captureLock = true;
$this->_captureType = $captureType;
$this->_captureScriptType = $type;
$this->_captureScriptAttrs = $attrs;
ob_start();
}
/**
* End capture action and store
*
* @return void
*/
public function captureEnd()
{
$content = ob_get_clean();
$type = $this->_captureScriptType;
$attrs = $this->_captureScriptAttrs;
$this->_captureScriptType = null;
$this->_captureScriptAttrs = null;
$this->_captureLock = false;
switch ($this->_captureType) {
case Zend_View_Helper_Placeholder_Container_Abstract::SET:
case Zend_View_Helper_Placeholder_Container_Abstract::PREPEND:
case Zend_View_Helper_Placeholder_Container_Abstract::APPEND:
$action = strtolower($this->_captureType) . 'Script';
break;
default:
$action = 'appendScript';
break;
}
$this->$action($content, $type, $attrs);
}
/**
* Overload method access
*
* Allows the following method calls:
* - appendFile($src, $type = 'text/javascript', $attrs = array())
* - offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())
* - prependFile($src, $type = 'text/javascript', $attrs = array())
* - setFile($src, $type = 'text/javascript', $attrs = array())
* - appendScript($script, $type = 'text/javascript', $attrs = array())
* - offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array())
* - prependScript($script, $type = 'text/javascript', $attrs = array())
* - setScript($script, $type = 'text/javascript', $attrs = array())
*
* @param string $method
* @param array $args
* @return Zend_View_Helper_HeadScript
* @throws Zend_View_Exception if too few arguments or invalid method
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<mode>File|Script)$/', $method, $matches)) {
if (1 > count($args)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Method "%s" requires at least one argument', $method));
}
$action = $matches['action'];
$mode = strtolower($matches['mode']);
$type = 'text/javascript';
$attrs = array();
if ('offsetSet' == $action) {
$index = array_shift($args);
if (1 > count($args)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Method "%s" requires at least two arguments, an index and source', $method));
}
}
$content = $args[0];
if (isset($args[1])) {
$type = (string) $args[1];
}
if (isset($args[2])) {
$attrs = (array) $args[2];
}
switch ($mode) {
case 'script':
$item = $this->createData($type, $attrs, $content);
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->$action($item);
}
break;
case 'file':
default:
if (!$this->_isDuplicate($content)) {
$attrs['src'] = $content;
$item = $this->createData($type, $attrs);
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->$action($item);
}
}
break;
}
return $this;
}
return parent::__call($method, $args);
}
/**
* Is the file specified a duplicate?
*
* @param string $file
* @return bool
*/
protected function _isDuplicate($file)
{
foreach ($this->getContainer() as $item) {
if (($item->source === null)
&& array_key_exists('src', $item->attributes)
&& ($file == $item->attributes['src']))
{
return true;
}
}
return false;
}
/**
* Is the script provided valid?
*
* @param mixed $value
* @param string $method
* @return bool
*/
protected function _isValid($value)
{
if ((!$value instanceof stdClass)
|| !isset($value->type)
|| (!isset($value->source) && !isset($value->attributes)))
{
return false;
}
return true;
}
/**
* Override append
*
* @param string $value
* @return void
*/
public function append($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid argument passed to append(); please use one of the helper methods, appendScript() or appendFile()');
}
return $this->getContainer()->append($value);
}
/**
* Override prepend
*
* @param string $value
* @return void
*/
public function prepend($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid argument passed to prepend(); please use one of the helper methods, prependScript() or prependFile()');
}
return $this->getContainer()->prepend($value);
}
/**
* Override set
*
* @param string $value
* @return void
*/
public function set($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid argument passed to set(); please use one of the helper methods, setScript() or setFile()');
}
return $this->getContainer()->set($value);
}
/**
* Override offsetSet
*
* @param string|int $index
* @param mixed $value
* @return void
*/
public function offsetSet($index, $value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
}
$this->_isValid($value);
return $this->getContainer()->offsetSet($index, $value);
}
/**
* Set flag indicating if arbitrary attributes are allowed
*
* @param bool $flag
* @return Zend_View_Helper_HeadScript
*/
public function setAllowArbitraryAttributes($flag)
{
$this->_arbitraryAttributes = (bool) $flag;
return $this;
}
/**
* Are arbitrary attributes allowed?
*
* @return bool
*/
public function arbitraryAttributesAllowed()
{
return $this->_arbitraryAttributes;
}
/**
* Create script HTML
*
* @param string $type
* @param array $attributes
* @param string $content
* @param string|int $indent
* @return string
*/
public function itemToString($item, $indent, $escapeStart, $escapeEnd)
{
$attrString = '';
if (!empty($item->attributes)) {
foreach ($item->attributes as $key => $value) {
if (!$this->arbitraryAttributesAllowed()
&& !in_array($key, $this->_optionalAttributes))
{
continue;
}
if ('defer' == $key) {
$value = 'defer';
}
$attrString .= sprintf(' %s="%s"', $key, ($this->_autoEscape) ? $this->_escape($value) : $value);
}
}
$type = ($this->_autoEscape) ? $this->_escape($item->type) : $item->type;
$html = $indent . '<script type="' . $type . '"' . $attrString . '>';
if (!empty($item->source)) {
$html .= PHP_EOL . $indent . ' ' . $escapeStart . PHP_EOL . $item->source . $indent . ' ' . $escapeEnd . PHP_EOL . $indent;
}
$html .= '</script>';
if (isset($item->attributes['conditional'])
&& !empty($item->attributes['conditional'])
&& is_string($item->attributes['conditional']))
{
$html = '<!--[if ' . $item->attributes['conditional'] . ']> ' . $html . '<![endif]-->';
}
return $html;
}
/**
* Retrieve string representation
*
* @param string|int $indent
* @return string
*/
public function toString($indent = null)
{
$indent = (null !== $indent)
? $this->getWhitespace($indent)
: $this->getIndent();
if ($this->view) {
$useCdata = $this->view->doctype()->isXhtml() ? true : false;
} else {
$useCdata = $this->useCdata ? true : false;
}
$escapeStart = ($useCdata) ? '//<![CDATA[' : '//<!--';
$escapeEnd = ($useCdata) ? '//]]>' : '//-->';
$items = array();
foreach ($this as $item) {
if (!$this->_isValid($item)) {
continue;
}
$items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd);
}
$return = implode($this->getSeparator(), $items);
return $return;
}
/**
* Create data item containing all necessary components of script
*
* @param string $type
* @param array $attributes
* @param string $content
* @return stdClass
*/
public function createData($type, array $attributes, $content = null)
{
$data = new stdClass();
$data->type = $type;
$data->attributes = $attributes;
$data->source = $content;
return $data;
}
}
Helper/HeadTitle.php 0000604 00000012071 15071177274 0010347 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 7078 2007-12-11 14:29:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/**
* Helper for setting and retrieving title element for HTML head
*
* @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HeadTitle extends Zend_View_Helper_Placeholder_Container_Standalone
{
/**
* Registry key for placeholder
* @var string
*/
protected $_regKey = 'Zend_View_Helper_HeadTitle';
/**
* Whether or not auto-translation is enabled
* @var boolean
*/
protected $_translate = false;
/**
* Translation object
*
* @var Zend_Translate_Adapter
*/
protected $_translator;
/**
* Retrieve placeholder for title element and optionally set state
*
* @param string $title
* @param string $setType
* @param string $separator
* @return Zend_View_Helper_HeadTitle
*/
public function headTitle($title = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
{
if ($title) {
if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
$this->set($title);
} elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
$this->prepend($title);
} else {
$this->append($title);
}
}
return $this;
}
/**
* Sets a translation Adapter for translation
*
* @param Zend_Translate|Zend_Translate_Adapter $translate
* @return Zend_View_Helper_HeadTitle
*/
public function setTranslator($translate)
{
if ($translate instanceof Zend_Translate_Adapter) {
$this->_translator = $translate;
} elseif ($translate instanceof Zend_Translate) {
$this->_translator = $translate->getAdapter();
} else {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
}
return $this;
}
/*
* Retrieve translation object
*
* If none is currently registered, attempts to pull it from the registry
* using the key 'Zend_Translate'.
*
* @return Zend_Translate_Adapter|null
*/
public function getTranslator()
{
if (null === $this->_translator) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Translate')) {
$this->setTranslator(Zend_Registry::get('Zend_Translate'));
}
}
return $this->_translator;
}
/**
* Enables translation
*
* @return Zend_View_Helper_HeadTitle
*/
public function enableTranslation()
{
$this->_translate = true;
return $this;
}
/**
* Disables translation
*
* @return Zend_View_Helper_HeadTitle
*/
public function disableTranslation()
{
$this->_translate = false;
return $this;
}
/**
* Turn helper into string
*
* @param string|null $indent
* @param string|null $locale
* @return string
*/
public function toString($indent = null, $locale = null)
{
$indent = (null !== $indent)
? $this->getWhitespace($indent)
: $this->getIndent();
$items = array();
if($this->_translate && $translator = $this->getTranslator()) {
foreach ($this as $item) {
$items[] = $translator->translate($item, $locale);
}
} else {
foreach ($this as $item) {
$items[] = $item;
}
}
$separator = $this->getSeparator();
$output = '';
if(($prefix = $this->getPrefix())) {
$output .= $prefix;
}
$output .= implode($separator, $items);
if(($postfix = $this->getPostfix())) {
$output .= $postfix;
}
$output = ($this->_autoEscape) ? $this->_escape($output) : $output;
return $indent . '<title>' . $output . '</title>';
}
}
Helper/HtmlFlash.php 0000604 00000003615 15071177274 0010372 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HtmlFlash.php 11525 2008-09-26 18:40:19Z norm2782 $
*/
/**
* @see Zend_View_Helper_HtmlObject
*/
require_once 'Zend/View/Helper/HtmlObject.php';
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HtmlFlash extends Zend_View_Helper_HtmlObject
{
/**
* Default file type for a flash applet
*
*/
const TYPE = 'application/x-shockwave-flash';
/**
* Output a flash movie object tag
*
* @param string $data The flash file
* @param array $attribs Attribs for the object tag
* @param array $params Params for in the object tag
* @param string $content Alternative content
* @return string
*/
public function htmlFlash($data, array $attribs = array(), array $params = array(), $content = null)
{
// Params
$params = array_merge(array('movie' => $data,
'quality' => 'high'), $params);
return $this->htmlObject($data, self::TYPE, $attribs, $params, $content);
}
}
Helper/HtmlQuicktime.php 0000604 00000004536 15071177274 0011273 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HtmlQuicktime.php 10192 2008-07-18 20:14:57Z matthew $
*/
/**
* @see Zend_View_Helper_HtmlObject
*/
require_once 'Zend/View/Helper/HtmlObject.php';
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HtmlQuicktime extends Zend_View_Helper_HtmlObject
{
/**
* Default file type for a movie applet
*
*/
const TYPE = 'video/quicktime';
/**
* Object classid
*
*/
const ATTRIB_CLASSID = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
/**
* Object Codebase
*
*/
const ATTRIB_CODEBASE = 'http://www.apple.com/qtactivex/qtplugin.cab';
/**
* Default attributes
*
* @var array
*/
protected $_attribs = array('classid' => self::ATTRIB_CLASSID,
'codebase' => self::ATTRIB_CODEBASE);
/**
* Output a quicktime movie object tag
*
* @param string $data The quicktime file
* @param array $attribs Attribs for the object tag
* @param array $params Params for in the object tag
* @param string $content Alternative content
* @return string
*/
public function htmlQuicktime($data, array $attribs = array(), array $params = array(), $content = null)
{
// Attrs
$attribs = array_merge($this->_attribs, $attribs);
// Params
$params = array_merge(array('src' => $data), $params);
return $this->htmlObject($data, self::TYPE, $attribs, $params, $content);
}
}
Helper/HtmlObject.php 0000604 00000005072 15071177274 0010542 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HtmlObject.php 10192 2008-07-18 20:14:57Z matthew $
*/
/**
* @see Zend_View_Helper_HtmlElement
*/
require_once 'Zend/View/Helper/HtmlElement.php';
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HtmlObject extends Zend_View_Helper_HtmlElement
{
/**
* Output an object set
*
* @param string $data The data file
* @param string $type Data file type
* @param array $attribs Attribs for the object tag
* @param array $params Params for in the object tag
* @param string $content Alternative content for object
* @return string
*/
public function htmlObject($data, $type, array $attribs = array(), array $params = array(), $content = null)
{
// Merge data and type
$attribs = array_merge(array('data' => $data,
'type' => $type), $attribs);
// Params
$paramHtml = array();
$closingBracket = $this->getClosingBracket();
foreach ($params as $param => $options) {
if (is_string($options)) {
$options = array('value' => $options);
}
$options = array_merge(array('name' => $param), $options);
$paramHtml[] = '<param' . $this->_htmlAttribs($options) . $closingBracket;
}
// Content
if (is_array($content)) {
$content = implode(self::EOL, $content);
}
// Object header
$xhtml = '<object' . $this->_htmlAttribs($attribs) . '>' . self::EOL
. implode(self::EOL, $paramHtml) . self::EOL
. ($content ? $content . self::EOL : '')
. '</object>';
return $xhtml;
}
}
Helper/Translate.php 0000604 00000012544 15071177274 0010446 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Translate.php 12062 2008-10-21 17:28:12Z thomas $
*/
/** Zend_Locale */
require_once 'Zend/Locale.php';
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Translation view helper
*
* @category Zend
* @package Zend_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Translate extends Zend_View_Helper_Abstract
{
/**
* Translation object
*
* @var Zend_Translate_Adapter
*/
protected $_translator;
/**
* Constructor for manually handling
*
* @param Zend_Translate|Zend_Translate_Adapter $translate Instance of Zend_Translate
*/
public function __construct($translate = null)
{
if (empty($translate) === false) {
$this->setTranslator($translate);
}
}
/**
* Translate a message
* You can give multiple params or an array of params.
* If you want to output another locale just set it as last single parameter
* Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale);
* Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale);
*
* @param string $messageid Id of the message to be translated
* @return string Translated message
*/
public function translate($messageid = null)
{
if ($messageid === null) {
return $this;
}
$translate = $this->getTranslator();
if ($translate === null) {
return $messageid;
}
$options = func_get_args();
array_shift($options);
$count = count($options);
$locale = null;
if ($count > 0) {
if (Zend_Locale::isLocale($options[($count - 1)], null, false) !== false) {
$locale = array_pop($options);
}
}
if ((count($options) === 1) and (is_array($options[0]) === true)) {
$options = $options[0];
}
$message = $translate->translate($messageid, $locale);
if ($count === 0) {
return $message;
}
return vsprintf($message, $options);
}
/**
* Sets a translation Adapter for translation
*
* @param Zend_Translate|Zend_Translate_Adapter $translate Instance of Zend_Translate
* @throws Zend_View_Exception When no or a false instance was set
* @return Zend_View_Helper_Translate
*/
public function setTranslator($translate)
{
if ($translate instanceof Zend_Translate_Adapter) {
$this->_translator = $translate;
} else if ($translate instanceof Zend_Translate) {
$this->_translator = $translate->getAdapter();
} else {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
}
return $this;
}
/**
* Retrieve translation object
*
* If none is currently registered, attempts to pull it from the registry
* using the key 'Zend_Translate'.
*
* @return Zend_Translate_Adapter|null
*/
public function getTranslator()
{
if ($this->_translator === null) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Translate') === true) {
$this->setTranslator(Zend_Registry::get('Zend_Translate'));
}
}
return $this->_translator;
}
/**
* Set's an new locale for all further translations
*
* @param string|Zend_Locale $locale New locale to set
* @throws Zend_View_Exception When no Zend_Translate instance was set
* @return Zend_View_Helper_Translate
*/
public function setLocale($locale = null)
{
$translate = $this->getTranslator();
if ($translate === null) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
}
$translate->setLocale($locale);
return $this;
}
/**
* Returns the set locale for translations
*
* @throws Zend_View_Exception When no Zend_Translate instance was set
* @return string|Zend_Locale
*/
public function getLocale()
{
$translate = $this->getTranslator();
if ($translate === null) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
}
return $translate->getLocale();
}
}
Helper/HeadLink.php 0000604 00000031034 15071177274 0010163 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 7078 2007-12-11 14:29:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/**
* Zend_Layout_View_Helper_HeadLink
*
* @see http://www.w3.org/TR/xhtml1/dtds.html
* @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_Standalone
{
/**
* $_validAttributes
*
* @var array
*/
protected $_itemKeys = array('charset', 'href', 'hreflang', 'media', 'rel', 'rev', 'type', 'title', 'extras');
/**
* @var string registry key
*/
protected $_regKey = 'Zend_View_Helper_HeadLink';
/**
* Constructor
*
* Use PHP_EOL as separator
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->setSeparator(PHP_EOL);
}
/**
* headLink() - View Helper Method
*
* Returns current object instance. Optionally, allows passing array of
* values to build link.
*
* @return Zend_View_Helper_HeadLink
*/
public function headLink(array $attributes = null, $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
{
if (null !== $attributes) {
$item = $this->createData($attributes);
switch ($placement) {
case Zend_View_Helper_Placeholder_Container_Abstract::SET:
$this->set($item);
break;
case Zend_View_Helper_Placeholder_Container_Abstract::PREPEND:
$this->prepend($item);
break;
case Zend_View_Helper_Placeholder_Container_Abstract::APPEND:
default:
$this->append($item);
break;
}
}
return $this;
}
/**
* Overload method access
*
* Creates the following virtual methods:
* - appendStylesheet($href, $media, $conditionalStylesheet, $extras)
* - offsetSetStylesheet($index, $href, $media, $conditionalStylesheet, $extras)
* - prependStylesheet($href, $media, $conditionalStylesheet, $extras)
* - setStylesheet($href, $media, $conditionalStylesheet, $extras)
* - appendAlternate($href, $type, $title, $extras)
* - offsetSetAlternate($index, $href, $type, $title, $extras)
* - prependAlternate($href, $type, $title, $extras)
* - setAlternate($href, $type, $title, $extras)
*
* Items that may be added in the future:
* - Navigation? need to find docs on this
* - public function appendStart()
* - public function appendContents()
* - public function appendPrev()
* - public function appendNext()
* - public function appendIndex()
* - public function appendEnd()
* - public function appendGlossary()
* - public function appendAppendix()
* - public function appendHelp()
* - public function appendBookmark()
* - Other?
* - public function appendCopyright()
* - public function appendChapter()
* - public function appendSection()
* - public function appendSubsection()
*
* @param mixed $method
* @param mixed $args
* @return void
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate)$/', $method, $matches)) {
$argc = count($args);
$action = $matches['action'];
$type = $matches['type'];
$index = null;
if ('offsetSet' == $action) {
if (0 < $argc) {
$index = array_shift($args);
--$argc;
}
}
if (1 > $argc) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('%s requires at least one argument', $method));
}
if (is_array($args[0])) {
$item = $this->createData($args[0]);
} else {
$dataMethod = 'createData' . $type;
$item = $this->$dataMethod($args);
}
if ($item) {
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->$action($item);
}
}
return $this;
}
return parent::__call($method, $args);
}
/**
* Check if value is valid
*
* @param mixed $value
* @return boolean
*/
protected function _isValid($value)
{
if (!$value instanceof stdClass) {
return false;
}
$vars = get_object_vars($value);
$keys = array_keys($vars);
$intersection = array_intersect($this->_itemKeys, $keys);
if (empty($intersection)) {
return false;
}
return true;
}
/**
* append()
*
* @param array $value
* @return void
*/
public function append($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('append() expects a data token; please use one of the custom append*() methods');
}
return $this->getContainer()->append($value);
}
/**
* offsetSet()
*
* @param string|int $index
* @param array $value
* @return void
*/
public function offsetSet($index, $value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('offsetSet() expects a data token; please use one of the custom offsetSet*() methods');
}
return $this->getContainer()->offsetSet($index, $value);
}
/**
* prepend()
*
* @param array $value
* @return Zend_Layout_ViewHelper_HeadLink
*/
public function prepend($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('prepend() expects a data token; please use one of the custom prepend*() methods');
}
return $this->getContainer()->prepend($value);
}
/**
* set()
*
* @param array $value
* @return Zend_Layout_ViewHelper_HeadLink
*/
public function set($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('set() expects a data token; please use one of the custom set*() methods');
}
return $this->getContainer()->set($value);
}
/**
* Create HTML link element from data item
*
* @param stdClass $item
* @return string
*/
public function itemToString(stdClass $item)
{
$attributes = (array) $item;
$link = '<link ';
foreach ($this->_itemKeys as $itemKey) {
if (isset($attributes[$itemKey])) {
if(is_array($attributes[$itemKey])) {
foreach($attributes[$itemKey] as $key => $value) {
$link .= sprintf('%s="%s" ', $key, ($this->_autoEscape) ? $this->_escape($value) : $value);
}
} else {
$link .= sprintf('%s="%s" ', $itemKey, ($this->_autoEscape) ? $this->_escape($attributes[$itemKey]) : $attributes[$itemKey]);
}
}
}
if ($this->view instanceof Zend_View_Abstract) {
$link .= ($this->view->doctype()->isXhtml()) ? '/>' : '>';
} else {
$link .= '/>';
}
if (($link == '<link />') || ($link == '<link >')) {
return '';
}
if (isset($attributes['conditionalStylesheet'])
&& !empty($attributes['conditionalStylesheet'])
&& is_string($attributes['conditionalStylesheet']))
{
$link = '<!--[if ' . $attributes['conditionalStylesheet'] . ']> ' . $link . '<![endif]-->';
}
return $link;
}
/**
* Render link elements as string
*
* @param string|int $indent
* @return string
*/
public function toString($indent = null)
{
$indent = (null !== $indent)
? $this->getWhitespace($indent)
: $this->getIndent();
$items = array();
foreach ($this as $item) {
$items[] = $this->itemToString($item);
}
return $indent . implode($this->_escape($this->getSeparator()) . $indent, $items);
}
/**
* Create data item for stack
*
* @param array $attributes
* @return stdClass
*/
public function createData(array $attributes)
{
$data = (object) $attributes;
return $data;
}
/**
* Create item for stylesheet link item
*
* @param array $args
* @return stdClass|false Returns fals if stylesheet is a duplicate
*/
public function createDataStylesheet(array $args)
{
$rel = 'stylesheet';
$type = 'text/css';
$media = 'screen';
$conditionalStylesheet = false;
$href = array_shift($args);
if ($this->_isDuplicateStylesheet($href)) {
return false;
}
if (0 < count($args)) {
$media = array_shift($args);
if(is_array($media)) {
$media = implode(',', $media);
} else {
$media = (string) $media;
}
}
if (0 < count($args)) {
$conditionalStylesheet = array_shift($args);
if(!empty($conditionalStylesheet) && is_string($conditionalStylesheet)) {
$conditionalStylesheet = (string) $conditionalStylesheet;
} else {
$conditionalStylesheet = null;
}
}
if(0 < count($args) && is_array($args[0])) {
$extras = array_shift($args);
$extras = (array) $extras;
}
$attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras');
return $this->createData($attributes);
}
/**
* Is the linked stylesheet a duplicate?
*
* @param string $uri
* @return bool
*/
protected function _isDuplicateStylesheet($uri)
{
foreach ($this->getContainer() as $item) {
if (($item->rel == 'stylesheet') && ($item->href == $uri)) {
return true;
}
}
return false;
}
/**
* Create item for alternate link item
*
* @param array $args
* @return stdClass
*/
public function createDataAlternate(array $args)
{
if (3 > count($args)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Alternate tags require 3 arguments; %s provided', count($args)));
}
$rel = 'alternate';
$href = array_shift($args);
$type = array_shift($args);
$title = array_shift($args);
if(0 < count($args) && is_array($args[0])) {
$extras = array_shift($args);
$extras = (array) $extras;
if(isset($extras['media']) && is_array($extras['media'])) {
$extras['media'] = implode(',', $extras['media']);
}
}
$href = (string) $href;
$type = (string) $type;
$title = (string) $title;
$attributes = compact('rel', 'href', 'type', 'title', 'extras');
return $this->createData($attributes);
}
}
Helper/HeadStyle.php 0000604 00000026735 15071177274 0010402 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 7078 2007-12-11 14:29:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/**
* Helper for setting and retrieving stylesheets
*
* @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_Standalone
{
/**
* Registry key for placeholder
* @var string
*/
protected $_regKey = 'Zend_View_Helper_HeadStyle';
/**
* Allowed optional attributes
* @var array
*/
protected $_optionalAttributes = array('lang', 'title', 'media', 'dir');
/**
* Allowed media types
* @var array
*/
protected $_mediaTypes = array(
'all', 'aural', 'braille', 'handheld', 'print',
'projection', 'screen', 'tty', 'tv'
);
/**
* Capture type and/or attributes (used for hinting during capture)
* @var string
*/
protected $_captureAttrs = null;
/**
* Capture lock
* @var bool
*/
protected $_captureLock;
/**
* Capture type (append, prepend, set)
* @var string
*/
protected $_captureType;
/**
* Constructor
*
* Set separator to PHP_EOL.
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->setSeparator(PHP_EOL);
}
/**
* Return headStyle object
*
* Returns headStyle helper object; optionally, allows specifying
*
* @param string $content Stylesheet contents
* @param string $placement Append, prepend, or set
* @param string|array $attributes Optional attributes to utilize
* @return Zend_View_Helper_HeadStyle
*/
public function headStyle($content = null, $placement = 'APPEND', $attributes = array())
{
if ((null !== $content) && is_string($content)) {
switch (strtoupper($placement)) {
case 'SET':
$action = 'setStyle';
break;
case 'PREPEND':
$action = 'prependStyle';
break;
case 'APPEND':
default:
$action = 'appendStyle';
break;
}
$this->$action($content, $attributes);
}
return $this;
}
/**
* Overload method calls
*
* Allows the following method calls:
* - appendStyle($content, $attributes = array())
* - offsetSetStyle($index, $content, $attributes = array())
* - prependStyle($content, $attributes = array())
* - setStyle($content, $attributes = array())
*
* @param string $method
* @param array $args
* @return void
* @throws Zend_View_Exception When no $content provided or invalid method
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(Style)$/', $method, $matches)) {
$index = null;
$argc = count($args);
$action = $matches['action'];
if ('offsetSet' == $action) {
if (0 < $argc) {
$index = array_shift($args);
--$argc;
}
}
if (1 > $argc) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Method "%s" requires minimally content for the stylesheet', $method));
}
$content = $args[0];
$attrs = array();
if (isset($args[1])) {
$attrs = (array) $args[1];
}
$item = $this->createData($content, $attrs);
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->$action($item);
}
return $this;
}
return parent::__call($method, $args);
}
/**
* Determine if a value is a valid style tag
*
* @param mixed $value
* @param string $method
* @return boolean
*/
protected function _isValid($value)
{
if ((!$value instanceof stdClass)
|| !isset($value->content)
|| !isset($value->attributes))
{
return false;
}
return true;
}
/**
* Override append to enforce style creation
*
* @param mixed $value
* @return void
*/
public function append($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to append; please use appendStyle()');
}
return $this->getContainer()->append($value);
}
/**
* Override offsetSet to enforce style creation
*
* @param string|int $index
* @param mixed $value
* @return void
*/
public function offsetSet($index, $value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()');
}
return $this->getContainer()->offsetSet($index, $value);
}
/**
* Override prepend to enforce style creation
*
* @param mixed $value
* @return void
*/
public function prepend($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to prepend; please use prependStyle()');
}
return $this->getContainer()->prepend($value);
}
/**
* Override set to enforce style creation
*
* @param mixed $value
* @return void
*/
public function set($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to set; please use setStyle()');
}
return $this->getContainer()->set($value);
}
/**
* Start capture action
*
* @param mixed $captureType
* @param string $typeOrAttrs
* @return void
*/
public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $attrs = null)
{
if ($this->_captureLock) {
require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest headStyle captures');
}
$this->_captureLock = true;
$this->_captureAttrs = $attrs;
$this->_captureType = $type;
ob_start();
}
/**
* End capture action and store
*
* @return void
*/
public function captureEnd()
{
$content = ob_get_clean();
$attrs = $this->_captureAttrs;
$this->_captureAttrs = null;
$this->_captureLock = false;
switch ($this->_captureType) {
case Zend_View_Helper_Placeholder_Container_Abstract::SET:
$this->setStyle($content, $attrs);
break;
case Zend_View_Helper_Placeholder_Container_Abstract::PREPEND:
$this->prependStyle($content, $attrs);
break;
case Zend_View_Helper_Placeholder_Container_Abstract::APPEND:
default:
$this->appendStyle($content, $attrs);
break;
}
}
/**
* Convert content and attributes into valid style tag
*
* @param stdClass $item Item to render
* @param string $indent Indentation to use
* @return string
*/
public function itemToString(stdClass $item, $indent)
{
$attrString = '';
if (!empty($item->attributes)) {
foreach ($item->attributes as $key => $value) {
if (!in_array($key, $this->_optionalAttributes)) {
continue;
}
if ('media' == $key) {
if(false === strpos($value, ',')) {
if (!in_array($value, $this->_mediaTypes)) {
continue;
}
} else {
$media_types = explode(',', $value);
$value = '';
foreach($media_types as $type) {
if (!in_array($type, $this->_mediaTypes)) {
continue;
}
$value .= $type .',';
}
$value = substr($value, 0, -1);
}
}
$attrString .= sprintf(' %s="%s"', $key, htmlspecialchars($value));
}
}
$html = '<style type="text/css"' . $attrString . '>' . PHP_EOL
. $indent . '<!--' . PHP_EOL . $indent . $item->content . PHP_EOL . $indent . '-->' . PHP_EOL
. '</style>';
if (isset($item->attributes['conditional'])
&& !empty($item->attributes['conditional'])
&& is_string($item->attributes['conditional']))
{
$html = '<!--[if ' . $item->attributes['conditional'] . ']> ' . $html . '<![endif]-->';
}
return $html;
}
/**
* Create string representation of placeholder
*
* @param string|int $indent
* @return string
*/
public function toString($indent = null)
{
$indent = (null !== $indent)
? $this->getWhitespace($indent)
: $this->getIndent();
$items = array();
foreach ($this as $item) {
if (!$this->_isValid($item)) {
continue;
}
$items[] = $this->itemToString($item, $indent);
}
$return = $indent . implode($this->getSeparator() . $indent, $items);
$return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return);
return $return;
}
/**
* Create data item for use in stack
*
* @param string $content
* @param array $attributes
* @return stdClass
*/
public function createData($content, array $attributes)
{
if (!isset($attributes['media'])) {
$attributes['media'] = 'screen';
} else if(is_array($attributes['media'])) {
$attributes['media'] = implode(',', $attributes['media']);
}
$data = new stdClass();
$data->content = $content;
$data->attributes = $attributes;
return $data;
}
}
Helper/Placeholder.php 0000604 00000004710 15071177274 0010727 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 10664 2008-08-05 10:56:06Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Registry */
require_once 'Zend/View/Helper/Placeholder/Registry.php';
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for passing data between otherwise segregated Views. It's called
* Placeholder to make its typical usage obvious, but can be used just as easily
* for non-Placeholder things. That said, the support for this is only
* guaranteed to effect subsequently rendered templates, and of course Layouts.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Placeholder extends Zend_View_Helper_Abstract
{
/**
* Placeholder items
* @var array
*/
protected $_items = array();
/**
* @var Zend_View_Helper_Placeholder_Registry
*/
protected $_registry;
/**
* Constructor
*
* Retrieve container registry from Zend_Registry, or create new one and register it.
*
* @return void
*/
public function __construct()
{
$this->_registry = Zend_View_Helper_Placeholder_Registry::getRegistry();
}
/**
* Placeholder helper
*
* @param string $name
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function placeholder($name)
{
$name = (string) $name;
return $this->_registry->getContainer($name);
}
/**
* Retrieve the registry
*
* @return Zend_View_Helper_Placeholder_Registry
*/
public function getRegistry()
{
return $this->_registry;
}
}
Helper/FormCheckbox.php 0000604 00000012350 15071177274 0011056 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "checkbox" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormCheckbox extends Zend_View_Helper_FormElement
{
/**
* Default checked/unchecked options
* @var array
*/
protected static $_defaultCheckedOptions = array(
'checked' => '1',
'unChecked' => '0'
);
/**
* Generates a 'checkbox' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
* @param mixed $value The element value.
* @param array $attribs Attributes for the element tag.
* @return string The element XHTML.
*/
public function formCheckbox($name, $value = null, $attribs = null, array $checkedOptions = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, id, value, attribs, options, listsep, disable
$checked = false;
if (isset($attribs['checked']) && $attribs['checked']) {
$checked = true;
unset($attribs['checked']);
} elseif (isset($attribs['checked'])) {
$checked = false;
unset($attribs['checked']);
}
$checkedOptions = self::determineCheckboxInfo($value, $checked, $checkedOptions);
// is the element disabled?
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// build the element
$xhtml = '';
if (!strstr($name, '[]')) {
$xhtml = $this->_hidden($name, $checkedOptions['unCheckedValue']);
}
$xhtml .= '<input type="checkbox"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. ' value="' . $this->view->escape($checkedOptions['checkedValue']) . '"'
. $checkedOptions['checkedString']
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
/**
* Determine checkbox information
*
* @param string $value
* @param bool $checked
* @param array|null $checkedOptions
* @return array
*/
public static function determineCheckboxInfo($value, $checked, array $checkedOptions = null)
{
// Checked/unchecked values
$checkedValue = null;
$unCheckedValue = null;
if (is_array($checkedOptions)) {
if (array_key_exists('checked', $checkedOptions)) {
$checkedValue = (string) $checkedOptions['checked'];
unset($checkedOptions['checked']);
}
if (array_key_exists('unChecked', $checkedOptions)) {
$unCheckedValue = (string) $checkedOptions['unChecked'];
unset($checkedOptions['unChecked']);
}
if (null === $checkedValue) {
$checkedValue = array_shift($checkedOptions);
}
if (null === $unCheckedValue) {
$unCheckedValue = array_shift($checkedOptions);
}
} elseif ($value !== null) {
$unCheckedValue = self::$_defaultCheckedOptions['unChecked'];
} else {
$checkedValue = self::$_defaultCheckedOptions['checked'];
$unCheckedValue = self::$_defaultCheckedOptions['unChecked'];
}
// is the element checked?
$checkedString = '';
if ($checked || ($value === $checkedValue)) {
$checkedString = ' checked="checked"';
$checked = true;
} else {
$checked = false;
}
// Checked value should be value if no checked options provided
if ($checkedValue == null) {
$checkedValue = $value;
}
return array(
'checked' => $checked,
'checkedString' => $checkedString,
'checkedValue' => $checkedValue,
'unCheckedValue' => $unCheckedValue,
);
}
}
Helper/Layout.php 0000604 00000004210 15071177274 0007755 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Layout.php 10664 2008-08-05 10:56:06Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* View helper for retrieving layout object
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Layout extends Zend_View_Helper_Abstract
{
/** @var Zend_Layout */
protected $_layout;
/**
* Get layout object
*
* @return Zend_Layout
*/
public function getLayout()
{
if (null === $this->_layout) {
require_once 'Zend/Layout.php';
$this->_layout = Zend_Layout::getMvcInstance();
if (null === $this->_layout) {
// Implicitly creates layout object
$this->_layout = new Zend_Layout();
}
}
return $this->_layout;
}
/**
* Set layout object
*
* @param Zend_Layout $layout
* @return Zend_Layout_Controller_Action_Helper_Layout
*/
public function setLayout(Zend_Layout $layout)
{
$this->_layout = $layout;
return $this;
}
/**
* Return layout object
*
* Usage: $this->layout()->setLayout('alternate');
*
* @return Zend_Layout
*/
public function layout()
{
return $this->getLayout();
}
}
Helper/FormButton.php 0000604 00000006072 15071177274 0010607 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "button" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormButton extends Zend_View_Helper_FormElement
{
/**
* Generates a 'button' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formButton($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, id, value, attribs, options, listsep, disable
// Get content
$content = '';
if (isset($attribs['content'])) {
$content = $attribs['content'];
unset($attribs['content']);
} else {
$content = $value;
}
// Ensure type is sane
$type = 'button';
if (isset($attribs['type'])) {
$attribs['type'] = strtolower($attribs['type']);
if (in_array($attribs['type'], array('submit', 'reset', 'button'))) {
$type = $attribs['type'];
}
unset($attribs['type']);
}
// build the element
if ($disable) {
$attribs['disabled'] = 'disabled';
}
$content = ($escape) ? $this->view->escape($content) : $content;
$xhtml = '<button'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. ' type="' . $type . '"';
// add a value if one is given
if (!empty($value)) {
$xhtml .= ' value="' . $this->view->escape($value) . '"';
}
// add attributes and close start tag
$xhtml .= $this->_htmlAttribs($attribs) . '>';
// add content and end tag
$xhtml .= $content . '</button>';
return $xhtml;
}
}
Helper/Abstract.php 0000604 00000003205 15071177274 0010246 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 10664 2008-08-05 10:56:06Z matthew $
*/
/**
* @see Zend_View_Helper_Interface
*/
require_once 'Zend/View/Helper/Interface.php';
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_Abstract implements Zend_View_Helper_Interface
{
/**
* View object
*
* @var Zend_View_Interface
*/
public $view = null;
/**
* Set the View object
*
* @param Zend_View_Interface $view
* @return Zend_View_Helper_Abstract
*/
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
return $this;
}
/**
* Strategy pattern: currently unutilized
*
* @return void
*/
public function direct()
{
}
}
Helper/HtmlPage.php 0000604 00000004157 15071177274 0010213 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HtmlPage.php 10192 2008-07-18 20:14:57Z matthew $
*/
/**
* @see Zend_View_Helper_HtmlObject
*/
require_once 'Zend/View/Helper/HtmlObject.php';
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HtmlPage extends Zend_View_Helper_HtmlObject
{
/**
* Default file type for html
*
*/
const TYPE = 'text/html';
/**
* Object classid
*
*/
const ATTRIB_CLASSID = 'clsid:25336920-03F9-11CF-8FD0-00AA00686F13';
/**
* Default attributes
*
* @var array
*/
protected $_attribs = array('classid' => self::ATTRIB_CLASSID);
/**
* Output a html object tag
*
* @param string $data The html url
* @param array $attribs Attribs for the object tag
* @param array $params Params for in the object tag
* @param string $content Alternative content
* @return string
*/
public function htmlPage($data, array $attribs = array(), array $params = array(), $content = null)
{
// Attrs
$attribs = array_merge($this->_attribs, $attribs);
// Params
$params = array_merge(array('data' => $data), $params);
return $this->htmlObject($data, self::TYPE, $attribs, $params, $content);
}
}
Helper/FormElement.php 0000604 00000012652 15071177274 0010726 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* @see Zend_View_Helper_HtmlElement
*/
require_once 'Zend/View/Helper/HtmlElement.php';
/**
* Base helper for form elements. Extend this, don't use it on its own.
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_FormElement extends Zend_View_Helper_HtmlElement
{
/**
* Converts parameter arguments to an element info array.
*
* E.g, formExample($name, $value, $attribs, $options, $listsep) is
* the same thing as formExample(array('name' => ...)).
*
* Note that you cannot pass a 'disable' param; you need to pass
* it as an 'attribs' key.
*
* @access protected
*
* @return array An element info array with keys for name, value,
* attribs, options, listsep, disable, and escape.
*/
protected function _getInfo($name, $value = null, $attribs = null,
$options = null, $listsep = null
) {
// the baseline info. note that $name serves a dual purpose;
// if an array, it's an element info array that will override
// these baseline values. as such, ignore it for the 'name'
// if it's an array.
$info = array(
'name' => is_array($name) ? '' : $name,
'id' => is_array($name) ? '' : $name,
'value' => $value,
'attribs' => $attribs,
'options' => $options,
'listsep' => $listsep,
'disable' => false,
'escape' => true,
);
// override with named args
if (is_array($name)) {
// only set keys that are already in info
foreach ($info as $key => $val) {
if (isset($name[$key])) {
$info[$key] = $name[$key];
}
}
}
// force attribs to an array, per note from Orjan Persson.
settype($info['attribs'], 'array');
// Normalize readonly tag
if (isset($info['attribs']['readonly'])
&& $info['attribs']['readonly'] != 'readonly')
{
$info['attribs']['readonly'] = 'readonly';
}
// Disable attribute
if (isset($info['attribs']['disable'])
&& is_scalar($info['attribs']['disable']))
{
// disable the element
$info['disable'] = (bool)$info['attribs']['disable'];
unset($info['attribs']['disable']);
} elseif (isset($info['attribs']['disable'])
&& is_array($info['attribs']['disable']))
{
$info['disable'] = $info['attribs']['disable'];
unset($info['attribs']['disable']);
}
// Set ID for element
if (isset($info['attribs']['id'])) {
$info['id'] = (string) $info['attribs']['id'];
} elseif (!isset($info['attribs']['id']) && !empty($info['name'])) {
$id = $info['name'];
if (substr($id, -2) == '[]') {
$id = substr($id, 0, strlen($id) - 2);
}
if (strstr($id, ']')) {
$id = trim($id, ']');
$id = str_replace('][', '-', $id);
$id = str_replace('[', '-', $id);
}
$info['id'] = $id;
}
// Determine escaping from attributes
if (isset($info['attribs']['escape'])) {
$info['escape'] = (bool) $info['attribs']['escape'];
}
// Determine listsetp from attributes
if (isset($info['attribs']['listsep'])) {
$info['listsep'] = (string) $info['attribs']['listsep'];
}
// Remove attribs that might overwrite the other keys. We do this LAST
// because we needed the other attribs values earlier.
foreach ($info as $key => $val) {
if (isset($info['attribs'][$key])) {
unset($info['attribs'][$key]);
}
}
// done!
return $info;
}
/**
* Creates a hidden element.
*
* We have this as a common method because other elements often
* need hidden elements for their operation.
*
* @access protected
*
* @param $name The element name.
*
* @param $value The element value.
*
* @param $attribs Attributes for the element.
*
* @return string A hidden element.
*/
protected function _hidden($name, $value = null, $attribs = null)
{
return '<input type="hidden"'
. ' name="' . $this->view->escape($name) . '"'
. ' value="' . $this->view->escape($value) . '"'
. $this->_htmlAttribs($attribs) . $this->getClosingBracket();
}
}
Helper/Placeholder/Container.php 0000604 00000002330 15071177274 0012645 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Container.php 9099 2008-03-30 19:35:47Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Container_Abstract */
require_once 'Zend/View/Helper/Placeholder/Container/Abstract.php';
/**
* Container for placeholder values
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Placeholder_Container extends Zend_View_Helper_Placeholder_Container_Abstract
{
}
Helper/Placeholder/Container/Standalone.php 0000604 00000016700 15071177274 0014743 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Standalone.php 13198 2008-12-13 13:51:40Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Registry */
require_once 'Zend/View/Helper/Placeholder/Registry.php';
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Base class for targetted placeholder helpers
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_View_Helper_Abstract implements IteratorAggregate, Countable, ArrayAccess
{
/**
* @var Zend_View_Helper_Placeholder_Container_Abstract
*/
protected $_container;
/**
* @var Zend_View_Helper_Placeholder_Registry
*/
protected $_registry;
/**
* Registry key under which container registers itself
* @var string
*/
protected $_regKey;
/**
* Flag wheter to automatically escape output, must also be
* enforced in the child class if __toString/toString is overriden
* @var book
*/
protected $_autoEscape = true;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->setRegistry(Zend_View_Helper_Placeholder_Registry::getRegistry());
$this->setContainer($this->getRegistry()->getContainer($this->_regKey));
}
/**
* Retrieve registry
*
* @return Zend_View_Helper_Placeholder_Registry
*/
public function getRegistry()
{
return $this->_registry;
}
/**
* Set registry object
*
* @param Zend_View_Helper_Placeholder_Registry $registry
* @return Zend_View_Helper_Placeholder_Container_Standalone
*/
public function setRegistry(Zend_View_Helper_Placeholder_Registry $registry)
{
$this->_registry = $registry;
return $this;
}
/**
* Set whether or not auto escaping should be used
*
* @param bool $autoEscape whether or not to auto escape output
* @return Zend_View_Helper_Placeholder_Container_Standalone
*/
public function setAutoEscape($autoEscape = true)
{
$this->_autoEscape = ($autoEscape) ? true : false;
return $this;
}
/**
* Return whether autoEscaping is enabled or disabled
*
* return bool
*/
public function getAutoEscape()
{
return $this->_autoEscape;
}
/**
* Escape a string
*
* @param string $string
* @return string
*/
protected function _escape($string)
{
if ($this->view instanceof Zend_View_Interface) {
return $this->view->escape($string);
}
return htmlentities((string) $string, null, 'UTF-8');
}
/**
* Set container on which to operate
*
* @param Zend_View_Helper_Placeholder_Container_Abstract $container
* @return Zend_View_Helper_Placeholder_Container_Standalone
*/
public function setContainer(Zend_View_Helper_Placeholder_Container_Abstract $container)
{
$this->_container = $container;
return $this;
}
/**
* Retrieve placeholder container
*
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function getContainer()
{
return $this->_container;
}
/**
* Overloading: set property value
*
* @param string $key
* @param mixed $value
* @return void
*/
public function __set($key, $value)
{
$container = $this->getContainer();
$container[$key] = $value;
}
/**
* Overloading: retrieve property
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
$container = $this->getContainer();
if (isset($container[$key])) {
return $container[$key];
}
return null;
}
/**
* Overloading: check if property is set
*
* @param string $key
* @return bool
*/
public function __isset($key)
{
$container = $this->getContainer();
return isset($container[$key]);
}
/**
* Overloading: unset property
*
* @param string $key
* @return void
*/
public function __unset($key)
{
$container = $this->getContainer();
if (isset($container[$key])) {
unset($container[$key]);
}
}
/**
* Overload
*
* Proxy to container methods
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
$container = $this->getContainer();
if (method_exists($container, $method)) {
$return = call_user_func_array(array($container, $method), $args);
if ($return === $container) {
// If the container is returned, we really want the current object
return $this;
}
return $return;
}
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Method "' . $method . '" does not exist');
}
/**
* String representation
*
* @return string
*/
public function toString()
{
return $this->getContainer()->toString();
}
/**
* Cast to string representation
*
* @return string
*/
public function __toString()
{
return $this->toString();
}
/**
* Countable
*
* @return int
*/
public function count()
{
$container = $this->getContainer();
return count($container);
}
/**
* ArrayAccess: offsetExists
*
* @param string|int $offset
* @return bool
*/
public function offsetExists($offset)
{
return $this->getContainer()->offsetExists($offset);
}
/**
* ArrayAccess: offsetGet
*
* @param string|int $offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->getContainer()->offsetGet($offset);
}
/**
* ArrayAccess: offsetSet
*
* @param string|int $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value)
{
return $this->getContainer()->offsetSet($offset, $value);
}
/**
* ArrayAccess: offsetUnset
*
* @param string|int $offset
* @return void
*/
public function offsetUnset($offset)
{
return $this->getContainer()->offsetUnset($offset);
}
/**
* IteratorAggregate: get Iterator
*
* @return Iterator
*/
public function getIterator()
{
return $this->getContainer()->getIterator();
}
}
Helper/Placeholder/Container/Abstract.php 0000604 00000022406 15071177274 0014416 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Abstract.php 9099 2008-03-30 19:35:47Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class representing container for placeholder values
*
* @package Zend_View
* @subpackage Helpers
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_Placeholder_Container_Abstract extends ArrayObject
{
/**
* Whether or not to override all contents of placeholder
* @const string
*/
const SET = 'SET';
/**
* Whether or not to append contents to placeholder
* @const string
*/
const APPEND = 'APPEND';
/**
* Whether or not to prepend contents to placeholder
* @const string
*/
const PREPEND = 'PREPEND';
/**
* What text to prefix the placeholder with when rendering
* @var string
*/
protected $_prefix = '';
/**
* What text to append the placeholder with when rendering
* @var string
*/
protected $_postfix = '';
/**
* What string to use between individual items in the placeholder when rendering
* @var string
*/
protected $_separator = '';
/**
* What string to use as the indentation of output, this will typically be spaces. Eg: ' '
* @var string
*/
protected $_indent = '';
/**
* Whether or not we're already capturing for this given container
* @var bool
*/
protected $_captureLock = false;
/**
* What type of capture (overwrite (set), append, prepend) to use
* @var string
*/
protected $_captureType;
/**
* Key to which to capture content
* @var string
*/
protected $_captureKey;
/**
* Constructor - This is needed so that we can attach a class member as the ArrayObject container
*
* @return void
*/
public function __construct()
{
parent::__construct(array(), parent::ARRAY_AS_PROPS);
}
/**
* Set a single value
*
* @param mixed $value
* @return void
*/
public function set($value)
{
$this->exchangeArray(array($value));
}
/**
* Prepend a value to the top of the container
*
* @param mixed $value
* @return void
*/
public function prepend($value)
{
$values = $this->getArrayCopy();
array_unshift($values, $value);
$this->exchangeArray($values);
}
/**
* Retrieve container value
*
* If single element registered, returns that element; otherwise,
* serializes to array.
*
* @return mixed
*/
public function getValue()
{
if (1 == count($this)) {
$keys = $this->getKeys();
$key = array_shift($keys);
return $this[$key];
}
return $this->getArrayCopy();
}
/**
* Set prefix for __toString() serialization
*
* @param string $prefix
* @return Zend_View_Helper_Placeholder_Container
*/
public function setPrefix($prefix)
{
$this->_prefix = (string) $prefix;
return $this;
}
/**
* Retrieve prefix
*
* @return string
*/
public function getPrefix()
{
return $this->_prefix;
}
/**
* Set postfix for __toString() serialization
*
* @param string $postfix
* @return Zend_View_Helper_Placeholder_Container
*/
public function setPostfix($postfix)
{
$this->_postfix = (string) $postfix;
return $this;
}
/**
* Retrieve postfix
*
* @return string
*/
public function getPostfix()
{
return $this->_postfix;
}
/**
* Set separator for __toString() serialization
*
* Used to implode elements in container
*
* @param string $separator
* @return Zend_View_Helper_Placeholder_Container
*/
public function setSeparator($separator)
{
$this->_separator = (string) $separator;
return $this;
}
/**
* Retrieve separator
*
* @return string
*/
public function getSeparator()
{
return $this->_separator;
}
/**
* Set the indentation string for __toString() serialization,
* optionally, if a number is passed, it will be the number of spaces
*
* @param string|int $indent
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function setIndent($indent)
{
$this->_indent = $this->getWhitespace($indent);
return $this;
}
/**
* Retrieve indentation
*
* @return string
*/
public function getIndent()
{
return $this->_indent;
}
/**
* Retrieve whitespace representation of $indent
*
* @param int|string $indent
* @return string
*/
public function getWhitespace($indent)
{
if (is_int($indent)) {
$indent = str_repeat(' ', $indent);
}
return (string) $indent;
}
/**
* Start capturing content to push into placeholder
*
* @param int $type How to capture content into placeholder; append, prepend, or set
* @return void
* @throws Zend_View_Helper_Placeholder_Exception if nested captures detected
*/
public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $key = null)
{
if ($this->_captureLock) {
require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest placeholder captures for the same placeholder');
}
$this->_captureLock = true;
$this->_captureType = $type;
if ((null !== $key) && is_scalar($key)) {
$this->_captureKey = (string) $key;
}
ob_start();
}
/**
* End content capture
*
* @return void
*/
public function captureEnd()
{
$data = ob_get_clean();
$key = null;
$this->_captureLock = false;
if (null !== $this->_captureKey) {
$key = $this->_captureKey;
}
switch ($this->_captureType) {
case self::SET:
if (null !== $key) {
$this[$key] = $data;
} else {
$this->exchangeArray(array($data));
}
break;
case self::PREPEND:
if (null !== $key) {
$array = array($key => $data);
$values = $this->getArrayCopy();
$final = $array + $values;
$this->exchangeArray($final);
} else {
$this->prepend($data);
}
break;
case self::APPEND:
default:
if (null !== $key) {
if (empty($this[$key])) {
$this[$key] = $data;
} else {
$this[$key] .= $data;
}
} else {
$this[$this->nextIndex()] = $data;
}
break;
}
}
/**
* Get keys
*
* @return array
*/
public function getKeys()
{
$array = $this->getArrayCopy();
return array_keys($array);
}
/**
* Next Index
*
* as defined by the PHP manual
* @return int
*/
public function nextIndex()
{
$keys = $this->getKeys();
if (0 == count($keys)) {
return 0;
}
return $nextIndex = max($keys) + 1;
}
/**
* Render the placeholder
*
* @return string
*/
public function toString($indent = null)
{
$indent = ($indent !== null)
? $this->getWhitespace($indent)
: $this->getIndent();
$items = $this->getArrayCopy();
$return = $indent
. $this->getPrefix()
. implode($this->getSeparator(), $items)
. $this->getPostfix();
$return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return);
return $return;
}
/**
* Serialize object to string
*
* @return string
*/
public function __toString()
{
return $this->toString();
}
}
Helper/Placeholder/Container/Exception.php 0000604 00000002320 15071177274 0014602 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Exception */
require_once 'Zend/View/Exception.php';
/**
* Exception for Zend_View_Helper_Placeholder_Container class.
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Placeholder_Container_Exception extends Zend_View_Exception
{
}
Helper/Placeholder/Registry/Exception.php 0000604 00000002316 15071177274 0014475 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Exception */
require_once 'Zend/View/Exception.php';
/**
* Exception for Zend_View_Helper_Placeholder_Registry class.
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Placeholder_Registry_Exception extends Zend_View_Exception
{
}
Helper/Placeholder/Registry.php 0000604 00000011413 15071177274 0012535 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Registry.php 9099 2008-03-30 19:35:47Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Registry */
require_once 'Zend/Registry.php';
/** Zend_View_Helper_Placeholder_Container_Abstract */
require_once 'Zend/View/Helper/Placeholder/Container/Abstract.php';
/** Zend_View_Helper_Placeholder_Container */
require_once 'Zend/View/Helper/Placeholder/Container.php';
/**
* Registry for placeholder containers
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Placeholder_Registry
{
/**
* Zend_Registry key under which placeholder registry exists
* @const string
*/
const REGISTRY_KEY = 'Zend_View_Helper_Placeholder_Registry';
/**
* Default container class
* @var string
*/
protected $_containerClass = 'Zend_View_Helper_Placeholder_Container';
/**
* Placeholder containers
* @var array
*/
protected $_items = array();
/**
* Retrieve or create registry instnace
*
* @return void
*/
public static function getRegistry()
{
if (Zend_Registry::isRegistered(self::REGISTRY_KEY)) {
$registry = Zend_Registry::get(self::REGISTRY_KEY);
} else {
$registry = new self();
Zend_Registry::set(self::REGISTRY_KEY, $registry);
}
return $registry;
}
/**
* createContainer
*
* @param string $key
* @param array $value
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function createContainer($key, array $value = array())
{
$key = (string) $key;
$this->_items[$key] = new $this->_containerClass(array());
return $this->_items[$key];
}
/**
* Retrieve a placeholder container
*
* @param string $key
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function getContainer($key)
{
$key = (string) $key;
if (isset($this->_items[$key])) {
return $this->_items[$key];
}
$container = $this->createContainer($key);
return $container;
}
/**
* Does a particular container exist?
*
* @param string $key
* @return bool
*/
public function containerExists($key)
{
$key = (string) $key;
$return = array_key_exists($key, $this->_items);
return $return;
}
/**
* Set the container for an item in the registry
*
* @param string $key
* @param Zend_View_Placeholder_Container_Abstract $container
* @return Zend_View_Placeholder_Registry
*/
public function setContainer($key, Zend_View_Helper_Placeholder_Container_Abstract $container)
{
$key = (string) $key;
$this->_items[$key] = $container;
return $this;
}
/**
* Delete a container
*
* @param string $key
* @return bool
*/
public function deleteContainer($key)
{
$key = (string) $key;
if (isset($this->_items[$key])) {
unset($this->_items[$key]);
return true;
}
return false;
}
/**
* Set the container class to use
*
* @param string $name
* @return Zend_View_Helper_Placeholder_Registry
*/
public function setContainerClass($name)
{
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($name);
$reflection = new ReflectionClass($name);
if (!$reflection->isSubclassOf(new ReflectionClass('Zend_View_Helper_Placeholder_Container_Abstract'))) {
require_once 'Zend/View/Helper/Placeholder/Registry/Exception.php';
throw new Zend_View_Helper_Placeholder_Registry_Exception('Invalid Container class specified');
}
$this->_containerClass = $name;
return $this;
}
/**
* Retrieve the container class
*
* @return string
*/
public function getContainerClass()
{
return $this->_containerClass;
}
}
Helper/InlineScript.php 0000604 00000004142 15071177274 0011107 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: InlineScript.php 9099 2008-03-30 19:35:47Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_HeadScript */
require_once 'Zend/View/Helper/HeadScript.php';
/**
* Helper for setting and retrieving script elements for inclusion in HTML body
* section
*
* @uses Zend_View_Helper_Head_Script
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_InlineScript extends Zend_View_Helper_HeadScript
{
/**
* Registry key for placeholder
* @var string
*/
protected $_regKey = 'Zend_View_Helper_InlineScript';
/**
* Return InlineScript object
*
* Returns InlineScript helper object; optionally, allows specifying a
* script or script file to include.
*
* @param string $mode Script or file
* @param string $spec Script/url
* @param string $placement Append, prepend, or set
* @param array $attrs Array of script attributes
* @param string $type Script type and/or array of script attributes
* @return Zend_View_Helper_InlineScript
*/
public function inlineScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
{
return $this->headScript($mode, $spec, $placement, $attrs, $type);
}
}
Helper/FormSelect.php 0000604 00000013263 15071177274 0010553 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate "select" list of options
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormSelect extends Zend_View_Helper_FormElement
{
/**
* Generates 'select' list of options.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The option value to mark as 'selected'; if an
* array, will mark all values in the array as 'selected' (used for
* multiple-select elements).
*
* @param array|string $attribs Attributes added to the 'select' tag.
*
* @param array $options An array of key-value pairs where the array
* key is the radio value, and the array value is the radio text.
*
* @param string $listsep When disabled, use this list separator string
* between list values.
*
* @return string The select tag and options XHTML.
*/
public function formSelect($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n")
{
$info = $this->_getInfo($name, $value, $attribs, $options, $listsep);
extract($info); // name, id, value, attribs, options, listsep, disable
// force $value to array so we can compare multiple values to multiple
// options; also ensure it's a string for comparison purposes.
$value = array_map('strval', (array) $value);
// check if element may have multiple values
$multiple = '';
if (substr($name, -2) == '[]') {
// multiple implied by the name
$multiple = ' multiple="multiple"';
}
if (isset($attribs['multiple'])) {
// Attribute set
if ($attribs['multiple']) {
// True attribute; set multiple attribute
$multiple = ' multiple="multiple"';
// Make sure name indicates multiple values are allowed
if (!empty($multiple) && (substr($name, -2) != '[]')) {
$name .= '[]';
}
} else {
// False attribute; ensure attribute not set
$multiple = '';
}
unset($attribs['multiple']);
}
// now start building the XHTML.
$disabled = '';
if (true === $disable) {
$disabled = ' disabled="disabled"';
}
// Build the surrounding select element first.
$xhtml = '<select'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $multiple
. $disabled
. $this->_htmlAttribs($attribs)
. ">\n ";
// build the list of options
$list = array();
foreach ((array) $options as $opt_value => $opt_label) {
if (is_array($opt_label)) {
$opt_disable = '';
if (is_array($disable) && in_array($opt_value, $disable)) {
$opt_disable = ' disabled="disabled"';
}
$list[] = '<optgroup'
. $opt_disable
. ' label="' . $this->view->escape($opt_value) .'">';
foreach ($opt_label as $val => $lab) {
$list[] = $this->_build($val, $lab, $value, $disable);
}
$list[] = '</optgroup>';
} else {
$list[] = $this->_build($opt_value, $opt_label, $value, $disable);
}
}
// add the options to the xhtml and close the select
$xhtml .= implode("\n ", $list) . "\n</select>";
return $xhtml;
}
/**
* Builds the actual <option> tag
*
* @param string $value Options Value
* @param string $label Options Label
* @param array $selected The option value(s) to mark as 'selected'
* @param array|bool $disable Whether the select is disabled, or individual options are
* @return string Option Tag XHTML
*/
protected function _build($value, $label, $selected, $disable)
{
if (is_bool($disable)) {
$disable = array();
}
$opt = '<option'
. ' value="' . $this->view->escape($value) . '"'
. ' label="' . $this->view->escape($label) . '"';
// selected?
if (in_array((string) $value, $selected)) {
$opt .= ' selected="selected"';
}
// disabled?
if (in_array($value, $disable)) {
$opt .= ' disabled="disabled"';
}
$opt .= '>' . $this->view->escape($label) . "</option>";
return $opt;
}
}
Helper/FormMultiCheckbox.php 0000604 00000004344 15071177274 0012075 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_FormRadio */
require_once 'Zend/View/Helper/FormRadio.php';
/**
* Helper to generate a set of checkbox button elements
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormMultiCheckbox extends Zend_View_Helper_FormRadio
{
/**
* Input type to use
* @var string
*/
protected $_inputType = 'checkbox';
/**
* Whether or not this element represents an array collection by default
* @var bool
*/
protected $_isArray = true;
/**
* Generates a set of checkbox button elements.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The checkbox value to mark as 'checked'.
*
* @param array $options An array of key-value pairs where the array
* key is the checkbox value, and the array value is the radio text.
*
* @param array|string $attribs Attributes added to each radio.
*
* @return string The radio buttons XHTML.
*/
public function formMultiCheckbox($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n")
{
return $this->formRadio($name, $value, $attribs, $options, $listsep);
}
}
Helper/FormErrors.php 0000604 00000007453 15071177274 0010614 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to render errors for a form element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormErrors extends Zend_View_Helper_FormElement
{
/**
* @var Zend_Form_Element
*/
protected $_element;
/**#@+
* @var string Element block start/end tags and separator
*/
protected $_htmlElementEnd = '</li></ul>';
protected $_htmlElementStart = '<ul%s><li>';
protected $_htmlElementSeparator = '</li><li>';
/**#@-*/
/**
* Render form errors
*
* @param string|array $errors Error(s) to render
* @param array $options
* @return string
*/
public function formErrors($errors, array $options = null)
{
$escape = true;
if (isset($options['escape'])) {
$escape = (bool) $options['escape'];
unset($options['escape']);
}
if (empty($options['class'])) {
$options['class'] = 'errors';
}
$start = $this->getElementStart();
if (strstr($start, '%s')) {
$attribs = $this->_htmlAttribs($options);
$start = sprintf($start, $attribs);
}
if ($escape) {
foreach ($errors as $key => $error) {
$errors[$key] = $this->view->escape($error);
}
}
$html = $start
. implode($this->getElementSeparator(), (array) $errors)
. $this->getElementEnd();
return $html;
}
/**
* Set end string for displaying errors
*
* @param string $string
* @return Zend_View_Helper_FormErrors
*/
public function setElementEnd($string)
{
$this->_htmlElementEnd = (string) $string;
return $this;
}
/**
* Retrieve end string for displaying errors
*
* @return string
*/
public function getElementEnd()
{
return $this->_htmlElementEnd;
}
/**
* Set separator string for displaying errors
*
* @param string $string
* @return Zend_View_Helper_FormErrors
*/
public function setElementSeparator($string)
{
$this->_htmlElementSeparator = (string) $string;
return $this;
}
/**
* Retrieve separator string for displaying errors
*
* @return string
*/
public function getElementSeparator()
{
return $this->_htmlElementSeparator;
}
/**
* Set start string for displaying errors
*
* @param string $string
* @return Zend_View_Helper_FormErrors
*/
public function setElementStart($string)
{
$this->_htmlElementStart = (string) $string;
return $this;
}
/**
* Retrieve start string for displaying errors
*
* @return string
*/
public function getElementStart()
{
return $this->_htmlElementStart;
}
}
Helper/Json.php 0000604 00000004012 15071177274 0007411 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Json.php 10664 2008-08-05 10:56:06Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Json */
require_once 'Zend/Json.php';
/** Zend_Controller_Front */
require_once 'Zend/Controller/Front.php';
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for simplifying JSON responses
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Json extends Zend_View_Helper_Abstract
{
/**
* Encode data as JSON, disable layouts, and set response header
*
* If $keepLayouts is true, does not disable layouts.
*
* @param mixed $data
* @param bool $keepLayouts
* @return string|void
*/
public function json($data, $keepLayouts = false)
{
$data = Zend_Json::encode($data);
if (!$keepLayouts) {
require_once 'Zend/Layout.php';
$layout = Zend_Layout::getMvcInstance();
if ($layout instanceof Zend_Layout) {
$layout->disableLayout();
}
}
$response = Zend_Controller_Front::getInstance()->getResponse();
$response->setHeader('Content-Type', 'application/json');
return $data;
}
}
Helper/FormRadio.php 0000604 00000013443 15071177274 0010372 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a set of radio button elements
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormRadio extends Zend_View_Helper_FormElement
{
/**
* Input type to use
* @var string
*/
protected $_inputType = 'radio';
/**
* Whether or not this element represents an array collection by default
* @var bool
*/
protected $_isArray = false;
/**
* Generates a set of radio button elements.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The radio value to mark as 'checked'.
*
* @param array $options An array of key-value pairs where the array
* key is the radio value, and the array value is the radio text.
*
* @param array|string $attribs Attributes added to each radio.
*
* @return string The radio buttons XHTML.
*/
public function formRadio($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n")
{
$info = $this->_getInfo($name, $value, $attribs, $options, $listsep);
extract($info); // name, value, attribs, options, listsep, disable
// retrieve attributes for labels (prefixed with 'label_' or 'label')
$label_attribs = array('style' => 'white-space: nowrap;');
foreach ($attribs as $key => $val) {
$tmp = false;
$keyLen = strlen($key);
if ((6 < $keyLen) && (substr($key, 0, 6) == 'label_')) {
$tmp = substr($key, 6);
} elseif ((5 < $keyLen) && (substr($key, 0, 5) == 'label')) {
$tmp = substr($key, 5);
}
if ($tmp) {
// make sure first char is lowercase
$tmp[0] = strtolower($tmp[0]);
$label_attribs[$tmp] = $val;
unset($attribs[$key]);
}
}
$labelPlacement = 'append';
foreach ($label_attribs as $key => $val) {
switch (strtolower($key)) {
case 'placement':
unset($label_attribs[$key]);
$val = strtolower($val);
if (in_array($val, array('prepend', 'append'))) {
$labelPlacement = $val;
}
break;
}
}
// the radio button values and labels
$options = (array) $options;
// build the element
$xhtml = '';
$list = array();
// should the name affect an array collection?
$name = $this->view->escape($name);
if ($this->_isArray && ('[]' != substr($name, -2))) {
$name .= '[]';
}
// ensure value is an array to allow matching multiple times
$value = (array) $value;
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// add radio buttons to the list.
require_once 'Zend/Filter/Alnum.php';
$filter = new Zend_Filter_Alnum();
foreach ($options as $opt_value => $opt_label) {
// Should the label be escaped?
if ($escape) {
$opt_label = $this->view->escape($opt_label);
}
// is it disabled?
$disabled = '';
if (true === $disable) {
$disabled = ' disabled="disabled"';
} elseif (is_array($disable) && in_array($opt_value, $disable)) {
$disabled = ' disabled="disabled"';
}
// is it checked?
$checked = '';
if (in_array($opt_value, $value)) {
$checked = ' checked="checked"';
}
// generate ID
$optId = $id . '-' . $filter->filter($opt_value);
// Wrap the radios in labels
$radio = '<label'
. $this->_htmlAttribs($label_attribs) . '>'
. (('prepend' == $labelPlacement) ? $opt_label : '')
. '<input type="' . $this->_inputType . '"'
. ' name="' . $name . '"'
. ' id="' . $optId . '"'
. ' value="' . $this->view->escape($opt_value) . '"'
. $checked
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag
. (('append' == $labelPlacement) ? $opt_label : '')
. '</label>';
// add to the array of radio buttons
$list[] = $radio;
}
// done!
$xhtml .= implode($listsep, $list);
return $xhtml;
}
}
Helper/RenderToPlaceholder.php 0000604 00000002641 15071177274 0012373 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id:$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for making easy links and getting urls that depend on the routes and router
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_RenderToPlaceholder extends Zend_View_Helper_Abstract
{
public function renderToPlaceholder($script, $placeholder)
{
$this->view->placeholder($placeholder)->captureStart();
echo $this->view->render($script);
$this->view->placeholder($placeholder)->captureEnd();
}
}
Helper/Doctype.php 0000604 00000014430 15071177274 0010114 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 7078 2007-12-11 14:29:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Registry */
require_once 'Zend/Registry.php';
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for setting and retrieving the doctype
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Doctype extends Zend_View_Helper_Abstract
{
/**#@+
* DocType constants
*/
const XHTML11 = 'XHTML11';
const XHTML1_STRICT = 'XHTML1_STRICT';
const XHTML1_TRANSITIONAL = 'XHTML1_TRANSITIONAL';
const XHTML1_FRAMESET = 'XHTML1_FRAMESET';
const XHTML_BASIC1 = 'XHTML_BASIC1';
const HTML4_STRICT = 'HTML4_STRICT';
const HTML4_LOOSE = 'HTML4_LOOSE';
const HTML4_FRAMESET = 'HTML4_FRAMESET';
const HTML5 = 'HTML5';
const CUSTOM_XHTML = 'CUSTOM_XHTML';
const CUSTOM = 'CUSTOM';
/**#@-*/
/**
* Default DocType
* @var string
*/
protected $_defaultDoctype = self::HTML4_LOOSE;
/**
* Registry containing current doctype and mappings
* @var ArrayObject
*/
protected $_registry;
/**
* Registry key in which helper is stored
* @var string
*/
protected $_regKey = 'Zend_View_Helper_Doctype';
/**
* Constructor
*
* Map constants to doctype strings, and set default doctype
*
* @return void
*/
public function __construct()
{
if (!Zend_Registry::isRegistered($this->_regKey)) {
$this->_registry = new ArrayObject(array(
'doctypes' => array(
self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
self::XHTML1_STRICT => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
self::XHTML1_FRAMESET => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
self::XHTML_BASIC1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">',
self::HTML4_STRICT => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
self::HTML4_LOOSE => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
self::HTML4_FRAMESET => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
self::HTML5 => '<!DOCTYPE html>',
)
));
Zend_Registry::set($this->_regKey, $this->_registry);
$this->setDoctype($this->_defaultDoctype);
} else {
$this->_registry = Zend_Registry::get($this->_regKey);
}
}
/**
* Set or retrieve doctype
*
* @param string $doctype
* @return Zend_View_Helper_Doctype
*/
public function doctype($doctype = null)
{
if (null !== $doctype) {
switch ($doctype) {
case self::XHTML11:
case self::XHTML1_STRICT:
case self::XHTML1_TRANSITIONAL:
case self::XHTML1_FRAMESET:
case self::XHTML_BASIC1:
case self::HTML4_STRICT:
case self::HTML4_LOOSE:
case self::HTML4_FRAMESET:
case self::HTML5:
$this->setDoctype($doctype);
break;
default:
if (substr($doctype, 0, 9) != '<!DOCTYPE') {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('The specified doctype is malformed');
}
if (stristr($doctype, 'xhtml')) {
$type = self::CUSTOM_XHTML;
} else {
$type = self::CUSTOM;
}
$this->setDoctype($type);
$this->_registry['doctypes'][$type] = $doctype;
break;
}
}
return $this;
}
/**
* Set doctype
*
* @param string $doctype
* @return Zend_View_Helper_Doctype
*/
public function setDoctype($doctype)
{
$this->_registry['doctype'] = $doctype;
return $this;
}
/**
* Retrieve doctype
*
* @return string
*/
public function getDoctype()
{
return $this->_registry['doctype'];
}
/**
* Get doctype => string mappings
*
* @return array
*/
public function getDoctypes()
{
return $this->_registry['doctypes'];
}
/**
* Is doctype XHTML?
*
* @return boolean
*/
public function isXhtml()
{
return (stristr($this->getDoctype(), 'xhtml') ? true : false);
}
/**
* String representation of doctype
*
* @return string
*/
public function __toString()
{
$doctypes = $this->getDoctypes();
return $doctypes[$this->getDoctype()];
}
}
Helper/HtmlList.php 0000604 00000005304 15071177274 0010245 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_View_Helper_FormELement
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper for ordered and unordered lists
*
* @uses Zend_View_Helper_FormElement
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HtmlList extends Zend_View_Helper_FormElement
{
/**
* Generates a 'List' element.
*
* @param array $items Array with the elements of the list
* @param boolean $ordered Specifies ordered/unordered list; default unordered
* @param array $attribs Attributes for the ol/ul tag.
* @return string The list XHTML.
*/
public function htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
{
if (!is_array($items)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('First param must be an array', $this);
}
$list = '';
foreach ($items as $item) {
if (!is_array($item)) {
if ($escape) {
$item = $this->view->escape($item);
}
$list .= '<li>' . $item . '</li>' . self::EOL;
} else {
if (5 < strlen($list)) {
$list = substr($list, 0, strlen($list) - 5)
. $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
} else {
$list .= '<li>' . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
}
}
}
if ($attribs) {
$attribs = $this->_htmlAttribs($attribs);
} else {
$attribs = '';
}
$tag = 'ul';
if ($ordered) {
$tag = 'ol';
}
return '<' . $tag . $attribs . '>' . self::EOL . $list . '</' . $tag . '>' . self::EOL;
}
}
Helper/FormFile.php 0000604 00000004525 15071177274 0010214 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "file" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormFile extends Zend_View_Helper_FormElement
{
/**
* Generates a 'file' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formFile($name, $attribs = null)
{
$info = $this->_getInfo($name, null, $attribs);
extract($info); // name, id, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
// build the element
$xhtml = '<input type="file"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
}
Helper/FormReset.php 0000604 00000005032 15071177274 0010411 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "reset" button
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormReset extends Zend_View_Helper_FormElement
{
/**
* Generates a 'reset' button.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formReset($name = '', $value = 'Reset', $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// check if disabled
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
// get closing tag
$endTag = '>';
if ($this->view->doctype()->isXhtml()) {
$endTag = ' />';
}
// Render button
$xhtml = '<input type="reset"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled;
// add a value if one is given
if (! empty($value)) {
$xhtml .= ' value="' . $this->view->escape($value) . '"';
}
// add attributes, close, and return
$xhtml .= $this->_htmlAttribs($attribs) . $endTag;
return $xhtml;
}
}
Helper/HtmlElement.php 0000604 00000007454 15071177274 0010733 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HtmlElement.php 12477 2008-11-09 01:55:35Z yoshida@zend.co.jp $
*/
/**
* @see Zend_View_Helper_Abstract
*/
require_once 'Zend/View/Helper/Abstract.php';
/**
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_HtmlElement extends Zend_View_Helper_Abstract
{
/**
* EOL character
*/
const EOL = "\n";
/**
* The tag closing bracket
*
* @var string
*/
protected $_closingBracket = null;
/**
* Get the tag closing bracket
*
* @return string
*/
public function getClosingBracket()
{
if (!$this->_closingBracket) {
if ($this->_isXhtml()) {
$this->_closingBracket = ' />';
} else {
$this->_closingBracket = '>';
}
}
return $this->_closingBracket;
}
/**
* Is doctype XHTML?
*
* @return boolean
*/
protected function _isXhtml()
{
$doctype = $this->view->doctype();
return $doctype->isXhtml();
}
/**
* Converts an associative array to a string of tag attributes.
*
* @access public
*
* @param array $attribs From this array, each key-value pair is
* converted to an attribute name and value.
*
* @return string The XHTML for the attributes.
*/
protected function _htmlAttribs($attribs)
{
$xhtml = '';
foreach ((array) $attribs as $key => $val) {
$key = $this->view->escape($key);
if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) {
// Don't escape event attributes; _do_ substitute double quotes with singles
if (!is_scalar($val)) {
// non-scalar data should be cast to JSON first
require_once 'Zend/Json.php';
$val = Zend_Json::encode($val);
}
$val = preg_replace('/"([^"]*)":/', '$1:', $val);
} else {
if (is_array($val)) {
$val = implode(' ', $val);
}
$val = $this->view->escape($val);
}
if ('id' == $key) {
$val = $this->_normalizeId($val);
}
if (strpos($val, '"') !== false) {
$xhtml .= " $key='$val'";
} else {
$xhtml .= " $key=\"$val\"";
}
}
return $xhtml;
}
/**
* Normalize an ID
*
* @param string $value
* @return string
*/
protected function _normalizeId($value)
{
if (strstr($value, '[')) {
if ('[]' == substr($value, -2)) {
$value = substr($value, 0, strlen($value) - 2);
}
$value = trim($value, ']');
$value = str_replace('][', '-', $value);
$value = str_replace('[', '-', $value);
}
return $value;
}
}
Helper/HeadMeta.php 0000604 00000024433 15071177274 0010161 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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Placeholder.php 7078 2007-12-11 14:29:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/** Zend_View_Exception */
require_once 'Zend/View/Exception.php';
/**
* Zend_Layout_View_Helper_HeadMeta
*
* @see http://www.w3.org/TR/xhtml1/dtds.html
* @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_Standalone
{
/**
* Types of attributes
* @var array
*/
protected $_typeKeys = array('name', 'http-equiv');
protected $_requiredKeys = array('content');
protected $_modifierKeys = array('lang', 'scheme');
/**
* @var string registry key
*/
protected $_regKey = 'Zend_View_Helper_HeadMeta';
/**
* Constructor
*
* Set separator to PHP_EOL
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->setSeparator(PHP_EOL);
}
/**
* Retrieve object instance; optionally add meta tag
*
* @param string $content
* @param string $keyValue
* @param string $keyType
* @param array $modifiers
* @param string $placement
* @return Zend_View_Helper_HeadMeta
*/
public function headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
{
if ((null !== $content) && (null !== $keyValue)) {
$item = $this->createData($keyType, $keyValue, $content, $modifiers);
$action = strtolower($placement);
switch ($action) {
case 'append':
case 'prepend':
case 'set':
$this->$action($item);
break;
default:
$this->append($item);
break;
}
}
return $this;
}
protected function _normalizeType($type)
{
switch ($type) {
case 'Name':
return 'name';
case 'HttpEquiv':
return 'http-equiv';
default:
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Invalid type "%s" passed to _normalizeType', $type));
}
}
/**
* Overload method access
*
* Allows the following 'virtual' methods:
* - appendName($keyValue, $content, $modifiers = array())
* - offsetGetName($index, $keyValue, $content, $modifers = array())
* - prependName($keyValue, $content, $modifiers = array())
* - setName($keyValue, $content, $modifiers = array())
* - appendHttpEquiv($keyValue, $content, $modifiers = array())
* - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array())
* - prependHttpEquiv($keyValue, $content, $modifiers = array())
* - setHttpEquiv($keyValue, $content, $modifiers = array())
*
* @param string $method
* @param array $args
* @return Zend_View_Helper_HeadMeta
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv)$/', $method, $matches)) {
$action = $matches['action'];
$type = $this->_normalizeType($matches['type']);
$argc = count($args);
$index = null;
if ('offsetSet' == $action) {
if (0 < $argc) {
$index = array_shift($args);
--$argc;
}
}
if (2 > $argc) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Too few arguments provided; requires key value, and content');
}
if (3 > $argc) {
$args[] = array();
}
$item = $this->createData($type, $args[0], $args[1], $args[2]);
if ('offsetSet' == $action) {
return $this->offsetSet($index, $item);
}
if ($action == 'set') {
//var_dump($this->getContainer());
}
$this->$action($item);
return $this;
}
return parent::__call($method, $args);
}
/**
* Determine if item is valid
*
* @param mixed $item
* @return boolean
*/
protected function _isValid($item)
{
if ((!$item instanceof stdClass)
|| !isset($item->type)
|| !isset($item->content)
|| !isset($item->modifiers))
{
return false;
}
return true;
}
/**
* Append
*
* @param string $value
* @return void
* @throws Zend_View_Exception
*/
public function append($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to append; please use appendMeta()');
}
return $this->getContainer()->append($value);
}
/**
* OffsetSet
*
* @param string|int $index
* @param string $value
* @return void
* @throws Zend_View_Exception
*/
public function offsetSet($index, $value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetMeta()');
}
return $this->getContainer()->offsetSet($index, $value);
}
/**
* OffsetUnset
*
* @param string|int $index
* @return void
* @throws Zend_View_Exception
*/
public function offsetUnset($index)
{
if (!in_array($index, $this->getContainer()->getKeys())) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid index passed to offsetUnset.');
}
return $this->getContainer()->offsetUnset($index);
}
/**
* Prepend
*
* @param string $value
* @return void
* @throws Zend_View_Exception
*/
public function prepend($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to prepend; please use prependMeta()');
}
return $this->getContainer()->prepend($value);
}
/**
* Set
*
* @param string $value
* @return void
* @throws Zend_View_Exception
*/
public function set($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to set; please use setMeta()');
}
$container = $this->getContainer();
foreach ($container->getArrayCopy() as $index => $item) {
if ($item->type == $value->type && $item->{$item->type} == $value->{$value->type}) {
$this->offsetUnset($index);
}
}
return $this->append($value);
}
/**
* Build meta HTML string
*
* @param string $type
* @param string $typeValue
* @param string $content
* @param array $modifiers
* @return string
*/
public function itemToString(stdClass $item)
{
if (!in_array($item->type, $this->_typeKeys)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Invalid type "%s" provided for meta', $item->type));
}
$type = $item->type;
$modifiersString = '';
foreach ($item->modifiers as $key => $value) {
if (!in_array($key, $this->_modifierKeys)) {
continue;
}
$modifiersString .= $key . '="' . $this->_escape($value) . '" ';
}
if ($this->view instanceof Zend_View_Abstract) {
$tpl = ($this->view->doctype()->isXhtml())
? '<meta %s="%s" content="%s" %s/>'
: '<meta %s="%s" content="%s" %s>';
} else {
$tpl = '<meta %s="%s" content="%s" %s/>';
}
$meta = sprintf(
$tpl,
$type,
$this->_escape($item->$type),
$this->_escape($item->content),
$modifiersString
);
return $meta;
}
/**
* Render placeholder as string
*
* @param string|int $indent
* @return string
*/
public function toString($indent = null)
{
$indent = (null !== $indent)
? $this->getWhitespace($indent)
: $this->getIndent();
$items = array();
foreach ($this as $item) {
$items[] = $this->itemToString($item);
}
return $indent . implode($this->_escape($this->getSeparator()) . $indent, $items);
}
/**
* Create data item for inserting into stack
*
* @param string $type
* @param string $typeValue
* @param string $content
* @param array $modifiers
* @return stdClass
*/
public function createData($type, $typeValue, $content, array $modifiers)
{
$data = new stdClass;
$data->type = $type;
$data->$type = $typeValue;
$data->content = $content;
$data->modifiers = $modifiers;
return $data;
}
}
Helper/FormText.php 0000604 00000004726 15071177274 0010264 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "text" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormText extends Zend_View_Helper_FormElement
{
/**
* Generates a 'text' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are used in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formText($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// build the element
$disabled = '';
if ($disable) {
// disabled
$disabled = ' disabled="disabled"';
}
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag= '>';
}
$xhtml = '<input type="text"'
. ' name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. ' value="' . $this->view->escape($value) . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. $endTag;
return $xhtml;
}
}
Helper/Partial.php 0000604 00000011157 15071177274 0010104 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Partial.php 12577 2008-11-12 01:31:34Z sidhighwind $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for rendering a template fragment in its own variable scope.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Partial extends Zend_View_Helper_Abstract
{
/**
* Variable to which object will be assigned
* @var string
*/
protected $_objectKey;
/**
* Renders a template fragment within a variable scope distinct from the
* calling View object.
*
* If no arguments are passed, returns the helper instance.
*
* If the $model is an array, it is passed to the view object's assign()
* method.
*
* If the $model is an object, it first checks to see if the object
* implements a 'toArray' method; if so, it passes the result of that
* method to to the view object's assign() method. Otherwise, the result of
* get_object_vars() is passed.
*
* @param string $name Name of view script
* @param string|array $module If $model is empty, and $module is an array,
* these are the variables to populate in the
* view. Otherwise, the module in which the
* partial resides
* @param array $model Variables to populate in the view
* @return string|Zend_View_Helper_Partial
*/
public function partial($name = null, $module = null, $model = null)
{
if (0 == func_num_args()) {
return $this;
}
$view = $this->cloneView();
if (isset($this->partialCounter)) {
$view->partialCounter = $this->partialCounter;
}
if ((null !== $module) && is_string($module)) {
require_once 'Zend/Controller/Front.php';
$moduleDir = Zend_Controller_Front::getInstance()->getControllerDirectory($module);
if (null === $moduleDir) {
require_once 'Zend/View/Helper/Partial/Exception.php';
throw new Zend_View_Helper_Partial_Exception('Cannot render partial; module does not exist');
}
$viewsDir = dirname($moduleDir) . '/views';
$view->addBasePath($viewsDir);
} elseif ((null == $model) && (null !== $module)
&& (is_array($module) || is_object($module)))
{
$model = $module;
}
if (!empty($model)) {
if (is_array($model)) {
$view->assign($model);
} elseif (is_object($model)) {
if (null !== ($objectKey = $this->getObjectKey())) {
$view->assign($objectKey, $model);
} elseif (method_exists($model, 'toArray')) {
$view->assign($model->toArray());
} else {
$view->assign(get_object_vars($model));
}
}
}
return $view->render($name);
}
/**
* Clone the current View
*
* @return Zend_View_Interface
*/
public function cloneView()
{
$view = clone $this->view;
$view->clearVars();
return $view;
}
/**
* Set object key
*
* @param string $key
* @return Zend_View_Helper_Partial
*/
public function setObjectKey($key)
{
if (null === $key) {
$this->_objectKey = null;
} else {
$this->_objectKey = (string) $key;
}
return $this;
}
/**
* Retrieve object key
*
* The objectKey is the variable to which an object in the iterator will be
* assigned.
*
* @return null|string
*/
public function getObjectKey()
{
return $this->_objectKey;
}
}
Helper/FormTextarea.php 0000604 00000005551 15071177274 0011112 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to generate a "textarea" element
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormTextarea extends Zend_View_Helper_FormElement
{
/**
* The default number of rows for a textarea.
*
* @access public
*
* @var int
*/
public $rows = 24;
/**
* The default number of columns for a textarea.
*
* @access public
*
* @var int
*/
public $cols = 80;
/**
* Generates a 'textarea' element.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The element value.
*
* @param array $attribs Attributes for the element tag.
*
* @return string The element XHTML.
*/
public function formTextarea($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
// is it disabled?
$disabled = '';
if ($disable) {
// disabled.
$disabled = ' disabled="disabled"';
}
// Make sure that there are 'rows' and 'cols' values
// as required by the spec. noted by Orjan Persson.
if (empty($attribs['rows'])) {
$attribs['rows'] = (int) $this->rows;
}
if (empty($attribs['cols'])) {
$attribs['cols'] = (int) $this->cols;
}
// build the element
$xhtml = '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>';
return $xhtml;
}
}
Helper/Fieldset.php 0000604 00000004511 15071177274 0010243 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Fieldset.php 11301 2008-09-08 20:09:10Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_FormElement */
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper for rendering fieldsets
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Fieldset extends Zend_View_Helper_FormElement
{
/**
* Render HTML form
*
* @param string $name Form name
* @param string $content Form content
* @param array $attribs HTML form attributes
* @return string
*/
public function fieldset($name, $content, $attribs = null)
{
$info = $this->_getInfo($name, $content, $attribs);
extract($info);
// get legend
$legend = '';
if (isset($attribs['legend'])) {
$legendString = trim($attribs['legend']);
if (!empty($legendString)) {
$legend = '<legend>'
. (($escape) ? $this->view->escape($legendString) : $legendString)
. '</legend>' . PHP_EOL;
}
unset($attribs['legend']);
}
// get id
if (!empty($id)) {
$id = ' id="' . $this->view->escape($id) . '"';
} else {
$id = '';
}
// render fieldset
$xhtml = '<fieldset'
. $id
. $this->_htmlAttribs($attribs)
. '>'
. $legend
. $content
. '</fieldset>';
return $xhtml;
}
}
Helper/PaginationControl.php 0000604 00000010403 15071177274 0012133 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_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PaginationControl.php 12321 2008-11-06 10:44:41Z doctorrock83 $
*/
/**
* @category Zend
* @package Zend_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_PaginationControl
{
/**
* View instance
*
* @var Zend_View_Instance
*/
public $view = null;
/**
* Default view partial
*
* @var string
*/
protected static $_defaultViewPartial = null;
/**
* Sets the view instance.
*
* @param Zend_View_Interface $view View instance
* @return Zend_View_Helper_PaginationControl
*/
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
return $this;
}
/**
* Sets the default view partial.
*
* @param string $partial View partial
*/
public static function setDefaultViewPartial($partial)
{
self::$_defaultViewPartial = $partial;
}
/**
* Gets the default view partial
*
* @return string
*/
public static function getDefaultViewPartial()
{
return self::$_defaultViewPartial;
}
/**
* Render the provided pages. This checks if $view->paginator is set and,
* if so, uses that. Also, if no scrolling style or partial are specified,
* the defaults will be used (if set).
*
* @param Zend_Paginator (Optional) $paginator
* @param string $scrollingStyle (Optional) Scrolling style
* @param string $partial (Optional) View partial
* @param array|string $params (Optional) params to pass to the partial
* @return string
* @throws Zend_View_Exception
*/
public function paginationControl(Zend_Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null)
{
if ($paginator === null) {
if (isset($this->view->paginator) and $this->view->paginator !== null and $this->view->paginator instanceof Zend_Paginator) {
$paginator = $this->view->paginator;
} else {
/**
* @see Zend_View_Exception
*/
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('No paginator instance provided or incorrect type');
}
}
if ($partial === null) {
if (self::$_defaultViewPartial === null) {
/**
* @see Zend_View_Exception
*/
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('No view partial provided and no default set');
}
$partial = self::$_defaultViewPartial;
}
$pages = get_object_vars($paginator->getPages($scrollingStyle));
if ($params !== null) {
$pages = array_merge($pages, (array) $params);
}
if (is_array($partial)) {
if (count($partial) != 2) {
/**
* @see Zend_View_Exception
*/
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('A view partial supplied as an array must contain two values: the filename and its module');
}
if ($partial[1] !== null) {
return $this->view->partial($partial[0], $partial[1], $pages);
}
$partial = $partial[0];
}
return $this->view->partial($partial, $pages);
}
} Helper/Url.php 0000604 00000003563 15071177274 0007254 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Url.php 10664 2008-08-05 10:56:06Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Helper for making easy links and getting urls that depend on the routes and router
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Url extends Zend_View_Helper_Abstract
{
/**
* Generates an url given the name of a route.
*
* @access public
*
* @param array $urlOptions Options passed to the assemble method of the Route object.
* @param mixed $name The name of a Route to use. If null it will use the current Route
* @param bool $reset Whether or not to reset the route defaults with those provided
* @return string Url for the link href attribute.
*/
public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
{
$router = Zend_Controller_Front::getInstance()->getRouter();
return $router->assemble($urlOptions, $name, $reset, $encode);
}
}
Helper/FormNote.php 0000604 00000003423 15071177274 0010236 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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class for extension
*/
require_once 'Zend/View/Helper/FormElement.php';
/**
* Helper to show an HTML note
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_FormNote extends Zend_View_Helper_FormElement
{
/**
* Helper to show a "note" based on a hidden value.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param array $value The note to display. HTML is *not* escaped; the
* note is displayed as-is.
*
* @return string The element XHTML.
*/
public function formNote($name, $value = null)
{
$info = $this->_getInfo($name, $value);
extract($info); // name, value, attribs, options, listsep, disable
return $value;
}
}
Interface.php 0000604 00000007362 15071177274 0007174 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_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Interface class for Zend_View compatible template engine implementations
*
* @category Zend
* @package Zend_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_View_Interface
{
/**
* Return the template engine object, if any
*
* If using a third-party template engine, such as Smarty, patTemplate,
* phplib, etc, return the template engine object. Useful for calling
* methods on these objects, such as for setting filters, modifiers, etc.
*
* @return mixed
*/
public function getEngine();
/**
* Set the path to find the view script used by render()
*
* @param string|array The directory (-ies) to set as the path. Note that
* the concrete view implentation may not necessarily support multiple
* directories.
* @return void
*/
public function setScriptPath($path);
/**
* Retrieve all view script paths
*
* @return array
*/
public function getScriptPaths();
/**
* Set a base path to all view resources
*
* @param string $path
* @param string $classPrefix
* @return void
*/
public function setBasePath($path, $classPrefix = 'Zend_View');
/**
* Add an additional path to view resources
*
* @param string $path
* @param string $classPrefix
* @return void
*/
public function addBasePath($path, $classPrefix = 'Zend_View');
/**
* Assign a variable to the view
*
* @param string $key The variable name.
* @param mixed $val The variable value.
* @return void
*/
public function __set($key, $val);
/**
* Allows testing with empty() and isset() to work
*
* @param string $key
* @return boolean
*/
public function __isset($key);
/**
* Allows unset() on object properties to work
*
* @param string $key
* @return void
*/
public function __unset($key);
/**
* Assign variables to the view script via differing strategies.
*
* Suggested implementation is to allow setting a specific key to the
* specified value, OR passing an array of key => value pairs to set en
* masse.
*
* @see __set()
* @param string|array $spec The assignment strategy to use (key or array of key
* => value pairs)
* @param mixed $value (Optional) If assigning a named variable, use this
* as the value.
* @return void
*/
public function assign($spec, $value = null);
/**
* Clear all assigned variables
*
* Clears all variables assigned to Zend_View either via {@link assign()} or
* property overloading ({@link __get()}/{@link __set()}).
*
* @return void
*/
public function clearVars();
/**
* Processes a view script and returns the output.
*
* @param string $name The script script name to process.
* @return string The script output.
*/
public function render($name);
}
Abstract.php 0000604 00000072776 15071177274 0007052 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_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Loader */
require_once 'Zend/Loader.php';
/** Zend_Loader_PluginLoader */
require_once 'Zend/Loader/PluginLoader.php';
/** Zend_View_Interface */
require_once 'Zend/View/Interface.php';
/**
* Abstract class for Zend_View to help enforce private constructs.
*
* @category Zend
* @package Zend_View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Abstract implements Zend_View_Interface
{
/**
* Path stack for script, helper, and filter directories.
*
* @var array
*/
private $_path = array(
'script' => array(),
'helper' => array(),
'filter' => array(),
);
/**
* Script file name to execute
*
* @var string
*/
private $_file = null;
/**
* Instances of helper objects.
*
* @var array
*/
private $_helper = array();
/**
* Map of helper => class pairs to help in determining helper class from
* name
* @var array
*/
private $_helperLoaded = array();
/**
* Map of helper => classfile pairs to aid in determining helper classfile
* @var array
*/
private $_helperLoadedDir = array();
/**
* Stack of Zend_View_Filter names to apply as filters.
* @var array
*/
private $_filter = array();
/**
* Stack of Zend_View_Filter objects that have been loaded
* @var array
*/
private $_filterClass = array();
/**
* Map of filter => class pairs to help in determining filter class from
* name
* @var array
*/
private $_filterLoaded = array();
/**
* Map of filter => classfile pairs to aid in determining filter classfile
* @var array
*/
private $_filterLoadedDir = array();
/**
* Callback for escaping.
*
* @var string
*/
private $_escape = 'htmlspecialchars';
/**
* Encoding to use in escaping mechanisms; defaults to latin1 (ISO-8859-1)
* @var string
*/
private $_encoding = 'ISO-8859-1';
/**
* Plugin loaders
* @var array
*/
private $_loaders = array();
/**
* Plugin types
* @var array
*/
private $_loaderTypes = array('filter', 'helper');
/**
* Strict variables flag; when on, undefined variables accessed in the view
* scripts will trigger notices
* @var boolean
*/
private $_strictVars = false;
private $_log;
/**
* Constructor.
*
* @param array $config Configuration key-value pairs.
*/
public function __construct($config = array())
{
// set inital paths and properties
$this->setScriptPath(null);
// $this->setHelperPath(null);
$this->setFilterPath(null);
// user-defined escaping callback
if (array_key_exists('escape', $config)) {
$this->setEscape($config['escape']);
}
// encoding
if (array_key_exists('encoding', $config)) {
$this->setEncoding($config['encoding']);
}
// base path
if (array_key_exists('basePath', $config)) {
$prefix = 'Zend_View';
if (array_key_exists('basePathPrefix', $config)) {
$prefix = $config['basePathPrefix'];
}
$this->setBasePath($config['basePath'], $prefix);
}
// user-defined view script path
if (array_key_exists('scriptPath', $config)) {
$this->addScriptPath($config['scriptPath']);
}
// user-defined helper path
if (array_key_exists('helperPath', $config)) {
$prefix = 'Zend_View_Helper';
if (array_key_exists('helperPathPrefix', $config)) {
$prefix = $config['helperPathPrefix'];
}
$this->addHelperPath($config['helperPath'], $prefix);
}
// user-defined filter path
if (array_key_exists('filterPath', $config)) {
$prefix = 'Zend_View_Filter';
if (array_key_exists('filterPathPrefix', $config)) {
$prefix = $config['filterPathPrefix'];
}
$this->addFilterPath($config['filterPath'], $prefix);
}
// user-defined filters
if (array_key_exists('filter', $config)) {
$this->addFilter($config['filter']);
}
// strict vars
if (array_key_exists('strictVars', $config)) {
$this->strictVars($config['strictVars']);
}
$this->init();
}
/**
* Return the template engine object
*
* Returns the object instance, as it is its own template engine
*
* @return Zend_View_Abstract
*/
public function getEngine()
{
return $this;
}
/**
* Allow custom object initialization when extending Zend_View_Abstract or
* Zend_View
*
* Triggered by {@link __construct() the constructor} as its final action.
*
* @return void
*/
public function init()
{
}
/**
* Prevent E_NOTICE for nonexistent values
*
* If {@link strictVars()} is on, raises a notice.
*
* @param string $key
* @return null
*/
public function __get($key)
{
if ($this->_strictVars) {
trigger_error('Key "' . $key . '" does not exist', E_USER_NOTICE);
}
return null;
}
/**
* Allows testing with empty() and isset() to work inside
* templates.
*
* @param string $key
* @return boolean
*/
public function __isset($key)
{
if ('_' != substr($key, 0, 1)) {
return isset($this->$key);
}
return false;
}
/**
* Directly assigns a variable to the view script.
*
* Checks first to ensure that the caller is not attempting to set a
* protected or private member (by checking for a prefixed underscore); if
* not, the public member is set; otherwise, an exception is raised.
*
* @param string $key The variable name.
* @param mixed $val The variable value.
* @return void
* @throws Zend_View_Exception if an attempt to set a private or protected
* member is detected
*/
public function __set($key, $val)
{
if ('_' != substr($key, 0, 1)) {
$this->$key = $val;
return;
}
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Setting private or protected class members is not allowed', $this);
}
/**
* Allows unset() on object properties to work
*
* @param string $key
* @return void
*/
public function __unset($key)
{
if ('_' != substr($key, 0, 1) && isset($this->$key)) {
unset($this->$key);
}
}
/**
* Accesses a helper object from within a script.
*
* If the helper class has a 'view' property, sets it with the current view
* object.
*
* @param string $name The helper name.
* @param array $args The parameters for the helper.
* @return string The result of the helper output.
*/
public function __call($name, $args)
{
// is the helper already loaded?
$helper = $this->getHelper($name);
// call the helper method
return call_user_func_array(
array($helper, $name),
$args
);
}
/**
* Given a base path, sets the script, helper, and filter paths relative to it
*
* Assumes a directory structure of:
* <code>
* basePath/
* scripts/
* helpers/
* filters/
* </code>
*
* @param string $path
* @param string $prefix Prefix to use for helper and filter paths
* @return Zend_View_Abstract
*/
public function setBasePath($path, $classPrefix = 'Zend_View')
{
$path = rtrim($path, '/');
$path = rtrim($path, '\\');
$path .= DIRECTORY_SEPARATOR;
$classPrefix = rtrim($classPrefix, '_') . '_';
$this->setScriptPath($path . 'scripts');
$this->setHelperPath($path . 'helpers', $classPrefix . 'Helper');
$this->setFilterPath($path . 'filters', $classPrefix . 'Filter');
return $this;
}
/**
* Given a base path, add script, helper, and filter paths relative to it
*
* Assumes a directory structure of:
* <code>
* basePath/
* scripts/
* helpers/
* filters/
* </code>
*
* @param string $path
* @param string $prefix Prefix to use for helper and filter paths
* @return Zend_View_Abstract
*/
public function addBasePath($path, $classPrefix = 'Zend_View')
{
$path = rtrim($path, '/');
$path = rtrim($path, '\\');
$path .= DIRECTORY_SEPARATOR;
$classPrefix = rtrim($classPrefix, '_') . '_';
$this->addScriptPath($path . 'scripts');
$this->addHelperPath($path . 'helpers', $classPrefix . 'Helper');
$this->addFilterPath($path . 'filters', $classPrefix . 'Filter');
return $this;
}
/**
* Adds to the stack of view script paths in LIFO order.
*
* @param string|array The directory (-ies) to add.
* @return Zend_View_Abstract
*/
public function addScriptPath($path)
{
$this->_addPath('script', $path);
return $this;
}
/**
* Resets the stack of view script paths.
*
* To clear all paths, use Zend_View::setScriptPath(null).
*
* @param string|array The directory (-ies) to set as the path.
* @return Zend_View_Abstract
*/
public function setScriptPath($path)
{
$this->_path['script'] = array();
$this->_addPath('script', $path);
return $this;
}
/**
* Return full path to a view script specified by $name
*
* @param string $name
* @return false|string False if script not found
* @throws Zend_View_Exception if no script directory set
*/
public function getScriptPath($name)
{
try {
$path = $this->_script($name);
return $path;
} catch (Zend_View_Exception $e) {
if (strstr($e->getMessage(), 'no view script directory set')) {
throw $e;
}
return false;
}
}
/**
* Returns an array of all currently set script paths
*
* @return array
*/
public function getScriptPaths()
{
return $this->_getPaths('script');
}
/**
* Set plugin loader for a particular plugin type
*
* @param Zend_Loader_PluginLoader $loader
* @param string $type
* @return Zend_View_Abstract
*/
public function setPluginLoader(Zend_Loader_PluginLoader $loader, $type)
{
$type = strtolower($type);
if (!in_array($type, $this->_loaderTypes)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Invalid plugin loader type "%s"', $type));
}
$this->_loaders[$type] = $loader;
return $this;
}
/**
* Retrieve plugin loader for a specific plugin type
*
* @param string $type
* @return Zend_Loader_PluginLoader
*/
public function getPluginLoader($type)
{
$type = strtolower($type);
if (!in_array($type, $this->_loaderTypes)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Invalid plugin loader type "%s"; cannot retrieve', $type));
}
if (!array_key_exists($type, $this->_loaders)) {
$prefix = 'Zend_View_';
$pathPrefix = 'Zend/View/';
$pType = ucfirst($type);
switch ($type) {
case 'filter':
case 'helper':
default:
$prefix .= $pType;
$pathPrefix .= $pType;
$loader = new Zend_Loader_PluginLoader(array(
$prefix => $pathPrefix
));
$this->_loaders[$type] = $loader;
break;
}
}
return $this->_loaders[$type];
}
/**
* Adds to the stack of helper paths in LIFO order.
*
* @param string|array The directory (-ies) to add.
* @param string $classPrefix Class prefix to use with classes in this
* directory; defaults to Zend_View_Helper
* @return Zend_View_Abstract
*/
public function addHelperPath($path, $classPrefix = 'Zend_View_Helper_')
{
return $this->_addPluginPath('helper', $classPrefix, (array) $path);
}
/**
* Resets the stack of helper paths.
*
* To clear all paths, use Zend_View::setHelperPath(null).
*
* @param string|array $path The directory (-ies) to set as the path.
* @param string $classPrefix The class prefix to apply to all elements in
* $path; defaults to Zend_View_Helper
* @return Zend_View_Abstract
*/
public function setHelperPath($path, $classPrefix = 'Zend_View_Helper_')
{
unset($this->_loaders['helper']);
return $this->addHelperPath($path, $classPrefix);
}
/**
* Get full path to a helper class file specified by $name
*
* @param string $name
* @return string|false False on failure, path on success
*/
public function getHelperPath($name)
{
return $this->_getPluginPath('helper', $name);
}
/**
* Returns an array of all currently set helper paths
*
* @return array
*/
public function getHelperPaths()
{
return $this->getPluginLoader('helper')->getPaths();
}
/**
* Get a helper by name
*
* @param string $name
* @return object
*/
public function getHelper($name)
{
return $this->_getPlugin('helper', $name);
}
/**
* Get array of all active helpers
*
* Only returns those that have already been instantiated.
*
* @return array
*/
public function getHelpers()
{
return $this->_helper;
}
/**
* Adds to the stack of filter paths in LIFO order.
*
* @param string|array The directory (-ies) to add.
* @param string $classPrefix Class prefix to use with classes in this
* directory; defaults to Zend_View_Filter
* @return Zend_View_Abstract
*/
public function addFilterPath($path, $classPrefix = 'Zend_View_Filter_')
{
return $this->_addPluginPath('filter', $classPrefix, (array) $path);
}
/**
* Resets the stack of filter paths.
*
* To clear all paths, use Zend_View::setFilterPath(null).
*
* @param string|array The directory (-ies) to set as the path.
* @param string $classPrefix The class prefix to apply to all elements in
* $path; defaults to Zend_View_Filter
* @return Zend_View_Abstract
*/
public function setFilterPath($path, $classPrefix = 'Zend_View_Filter_')
{
unset($this->_loaders['filter']);
return $this->addFilterPath($path, $classPrefix);
}
/**
* Get full path to a filter class file specified by $name
*
* @param string $name
* @return string|false False on failure, path on success
*/
public function getFilterPath($name)
{
return $this->_getPluginPath('filter', $name);
}
/**
* Get a filter object by name
*
* @param string $name
* @return object
*/
public function getFilter($name)
{
return $this->_getPlugin('filter', $name);
}
/**
* Return array of all currently active filters
*
* Only returns those that have already been instantiated.
*
* @return array
*/
public function getFilters()
{
return $this->_filter;
}
/**
* Returns an array of all currently set filter paths
*
* @return array
*/
public function getFilterPaths()
{
return $this->getPluginLoader('filter')->getPaths();
}
/**
* Return associative array of path types => paths
*
* @return array
*/
public function getAllPaths()
{
$paths = $this->_path;
$paths['helper'] = $this->getHelperPaths();
$paths['filter'] = $this->getFilterPaths();
return $paths;
}
/**
* Add one or more filters to the stack in FIFO order.
*
* @param string|array One or more filters to add.
* @return Zend_View_Abstract
*/
public function addFilter($name)
{
foreach ((array) $name as $val) {
$this->_filter[] = $val;
}
return $this;
}
/**
* Resets the filter stack.
*
* To clear all filters, use Zend_View::setFilter(null).
*
* @param string|array One or more filters to set.
* @return Zend_View_Abstract
*/
public function setFilter($name)
{
$this->_filter = array();
$this->addFilter($name);
return $this;
}
/**
* Sets the _escape() callback.
*
* @param mixed $spec The callback for _escape() to use.
* @return Zend_View_Abstract
*/
public function setEscape($spec)
{
$this->_escape = $spec;
return $this;
}
/**
* Assigns variables to the view script via differing strategies.
*
* Zend_View::assign('name', $value) assigns a variable called 'name'
* with the corresponding $value.
*
* Zend_View::assign($array) assigns the array keys as variable
* names (with the corresponding array values).
*
* @see __set()
* @param string|array The assignment strategy to use.
* @param mixed (Optional) If assigning a named variable, use this
* as the value.
* @return Zend_View_Abstract Fluent interface
* @throws Zend_View_Exception if $spec is neither a string nor an array,
* or if an attempt to set a private or protected member is detected
*/
public function assign($spec, $value = null)
{
// which strategy to use?
if (is_string($spec)) {
// assign by name and value
if ('_' == substr($spec, 0, 1)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Setting private or protected class members is not allowed', $this);
}
$this->$spec = $value;
} elseif (is_array($spec)) {
// assign from associative array
$error = false;
foreach ($spec as $key => $val) {
if ('_' == substr($key, 0, 1)) {
$error = true;
break;
}
$this->$key = $val;
}
if ($error) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Setting private or protected class members is not allowed', $this);
}
} else {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('assign() expects a string or array, received ' . gettype($spec), $this);
}
return $this;
}
/**
* Return list of all assigned variables
*
* Returns all public properties of the object. Reflection is not used
* here as testing reflection properties for visibility is buggy.
*
* @return array
*/
public function getVars()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ('_' == substr($key, 0, 1)) {
unset($vars[$key]);
}
}
return $vars;
}
/**
* Clear all assigned variables
*
* Clears all variables assigned to Zend_View either via {@link assign()} or
* property overloading ({@link __set()}).
*
* @return void
*/
public function clearVars()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ('_' != substr($key, 0, 1)) {
unset($this->$key);
}
}
}
/**
* Processes a view script and returns the output.
*
* @param string $name The script script name to process.
* @return string The script output.
*/
public function render($name)
{
// find the script file name using the parent private method
$this->_file = $this->_script($name);
unset($name); // remove $name from local scope
ob_start();
$this->_run($this->_file);
return $this->_filter(ob_get_clean()); // filter output
}
/**
* Escapes a value for output in a view script.
*
* If escaping mechanism is one of htmlspecialchars or htmlentities, uses
* {@link $_encoding} setting.
*
* @param mixed $var The output to escape.
* @return mixed The escaped value.
*/
public function escape($var)
{
if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities'))) {
return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_encoding);
}
return call_user_func($this->_escape, $var);
}
/**
* Set encoding to use with htmlentities() and htmlspecialchars()
*
* @param string $encoding
* @return Zend_View_Abstract
*/
public function setEncoding($encoding)
{
$this->_encoding = $encoding;
return $this;
}
/**
* Return current escape encoding
*
* @return string
*/
public function getEncoding()
{
return $this->_encoding;
}
/**
* Enable or disable strict vars
*
* If strict variables are enabled, {@link __get()} will raise a notice
* when a variable is not defined.
*
* Use in conjunction with {@link Zend_View_Helper_DeclareVars the declareVars() helper}
* to enforce strict variable handling in your view scripts.
*
* @param boolean $flag
* @return Zend_View_Abstract
*/
public function strictVars($flag = true)
{
$this->_strictVars = ($flag) ? true : false;
return $this;
}
/**
* Finds a view script from the available directories.
*
* @param $name string The base name of the script.
* @return void
*/
protected function _script($name)
{
if (0 == count($this->_path['script'])) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('no view script directory set; unable to determine location for view script',
$this);
}
foreach ($this->_path['script'] as $dir) {
if (is_readable($dir . $name)) {
return $dir . $name;
}
}
require_once 'Zend/View/Exception.php';
$message = "script '$name' not found in path ("
. implode(PATH_SEPARATOR, $this->_path['script'])
. ")";
throw new Zend_View_Exception($message, $this);
}
/**
* Applies the filter callback to a buffer.
*
* @param string $buffer The buffer contents.
* @return string The filtered buffer.
*/
private function _filter($buffer)
{
// loop through each filter class
foreach ($this->_filter as $name) {
// load and apply the filter class
$filter = $this->getFilter($name);
$buffer = call_user_func(array($filter, 'filter'), $buffer);
}
// done!
return $buffer;
}
/**
* Adds paths to the path stack in LIFO order.
*
* Zend_View::_addPath($type, 'dirname') adds one directory
* to the path stack.
*
* Zend_View::_addPath($type, $array) adds one directory for
* each array element value.
*
* In the case of filter and helper paths, $prefix should be used to
* specify what class prefix to use with the given path.
*
* @param string $type The path type ('script', 'helper', or 'filter').
* @param string|array $path The path specification.
* @param string $prefix Class prefix to use with path (helpers and filters
* only)
* @return void
*/
private function _addPath($type, $path, $prefix = null)
{
foreach ((array) $path as $dir) {
// attempt to strip any possible separator and
// append the system directory separator
$dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $dir);
$dir = rtrim($dir, DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR)
. DIRECTORY_SEPARATOR;
switch ($type) {
case 'script':
// add to the top of the stack.
array_unshift($this->_path[$type], $dir);
break;
case 'filter':
case 'helper':
default:
// add as array with prefix and dir keys
array_unshift($this->_path[$type], array('prefix' => $prefix, 'dir' => $dir));
break;
}
}
}
/**
* Resets the path stack for helpers and filters.
*
* @param string $type The path type ('helper' or 'filter').
* @param string|array $path The directory (-ies) to set as the path.
* @param string $classPrefix Class prefix to apply to elements of $path
*/
private function _setPath($type, $path, $classPrefix = null)
{
$dir = DIRECTORY_SEPARATOR . ucfirst($type) . DIRECTORY_SEPARATOR;
switch ($type) {
case 'script':
$this->_path[$type] = array(dirname(__FILE__) . $dir);
$this->_addPath($type, $path);
break;
case 'filter':
case 'helper':
default:
$this->_path[$type] = array(array(
'prefix' => 'Zend_View_' . ucfirst($type) . '_',
'dir' => dirname(__FILE__) . $dir
));
$this->_addPath($type, $path, $classPrefix);
break;
}
}
/**
* Return all paths for a given path type
*
* @param string $type The path type ('helper', 'filter', 'script')
* @return array
*/
private function _getPaths($type)
{
return $this->_path[$type];
}
/**
* Register helper class as loaded
*
* @param string $name
* @param string $class
* @param string $file path to class file
* @return void
*/
private function _setHelperClass($name, $class, $file)
{
$this->_helperLoadedDir[$name] = $file;
$this->_helperLoaded[$name] = $class;
}
/**
* Register filter class as loaded
*
* @param string $name
* @param string $class
* @param string $file path to class file
* @return void
*/
private function _setFilterClass($name, $class, $file)
{
$this->_filterLoadedDir[$name] = $file;
$this->_filterLoaded[$name] = $class;
}
/**
* Add a prefixPath for a plugin type
*
* @param string $type
* @param string $classPrefix
* @param array $paths
* @return Zend_View_Abstract
*/
private function _addPluginPath($type, $classPrefix, array $paths)
{
$loader = $this->getPluginLoader($type);
foreach ($paths as $path) {
$loader->addPrefixPath($classPrefix, $path);
}
return $this;
}
/**
* Get a path to a given plugin class of a given type
*
* @param string $type
* @param string $name
* @return string|false
*/
private function _getPluginPath($type, $name)
{
$loader = $this->getPluginLoader($type);
if ($loader->isLoaded($name)) {
return $loader->getClassPath($name);
}
try {
$loader->load($name);
return $loader->getClassPath($name);
} catch (Zend_Loader_Exception $e) {
return false;
}
}
/**
* Retrieve a plugin object
*
* @param string $type
* @param string $name
* @return object
*/
private function _getPlugin($type, $name)
{
$name = ucfirst($name);
switch ($type) {
case 'filter':
$storeVar = '_filterClass';
$store = $this->_filterClass;
break;
case 'helper':
$storeVar = '_helper';
$store = $this->_helper;
break;
}
if (!isset($store[$name])) {
$class = $this->getPluginLoader($type)->load($name);
$store[$name] = new $class();
if (method_exists($store[$name], 'setView')) {
$store[$name]->setView($this);
}
}
$this->$storeVar = $store;
return $store[$name];
}
/**
* Use to include the view script in a scope that only allows public
* members.
*
* @return mixed
*/
abstract protected function _run();
}
Exception.php 0000604 00000002133 15071177274 0007221 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 { } Helper/ContentPane.php 0000604 00000003740 15071215236 0010714 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ContentPane.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo ContentPane dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_ContentPane extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.ContentPane';
/**
* Module being used
* @var string
*/
protected $_module = 'dijit.layout.ContentPane';
/**
* dijit.layout.ContentPane
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function contentPane($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}
Helper/DijitContainer.php 0000604 00000005422 15071215236 0011403 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DijitContainer.php 11744 2008-10-08 18:06:15Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dijit layout container base class
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Dojo_View_Helper_DijitContainer extends Zend_Dojo_View_Helper_Dijit
{
/**
* Capture locks
* @var array
*/
protected $_captureLock = array();
/**
* Metadata information to use with captured content
* @var array
*/
protected $_captureInfo = array();
/**
* Begin capturing content for layout container
*
* @param string $id
* @param array $params
* @param array $attribs
* @return void
*/
public function captureStart($id, array $params = array(), array $attribs = array())
{
if (array_key_exists($id, $this->_captureLock)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('Lock already exists for id "%s"', $id));
}
$this->_captureLock[$id] = true;
$this->_captureInfo[$id] = array(
'params' => $params,
'attribs' => $attribs,
);
ob_start();
return;
}
/**
* Finish capturing content for layout container
*
* @param string $id
* @return string
*/
public function captureEnd($id)
{
if (!array_key_exists($id, $this->_captureLock)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_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->_createLayoutContainer($id, $content, $params, $attribs);
}
}
Helper/AccordionContainer.php 0000604 00000012341 15071215236 0012237 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;
}
} Helper/Slider.php 0000604 00000013271 15071215236 0007720 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;
}
} Helper/Dojo.php 0000604 00000011035 15071215236 0007365 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Dojo.php 10024 2008-07-10 14:04:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Registry */
require_once 'Zend/Registry.php';
/**
* Zend_Dojo_View_Helper_Dojo: Dojo View Helper
*
* Allows specifying stylesheets, path to dojo, module paths, and onLoad
* events.
*
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc.
* @license New BSD {@link http://framework.zend.com/license/new-bsd}
*/
class Zend_Dojo_View_Helper_Dojo
{
/**#@+
* @const Programmatic dijit creation style constants
*/
const PROGRAMMATIC_SCRIPT = 1;
const PROGRAMMATIC_NOSCRIPT = -1;
/**#@-*/
/**
* @var Zend_View_Interface
*/
public $view;
/**
* @var Zend_Dojo_View_Helper_Dojo_Container
*/
protected $_container;
/**
* @var bool Whether or not dijits should be declared programmatically
*/
protected static $_useProgrammatic = true;
/**
* 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 'Zend/Dojo/View/Helper/Dojo/Container.php';
$container = new Zend_Dojo_View_Helper_Dojo_Container();
$registry[__CLASS__] = $container;
}
$this->_container = $registry[__CLASS__];
}
/**
* Set view object
*
* @param Zend_Dojo_View_Interface $view
* @return void
*/
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
$this->_container->setView($view);
}
/**
* Return dojo container
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function dojo()
{
return $this->_container;
}
/**
* Proxy to container methods
*
* @param string $method
* @param array $args
* @return mixed
* @throws Zend_Dojo_View_Exception For invalid method calls
*/
public function __call($method, $args)
{
if (!method_exists($this->_container, $method)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('Invalid method "%s" called on dojo view helper', $method));
}
return call_user_func_array(array($this->_container, $method), $args);
}
/**
* Set whether or not dijits should be created declaratively
*
* @return void
*/
public static function setUseDeclarative()
{
self::$_useProgrammatic = false;
}
/**
* Set whether or not dijits should be created programmatically
*
* Optionally, specifiy whether or not dijit helpers should generate the
* programmatic dojo.
*
* @param int $style
* @return void
*/
public static function setUseProgrammatic($style = self::PROGRAMMATIC_SCRIPT)
{
if (!in_array($style, array(self::PROGRAMMATIC_SCRIPT, self::PROGRAMMATIC_NOSCRIPT))) {
$style = self::PROGRAMMATIC_SCRIPT;
}
self::$_useProgrammatic = $style;
}
/**
* Should dijits be created declaratively?
*
* @return bool
*/
public static function useDeclarative()
{
return (false === self::$_useProgrammatic);
}
/**
* Should dijits be created programmatically?
*
* @return bool
*/
public static function useProgrammatic()
{
return (false !== self::$_useProgrammatic);
}
/**
* Should dijits be created programmatically but without scripts?
*
* @return bool
*/
public static function useProgrammaticNoScript()
{
return (self::PROGRAMMATIC_NOSCRIPT === self::$_useProgrammatic);
}
}
Helper/Editor.php 0000604 00000007071 15071215236 0007725 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/** Zend_Dojo_View_Helper_Textarea */
require_once 'Zend/Dojo/View/Helper/Textarea.php';
/** Zend_Json */
require_once 'Zend/Json.php';
/**
* Dojo Editor dijit
*
* @uses Zend_Dojo_View_Helper_Textarea
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Textarea
{
/**
* @param string Dijit type
*/
protected $_dijit = 'dijit.Editor';
/**
* @var string Dijit module to load
*/
protected $_module = 'dijit.Editor';
/**
* JSON-encoded parameters
* @var array
*/
protected $_jsonParams = array('captureEvents', 'events', 'plugins');
/**
* dijit.Editor
*
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @return string
*/
public function editor($id, $value = null, $params = array(), $attribs = array())
{
$hiddenName = $id;
if (array_key_exists('id', $attribs)) {
$hiddenId = $attribs['id'];
} else {
$hiddenId = $hiddenName;
}
$hiddenId = $this->_normalizeId($hiddenId);
$textareaName = $this->_normalizeEditorName($hiddenName);
$textareaId = $hiddenId . '-Editor';
$hiddenAttribs = array(
'id' => $hiddenId,
'name' => $hiddenName,
'value' => $value,
'type' => 'hidden',
);
$attribs['id'] = $textareaId;
$this->_createGetParentFormFunction();
$this->_createEditorOnSubmit($hiddenId, $textareaId);
$html = '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket()
. $this->textarea($textareaName, $value, $params, $attribs);
return $html;
}
/**
* Normalize editor element name
*
* @param string $name
* @return string
*/
protected function _normalizeEditorName($name)
{
if ('[]' == substr($name, -2)) {
$name = substr($name, 0, strlen($name) - 2);
$name .= '[Editor][]';
} else {
$name .= '[Editor]';
}
return $name;
}
/**
* Create onSubmit binding for element
*
* @param string $hiddenId
* @param string $editorId
* @return void
*/
protected function _createEditorOnSubmit($hiddenId, $editorId)
{
$this->dojo->onLoadCaptureStart();
echo <<<EOJ
function() {
var form = zend.findParentForm(dojo.byId('$hiddenId'));
dojo.connect(form, 'onsubmit', function () {
dojo.byId('$hiddenId').value = dijit.byId('$editorId').getValue(false);
});
}
EOJ;
$this->dojo->onLoadCaptureEnd();
}
}
Helper/Dijit.php 0000604 00000020522 15071215236 0007536 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Dijit.php 12281 2008-11-04 14:40:05Z matthew $
*/
/** Zend_View_Helper_HtmlElement */
require_once 'Zend/View/Helper/HtmlElement.php';
/**
* Dojo dijit base class
*
* @uses Zend_View_Helper_Abstract
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Dojo_View_Helper_Dijit extends Zend_View_Helper_HtmlElement
{
/**
* @var Zend_Dojo_View_Helper_Dojo_Container
*/
public $dojo;
/**
* Dijit being used
* @var string
*/
protected $_dijit;
/**
* Element type
* @var string
*/
protected $_elementType;
/**
* Parameters that should be JSON encoded
* @var array
*/
protected $_jsonParams = array('constraints');
/**
* Dojo module to use
* @var string
*/
protected $_module;
/**
* Set view
*
* Set view and enable dojo
*
* @param Zend_View_Interface $view
* @return Zend_Dojo_View_Helper_Dijit
*/
public function setView(Zend_View_Interface $view)
{
parent::setView($view);
$this->dojo = $this->view->dojo();
$this->dojo->enable();
return $this;
}
/**
* Whether or not to use declarative dijit creation
*
* @return bool
*/
protected function _useDeclarative()
{
return Zend_Dojo_View_Helper_Dojo::useDeclarative();
}
/**
* Whether or not to use programmatic dijit creation
*
* @return bool
*/
protected function _useProgrammatic()
{
return Zend_Dojo_View_Helper_Dojo::useProgrammatic();
}
/**
* Whether or not to use programmatic dijit creation w/o script creation
*
* @return bool
*/
protected function _useProgrammaticNoScript()
{
return Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript();
}
/**
* Create a layout container
*
* @param int $id
* @param string $content
* @param array $params
* @param array $attribs
* @param string|null $dijit
* @return string
*/
protected function _createLayoutContainer($id, $content, array $params, array $attribs, $dijit = null)
{
$attribs['id'] = $id;
$attribs = $this->_prepareDijit($attribs, $params, 'layout', $dijit);
$html = '<div' . $this->_htmlAttribs($attribs) . '>'
. $content
. "</div>\n";
return $html;
}
/**
* Create HTML representation of a dijit form element
*
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @param string|null $dijit
* @return string
*/
public function _createFormElement($id, $value, array $params, array $attribs, $dijit = null)
{
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs['name'] = $id;
$attribs['value'] = (string) $value;
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'element', $dijit);
$html = '<input'
. $this->_htmlAttribs($attribs)
. $this->getClosingBracket();
return $html;
}
/**
* Merge attributes and parameters
*
* Also sets up requires
*
* @param array $attribs
* @param array $params
* @param string $type
* @param string $dijit Dijit type to use (otherwise, pull from $_dijit)
* @return array
*/
protected function _prepareDijit(array $attribs, array $params, $type, $dijit = null)
{
$this->dojo->requireModule($this->_module);
switch ($type) {
case 'layout':
$stripParams = array('id');
break;
case 'element':
$stripParams = array('id', 'name', 'value', 'type');
foreach (array('checked', 'disabled', 'readonly') as $attrib) {
if (array_key_exists($attrib, $attribs)) {
if ($attribs[$attrib]) {
$attribs[$attrib] = $attrib;
} else {
unset($attribs[$attrib]);
}
}
}
break;
case 'textarea':
$stripParams = array('id', 'name', 'type');
break;
default:
}
foreach ($stripParams as $param) {
if (array_key_exists($param, $params)) {
unset($params[$param]);
}
}
// Normalize constraints, if present
foreach ($this->_jsonParams as $param) {
if (array_key_exists($param, $params)) {
require_once 'Zend/Json.php';
if (is_array($params[$param])) {
$values = array();
foreach ($params[$param] as $key => $value) {
if (!is_scalar($value)) {
continue;
}
$values[$key] = $value;
}
} elseif (is_string($params[$param])) {
$values = (array) $params[$param];
} else {
$values = array();
}
$values = Zend_Json::encode($values);
if ($this->_useDeclarative()) {
$values = str_replace('"', "'", $values);
}
$params[$param] = $values;
}
}
$dijit = (null === $dijit) ? $this->_dijit : $dijit;
if ($this->_useDeclarative()) {
$attribs = array_merge($attribs, $params);
$attribs['dojoType'] = $dijit;
} elseif (!$this->_useProgrammaticNoScript()) {
$this->_createDijit($dijit, $attribs['id'], $params);
}
return $attribs;
}
/**
* Create a dijit programmatically
*
* @param string $dijit
* @param string $id
* @param array $params
* @return void
*/
protected function _createDijit($dijit, $id, array $params)
{
$params['dojoType'] = $dijit;
array_walk_recursive($params, array($this, '_castBoolToString'));
$this->dojo->setDijit($id, $params);
}
/**
* Cast a boolean to a string value
*
* @param mixed $item
* @param string $key
* @return void
*/
protected function _castBoolToString(&$item, $key)
{
if (!is_bool($item)) {
return;
}
$item = ($item) ? "true" : "false";
}
/**
* Render a hidden element to hold a value
*
* @param string $id
* @param string|int|float $value
* @return string
*/
protected function _renderHiddenElement($id, $value)
{
$hiddenAttribs = array(
'name' => $id,
'value' => (string) $value,
'type' => 'hidden',
);
return '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
}
/**
* Create JS function for retrieving parent form
*
* @return void
*/
protected function _createGetParentFormFunction()
{
$function =<<<EOJ
if (zend == undefined) {
var zend = {};
}
zend.findParentForm = function(elementNode) {
while (elementNode.nodeName.toLowerCase() != 'form') {
elementNode = elementNode.parentNode;
}
return elementNode;
};
EOJ;
$this->dojo->addJavascript($function);
}
}
Helper/FilteringSelect.php 0000604 00000003712 15071215236 0011560 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FilteringSelect.php 9978 2008-07-07 12:39:39Z matthew $
*/
/** Zend_Dojo_View_Helper_ComboBox */
require_once 'Zend/Dojo/View/Helper/ComboBox.php';
/**
* Dojo FilteringSelect dijit
*
* @uses Zend_Dojo_View_Helper_ComboBox
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_FilteringSelect extends Zend_Dojo_View_Helper_ComboBox
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.FilteringSelect';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.FilteringSelect';
/**
* dijit.form.FilteringSelect
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array|null $options Select options
* @return string
*/
public function filteringSelect($id, $value = null, array $params = array(), array $attribs = array(), array $options = null)
{
return $this->comboBox($id, $value, $params, $attribs, $options);
}
}
Helper/VerticalSlider.php 0000604 00000003531 15071215236 0011410 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: VerticalSlider.php 9965 2008-07-06 14:46:20Z matthew $
*/
/** Zend_Dojo_View_Helper_Slider */
require_once 'Zend/Dojo/View/Helper/Slider.php';
/**
* Dojo VerticalSlider dijit
*
* @uses Zend_Dojo_View_Helper_Slider
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_VerticalSlider extends Zend_Dojo_View_Helper_Slider
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.VerticalSlider';
/**
* Slider type
* @var string
*/
protected $_sliderType = 'Vertical';
/**
* dijit.form.VerticalSlider
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function verticalSlider($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->prepareSlider($id, $value, $params, $attribs);
}
}
Helper/SimpleTextarea.php 0000604 00000004345 15071215236 0011427 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* dijit.form.SimpleTextarea view helper
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_SimpleTextarea extends Zend_Dojo_View_Helper_Dijit
{
/**
* @var string Dijit type
*/
protected $_dijit = 'dijit.form.SimpleTextarea';
/**
* @var string HTML element type
*/
protected $_elementType = 'textarea';
/**
* @var string Dojo module
*/
protected $_module = 'dijit.form.SimpleTextarea';
/**
* dijit.form.SimpleTextarea
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function simpleTextarea($id, $value = null, array $params = array(), array $attribs = array())
{
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs['name'] = $id;
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'textarea');
$html = '<textarea' . $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value)
. "</textarea>\n";
return $html;
}
}
Helper/StackContainer.php 0000604 00000003766 15071215236 0011416 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StackContainer.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo StackContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_StackContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.StackContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.StackContainer';
/**
* dijit.layout.StackContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function stackContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}
Helper/TextBox.php 0000604 00000003640 15071215236 0010072 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo TextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_TextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.TextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.TextBox';
/**
* dijit.form.TextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function textBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/TimeTextBox.php 0000604 00000003674 15071215236 0010720 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TimeTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo TimeTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_TimeTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.TimeTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.TimeTextBox';
/**
* dijit.form.TimeTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function timeTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/Dojo/Container.php 0000604 00000061111 15071215236 0011307 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Container.php 11991 2008-10-16 15:12:15Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Dojo */
require_once 'Zend/Dojo.php';
/**
* Container for Dojo View Helper
*
*
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc.
* @license New BSD {@link http://framework.zend.com/license/new-bsd}
*/
class Zend_Dojo_View_Helper_Dojo_Container
{
/**
* @var Zend_View_Interface
*/
public $view;
/**
* addOnLoad capture lock
* @var bool
*/
protected $_captureLock = false;
/**
* addOnLoad object on which to apply lambda
* @var string
*/
protected $_captureObj;
/**
* Base CDN url to utilize
* @var string
*/
protected $_cdnBase = Zend_Dojo::CDN_BASE_GOOGLE;
/**
* Path segment following version string of CDN path
* @var string
*/
protected $_cdnDojoPath = Zend_Dojo::CDN_DOJO_PATH_GOOGLE;
/**
* Dojo version to use from CDN
* @var string
*/
protected $_cdnVersion = '1.2.0';
/**
* Has the dijit loader been registered?
* @var bool
*/
protected $_dijitLoaderRegistered = false;
/**
* Registered programmatic dijits
* @var array
*/
protected $_dijits = array();
/**
* Dojo configuration
* @var array
*/
protected $_djConfig = array();
/**
* Whether or not dojo is enabled
* @var bool
*/
protected $_enabled = false;
/**
* Are we rendering as XHTML?
* @var bool
*/
protected $_isXhtml = false;
/**
* Arbitrary javascript to include in dojo script
* @var array
*/
protected $_javascriptStatements = array();
/**
* Dojo layers (custom builds) to use
* @var array
*/
protected $_layers = array();
/**
* Relative path to dojo
* @var string
*/
protected $_localPath = null;
/**
* Root of dojo where all dojo files are installed
* @var string
*/
protected $_localRelativePath = null;
/**
* Modules to require
* @var array
*/
protected $_modules = array();
/**
* Registered module paths
* @var array
*/
protected $_modulePaths = array();
/**
* Actions to perform on window load
* @var array
*/
protected $_onLoadActions = array();
/**
* Register the Dojo stylesheet?
* @var bool
*/
protected $_registerDojoStylesheet = false;
/**
* Style sheet modules to load
* @var array
*/
protected $_stylesheetModules = array();
/**
* Local stylesheets
* @var array
*/
protected $_stylesheets = array();
/**
* Set view object
*
* @param Zend_Dojo_View_Interface $view
* @return void
*/
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
}
/**
* Enable dojo
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function enable()
{
$this->_enabled = true;
return $this;
}
/**
* Disable dojo
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function disable()
{
$this->_enabled = false;
return $this;
}
/**
* Is dojo enabled?
*
* @return bool
*/
public function isEnabled()
{
return $this->_enabled;
}
/**
* Specify a module to require
*
* @param string $module
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function requireModule($module)
{
if (!is_string($module) && !is_array($module)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception('Invalid module name specified; must be a string or an array of strings');
}
$module = (array) $module;
foreach ($module as $mod) {
if (!preg_match('/^[a-z][a-z0-9._-]+$/i', $mod)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('Module name specified, "%s", contains invalid characters', (string) $mod));
}
if (!in_array($mod, $this->_modules)) {
$this->_modules[] = $mod;
}
}
return $this;
}
/**
* Retrieve list of modules to require
*
* @return array
*/
public function getModules()
{
return $this->_modules;
}
/**
* Register a module path
*
* @param string $path
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function registerModulePath($module, $path)
{
$path = (string) $path;
if (!in_array($module, $this->_modulePaths)) {
$this->_modulePaths[$module] = $path;
}
return $this;
}
/**
* List registered module paths
*
* @return array
*/
public function getModulePaths()
{
return $this->_modulePaths;
}
/**
* Add layer (custom build) path
*
* @param string $path
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addLayer($path)
{
$path = (string) $path;
if (!in_array($path, $this->_layers)) {
$this->_layers[] = $path;
}
return $this;
}
/**
* Get registered layers
*
* @return array
*/
public function getLayers()
{
return $this->_layers;
}
/**
* Remove a registered layer
*
* @param string $path
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function removeLayer($path)
{
$path = (string) $path;
$layers = array_flip($this->_layers);
if (array_key_exists($path, $layers)) {
unset($layers[$path]);
$this->_layers = array_keys($layers);
}
return $this;
}
/**
* Clear all registered layers
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function clearLayers()
{
$this->_layers = array();
return $this;
}
/**
* Set CDN base path
*
* @param string $url
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setCdnBase($url)
{
$this->_cdnBase = (string) $url;
return $this;
}
/**
* Return CDN base URL
*
* @return string
*/
public function getCdnBase()
{
return $this->_cdnBase;
}
/**
* Use CDN, using version specified
*
* @param string $version
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setCdnVersion($version = null)
{
$this->enable();
if (preg_match('/^[1-9]\.[0-9](\.[0-9])?$/', $version)) {
$this->_cdnVersion = $version;
}
return $this;
}
/**
* Get CDN version
*
* @return string
*/
public function getCdnVersion()
{
return $this->_cdnVersion;
}
/**
* Set CDN path to dojo (relative to CDN base + version)
*
* @param string $path
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setCdnDojoPath($path)
{
$this->_cdnDojoPath = (string) $path;
return $this;
}
/**
* Get CDN path to dojo (relative to CDN base + version)
*
* @return string
*/
public function getCdnDojoPath()
{
return $this->_cdnDojoPath;
}
/**
* Are we using the CDN?
*
* @return bool
*/
public function useCdn()
{
return !$this->useLocalPath();
}
/**
* Set path to local dojo
*
* @param string $path
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setLocalPath($path)
{
$this->enable();
$this->_localPath = (string) $path;
return $this;
}
/**
* Get local path to dojo
*
* @return string
*/
public function getLocalPath()
{
return $this->_localPath;
}
/**
* Are we using a local path?
*
* @return bool
*/
public function useLocalPath()
{
return (null === $this->_localPath) ? false : true;
}
/**
* Set Dojo configuration
*
* @param string $option
* @param mixed $value
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setDjConfig(array $config)
{
$this->_djConfig = $config;
return $this;
}
/**
* Set Dojo configuration option
*
* @param string $option
* @param mixed $value
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setDjConfigOption($option, $value)
{
$option = (string) $option;
$this->_djConfig[$option] = $value;
return $this;
}
/**
* Retrieve dojo configuration values
*
* @return array
*/
public function getDjConfig()
{
return $this->_djConfig;
}
/**
* Get dojo configuration value
*
* @param string $option
* @param mixed $default
* @return mixed
*/
public function getDjConfigOption($option, $default = null)
{
$option = (string) $option;
if (array_key_exists($option, $this->_djConfig)) {
return $this->_djConfig[$option];
}
return $default;
}
/**
* Add a stylesheet by module name
*
* @param string $module
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addStylesheetModule($module)
{
if (!preg_match('/^[a-z0-9]+\.[a-z0-9_-]+(\.[a-z0-9_-]+)*$/i', $module)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception('Invalid stylesheet module specified');
}
if (in_array($module, $this->_stylesheetModules)) {
return $this;
}
$this->_stylesheetModules[] = $module;
return $this;
}
/**
* Get all stylesheet modules currently registered
*
* @return array
*/
public function getStylesheetModules()
{
return $this->_stylesheetModules;
}
/**
* Add a stylesheet
*
* @param string $path
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addStylesheet($path)
{
$path = (string) $path;
if (!in_array($path, $this->_stylesheets)) {
$this->_stylesheets[] = (string) $path;
}
return $this;
}
/**
* Register the dojo.css stylesheet?
*
* With no arguments, returns the status of the flag; with arguments, sets
* the flag and returns the object.
*
* @param null|bool $flag
* @return Zend_Dojo_View_Helper_Dojo_Container|bool
*/
public function registerDojoStylesheet($flag = null)
{
if (null === $flag) {
return $this->_registerDojoStylesheet;
}
$this->_registerDojoStylesheet = (bool) $flag;
return $this;
}
/**
* Retrieve registered stylesheets
*
* @return array
*/
public function getStylesheets()
{
return $this->_stylesheets;
}
/**
* Add a script to execute onLoad
*
* dojo.addOnLoad accepts:
* - function name
* - lambda
*
* @param string $callback Lambda
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addOnLoad($callback)
{
if (!in_array($callback, $this->_onLoadActions, true)) {
$this->_onLoadActions[] = $callback;
}
return $this;
}
/**
* Retrieve all registered onLoad actions
*
* @return array
*/
public function getOnLoadActions()
{
return $this->_onLoadActions;
}
/**
* Start capturing routines to run onLoad
*
* @return bool
*/
public function onLoadCaptureStart()
{
if ($this->_captureLock) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception('Cannot nest onLoad captures');
}
$this->_captureLock = true;
ob_start();
return;
}
/**
* Stop capturing routines to run onLoad
*
* @return bool
*/
public function onLoadCaptureEnd()
{
$data = ob_get_clean();
$this->_captureLock = false;
$this->addOnLoad($data);
return true;
}
/**
* Add a programmatic dijit
*
* @param string $id
* @param array $params
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addDijit($id, array $params)
{
if (array_key_exists($id, $this->_dijits)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('Duplicate dijit with id "%s" already registered', $id));
}
$this->_dijits[$id] = array(
'id' => $id,
'params' => $params,
);
return $this;
}
/**
* Set a programmatic dijit (overwrites)
*
* @param string $id
* @param array $params
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setDijit($id, array $params)
{
$this->removeDijit($id);
return $this->addDijit($id, $params);
}
/**
* Add multiple dijits at once
*
* Expects an array of id => array $params pairs
*
* @param array $dijits
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addDijits(array $dijits)
{
foreach ($dijits as $id => $params) {
$this->addDijit($id, $params);
}
return $this;
}
/**
* Set multiple dijits at once (overwrites)
*
* Expects an array of id => array $params pairs
*
* @param array $dijits
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function setDijits(array $dijits)
{
$this->clearDijits();
return $this->addDijits($dijits);
}
/**
* Is the given programmatic dijit already registered?
*
* @param string $id
* @return bool
*/
public function hasDijit($id)
{
return array_key_exists($id, $this->_dijits);
}
/**
* Retrieve a dijit by id
*
* @param string $id
* @return array|null
*/
public function getDijit($id)
{
if ($this->hasDijit($id)) {
return $this->_dijits[$id]['params'];
}
return null;
}
/**
* Retrieve all dijits
*
* Returns dijits as an array of assoc arrays
*
* @return array
*/
public function getDijits()
{
return array_values($this->_dijits);
}
/**
* Remove a programmatic dijit if it exists
*
* @param string $id
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function removeDijit($id)
{
if (array_key_exists($id, $this->_dijits)) {
unset($this->_dijits[$id]);
}
return $this;
}
/**
* Clear all dijits
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function clearDijits()
{
$this->_dijits = array();
return $this;
}
/**
* Render dijits as JSON structure
*
* @return string
*/
public function dijitsToJson()
{
require_once 'Zend/Json.php';
return Zend_Json::encode($this->getDijits());
}
/**
* Create dijit loader functionality
*
* @return void
*/
public function registerDijitLoader()
{
if (!$this->_dijitLoaderRegistered) {
$js =<<<EOJ
function() {
dojo.forEach(zendDijits, function(info) {
var n = dojo.byId(info.id);
if (null != n) {
dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
}
});
dojo.parser.parse();
}
EOJ;
$this->requireModule('dojo.parser');
$this->addOnLoad($js);
$this->addJavascript('var zendDijits = ' . $this->dijitsToJson() . ';');
$this->_dijitLoaderRegistered = true;
}
}
/**
* Add arbitrary javascript to execute in dojo JS container
*
* @param string $js
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function addJavascript($js)
{
$js = preg_replace('/^\s*(.*?)\s*$/s', '$1', $js);
if (!in_array(substr($js, -1), array(';', '}'))) {
$js .= ';';
}
if (in_array($js, $this->_javascriptStatements)) {
return $this;
}
$this->_javascriptStatements[] = $js;
return $this;
}
/**
* Return all registered javascript statements
*
* @return array
*/
public function getJavascript()
{
return $this->_javascriptStatements;
}
/**
* Clear arbitrary javascript stack
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function clearJavascript()
{
$this->_javascriptStatements = array();
return $this;
}
/**
* Capture arbitrary javascript to include in dojo script
*
* @return void
*/
public function javascriptCaptureStart()
{
if ($this->_captureLock) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception('Cannot nest captures');
}
$this->_captureLock = true;
ob_start();
return;
}
/**
* Finish capturing arbitrary javascript to include in dojo script
*
* @return true
*/
public function javascriptCaptureEnd()
{
$data = ob_get_clean();
$this->_captureLock = false;
$this->addJavascript($data);
return true;
}
/**
* String representation of dojo environment
*
* @return string
*/
public function __toString()
{
if (!$this->isEnabled()) {
return '';
}
$this->_isXhtml = $this->view->doctype()->isXhtml();
if (Zend_Dojo_View_Helper_Dojo::useDeclarative()) {
if (null === $this->getDjConfigOption('parseOnLoad')) {
$this->setDjConfigOption('parseOnLoad', true);
}
}
if (!empty($this->_dijits)) {
$this->registerDijitLoader();
}
$html = $this->_renderStylesheets() . PHP_EOL
. $this->_renderDjConfig() . PHP_EOL
. $this->_renderDojoScriptTag() . PHP_EOL
. $this->_renderLayers() . PHP_EOL
. $this->_renderExtras();
return $html;
}
/**
* Retrieve local path to dojo resources for building relative paths
*
* @return string
*/
protected function _getLocalRelativePath()
{
if (null === $this->_localRelativePath) {
$localPath = $this->getLocalPath();
$localPath = preg_replace('|[/\\\\]dojo[/\\\\]dojo.js[^/\\\\]*$|i', '', $localPath);
$this->_localRelativePath = $localPath;
}
return $this->_localRelativePath;
}
/**
* Render dojo stylesheets
*
* @return string
*/
protected function _renderStylesheets()
{
if ($this->useCdn()) {
$base = $this->getCdnBase()
. $this->getCdnVersion();
} else {
$base = $this->_getLocalRelativePath();
}
$registeredStylesheets = $this->getStylesheetModules();
foreach ($registeredStylesheets as $stylesheet) {
$themeName = substr($stylesheet, strrpos($stylesheet, '.') + 1);
$stylesheet = str_replace('.', '/', $stylesheet);
$stylesheets[] = $base . '/' . $stylesheet . '/' . $themeName . '.css';
}
foreach ($this->getStylesheets() as $stylesheet) {
$stylesheets[] = $stylesheet;
}
if ($this->_registerDojoStylesheet) {
$stylesheets[] = $base . '/dojo/resources/dojo.css';
}
if (empty($stylesheets)) {
return '';
}
array_reverse($stylesheets);
$style = '<style type="text/css">' . PHP_EOL
. (($this->_isXhtml) ? '<!--' : '<!--') . PHP_EOL;
foreach ($stylesheets as $stylesheet) {
$style .= ' @import "' . $stylesheet . '";' . PHP_EOL;
}
$style .= (($this->_isXhtml) ? '-->' : '-->') . PHP_EOL
. '</style>';
return $style;
}
/**
* Render DjConfig values
*
* @return string
*/
protected function _renderDjConfig()
{
$djConfigValues = $this->getDjConfig();
if (empty($djConfigValues)) {
return '';
}
require_once 'Zend/Json.php';
$scriptTag = '<script type="text/javascript">' . PHP_EOL
. (($this->_isXhtml) ? '//<![CDATA[' : '//<!--') . PHP_EOL
. ' var djConfig = ' . Zend_Json::encode($djConfigValues) . ';' . PHP_EOL
. (($this->_isXhtml) ? '//]]>' : '//-->') . PHP_EOL
. '</script>';
return $scriptTag;
}
/**
* Render dojo script tag
*
* Renders Dojo script tag by utilizing either local path provided or the
* CDN. If any djConfig values were set, they will be serialized and passed
* with that attribute.
*
* @return string
*/
protected function _renderDojoScriptTag()
{
if ($this->useCdn()) {
$source = $this->getCdnBase()
. $this->getCdnVersion()
. $this->getCdnDojoPath();
} else {
$source = $this->getLocalPath();
}
$scriptTag = '<script type="text/javascript" src="' . $source . '"></script>';
return $scriptTag;
}
/**
* Render layers (custom builds) as script tags
*
* @return string
*/
protected function _renderLayers()
{
$layers = $this->getLayers();
if (empty($layers)) {
return '';
}
$html = array();
foreach ($layers as $path) {
$html[] = sprintf(
'<script type="text/javascript" src="%s"></script>',
htmlentities($path, ENT_QUOTES)
);
}
return implode("\n", $html);
}
/**
* Render dojo module paths and requires
*
* @return string
*/
protected function _renderExtras()
{
$js = array();
$modulePaths = $this->getModulePaths();
if (!empty($modulePaths)) {
foreach ($modulePaths as $module => $path) {
$js[] = 'dojo.registerModulePath("' . $this->view->escape($module) . '", "' . $this->view->escape($path) . '");';
}
}
$modules = $this->getModules();
if (!empty($modules)) {
foreach ($modules as $module) {
$js[] = 'dojo.require("' . $this->view->escape($module) . '");';
}
}
$onLoadActions = array();
foreach ($this->getOnLoadActions() as $callback) {
$onLoadActions[] = 'dojo.addOnLoad(' . $callback . ');';
}
$javascript = implode("\n ", $this->getJavascript());
$content = '';
if (!empty($js)) {
$content .= implode("\n ", $js) . "\n";
}
if (!empty($onLoadActions)) {
$content .= implode("\n ", $onLoadActions) . "\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;
}
}
Helper/BorderContainer.php 0000604 00000004664 15071215236 0011564 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: BorderContainer.php 12378 2008-11-07 18:39:20Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo BorderContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_BorderContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.BorderContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.BorderContainer';
/**
* Ensure style is only registered once
* @var bool
*/
protected $_styleIsRegistered = false;
/**
* dijit.layout.BorderContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function borderContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
// this will ensure that the border container is viewable:
if (!$this->_styleIsRegistered) {
$this->view->headStyle()->appendStyle('html, body { height: 100%; width: 100%; margin: 0; padding: 0; }');
$this->_styleIsRegistered = true;
}
// and now we create it:
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}
Helper/PasswordTextBox.php 0000604 00000003516 15071215236 0011617 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PasswordTextBox.php 10667 2008-08-05 13:00:56Z matthew $
*/
/** Zend_Dojo_View_Helper_ValidationTextBox */
require_once 'Zend/Dojo/View/Helper/ValidationTextBox.php';
/**
* Dojo ValidationTextBox dijit tied to password input
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_PasswordTextBox extends Zend_Dojo_View_Helper_ValidationTextBox
{
/**
* HTML element type
* @var string
*/
protected $_elementType = 'password';
/**
* dijit.form.ValidationTextBox tied to password input
*
* @param string $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function passwordTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/RadioButton.php 0000604 00000005447 15071215236 0010736 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RadioButton.php 10091 2008-07-15 03:46:37Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo RadioButton dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_RadioButton extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.RadioButton';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.CheckBox';
/**
* dijit.form.RadioButton
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array $options Array of radio options
* @param string $listsep String with which to separate options
* @return string
*/
public function radioButton(
$id,
$value = null,
array $params = array(),
array $attribs = array(),
array $options = null,
$listsep = "<br />\n"
) {
$attribs['name'] = $id;
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs = $this->_prepareDijit($attribs, $params, 'element');
if (is_array($options) && $this->_useProgrammatic() && !$this->_useProgrammaticNoScript()) {
$baseId = $id;
if (array_key_exists('id', $attribs)) {
$baseId = $attribs['id'];
}
require_once 'Zend/Filter/Alnum.php';
$filter = new Zend_Filter_Alnum();
foreach (array_keys($options) as $key) {
$optId = $baseId . '-' . $filter->filter($key);
$this->_createDijit($this->_dijit, $optId, array());
}
}
return $this->view->formRadio($id, $value, $attribs, $options, $listsep);
}
}
Helper/AccordionPane.php 0000604 00000005072 15071215236 0011203 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);
}
} Helper/Button.php 0000604 00000003766 15071215236 0007761 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Button.php 10091 2008-07-15 03:46:37Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo Button dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_Button extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.Button';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.Button';
/**
* dijit.form.Button
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function button($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs['name'] = $id;
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs = $this->_prepareDijit($attribs, $params, 'element');
return $this->view->formButton($id, $value, $attribs);
}
}
Helper/NumberSpinner.php 0000604 00000005417 15071215236 0011270 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NumberSpinner.php 10043 2008-07-11 15:41:54Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo NumberSpinner dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_NumberSpinner extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.NumberSpinner';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.NumberSpinner';
/**
* dijit.form.NumberSpinner
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function numberSpinner($id, $value = null, array $params = array(), array $attribs = array())
{
// Get constraints and serialize to JSON if necessary
if (array_key_exists('constraints', $params)) {
if (!is_array($params['constraints'])) {
unset($params['constraints']);
}
} else {
$constraints = array();
if (array_key_exists('min', $params)) {
$constraints['min'] = $params['min'];
unset($params['min']);
}
if (array_key_exists('max', $params)) {
$constraints['max'] = $params['max'];
unset($params['max']);
}
if (array_key_exists('places', $params)) {
$constraints['places'] = $params['places'];
unset($params['places']);
}
$params['constraints'] = $constraints;
}
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/SubmitButton.php 0000604 00000004344 15071215236 0011136 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SubmitButton.php 12692 2008-11-18 20:30:09Z matthew $
*/
/** Zend_Dojo_View_Helper_Button */
require_once 'Zend/Dojo/View/Helper/Button.php';
/**
* Dojo Button dijit tied to submit input
*
* @uses Zend_Dojo_View_Helper_Button
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_SubmitButton extends Zend_Dojo_View_Helper_Button
{
/**
* @var string Submit input
*/
protected $_elementType = 'submit';
/**
* dijit.form.Button tied to submit input
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function submitButton($id, $value = null, array $params = array(), array $attribs = array())
{
if (!array_key_exists('label', $params)) {
$params['label'] = $value;
}
if (empty($params['label']) && !empty($params['content'])) {
$params['label'] = $params['content'];
$value = $params['content'];
}
if (empty($params['label']) && !empty($attribs['content'])) {
$params['label'] = $attribs['content'];
$value = $attribs['content'];
unset($attribs['content']);
}
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/CheckBox.php 0000604 00000006225 15071215236 0010165 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CheckBox.php 11292 2008-09-08 18:51:39Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo CheckBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_CheckBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.CheckBox';
/**
* Element type
* @var string
*/
protected $_elementType = 'checkbox';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.CheckBox';
/**
* dijit.form.CheckBox
*
* @param int $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array $checkedOptions Should contain either two items, or the keys checkedValue and unCheckedValue
* @return string
*/
public function checkBox($id, $value = null, array $params = array(), array $attribs = array(), array $checkedOptions = null)
{
// Prepare the checkbox options
require_once 'Zend/View/Helper/FormCheckbox.php';
$checked = false;
if (isset($attribs['checked']) && $attribs['checked']) {
$checked = true;
} elseif (isset($attribs['checked'])) {
$checked = false;
}
$checkboxInfo = Zend_View_Helper_FormCheckbox::determineCheckboxInfo($value, $checked, $checkedOptions);
$attribs['checked'] = $checkboxInfo['checked'];
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs = $this->_prepareDijit($attribs, $params, 'element');
// strip options so they don't show up in markup
if (array_key_exists('options', $attribs)) {
unset($attribs['options']);
}
// and now we create it:
$html = '';
if (!strstr($id, '[]')) {
// hidden element for unchecked value
$html .= $this->_renderHiddenElement($id, $checkboxInfo['unCheckedValue']);
}
// and final element
$html .= $this->_createFormElement($id, $checkboxInfo['checkedValue'], $params, $attribs);
return $html;
}
}
Helper/HorizontalSlider.php 0000604 00000003547 15071215236 0011777 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HorizontalSlider.php 9965 2008-07-06 14:46:20Z matthew $
*/
/** Zend_Dojo_View_Helper_Slider */
require_once 'Zend/Dojo/View/Helper/Slider.php';
/**
* Dojo HorizontalSlider dijit
*
* @uses Zend_Dojo_View_Helper_Slider
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_HorizontalSlider extends Zend_Dojo_View_Helper_Slider
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.HorizontalSlider';
/**
* Slider type
* @var string
*/
protected $_sliderType = 'Horizontal';
/**
* dijit.form.HorizontalSlider
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function horizontalSlider($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->prepareSlider($id, $value, $params, $attribs);
}
}
Helper/SplitContainer.php 0000604 00000003766 15071215236 0011444 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SplitContainer.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo SplitContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_SplitContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.SplitContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.SplitContainer';
/**
* dijit.layout.SplitContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function splitContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}
Helper/ComboBox.php 0000604 00000011621 15071215236 0010203 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ComboBox.php 11014 2008-08-24 21:15:31Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo ComboBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_ComboBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.ComboBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.ComboBox';
/**
* dijit.form.ComboBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array|null $options Select options
* @return string
*/
public function comboBox($id, $value = null, array $params = array(), array $attribs = array(), array $options = null)
{
$html = '';
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
if (array_key_exists('store', $params) && is_array($params['store'])) {
// using dojo.data datastore
if (false !== ($store = $this->_renderStore($params['store']))) {
$params['store'] = $params['store']['store'];
if (is_string($store)) {
$html .= $store;
}
$html .= $this->_createFormElement($id, $value, $params, $attribs);
return $html;
}
unset($params['store']);
} elseif (array_key_exists('store', $params)) {
if (array_key_exists('storeType', $params)) {
$storeParams = array(
'store' => $params['store'],
'type' => $params['storeType'],
);
unset($params['storeType']);
if (array_key_exists('storeParams', $params)) {
$storeParams['params'] = $params['storeParams'];
unset($params['storeParams']);
}
if (false !== ($store = $this->_renderStore($storeParams))) {
if (is_string($store)) {
$html .= $store;
}
}
}
$html .= $this->_createFormElement($id, $value, $params, $attribs);
return $html;
}
// do as normal select
$attribs = $this->_prepareDijit($attribs, $params, 'element');
return $this->view->formSelect($id, $value, $attribs, $options);
}
/**
* Render data store element
*
* Renders to dojo view helper
*
* @param array $params
* @return string|false
*/
protected function _renderStore(array $params)
{
if (!array_key_exists('store', $params) || !array_key_exists('type', $params)) {
return false;
}
$this->dojo->requireModule($params['type']);
$extraParams = array();
$storeParams = array(
'dojoType' => $params['type'],
'jsId' => $params['store'],
);
if (array_key_exists('params', $params)) {
$storeParams = array_merge($storeParams, $params['params']);
$extraParams = $params['params'];
}
if ($this->_useProgrammatic()) {
if (!$this->_useProgrammaticNoScript()) {
$this->dojo->addJavascript('var ' . $storeParams['jsId'] . ';');
require_once 'Zend/Json.php';
$js = "function() {\n"
. ' ' . $storeParams['jsId'] . ' = '
. 'new ' . $storeParams['dojoType'] . '('
. Zend_Json::encode($extraParams)
. ");\n}";
$this->dojo->addOnLoad($js);
}
return true;
}
return '<div' . $this->_htmlAttribs($storeParams) . '></div>';
}
}
Helper/ValidationTextBox.php 0000604 00000003746 15071215236 0012114 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ValidationTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo ValidationTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_ValidationTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.ValidationTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.ValidationTextBox';
/**
* dijit.form.ValidationTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function validationTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/CurrencyTextBox.php 0000604 00000003730 15071215236 0011605 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CurrencyTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo CurrencyTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_CurrencyTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.CurrencyTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.CurrencyTextBox';
/**
* dijit.form.CurrencyTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function currencyTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/TabContainer.php 0000604 00000010255 15071215236 0011046 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;
}
} Helper/NumberTextBox.php 0000604 00000003712 15071215236 0011243 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NumberTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo NumberTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_NumberTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.NumberTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.NumberTextBox';
/**
* dijit.form.NumberTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function numberTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/Textarea.php 0000604 00000004353 15071215236 0010254 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Textarea.php 10256 2008-07-21 14:09:27Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo Textarea dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_Textarea extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.Textarea';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.Textarea';
/**
* dijit.form.Textarea
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function textarea($id, $value = null, array $params = array(), array $attribs = array())
{
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs['name'] = $id;
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'textarea');
$html = '<textarea' . $this->_htmlAttribs($attribs) . '>'
. $value
. "</textarea>\n";
return $html;
}
}
Helper/DateTextBox.php 0000604 00000003674 15071215236 0010677 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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DateTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo DateTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_View_Helper_DateTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.DateTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.DateTextBox';
/**
* dijit.form.DateTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function dateTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}
Helper/ColorPicker.php 0000604 00000004164 15071255372 0010720 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);
}
} Helper/Spinner.php 0000604 00000004231 15071255372 0010115 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);
}
} Helper/JQuery/Container.php 0000604 00000046306 15071255372 0011651 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;
}
} Helper/UiWidget.php 0000604 00000004456 15071255372 0010231 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;
}
} Helper/TabPane.php 0000604 00000004353 15071255372 0010016 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);
}
} Helper/DialogContainer.php 0000604 00000004240 15071255372 0011541 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;
}
} Helper/DatePicker.php 0000604 00000011156 15071255372 0010516 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;
}
} Helper/AutoComplete.php 0000604 00000006313 15071255372 0011103 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);
}
} Helper/AjaxLink.php 0000604 00000030523 15071255372 0010203 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;
}
} Helper/UiWidgetPane.php 0000604 00000006125 15071255372 0011030 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());
} Helper/JQuery.php 0000604 00000010415 15071255372 0007717 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':'$');
}
}