1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace ICanBoogie\Modules\Taxonomy\Support;
13
14 class Module extends \Icybee\Module
15 {
16 /**
17 * The getManageColumns method can be used by modules whishing to display
18 * vocabularies columns in their management table.
19 *
20 * @param $scope
21 * The scope for which to retreive columns.
22 *
23 * @return
24 * An array of columns for the Icybee\ManageBlock class
25 */
26
27 /*
28 public function getManageColumns($scope)
29 {
30 $vocabularies = $this->vocabulary->model('scope')->loadAll
31 (
32 'where scope = ? and is_multiple = 0 order by weight, vocabulary', array
33 (
34 $scope
35 )
36 );
37
38 $columns = array();
39
40 foreach ($vocabularies as $vocabulary)
41 {
42 $columns[$vocabulary->vocabularyslug] = array
43 (
44 'label' => $vocabulary->vocabulary
45 );
46 }
47
48 return $columns;
49 }
50
51 public function getSelectIdentifiers($scope)
52 {
53 $vocabularies = $this->vocabulary->model('scope')->loadAll
54 (
55 'where scope = ? order by weight, vocabulary', array
56 (
57 $scope
58 )
59 );
60
61 $i = 0;
62 $identifiers = array();
63
64 foreach ($vocabularies as $vocabulary)
65 {
66 $i++;
67
68 $vid = $vocabulary->vid;
69 $identifier = $vocabulary->vocabularyslug;
70
71 #
72 # update identifiers
73 #
74
75 $definition = '(select ';
76
77 if ($vocabulary->is_multiple)
78 {
79 $definition .= 'GROUP_CONCAT(term)';
80 }
81 else
82 {
83 $definition .= 'term';
84 }
85
86 $definition .= ' from {prefix}terms__nodes as s' . $i . 't1 inner join `{prefix}terms` as s' . $i . 't2 on (s' . $i . 't1.vtid = s' . $i . 't2.vtid and s' . $i .'t2.vid = ' . $vid . ')
87 where s' . $i . 't1.nid = node.nid)';
88
89 $identifiers[$identifier] = $definition;
90 }
91
92 return $identifiers;
93 }
94 */
95
96 /**
97 * Complete a WdDatabaseView schema in order to incorporate the vocabulary
98 * of a given scope.
99 *
100 * @param $schema
101 * The schema that will be used by WdDatabaseView to create a view.
102 *
103 * @return array
104 * The modified schema
105 */
106
107 /*
108 public function completeViewSchema(array $schema, $scope)
109 {
110 $vocabularies = $this->vocabulary->model('scope')->loadAll
111 (
112 'where scope = ? order by weight, vocabulary', array
113 (
114 $scope
115 )
116 );
117
118 $identifiers = &$schema['identifiers'];
119 $fields = &$schema['fields'];
120
121 $i = 0;
122
123 foreach ($vocabularies as $vocabulary)
124 {
125 $i++;
126
127 $vid = $vocabulary->vid;
128 $identifier = $vocabulary->slug;
129
130 #
131 # update fields
132 #
133
134 $fields[$identifier] = array('type' => 'varchar');
135
136 #
137 # update identifiers
138 #
139
140 $definition = '(select ';
141
142 if ($vocabulary->is_multiple)
143 {
144 $definition .= 'GROUP_CONCAT(term)';
145 }
146 else
147 {
148 $definition .= 'term';
149 }
150
151 $definition .= ' from {prefix}terms__nodes as s' . $i . 't1 inner join `{prefix}terms` as s' . $i . 't2 on (s' . $i . 't1.vtid = s' . $i . 't2.vtid and s' . $i .'t2.vid = ' . $vid . ')
152 where s' . $i . 't1.nid = t1.nid) as `' . $identifier . '`';
153
154 $identifiers[$identifier] = $definition;
155 }
156
157 return $schema;
158 }
159 */
160 }