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["header"],$col2["header"]);'));
51 $this->columns=$columns;
53 //plc_debug('columns',$columns);
58 function column_names () {
59 return array_map(create_function('$tt','return $tt["tagname"];'),$this->columns());
62 // to add with array_merge to the headers part of the Plekit Table
65 $columns=$this->columns();
66 foreach ($columns as $column)
68 if ($column['header'] == 'f')
71 //panos: needed a few more fields in the header array
72 $headerId = $column['header'];
73 if ($column['headerId'] != "")
74 $headerId = $column['headerId'];
76 $headers[$headerId]=array('header'=>$column['header'],'headerId'=>$headerId, 'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['description']);
79 if ($column['header'] == $column['tagname'])
80 $headers[$column['header']]=$column['type'];
82 $headers[$column['header']]=array('type'=>$column['type'],'title'=>$column['description']);
87 // to add with array_merge to the notes part of the Plekit Table
90 $columns=$this->columns();
91 foreach ($columns as $column)
92 if ($column['header'] != $column['tagname'])
93 $notes []= strtoupper($column['header']) . ' = ' . $column['description'];