/libraries/joomla/html/pane.php

https://github.com/andreatarr/joomla-platform · PHP · 417 lines · 143 code · 47 blank · 227 comment · 12 complexity · 674fb6d9d1de0b47de2f4ecc527588fc MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Platform
  4. * @subpackage HTML
  5. *
  6. * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * JPane abstract class
  12. *
  13. * @package Joomla.Platform
  14. * @subpackage HTML
  15. * @since 11.1
  16. * @deprecated 12.1 Use JHtml::_ static helpers
  17. */
  18. abstract class JPane extends JObject
  19. {
  20. public $useCookies = false;
  21. /**
  22. * Returns a JPanel object.
  23. *
  24. * @param string $behavior The behavior to use.
  25. * @param array $params Associative array of values.
  26. *
  27. * @return object
  28. *
  29. * @deprecated 12.1
  30. * @since 11.1
  31. *
  32. */
  33. public static function getInstance($behavior = 'Tabs', $params = array())
  34. {
  35. // Deprecation warning.
  36. JLog::add('JPane::getInstance is deprecated.', JLog::WARNING, 'deprecated');
  37. $classname = 'JPane' . $behavior;
  38. $instance = new $classname($params);
  39. return $instance;
  40. }
  41. /**
  42. * Creates a pane and creates the javascript object for it.
  43. *
  44. * @param string $id The pane identifier.
  45. *
  46. * @return string
  47. *
  48. * @since 11.1
  49. *
  50. * @deprecated 12.1
  51. */
  52. abstract public function startPane($id);
  53. /**
  54. * Ends the pane.
  55. *
  56. * @since 11.1
  57. *
  58. * @return string
  59. *
  60. * @deprecated 12.1
  61. */
  62. abstract public function endPane();
  63. /**
  64. * Creates a panel with title text and starts that panel.
  65. *
  66. * @param string $text The panel name and/or title.
  67. * @param string $id The panel identifer.
  68. *
  69. * @return string
  70. *
  71. * @deprecated 12.1
  72. * @since 11.1
  73. */
  74. abstract public function startPanel($text, $id);
  75. /**
  76. * Ends a panel.
  77. *
  78. * @return string
  79. *
  80. * @since 11.1
  81. * @deprecated 12.1
  82. */
  83. abstract public function endPanel();
  84. /**
  85. * Load the javascript behavior and attach it to the document.
  86. *
  87. * @return void
  88. *
  89. * @deprecated 12.1
  90. * @since 11.1
  91. */
  92. abstract protected function _loadBehavior();
  93. }
  94. /**
  95. * JPanelTabs class to to draw parameter panes.
  96. *
  97. * @package Joomla.Platform
  98. * @subpackage HTML
  99. * @since 11.1
  100. * @deprecated Use JHtml::_ static helpers
  101. */
  102. class JPaneTabs extends JPane
  103. {
  104. /**
  105. * Constructor.
  106. *
  107. * @param array $params Associative array of values
  108. *
  109. * @return void
  110. *
  111. * @since 11.1
  112. */
  113. function __construct($params = array())
  114. {
  115. // Deprecation warning.
  116. JLog::add('JPaneTabs is deprecated.', JLog::WARNING, 'deprecated');
  117. static $loaded = false;
  118. parent::__construct($params);
  119. if (!$loaded)
  120. {
  121. $this->_loadBehavior($params);
  122. $loaded = true;
  123. }
  124. }
  125. /**
  126. * Creates a pane and creates the javascript object for it.
  127. *
  128. * @param string $id The pane identifier.
  129. *
  130. * @return string HTML to start the pane dl
  131. *
  132. * @since 11.1
  133. *
  134. * @deprecated 12.1
  135. */
  136. public function startPane($id)
  137. {
  138. // Deprecation warning.
  139. JLog::add('JPane::startPane is deprecated.', JLog::WARNING, 'deprecated');
  140. return '<dl class="tabs" id="' . $id . '">';
  141. }
  142. /**
  143. * Ends the pane.
  144. *
  145. * @return string HTML to end the pane dl
  146. *
  147. * @since 11.1
  148. *
  149. * @deprecated 12.1
  150. */
  151. public function endPane()
  152. {
  153. // Deprecation warning.
  154. JLog::add('JPaneTabs::endPane is deprecated.', JLog::WARNING, 'deprecated');
  155. return "</dl>";
  156. }
  157. /**
  158. * Creates a tab panel with title text and starts that panel.
  159. *
  160. * @param string $text The name of the tab
  161. * @param string $id The tab identifier
  162. *
  163. * @return string HTML for the dt tag.
  164. *
  165. * @since 11.1
  166. *
  167. * @deprecated 12.1
  168. */
  169. public function startPanel($text, $id)
  170. {
  171. // Deprecation warning.
  172. JLog::add('JPaneTabs::startPanel is deprecated.', JLog::WARNING, 'deprecated');
  173. return '<dt class="' . $id . '"><span>' . $text . '</span></dt><dd>';
  174. }
  175. /**
  176. * Ends a tab page.
  177. *
  178. * @return string HTML for the dd tag.
  179. *
  180. * @since 11.1
  181. *
  182. * @deprecated 12.1
  183. */
  184. public function endPanel()
  185. {
  186. // Deprecation warning.
  187. JLog::add('JPaneTabs::endPanel is deprecated.', JLog::WARNING, 'deprecated');
  188. return "</dd>";
  189. }
  190. /**
  191. * Load the javascript behavior and attach it to the document.
  192. *
  193. * @param array $params Associative array of values
  194. *
  195. * @return void
  196. *
  197. * @since 11.1
  198. * @deprecated 12.1
  199. */
  200. protected function _loadBehavior($params = array())
  201. {
  202. // Deprecation warning.
  203. JLog::add('JPaneTabs::_loadBehavior is deprecated.', JLog::WARNING, 'deprecated');
  204. // Include mootools framework
  205. JHtml::_('behavior.framework', true);
  206. $document = JFactory::getDocument();
  207. $options = '{';
  208. $opt['onActive'] = (isset($params['onActive'])) ? $params['onActive'] : null;
  209. $opt['onBackground'] = (isset($params['onBackground'])) ? $params['onBackground'] : null;
  210. $opt['display'] = (isset($params['startOffset'])) ? (int) $params['startOffset'] : null;
  211. foreach ($opt as $k => $v)
  212. {
  213. if ($v)
  214. {
  215. $options .= $k . ': ' . $v . ',';
  216. }
  217. }
  218. if (substr($options, -1) == ',')
  219. {
  220. $options = substr($options, 0, -1);
  221. }
  222. $options .= '}';
  223. $js = ' window.addEvent(\'domready\', function(){ $$(\'dl.tabs\').each(function(tabs){ new JTabs(tabs, ' . $options . '); }); });';
  224. $document->addScriptDeclaration($js);
  225. JHtml::_('script', 'system/tabs.js', false, true);
  226. }
  227. }
  228. /**
  229. * JPanelSliders class to to draw parameter panes.
  230. *
  231. * @package Joomla.Platform
  232. * @subpackage HTML
  233. * @since 11.1
  234. *
  235. * @deprecated Use JHtml::_ static helpers
  236. */
  237. class JPaneSliders extends JPane
  238. {
  239. /**
  240. * Constructor.
  241. *
  242. * @param array $params Associative array of values.
  243. *
  244. * @since 11.1
  245. *
  246. * @deprecated 12.1
  247. */
  248. function __construct($params = array())
  249. {
  250. // Deprecation warning.
  251. JLog::add('JPanelSliders::__construct is deprecated.', JLog::WARNING, 'deprecated');
  252. static $loaded = false;
  253. parent::__construct($params);
  254. if (!$loaded)
  255. {
  256. $this->_loadBehavior($params);
  257. $loaded = true;
  258. }
  259. }
  260. /**
  261. * Creates a pane and creates the javascript object for it.
  262. *
  263. * @param string $id The pane identifier.
  264. *
  265. * @return string HTML to start the slider div.
  266. *
  267. * @since 11.1
  268. *
  269. * @deprecated 12.1
  270. */
  271. public function startPane($id)
  272. {
  273. // Deprecation warning.
  274. JLog::add('JPaneSliders::startPane is deprecated.', JLog::WARNING, 'deprecated');
  275. return '<div id="' . $id . '" class="pane-sliders">';
  276. }
  277. /**
  278. * Ends the pane.
  279. *
  280. * @return string HTML to end the slider div.
  281. *
  282. * @since 11.1
  283. *
  284. * @deprecated 12.1
  285. */
  286. public function endPane()
  287. {
  288. // Deprecation warning.
  289. JLog::add('JPaneSliders::endPane is deprecated.', JLog::WARNING, 'deprecated');
  290. return '</div>';
  291. }
  292. /**
  293. * Creates a tab panel with title text and starts that panel.
  294. *
  295. * @param string $text The name of the tab.
  296. * @param string $id The tab identifier.
  297. *
  298. * @return string HTML to start the tab panel div.
  299. *
  300. * @since 11.1
  301. *
  302. * @deprecated 12.1
  303. */
  304. public function startPanel($text, $id)
  305. {
  306. // Deprecation warning.
  307. JLog::add('JPaneSliders::startPanel is deprecated.', JLog::WARNING, 'deprecated');
  308. return '<div class="panel">' . '<h3 class="pane-toggler title" id="' . $id . '"><a href="javascript:void(0);"><span>' . $text
  309. . '</span></a></h3>' . '<div class="pane-slider content">';
  310. }
  311. /**
  312. * Ends a tab page.
  313. *
  314. * @return string HTML to end the tab divs.
  315. *
  316. * @since 11.1
  317. *
  318. * @deprecated 12.1
  319. */
  320. public function endPanel()
  321. {
  322. // Deprecation warning.
  323. JLog::add('JPaneSliders::endPanel is deprecated.', JLog::WARNING, 'deprecated');
  324. return '</div></div>';
  325. }
  326. /**
  327. * Load the javascript behavior and attach it to the document.
  328. *
  329. * @param array $params Associative array of values.
  330. *
  331. * @return void
  332. *
  333. * @since 11.1
  334. *
  335. * @deprecated 12.1
  336. */
  337. protected function _loadBehavior($params = array())
  338. {
  339. // Deprecation warning.
  340. JLog::add('JPaneSliders::_loadBehavior is deprecated.', JLog::WARNING, 'deprecated');
  341. // Include mootools framework.
  342. JHtml::_('behavior.framework', true);
  343. $document = JFactory::getDocument();
  344. $options = '{';
  345. $opt['onActive'] = 'function(toggler, i) { toggler.addClass(\'pane-toggler-down\');' .
  346. ' toggler.removeClass(\'pane-toggler\');i.addClass(\'pane-down\');i.removeClass(\'pane-hide\'); }';
  347. $opt['onBackground'] = 'function(toggler, i) { toggler.addClass(\'pane-toggler\');' .
  348. ' toggler.removeClass(\'pane-toggler-down\');i.addClass(\'pane-hide\');i.removeClass(\'pane-down\'); }';
  349. $opt['duration'] = (isset($params['duration'])) ? (int) $params['duration'] : 300;
  350. $opt['display'] = (isset($params['startOffset']) && ($params['startTransition'])) ? (int) $params['startOffset'] : null;
  351. $opt['show'] = (isset($params['startOffset']) && (!$params['startTransition'])) ? (int) $params['startOffset'] : null;
  352. $opt['opacity'] = (isset($params['opacityTransition']) && ($params['opacityTransition'])) ? 'true' : 'false';
  353. $opt['alwaysHide'] = (isset($params['allowAllClose']) && (!$params['allowAllClose'])) ? 'false' : 'true';
  354. foreach ($opt as $k => $v)
  355. {
  356. if ($v)
  357. {
  358. $options .= $k . ': ' . $v . ',';
  359. }
  360. }
  361. if (substr($options, -1) == ',')
  362. {
  363. $options = substr($options, 0, -1);
  364. }
  365. $options .= '}';
  366. $js = ' window.addEvent(\'domready\', function(){ new Fx.Accordion($$(\'.panel h3.pane-toggler\'), $$(\'.panel div.pane-slider\'), '
  367. . $options . '); });';
  368. $document->addScriptDeclaration($js);
  369. }
  370. }