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/.
.
.
百纵科技:美国云服务器活动重磅来袭,洛杉矶C3机房 带金盾高防,会员后台可自助管理防火墙,添加黑白名单 CC策略开启低中高.CPU全系列E52680v3 DDR4内存 三星固态盘列阵。另有高防清洗!百纵科技官网:https://www.baizon.cn/联系QQ:3005827206美国洛杉矶 CN2 云服务器CPU内存带宽数据盘防御价格活动活动地址1核1G10M10G10G38/月续费同价点击...
Hostadvice主机目录对我们的服务进行了测试,然后给PQ.hosting颁发了十大WordPress托管奖。为此,宣布PQ.Hosting将在一周内进行折扣优惠,购买和续订虚拟服务器使用优惠码:Hostadvice ,全部优惠10%。PQ.hosting,国外商家,成天于2019年,正规公司,是全球互联网注册商协会 RIPE 的成员。主要是因为提供1Gbps带宽、不限流量的基于KVM虚拟的V...
阿里云(aliyun)在这个月又推出了一个金秋上云季活动,到9月30日前,每天两场秒杀活动,包括轻量应用服务器、云服务器、云数据库、短信包、存储包、CDN流量包等等产品,其中Aliyun轻量云服务器最低60元/年起,还可以99元续费3次!活动针对新用户和没有购买过他们的产品的老用户均可参与,每人限购1件。关于阿里云不用多说了,国内首屈一指的云服务器商家,无论建站还是学习都是相当靠谱的。活动地址:h...
file_get_contents为你推荐
followcss支持ipad齐鲁工业大学高水平学科建设专项tracerouteLinux 下traceroute的工作原理是什么 !tracerouteTRACEROUTE的作用是什么tcpip上的netbiostcp 协议里的 netbios . 在哪,找不到googleadsense我申请Google AdSense要怎样才能通过Google AdSense呀?google统计google分析里的数据包括搜索引擎爬虫的数据吗?Google中文专题交流www.baidu.jpbaidu 百度苹果5.1完美越狱ios5.1能不能完美越狱?
xenvps linode 新世界电讯 智能骨干网 seednet admit的用法 网站在线扫描 登陆空间 重庆联通服务器托管 ncp是什么 建站论坛 qq空间打开很慢 weblogic部署 paypal兑换 ddos防火墙 国内免备案空间 网易轻博客 ftp服务器架设 服务器操作系统安装 灵动鬼影实录4 更多