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怎么样?racknerd今天发布了几款美国特价独立服务器的促销,本次商家主推高配置的服务器,各个配置给的都比较高,有Intel和AMD两种,硬盘也有NVMe和SSD等多咱组合可以选择,机房目前有夏洛特、洛杉矶、犹他州可以选择,性价比很高,有需要独服的朋友可以看看。点击进入:racknerd官方网站RackNerd暑假独服促销:CPU:双E5-2680v3 (24核心,48线程)内存...
说明一下:gcorelabs的俄罗斯远东机房“伯力”既有“Virtual servers”也有“CLOUD SERVICES”,前者是VPS,后者是云服务器,不是一回事;由于平日大家习惯把VPS和云服务器当做一回事儿,所以这里要特别说明一下。本次测评的是gcorelabs的cloud,也就是云服务器。 官方网站:https://gcorelabs.com 支持:数字加密货币、信用卡、PayPal...
UCloud优刻得近日针对全球大促活动进行了一次改版,这次改版更加优惠了,要比之前的优惠价格还要低一些,并且新增了1核心1G内存的快杰云服务器,2元/首年,47元/年,这个价格应该是目前市面上最低最便宜的云服务器产品了,有需要国内外便宜VPS云服务器的朋友可以关注一下。UCloud好不好,UCloud服务器怎么样?UCloud服务器值不值得购买UCloud是优刻得科技股份有限公司旗下拥有的云计算服...
file_get_contents为你推荐
我研制千万亿次超级电脑三星iphoneiphonewifi苹果wifi版和4G版是什么意思,有什么区别吗win7关闭135端口win7下怎么关135和8909端口css3按钮html点击按钮怎么弹出一个浮动的窗体chromeframechrome需要frame吗苹果5.1完美越狱ios5.1能不能完美越狱?fastreport2.5GPA2.5相当于什么水平morphvoxpro怎么用怎么使用morphvox proios5.1.1固件下载关于iphone4s 现在的系统是ios5.1.1,可以直接升级到系统ios6.1?
香港服务器租用99idc 科迈动态域名 便宜建站 godaddy http500内部服务器错误 windows2003iso 网站挂马检测工具 100m免费空间 七夕快乐英文 怎样建立邮箱 me空间社区 169邮箱 cdn加速原理 免费申请个人网站 卡巴斯基是免费的吗 1元域名 国内域名 万网注册 服务器托管价格 聚惠网 更多