Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / modules / categories [ view in CVS ]
| Date | Directory [filter] | File(s) [view] | Author [filter] |
| 29 Jul 2002 11:00:55 | postnuke_official/html/modules/categories | pnvisualapi.php,1.4,1.5 | Mike |
| add visual listarray function (<ul><li>...</li> style) | |||
Update of /home/cvsroot/postnuke_official/html/modules/categories
In directory ns7.hostnuke.net:/tmp/cvs-serv7664
Modified Files:
pnvisualapi.php
Log Message:
add visual listarray function (<ul><li>...</li> style)
Index: pnvisualapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/categories/pnvisualapi.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pnvisualapi.php 29 Jul 2002 09:45:49 -0000 1.4
--- pnvisualapi.php 29 Jul 2002 11:00:53 -0000 1.5
***************
*** 284,287 ****
--- 284,382 ----
/**
+ * Build array with visual tree of categories (<ul><li>...</li> style)
+ * for use in view maps etc.
+ *
+ * -- INPUT --
+ * @param $args['cid'] The ID of the root category used for the tree
+ * @param $args['eid'] optional ID to exclude from the tree (e.g. the ID of
+ * your current category)
+ *
+ * -- OUTPUT --
+ * @returns array
+ * @return array of array('id' => 123,
+ * 'name' => 'My Cat',
+ * 'beforetags' => '<ul><li> ',
+ * 'aftertags' => ' </li></ul></ul>')
+ */
+ function categories_visualapi_listarray ($args)
+ {
+ // Load User API
+ if (!pnModAPILoad('categories', 'user')) {
+ pnSessionSetVar('errormsg', _LOADFAILED);
+ return false;
+ }
+
+ // Getting categories Array
+ $categories = pnModAPIFunc
+ (
+ 'categories',
+ 'user',
+ 'getcat',
+ Array
+ (
+ 'eid' => (isset($args['eid']))?$args['eid']:false,
+ 'cid' => (isset($args['cid']))?$args['cid']:false,
+ 'return_itself' => true,
+ 'getchildren' => true
+ )
+ );
+
+ if ($categories === false) {// If it returned false
+ pnSessionSetVar('errormsg', _CATEGORYPROBLEM);
+ return false;
+ }
+
+ if (!empty($args['cid']) && is_numeric($args['cid'])) {
+ $root = $args['cid'];
+ } else {
+ $root = 0;
+ $startindent = 0;
+ }
+ $oldcid = 0;
+ $oldindent = 0;
+
+ $items = array();
+ $itemlist = array();
+ foreach ($categories as $category)
+ {
+ $itemlist[] = $category['cid'];
+ $items[$category['cid']] = array();
+ $items[$category['cid']]['id'] = $category['cid'];
+ $items[$category['cid']]['name'] = $category['name'];
+ $items[$category['cid']]['beforetags'] = '';
+ $items[$category['cid']]['aftertags'] = '';
+ if ($category['cid'] == $root) {
+ $startindent = $category['indentation'];
+ } else {
+ if ($category['indentation'] > $oldindent) {
+ for ($i=$oldindent;$i<$category['indentation'];$i++) {
+ $items[$category['cid']]['beforetags'] .= '<ul>';
+ }
+ } elseif ($category['indentation'] < $oldindent && $oldcid > 0) {
+ for ($i=$category['indentation'];$i<$oldindent;$i++) {
+ $items[$oldcid]['aftertags'] .= '</ul>';
+ }
+ }
+ $items[$category['cid']]['beforetags'] .= '<li> ';
+ $items[$category['cid']]['aftertags'] .= ' </li>';
+ }
+ $oldindent = $category['indentation'];
+ $oldcid = $category['cid'];
+ }
+ if ($oldcid > 0 && $oldindent > $startindent) {
+ for ($i=$startindent;$i<$oldindent;$i++) {
+ $items[$oldcid]['aftertags'] .= '</ul>';
+ }
+ }
+
+ $list_data = Array ();
+ foreach ($itemlist as $cid) {
+ $list_data[] = $items[$cid];
+ }
+
+ return $list_data;
+ }
+
+ /**
* Visual Menu with Selects for the location of the category
*
View Statistics - Next Notice - Previous Notice
| Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |