3 // $Id: plc_functions.php 15734 2009-11-13 10:52:31Z thierry $
5 // utility function for displaying extra columns based on tags and categories
6 // expected type is e.g. 'node'
12 function VisibleTags ($api,$type) {
18 // returns an ordered set of columns - compute only once
21 if ($this->columns != NULL)
22 return $this->columns;
24 // scan tag types to find relevant additional columns
25 $tag_types = $this->api->GetTagTypes(array('category'=>"$type*/ui*"));
28 foreach ($tag_types as $tag_type) {
29 $tagname=$tag_type['tagname'];
31 $column['tagname']=$tagname;
33 $column['header']=$tagname;
34 $column['rank']=$tagname;
35 $column['type']='string';
36 $column['description']=$tag_type['description'];
37 // split category and parse any setting
38 $category_tokens=explode('/',$tag_type['category']);
39 foreach ($category_tokens as $token) {
40 $assign=explode('=',$token);
41 if (count($assign)==2)
42 $column[$assign[0]]=$assign[1];
48 usort ($columns, create_function('$col1,$col2','return strcmp($col1["rank"],$col2["rank"]);'));
51 $this->columns=$columns;
52 // plc_debug('columns',$columns);
57 function column_names () {
58 return array_map(create_function('$tt','return $tt["tagname"];'),$this->columns());
61 // to add with array_merge to the headers part of the Plekit Table
64 $columns=$this->columns();
65 foreach ($columns as $column)
66 if ($column['header'] == $column['tagname'])
67 $headers[$column['header']]=$column['type'];
69 $headers[$column['header']]=array('type'=>$column['type'],'title'=>$column['description']);
73 // to add with array_merge to the notes part of the Plekit Table
76 $columns=$this->columns();
77 foreach ($columns as $column)
78 if ($column['header'] != $column['tagname'])
79 $notes []= strtoupper($column['header']) . ' = ' . $column['description'];