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/.
.
.
RackNerd 商家我们应该是比较熟悉的商家,速度一般,但是人家便宜且可选机房也是比较多的,较多集中在美国机房。包括前面的新年元旦促销的时候有提供年付10美元左右的方案,实际上RackNerd商家的营销策略也是如此,每逢节日都有活动,配置简单变化,价格基本差不多,所以我们网友看到没有必要囤货,有需要就选择。RackNerd 商家这次2022农历新年也是有几款年付套餐。低至RackNerd VPS...
易探云怎么样?易探云是目前国内少数优质的香港云服务器服务商家,目前推出多个香港机房的香港云服务器,有新界、九龙、沙田、葵湾等机房,还提供CN2、BGP及CN2三网直连香港云服务器。近年来,许多企业外贸出海会选择香港云服务器来部署自己的外贸网站,使得越来越多的用户会选择易探云作为网站服务提供平台。今天,云服务器网(yuntue.com)小编来谈谈易探云和易探云服务器怎么样?具体香港云服务器多少钱1个...
TMThosting发布了一个2021 Summer Sale活动,针对西雅图VPS主机提供月付7折优惠码,年付65折优惠码,独立服务器提供95折优惠码,本轮促销活动到7月25日。这是一家成立于2018年的国外主机商,主要提供VPS和独立服务器租用业务,数据中心包括美国西雅图和达拉斯,其中VPS基于KVM架构,都有提供免费的DDoS保护,支持选择Windows或者Linux操作系统。Budget ...
file_get_contents为你推荐
enter苹果5SCProute支持ipad支持ipad国家标准苹果5x-routerx-arcsinx的等价无穷小是什么?canvas2Canvas ~セピア色のモチーフ~ 这个动画片的中文翻译是什么?从哪看?iphonewifi苹果手机怎么wi-fi共享googleadsenceGoogle AdSense 帐户状态是什么意思!css选择器css有哪些选择器
东莞虚拟主机 美国免费虚拟主机 三级域名网站 已经备案域名 diahosting l5639 mach5 便宜建站 42u机柜尺寸 空间打开慢 godaddy支付宝 ev证书 admit的用法 可外链相册 t云 申请免费空间和域名 安徽双线服务器 双12 360云服务 实惠 更多