- <?php
-
- /**
- * TCssDropDownMenu class file
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the BSD License.
- *
- * Copyright(c) 2004 by Scott Fuelberth.
- *
- * To contact the author write to {@link mailto:skot@bastardcat.org Scott Fuelberth}
- * The latest version of PRADO can be obtained from:
- * {@link http://prado.sourceforge.net/}
- *
- * =================================================
- * NOTICE: This is an pre-alpha version for PRADO v3
- * -- VERY UNTESTED! -- USER FEATURES DISABLED --
- * author: Tobias Munk <webmaster@lithron.de>
- * =================================================
- *
- * @author Scott Fuelberth <skot@bastardcat.org>
- * @version $Revision: 188 $ $Date: 2006-05-11 10:50:16 +0200 (Do, 11 Mai 2006) $
- * @package Lithron.LCssDropDownMenu
- * @subpackage WebControls
- */
-
- /**
- * TCssDropDownMenu class file class
- *
- * TCssDropDownMenu class file displays a css driven menu on a Web page. You can set the alignment of the menu
- * through the <b>Horizontal</b> property.
- *
- * Example: <code><com:TCssDropDownMenu Horizontal="false" /></code>
- *
- * Namespace: Lithron.Web.UI.WebControls
- *
- * Properties
- * - <b>Horizontal</b>, boolean, kept in viewstate
- * <br>Sets the alignment of the menu, true = horizontal and false = vertical.
- * - <b>CssHorizontalFile</b>, string, kept in view state
- * <br>Sets the css file to be used for horizontal menus
- * - <b>CssVerticalFile</b>, string, kept in view state
- * <br>Sets the css file to be used for vertical menus
- * - <b>CssDirectory</b>, string, kept in view state
- * <br>Sets the css file directory
- * - <b>JsDirectory</b>, string, kept in view state
- * <br>Set the javascript directory
- * - <b>JsFile</b>, string, kept in view state
- * <br>Set the javascript filename
- * - <b>TopParentNodeCssClass</b>, string, kept in view state
- * <br>Set the css class name of the top most TCssDropDownMenuNode
- * - <b>ParentNodeCssClass<b>, string, kept in view state
- * <br>Set the css class name of parent (nodes with children nodes) TCssDropDownMenuNodes
- * - <b>NodeCssClass</b>, string, kept in view state
- * <br>Set the node css class name of ending TCssDropDownMenuNodes
- * - <b>DisabledCssClass</b>, string kept in view state
- * <br>Set the node css class name of disabled TCssDropDownMenuNodes
- *
- * Note, that the default css files need to be located under the root of your site unders js/cssdropdownmenu/css with
- * cssdropdownmenu-horizontal.css and cssdropdownmenu-vertical.css controlling the aligments. There is also a small
- * javascript file for IE non-support of the virtual tage hover. Based off the work of Son of Suckerfish by
- * Patrick Griffiths and Dan Webb, see http://www.htmldog.com/articles/suckerfish/dropdowns/
- *
- * @package System.Web.UI.WebControls
- */
- class LCssDropDownMenu extends TWebControl
- {
- private $_tagName;
-
- protected function getTagName()
- {
- return $this->_tagName;
- }
-
- function setTagName($value)
- {
- $this->_tagName = $value;
- }
-
- /**
- * Constructor.
- * Sets TagName property to 'ul'
- */
- function __construct()
- {
- parent :: __construct();
- $this->setTagName('ul');
- }
-
- /**
- * @return string the disabled menu node css class
- * the css class name
- */
- function getDisabledCssClass()
- {
- return $this->getViewState('DisabledCssClass', '');
- }
-
- /**
- * @param string the menu alignment
- * css class name
- */
- function setDisabledCssClass($value)
- {
- $this->setViewState('DisabledCssClass', $value, '');
- }
-
- /**
- * @return boolean the menu alignment
- * true means a horizontal menu, false means a vertical menu
- */
- function getHorizontal()
- {
- return $this->getViewState('Horizontal', '');
- }
-
- /**
- * @param boolean the menu alignment
- * true means a horizontal menu, false means a vertical menu
- */
- function setHorizontal($value)
- {
- $this->setViewState('Horizontal', $value);
- }
-
- /**
- * @return string the name of the css horizontal file
- */
- function getCssHorizontalFile()
- {
- return $this->getViewState('CssHorizontalFile');
- }
-
- /**
- * @param boolean the name of the css horizontal file
- */
- function setCssHorizontalFile($value)
- {
- $this->setViewState('CssHorizontalFile', $value);
- }
-
- /**
- * @return string the name of the css vertical file
- */
- function getCssVerticalFile()
- {
- return $this->getViewState('CssVerticalFile');
- }
-
- /**
- * @param boolean the name of the css vertical file
- */
- function setCssVerticalFile($value)
- {
- $this->setViewState('CssVerticalFile', $value, '');
- }
-
- /**
- * @return string the name of the css directory
- */
- function getCssDirectory()
- {
- return $this->getViewState('CssDirectory', 'js/cssdropdownmenu/css');
- }
-
- /**
- * @param boolean the name of the css directory
- */
- function setCssDirectory($value)
- {
- $this->setViewState('CssDirectory', $value, 'js/cssdropdownmenu/css');
- }
-
- /**
- * @return string the name of the js directory
- */
- function getJsDirectory()
- {
- return $this->getViewState('JsDirectory', 'js/cssdropdownmenu');
- }
-
- /**
- * @param boolean the name of the js directory
- */
- function setJsDirectory($value)
- {
- $this->setViewState('JsDirectory', $value, 'js/cssdropdownmenu');
- }
-
- /**
- * @return string the name of the js file
- */
- function getJsFile()
- {
- return $this->getViewState('JsFile', 'cssdropdownmenu.js');
- }
-
- /**
- * @param boolean the name of the js file
- */
- function setJsFile($value)
- {
- $this->setViewState('JsFile', $value, 'cssdropdownmenu.js');
- }
-
- /**
- * @return string the top level parent node css class name
- */
- function getTopParentNodeCssClass()
- {
- return $this->getViewState('TopParentNodeCssClass', '');
- }
-
- /**
- * @param string the top level parent node css class name
- */
- function setTopParentNodeCssClass($value)
- {
- $this->setViewState('TopParentNodeCssClass', $value, '');
- }
-
- /**
- * @return string the parent node css class name
- */
- function getParentNodeCssClass()
- {
- return $this->getViewState('ParentNodeCssClass', '');
- }
-
- /**
- * @param string the parent node css class name
- */
- function setParentNodeCssClass($value)
- {
- $this->setViewState('ParentNodeCssClass', $value, '');
- }
-
- /**
- * @return string the node css class name
- */
- function getNodeCssClass()
- {
- return $this->getViewState('NodeCssClass', '');
- }
-
- /**
- * @param string the node css class name
- */
- function setNodeCssClass($value)
- {
- $this->setViewState('NodeCssClass', $value, '');
- }
-
- /**
- * @param boolean the name of the css horizontal asset
- */
- function setCssHorizontalAsset($value)
- {
- $this->setViewState('CssHorizontalAsset', $value);
- }
- /**
- * @return string the name of the css horizontal asset
- */
- function getCssHorizontalAsset()
- {
- $asset = $this->getViewState('CssHorizontalAsset', 'assets/horizontal.css');
- return $this->publishAsset($asset);
- #$this->setViewState('JsAsset',$value);
- }
-
- /**
- * @param boolean the name of the css vertical asset
- */
- function setCssVerticalAsset($value)
- {
- $this->setViewState('CssVerticalAsset', $value);
- }
-
- /**
- * @return string the name of the css vertical asset
- */
- function getCssVerticalAsset()
- {
- $asset = $this->getViewState('CssVerticalAsset', 'assets/vertical.css');
- return $this->publishAsset($asset);
- #$this->setViewState('JsAsset',$value);
- }
-
- /**
- * @param boolean the name of the js asset
- */
- function setJsAsset($value)
- {
- $this->setViewState('JsAsset', $value);
- }
-
- /**
- * @return string the name of the js asset
- */
- function getJsAsset()
- {
- $asset = $this->getViewState('JsAsset', 'assets/script.js');
- return $this->publishAsset($asset);
- #$this->setViewState('JsAsset',$value);
- }
-
- /**
- * Renders the menu, and itinitialize top parent nodes css.
- * @return void
- */
- function render($writer)
- {
- #Prado :: trace("Begin Menu render", 'System.Lithron.LPageService');
- $body = $this->getControls();
- foreach ($body as $item)
- {
- if ($item instanceof LCssDropDownMenuNode)
- {
- //$this->setCssClass(" parent");
- $item->setTopParent(true);
- $item->setTopParentNodeCssClass($this->getTopParentNodeCssClass());
- $item->setParentNodeCssClass($this->getParentNodeCssClass());
- $item->setNodeCssClass($this->getNodeCssClass());
- $item->setDisabledNodeCssClass($this->getDisabledCssClass());
- }
- }
- #Prado :: trace("End Menu render", 'System.Lithron.LPageService');
- parent :: render($writer);
- }
-
- /**
- * Menu initialization
- * @return void
- */
- function onLoad($param)
- {
- #Prado :: trace("Initializing TCssDropDownMenu ...", 'Lithron.LCssDrownDownMenu');
-
- $this->publishAsset('assets/rightarrow.gif'); // TODO
- $scriptMgr = $this->getPage()->getClientScript();
- $scriptMgr->registerStyleSheetFile('LCssDropDownMenu:Shared', $this->publishAsset("assets/shared.css"));
- #Prado :: trace("Registering menu CSS file", 'Lithron.LCssDrownDownMenu');
- $scriptMgr->registerScriptFile('LCssDropDownMenu:Js', $this->getJsAsset());
- #Prado :: trace("Registering menu JS file", 'Lithron.LCssDrownDownMenu');
- if ($this->getHorizontal())
- {
- $this->setCssClass("menuS menuH");
- $cssFile = $this->getCssHorizontalAsset();
- $scriptMgr->registerStyleSheetFile('LCssDropDownMenu:Horizontal', $cssFile);
-
- } else
- {
- $this->setCssClass("menuS menuV");
- $cssFile = $this->getCssVerticalAsset();
- $scriptMgr->registerStyleSheetFile('LCssDropDownMenu:Vertical', $cssFile);
- }
-
- parent :: onLoad($param);
- #Prado :: trace("TCssDropDownMenu onLoad finished", 'Lithron.LCssDrownDownMenu');
- }
-
- }
- ?>