HTML_TreeMenuDocumentationIntroductionHTML_TreeMenuisasetofPHPclassestoenabletheeasycreationofHTMLbasedtreemenus.
ItcurrentlyhastheabilitytocreatebothDHTML,staticandlistboxmenus.
AllhavetheprerequisiteofJavascript,howevertheJavscriptcodecouldbeusedmanually,withoutthePHPclasses.
AuthorsHTML_TreeMenuwaswrittenbyRichardHeyesandHaraldRadi.
Contributions/patcheshavealsobeenreceivedandincorporatedfromvariouspeople.
FeaturesEasytolearnOObasedAPIDHTML(traditional)orlistbox()outputstylesMultiplemenusperpageCrossbrowserDOMcompatibleDHTMLOptionalbranchstatuspersistenceusingcookiesOptionalstaticmodewithoutDHTML(stillrequiresJavascriptsupport)Pernodeiconwithalternate"expanded"iconPernodeCSSclassspecificationPernodelinktargetsPernodeJavascripteventspecificationwithcustomonExpand,onCollapseandonToggleeventsAbilitytospecifyfrommenucreationifanodeisexpandedbydefault,andifitshouldbemadetobevisible(ieitsparentsareexpanded)StructureOverviewTherearefiveclassesintotal:HTML_TreeMenuThe"toplevel"treeclass.
HTML_TreeNodeThenodeclass.
HTML_TreeMenu_PresentationAnabstractbaseclassforthenexttwoclasses.
HTML_TreeMenu_DHTMLProducesaDHTMLstylemenu.
HTML_TreeMenu_ListboxProducesalistboxmenu.
TheHTML_TreeNodeclassisusedtocreatethestructurewhichisaddedtoaninstanceoftheHTML_TreeMenuclass.
Thisisinturnpassedtoaninstanceofeitherofthepresentationclasses(DHTMLorListbox).
Thesetwo"presentation"classeshaveaprintMenu()methodwhichcanbecalledtoprinttheresultingmenu.
ExampleSeetheexample.
phpfileforthecode.
Thiscodemakesasimplemenuwithtworootnodes,eachwithfivenestednodes.
ThecodegoesaboutcreatingtheinitialHTML_TreeMenuobject,andthencreatesthenodestobeadded.
Thenodesarethenaddedtothemenuobject,whichitselfisthenpassedtoaninstanceoftheHTML_TreeMenu_DHTMLobject(throughtheconstructor)andalsoanHTML_TreeMenu_Listboxobject.
ThenfollowssomeHTMLinwhichtheprintMenu()methodofeachpresentationobjectiscalledtoshowthemenus.
NotetheuseofreferenceswhenassigningthereturnofaddItem().
Failuretoassignbyreferencewillcauseproblems.
APIReferenceHTML_TreeMenuMethods&addItem(object&$node)ThismethodisusedtoaddaHTML_TreeNodetothetree.
IttakesaHTML_TreeNodeasitssoleargumentandreturnsareferencetothenodeinsidetheTreeMenuobject.
createFromStructure(array$params)Thismethodisanextremelyusefuloneifyoualreadyhaveatreestructuredefinedusingoneofthesupportedtreeclasses.
Ittakessaidtreestructureandreturnsatreemenubaseduponit.
Thistakestheworkoutoftraversingyourtreeandcreatingthestructureyourself.
ThesupportedtreestructuresareRichardHeyes'Treeclass(http://www.
phpguru.
org/tree.
html)andWolframKriesings'TreeclassavailablethroughPEARhttp://pear.
php.
net/Tree.
The$paramsargumentshouldbeanassociativearraywhichcanconsistofthefollowing:structureThetreestructuretypeThetype.
Defaultsto'heyes'.
Canalsobe'kriesing'.
nodeOptionsDefaultHTML_TreeNodeoptionswhichareusedwhilstbuildingthemenu.
InthecaseofmyownTreeclass,thesewillbemergedwiththetagdata.
ThereturnvalueistheHTML_TreeMenuobject.
createFromXML(mixed$xml)ThismethodwillcreateanHTML_TreeMenuobjectfromthesupplied$xmlargument.
ThisargumentcaneitherbeastringcontainingtheXML,oraPEAR::XML_Treeobject.
Iftheargumentisastring,themethodwillattempttorequire()theXML_TreeclassusingstandardPEARtechniques(ie:require_once('XML/Tree.
php')),andthencreateanXML_Treeobjectbasedonthestring.
ThemethodwillthenconverttheXML_TreeobjecttoaTreeclassusingmyownTreeclass(availablehere:http://phpguru.
org/tree.
html)sothisfile(Tree.
php)MUSTbeinclude()edorrequire()edbeforecallingthismethod.
IftheTreeclasscannotbefound,thismethodwilldie().
Onceconverted,themethodwillthenusethecreateFromStructure()methoddescribedabovetocreateanHTML_TreeMenuobjectandreturnit.
ForfurtherinformationonusingthismethodandtheXMLschemaseethecasestudybelow.
HTML_TreeNodeMethodsConstructor([array$options[,array$events]])Theconstructorhandlessettingupthenodeobjectbasedontheoptionssupplied.
The$optionsargumentshouldbeanassociativearraywhichcanconsistofthefollowing:textTitleofthenode,defaultstoblank.
linkHREFofthelink,defaultstoblank.
iconFilenameoftheicon.
Shouldbeintheimagesdirectoryassuppliedtothepresentationobject.
expandedIconFilenameoftheicontobeusedwhenthenodeisexpanded.
classCSSclassforthisnode,defaultstoblank.
expandedDefaultexpandedstatusofthisnode.
Defaultstofalse,andhasnoeffectonnondynamicpresentations.
linkTargetTargetforthelink.
DefaultstolinkTargetofthepresentationclass.
isDynamicIfthisnodeisdynamicornot.
Defaultstotrue.
ensureVisibleIftrue,thisnodewillbemadevisibleregardlessoftheexpandedsettingsandclientsidepersistence.
Defaultstofalse.
ThesecondargumentisanassociativearrayofJavascripteventsandassociatedhandlercode.
Thiscanalsoincludethreecustomevents:onexpand,oncollapse,andontoggle,whichshouldbeselfexplanatory.
Thisargumentcouldalsobesuppliedastheeventskeyinthefirstargument.
setOption(string$option,mixed$value)Usethismethodtosetanyoftheoptionsafterthenodehasbeencreated.
Theoptionnamesarethesameasthoseintheconstructor,andtakesimilarvalues.
&addItem(object&$node)ThisissimilarineveryrespecttotheaddItem()methodoftheHTML_TreeMenuclassandisusedtoaddchildnodes.
HTML_TreeMenu_DHTMLMethodsConstructor(&$structure[,array$options[,$isDynamic]])Thissetsupthepresentationobjectwiththegivenstructureandoptions.
ThestructureshouldbeanHTML_TreeMenuobject.
Theoptionsargumentshouldbeanassociativearray,andcanconsistofthefollowing:imagesThefoldertolookinforimages.
Defaultsto"images".
linkTargetTargetforanylinks.
Canbesethereinsteadofforeverynode.
Defaultsto"_self".
defaultClassDefaultCSSclasstouse.
Defaultstoblank.
usePersistenceWhethertouseclientsidepersistenceornot(withcookies).
Defaultstotrue.
noTopLevelImagesWhethertoskipthedisplayofthefirstlevelofbranchimagesiftherearemultiplerootnodes.
Defaultstofalse.
Thethridargument$isDynamiccanbeusedtospecifyWhethertheentiretreeisdynamicornot.
Defaultstotrue.
printMenu([$options])ThisisamethodinheritedfromtheabstractHTML_TreeMenu_Presentationclassandisusedtoprintthemenu.
Theoptionalargument$optionsshouldbeanassociativearraywhichcanconsistofthesameoptionsasthe$optionsargumentoftheconstructor.
HTML_TreeMenu_ListboxMethodsConstructor(&$structure[,array$options])Thissetsupthepresentationobjectwiththegivenstructureandoptions.
ThestructureshouldbeanHTML_TreeMenuobject.
Theoptionsargumentshouldbeanassociativearray,andcanconsistofthefollowing:promoTextThetextthatappearsatthetopofthelistbox.
Defaultsto"Select…"indentCharThecharacterusedtoindentthenodes.
Defaultsto" ".
indentNumHowmanyindentCharstouseperindentationlevel.
linkTargetTargetforanylinks.
Canbesethereinsteadofforeverynode.
Defaultsto"_self".
submitTextTextforthesubmitbutton.
Defaultsto"Go".
printMenu([$options])ThisisamethodinheritedfromtheabstractHTML_TreeMenu_Presentationclassandisusedtoprintthemenu.
Theoptionalargument$optionsshouldbeanassociativearraywhichcanconsistofthesameoptionsasthe$optionsargumentoftheconstructor.
Casestudy:CreatingatreemenuusingXMLTheHTML_TreeMenu::createFromXML()methodisanextremelyusefuloneifyouhaveatreemenutomaintainandwishtodosoinsimplerfashionthanupdatingPHPcodeeverytimeachangeisneed.
TheXMLcanbekeptinafileandreadintocreatethemenu,withlittlemorethanafewlinesofPHPcodenecessary.
Pros:VeryeasytomaintainLittlecodingrequiredbyyouNolossofcontroloverpresentationbywayofXMLtagattributesCons:SlowerAsaresultof:Increasedamountofincludedcode(Treeclass,XML_Treeclass,XML_Tree_Nodeclass,XML_Parserclass)XMLparsingthedecreasedspeedissignificantenoughtowarrantcachingoftheresultingHTML_TreeMenuobject,eitherinausers'sessionorperhapsafilebasedcache.
(PEARhasacoupleofcandidates–Cache&Cache_Lite).
IfyoudocachethetreeMenu,thenit'sentirelyconcievablethatitmayendupbeingfasterthanbuildingitinPHPeverytime,sothespeeddrawbackbecomesanon-issue.
TheXMLschemayoushoulduseconsistsoftwotags,and.
Thetagistherootelementandthereshouldonlyeverbeoneofthese.
Thetagdefinesanodeinthetreeandcanbenestedasmuchasyouwant.
ThetagcantakeasattributesanyoftheoptionswhichcanbepassedtotheHTML_TreeNodeconstructor(eg.
text,link,iconetc).
SomeexampleXML:Asyoucanseeit'sperfectlyOKtousetheXMLshortcutinsteadofifanodehasnochildnodes.
ThisXMLwillcreateatreeMenuwithfiverootnodes,withthefourthhavingfourchildnodes.
ThecodeyouwouldneedtousetocreatetheHTML_TreeMenuobjectisasfollows:You'rethenfreetousethe$treeMenustructurewitheitherofthepresentationclassesasnormal.
LicenseThepackageisdistributedundertheBSDlicense.
Wishlistfulfilmentisalwaysappreciatedofcourse:RichardHeyeshttp://phpguru.
org/wishlistHaraldRadihttp://www.
amazon.
com/.
.
.
ZJI发布了一款7月份特别促销独立服务器:香港邦联四型,提供65折优惠码,限量30台(每用户限购1台),优惠后每月520元起。ZJI是原来Wordpress圈知名主机商家:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册等业务。下面列出这款服务器的配置信息。香港邦联四型CPU:2*E5-2...
wordpress高级全行业大气外贸主题,wordpress通用全行业高级外贸企业在线询单自适应主题建站程序,完善的外贸企业建站功能模块 + 高效通用的后台自定义设置,更实用的移动设备特色功能模块 + 更适于欧美国外用户操作体验 大气简洁的网站风格设计 + 高效优化的网站程序结构,更利于Goolge等SEO搜索优化和站点收录排名。点击进入:wordpress高级全行业大气外贸主题主题价格:¥398...
阿里云国际版注册认证教程-免绑卡-免实名买服务器安全、便宜、可靠、良心,支持人民币充值,提供代理折扣简介SunthyCloud成立于2015年,是阿里云国际版正规战略级渠道商,也是阿里云国际版最大的分销商,专业为全球企业客户提供阿里云国际版开户注册、认证、充值等服务,通过SunthyCloud开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡就可以帮你开通、充值、新购、续费阿里云国际版,服务...
file_get_contents为你推荐
lsusbwinrar5stronglyios11Telewizjamedia支持ipad国家标准苹果5netbios端口如何组织netbios端口的外部通信itunes备份怎么使用iTunes备份127.0.0.1传奇服务器非法网关连接: 127.0.0.1icloudiphone苹果6显示已停用请连接itunes什么意思chromeframechrome需要frame吗
美国虚拟主机推荐 域名服务器的作用 域名备案批量查询 火车票抢票攻略 ev证书 中国智能物流骨干网 hkg 免费防火墙 亚马逊香港官网 酷番云 网游服务器 购买国外空间 shuang12 国内域名 论坛主机 广州虚拟主机 宿迁服务器 聚惠网 美国主机侦探 机柜尺寸 更多