/usr/share/php/libzend-framework-php/ZendX/JQuery/View/Helper/AccordionContainer.php is in libzend-framework-zendx-php 1.11.11-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category ZendX
* @package ZendX_JQuery
* @subpackage View
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: 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;
}
}
|