Difference between revisions of "Extension talk:Treeview5.php"

From Organic Design wiki
(Dtree -> DTree)
(Dtree API: rm copy of usage)
Line 28: Line 28:
 
See file api.html in the [http://www.destroydrop.com/javascripts/tree/ DTree] directory.
 
See file api.html in the [http://www.destroydrop.com/javascripts/tree/ DTree] directory.
 
Basically this extension need to provide an interface from a parser function which deals with nested bullet lists to creating the javascript output. At the bullet list stage the php function [http://nz2.php.net/manual/en/function.htmlspecialchars.php htmlspecialchars] on the input to prevent cross site scripting. See [http://www.technicalinfo.net/papers/CSS.html HTML Code Injection and Cross-site scripting] for details.
 
Basically this extension need to provide an interface from a parser function which deals with nested bullet lists to creating the javascript output. At the bullet list stage the php function [http://nz2.php.net/manual/en/function.htmlspecialchars.php htmlspecialchars] on the input to prevent cross site scripting. See [http://www.technicalinfo.net/papers/CSS.html HTML Code Injection and Cross-site scripting] for details.
----
 
===Overview===
 
 
    * Functions
 
          o add
 
          o openAll
 
          o closeAll
 
          o openTo
 
    * Configuration
 
 
===Functions===
 
;add()
 
 
Adds a node to the tree.
 
Can only be called before the tree is drawn.
 
 
id, pid and name are required.
 
===Parameters===
 
<pre>
 
Name Type Description
 
id Number Unique identity number.
 
pid Number Number refering to the parent node. The value for the root node has to be -1.
 
name String Text label for the node.
 
url String Url for the node.
 
title String Title for the node.
 
target String Target for the node.
 
icon String Image file to use as the icon. Uses default if not specified.
 
iconOpen String Image file to use as the open icon. Uses default if not specified.
 
open Boolean Is the node open.
 
</pre>
 
===Example===
 
{{code|<javascript>
 
mytree.add(1, 0, 'My node', 'node.html', 'node title', 'mainframe', 'img/musicfolder.gif');
 
</javascript>
 
}}
 
 
===openAll()===
 
 
Opens all the nodes.
 
Can be called before and after the tree is drawn.
 
===Example===
 
 
mytree.openAll();
 
 
===closeAll()===
 
 
Closes all the nodes.
 
Can be called before and after the tree is drawn.
 
===Example===
 
 
mytree.closeAll();
 
 
===openTo()===
 
 
Opens the tree to a certain node and can also select the node.
 
Can only be called after the tree is drawn.
 
===Parameters===
 
<pre>
 
Name Type Description
 
id Number Identity number for the node.
 
select Boolean Should the node be selected.
 
</pre>
 
===Example===
 
{{code|<javascript>
 
mytree.openTo(4, true);
 
</javascript>
 
}}
 
===Configuration===
 
<pre>
 
Variable Type Default Description
 
target String true Target for all the nodes.
 
folderLinks Boolean true Should folders be links.
 
useSelection Boolean true Nodes can be selected(highlighted).
 
useCookies Boolean true The tree uses cookies to rember it's state.
 
useLines Boolean true Tree is drawn with lines.
 
useIcons Boolean true Tree is drawn with icons.
 
useStatusText Boolean false Displays node names in the statusbar instead of the url.
 
closeSameLevel Boolean false Only one node within a parent can be expanded at the same time. openAll() and closeAll() functions do not work when this is enabled.
 
inOrder Boolean false If parent nodes are always added before children, setting this to true speeds up the tree.
 
</pre>
 
===Example===
 
mytree.config.target = "mytarget";
 
----
 

Revision as of 21:01, 19 February 2008

Info.svg This talk page pertains specifically to the development of this extension. For more general discussion about bugs and usage etc, please refer to the mediawiki.org talk page at MW:Extension talk:Tree view

A more logical way of approaching a treeview in MediaWiki is for the PHP extension part to concentrate on allowing the bullet lists (and maybe numbered lists too) to work recusively with transclusion, and for the tree rendering to be handled by existing JavaScript components such as DTree which are very good and packed with features such as persistence between pages.


Note.svg Note: If this extension is going to use an external tool, we could for the fork and rename of the extension to Extension:DTree.php, as it is now going to be an interface to a javascript application. There is currently no extension on MediaWiki called MW:Extension:DTree.


Treeview4 already handles the recursion aspect well and has been written in a much more modular way than Treeview3 allowing it to be independent of the tree rendering. But with this version I'd like to make the list-recursion work without any parser-function syntax at all - i.e. essentially to fix the MediaWiki parser's limitation of not allowing transclusion to work properly with lists as in the following example.

*Foo
**Bar
**{{:Baz}}
**Fodda

The new version would allow the Baz article (if it were a bullet list) to be properly nested at the correct level in the parent tree. This would simply be based on the fact that the transclusion is directly after an asterisk.

The #tree parser-function would still be used to make bullet lists into trees, but would be optional and would simple wrap the structure in the appropriate HTML to activate the DTree JavaScript tree.

Persistance

How does http://www.destroydrop.com/javascripts/tree/ DTree] handle persistance? Looks like it does it through cookies, see dtree.js, line 36.


If it does it by saving temporary files we would want a temporary file location for the trees and a GUID such as [ArticleName]-[Database revision]

See also

Dtree API

See file api.html in the DTree directory. Basically this extension need to provide an interface from a parser function which deals with nested bullet lists to creating the javascript output. At the bullet list stage the php function htmlspecialchars on the input to prevent cross site scripting. See HTML Code Injection and Cross-site scripting for details.