3 // utility function for displaying extra columns based on tags and categories
4 // expected type is e.g. 'node'
10 function __construct ($api, $type) {
16 // returns an ordered set of columns - compute only once
19 if ($this->columns != NULL)
20 return $this->columns;
22 // scan tag types to find relevant additional columns
23 $tag_types = $this->api->GetTagTypes(array('category'=>"$this->type*/ui*"));
26 foreach ($tag_types as $tag_type) {
27 $tagname=$tag_type['tagname'];
29 $column['tagname']=$tagname;
31 $column['header']=$tagname;
32 $column['rank']=$tagname;
33 $column['type']='string';
34 $column['description']=$tag_type['description'];
35 // split category and parse any setting
36 $category_tokens=explode('/',$tag_type['category']);
37 foreach ($category_tokens as $token) {
38 $assign=explode('=',$token);
39 if (count($assign)==2)
40 $column[$assign[0]]=$assign[1];
46 usort ($columns, function($col1, $col2) { return strcmp($col1["header"],$col2["header"]); });
49 $this->columns=$columns;
51 //plc_debug('columns',$columns);
56 function column_names () {
57 return array_map(function($tt) {return $tt["tagname"];},
61 // to add with array_merge to the headers part of the Plekit Table
64 $columns=$this->columns();
65 foreach ($columns as $column)
67 if ($column['header'] == 'f')
70 //panos: needed a few more fields in the header array
71 $headerId = $column['header'];
72 if ($column['headerId'] != "")
73 $headerId = $column['headerId'];
75 $headers[$headerId]=array('header'=>$column['header'],'headerId'=>$headerId, 'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['description']);
78 if ($column['header'] == $column['tagname'])
79 $headers[$column['header']]=$column['type'];
81 $headers[$column['header']]=array('type'=>$column['type'],'title'=>$column['description']);
86 // to add with array_merge to the notes part of the Plekit Table
89 $columns=$this->columns();
90 foreach ($columns as $column)
91 if ($column['header'] != $column['tagname'])
92 $notes []= strtoupper($column['header']) . ' = ' . $column['description'];