Revision: 10135
http://xoops.svn.sourceforge.net/xoops/?rev=10135&view=rev
Author: mageg
Date: 2012-08-29 20:46:24 +0000 (Wed, 29 Aug 2012)
Log Message:
-----------
add function in tree.php
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0/htdocs/class/tree.php
Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/tree.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/tree.php 2012-08-29 12:30:05 UTC (rev 10134)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/tree.php 2012-08-29 20:46:24 UTC (rev 10135)
@@ -211,7 +211,6 @@
/**
* Make a select box with options from the tree
*
- * @param string $name Name of the select box
* @param string $fieldName Name of the member variable from the
* node objects that should be used as the title for the options.
* @param string $prefix String to indent deeper levels
@@ -230,4 +229,44 @@
$this->_makeSelBoxOptions($fieldName, $selected, $key, $ret, $prefix);
return $ret . '</select>';
}
+
+ /**
+ * Make options for a array
+ *
+ * @param string $fieldName Name of the member variable from the
+ * node objects that should be used as the column.
+ * @param string $prefix String to indent deeper levels
+ * @param integer $key ID of the object to display as the root of the array
+ * @return array
+ */
+ public function makeArrayTree( $fieldName, $prefix = '-', $key = 0) {
+ $ret = array();
+ $this->_makeArrayTreeOptions( $fieldName, $key, $ret, $prefix );
+ return $ret;
+ }
+
+ /**
+ * Make a array with options from the tree
+ *
+ * @param string $fieldName Name of the member variable from the
+ * node objects that should be used as the column.
+ * @param integer $key ID of the object to display as the root of the array
+ * @param string $prefix_orig String to indent deeper levels (origin)
+ * @param string $prefix_curr String to indent deeper levels (current)
+ *
+ * @return void
+ */
+ public function _makeArrayTreeOptions( $fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '' ) {
+ if ( $key > 0 ) {
+ $value = $this->_tree[$key]['obj']->getVar( $this->_myId );
+ $ret[$value] = $prefix_curr . $this->_tree[$key]['obj']->getVar( $fieldName );
+ $prefix_curr .= $prefix_orig;
+
+ }
+ if ( isset( $this->_tree[$key]['child'] ) && !empty( $this->_tree[$key]['child'] ) ) {
+ foreach ( $this->_tree[$key]['child'] as $childkey ) {
+ $this->_makeArrayTreeOptions( $fieldName, $childkey, $ret, $prefix_orig, $prefix_curr );
+ }
+ }
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|