Lithron.LCssDropDownMenu
[ class tree: Lithron.LCssDropDownMenu ] [ index: Lithron.LCssDropDownMenu ] [ all elements ]

Source for file LCssDropDownMenu.php

Documentation is available at LCssDropDownMenu.php

  1. <?php
  2.  
  3. /**
  4. * TCssDropDownMenu class file
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the BSD License.
  8. *
  9. * Copyright(c) 2004 by Scott Fuelberth.
  10. *
  11. * To contact the author write to {@link mailto:skot@bastardcat.org Scott Fuelberth}
  12. * The latest version of PRADO can be obtained from:
  13. * {@link http://prado.sourceforge.net/}
  14. *
  15. * =================================================
  16. * NOTICE: This is an pre-alpha version for PRADO v3
  17. * -- VERY UNTESTED! -- USER FEATURES DISABLED --
  18. * author: Tobias Munk <webmaster@lithron.de>
  19. * =================================================
  20. *
  21. * @author Scott Fuelberth <skot@bastardcat.org>
  22. * @version $Revision: 188 $ $Date: 2006-05-11 10:50:16 +0200 (Do, 11 Mai 2006) $
  23. * @package Lithron.LCssDropDownMenu
  24. * @subpackage WebControls
  25. */
  26.  
  27. /**
  28. * TCssDropDownMenu class file class
  29. *
  30. * TCssDropDownMenu class file displays a css driven menu on a Web page. You can set the alignment of the menu
  31. * through the <b>Horizontal</b> property.
  32. *
  33. * Example: <code><com:TCssDropDownMenu Horizontal="false" /></code>
  34. *
  35. * Namespace: Lithron.Web.UI.WebControls
  36. *
  37. * Properties
  38. * - <b>Horizontal</b>, boolean, kept in viewstate
  39. * <br>Sets the alignment of the menu, true = horizontal and false = vertical.
  40. * - <b>CssHorizontalFile</b>, string, kept in view state
  41. * <br>Sets the css file to be used for horizontal menus
  42. * - <b>CssVerticalFile</b>, string, kept in view state
  43. * <br>Sets the css file to be used for vertical menus
  44. * - <b>CssDirectory</b>, string, kept in view state
  45. * <br>Sets the css file directory
  46. * - <b>JsDirectory</b>, string, kept in view state
  47. * <br>Set the javascript directory
  48. * - <b>JsFile</b>, string, kept in view state
  49. * <br>Set the javascript filename
  50. * - <b>TopParentNodeCssClass</b>, string, kept in view state
  51. * <br>Set the css class name of the top most TCssDropDownMenuNode
  52. * - <b>ParentNodeCssClass<b>, string, kept in view state
  53. * <br>Set the css class name of parent (nodes with children nodes) TCssDropDownMenuNodes
  54. * - <b>NodeCssClass</b>, string, kept in view state
  55. * <br>Set the node css class name of ending TCssDropDownMenuNodes
  56. * - <b>DisabledCssClass</b>, string kept in view state
  57. * <br>Set the node css class name of disabled TCssDropDownMenuNodes
  58. *
  59. * Note, that the default css files need to be located under the root of your site unders js/cssdropdownmenu/css with
  60. * cssdropdownmenu-horizontal.css and cssdropdownmenu-vertical.css controlling the aligments. There is also a small
  61. * javascript file for IE non-support of the virtual tage hover. Based off the work of Son of Suckerfish by
  62. * Patrick Griffiths and Dan Webb, see http://www.htmldog.com/articles/suckerfish/dropdowns/
  63. *
  64. * @package System.Web.UI.WebControls
  65. */
  66. class LCssDropDownMenu extends TWebControl
  67. {
  68. private $_tagName;
  69.  
  70. protected function getTagName()
  71. {
  72. return $this->_tagName;
  73. }
  74.  
  75. function setTagName($value)
  76. {
  77. $this->_tagName = $value;
  78. }
  79.  
  80. /**
  81. * Constructor.
  82. * Sets TagName property to 'ul'
  83. */
  84. function __construct()
  85. {
  86. parent :: __construct();
  87. $this->setTagName('ul');
  88. }
  89.  
  90. /**
  91. * @return string the disabled menu node css class
  92. * the css class name
  93. */
  94. function getDisabledCssClass()
  95. {
  96. return $this->getViewState('DisabledCssClass', '');
  97. }
  98.  
  99. /**
  100. * @param string the menu alignment
  101. * css class name
  102. */
  103. function setDisabledCssClass($value)
  104. {
  105. $this->setViewState('DisabledCssClass', $value, '');
  106. }
  107.  
  108. /**
  109. * @return boolean the menu alignment
  110. * true means a horizontal menu, false means a vertical menu
  111. */
  112. function getHorizontal()
  113. {
  114. return $this->getViewState('Horizontal', '');
  115. }
  116.  
  117. /**
  118. * @param boolean the menu alignment
  119. * true means a horizontal menu, false means a vertical menu
  120. */
  121. function setHorizontal($value)
  122. {
  123. $this->setViewState('Horizontal', $value);
  124. }
  125.  
  126. /**
  127. * @return string the name of the css horizontal file
  128. */
  129. function getCssHorizontalFile()
  130. {
  131. return $this->getViewState('CssHorizontalFile');
  132. }
  133.  
  134. /**
  135. * @param boolean the name of the css horizontal file
  136. */
  137. function setCssHorizontalFile($value)
  138. {
  139. $this->setViewState('CssHorizontalFile', $value);
  140. }
  141.  
  142. /**
  143. * @return string the name of the css vertical file
  144. */
  145. function getCssVerticalFile()
  146. {
  147. return $this->getViewState('CssVerticalFile');
  148. }
  149.  
  150. /**
  151. * @param boolean the name of the css vertical file
  152. */
  153. function setCssVerticalFile($value)
  154. {
  155. $this->setViewState('CssVerticalFile', $value, '');
  156. }
  157.  
  158. /**
  159. * @return string the name of the css directory
  160. */
  161. function getCssDirectory()
  162. {
  163. return $this->getViewState('CssDirectory', 'js/cssdropdownmenu/css');
  164. }
  165.  
  166. /**
  167. * @param boolean the name of the css directory
  168. */
  169. function setCssDirectory($value)
  170. {
  171. $this->setViewState('CssDirectory', $value, 'js/cssdropdownmenu/css');
  172. }
  173.  
  174. /**
  175. * @return string the name of the js directory
  176. */
  177. function getJsDirectory()
  178. {
  179. return $this->getViewState('JsDirectory', 'js/cssdropdownmenu');
  180. }
  181.  
  182. /**
  183. * @param boolean the name of the js directory
  184. */
  185. function setJsDirectory($value)
  186. {
  187. $this->setViewState('JsDirectory', $value, 'js/cssdropdownmenu');
  188. }
  189.  
  190. /**
  191. * @return string the name of the js file
  192. */
  193. function getJsFile()
  194. {
  195. return $this->getViewState('JsFile', 'cssdropdownmenu.js');
  196. }
  197.  
  198. /**
  199. * @param boolean the name of the js file
  200. */
  201. function setJsFile($value)
  202. {
  203. $this->setViewState('JsFile', $value, 'cssdropdownmenu.js');
  204. }
  205.  
  206. /**
  207. * @return string the top level parent node css class name
  208. */
  209. function getTopParentNodeCssClass()
  210. {
  211. return $this->getViewState('TopParentNodeCssClass', '');
  212. }
  213.  
  214. /**
  215. * @param string the top level parent node css class name
  216. */
  217. function setTopParentNodeCssClass($value)
  218. {
  219. $this->setViewState('TopParentNodeCssClass', $value, '');
  220. }
  221.  
  222. /**
  223. * @return string the parent node css class name
  224. */
  225. function getParentNodeCssClass()
  226. {
  227. return $this->getViewState('ParentNodeCssClass', '');
  228. }
  229.  
  230. /**
  231. * @param string the parent node css class name
  232. */
  233. function setParentNodeCssClass($value)
  234. {
  235. $this->setViewState('ParentNodeCssClass', $value, '');
  236. }
  237.  
  238. /**
  239. * @return string the node css class name
  240. */
  241. function getNodeCssClass()
  242. {
  243. return $this->getViewState('NodeCssClass', '');
  244. }
  245.  
  246. /**
  247. * @param string the node css class name
  248. */
  249. function setNodeCssClass($value)
  250. {
  251. $this->setViewState('NodeCssClass', $value, '');
  252. }
  253.  
  254. /**
  255. * @param boolean the name of the css horizontal asset
  256. */
  257. function setCssHorizontalAsset($value)
  258. {
  259. $this->setViewState('CssHorizontalAsset', $value);
  260. }
  261. /**
  262. * @return string the name of the css horizontal asset
  263. */
  264. function getCssHorizontalAsset()
  265. {
  266. $asset = $this->getViewState('CssHorizontalAsset', 'assets/horizontal.css');
  267. return $this->publishAsset($asset);
  268. #$this->setViewState('JsAsset',$value);
  269. }
  270.  
  271. /**
  272. * @param boolean the name of the css vertical asset
  273. */
  274. function setCssVerticalAsset($value)
  275. {
  276. $this->setViewState('CssVerticalAsset', $value);
  277. }
  278.  
  279. /**
  280. * @return string the name of the css vertical asset
  281. */
  282. function getCssVerticalAsset()
  283. {
  284. $asset = $this->getViewState('CssVerticalAsset', 'assets/vertical.css');
  285. return $this->publishAsset($asset);
  286. #$this->setViewState('JsAsset',$value);
  287. }
  288.  
  289. /**
  290. * @param boolean the name of the js asset
  291. */
  292. function setJsAsset($value)
  293. {
  294. $this->setViewState('JsAsset', $value);
  295. }
  296.  
  297. /**
  298. * @return string the name of the js asset
  299. */
  300. function getJsAsset()
  301. {
  302. $asset = $this->getViewState('JsAsset', 'assets/script.js');
  303. return $this->publishAsset($asset);
  304. #$this->setViewState('JsAsset',$value);
  305. }
  306.  
  307. /**
  308. * Renders the menu, and itinitialize top parent nodes css.
  309. * @return void
  310. */
  311. function render($writer)
  312. {
  313. #Prado :: trace("Begin Menu render", 'System.Lithron.LPageService');
  314. $body = $this->getControls();
  315. foreach ($body as $item)
  316. {
  317. if ($item instanceof LCssDropDownMenuNode)
  318. {
  319. //$this->setCssClass(" parent");
  320. $item->setTopParent(true);
  321. $item->setTopParentNodeCssClass($this->getTopParentNodeCssClass());
  322. $item->setParentNodeCssClass($this->getParentNodeCssClass());
  323. $item->setNodeCssClass($this->getNodeCssClass());
  324. $item->setDisabledNodeCssClass($this->getDisabledCssClass());
  325. }
  326. }
  327. #Prado :: trace("End Menu render", 'System.Lithron.LPageService');
  328. parent :: render($writer);
  329. }
  330.  
  331. /**
  332. * Menu initialization
  333. * @return void
  334. */
  335. function onLoad($param)
  336. {
  337. #Prado :: trace("Initializing TCssDropDownMenu ...", 'Lithron.LCssDrownDownMenu');
  338.  
  339. $this->publishAsset('assets/rightarrow.gif'); // TODO
  340. $scriptMgr = $this->getPage()->getClientScript();
  341. $scriptMgr->registerStyleSheetFile('LCssDropDownMenu:Shared', $this->publishAsset("assets/shared.css"));
  342. #Prado :: trace("Registering menu CSS file", 'Lithron.LCssDrownDownMenu');
  343. $scriptMgr->registerScriptFile('LCssDropDownMenu:Js', $this->getJsAsset());
  344. #Prado :: trace("Registering menu JS file", 'Lithron.LCssDrownDownMenu');
  345. if ($this->getHorizontal())
  346. {
  347. $this->setCssClass("menuS menuH");
  348. $cssFile = $this->getCssHorizontalAsset();
  349. $scriptMgr->registerStyleSheetFile('LCssDropDownMenu:Horizontal', $cssFile);
  350.  
  351. } else
  352. {
  353. $this->setCssClass("menuS menuV");
  354. $cssFile = $this->getCssVerticalAsset();
  355. $scriptMgr->registerStyleSheetFile('LCssDropDownMenu:Vertical', $cssFile);
  356. }
  357.  
  358. parent :: onLoad($param);
  359. #Prado :: trace("TCssDropDownMenu onLoad finished", 'Lithron.LCssDrownDownMenu');
  360. }
  361.  
  362. }
  363. ?>

Documentation generated on Tue, 20 Jun 2006 05:15:05 +0200 by phpDocumentor 1.3.0RC4