  |
142 | 142 | | return $modules; |
| |
143 | 143 | | } |
| |
144 | 144 | | |
  |
145 | | - | function isInstalled() { |
| |
| 145 | + | function isInstalled($code = '', $group = '') { |
|
146 | 146 | | global $osC_Database; |
| |
147 | 147 | | |
  |
148 | | - | static $is_installed; |
| |
| 148 | + | if (empty($code) && empty($group)) { |
| |
| 149 | + | static $is_installed; |
|
149 | 150 | | |
  |
| 151 | + | $code = $this->_code; |
| |
| 152 | + | $group = $this->_group; |
| |
| 153 | + | } |
| |
| 154 | + | |
|
150 | 155 | | if (isset($is_installed) === false) { |
| |
151 | 156 | | $Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); |
| |
152 | 157 | | $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
  |
153 | | - | $Qcheck->bindValue(':code', $this->_code); |
| |
154 | | - | $Qcheck->bindValue(':modules_group', $this->_group); |
| |
| 158 | + | $Qcheck->bindValue(':code', $code); |
| |
| 159 | + | $Qcheck->bindValue(':modules_group', $group); |
|
155 | 160 | | $Qcheck->execute(); |
| |
156 | 161 | | |
| |
157 | 162 | | $is_installed = ($Qcheck->numberOfRows()) ? true : false; |
| |
|
|
 |
… |
|
183 | 188 | | } |
| |
184 | 189 | | |
| |
185 | 190 | | function install() { |
  |
186 | | - | global $osC_Database; |
| |
| 191 | + | global $osC_Database, $osC_Language; |
|
187 | 192 | | |
| |
188 | 193 | | $Qinstall = $osC_Database->query('insert into :table_templates_boxes (title, code, author_name, author_www, modules_group) values (:title, :code, :author_name, :author_www, :modules_group)'); |
| |
189 | 194 | | $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
|
|
 |
… |
|
193 | 198 | | $Qinstall->bindValue(':author_www', $this->_author_www); |
| |
194 | 199 | | $Qinstall->bindValue(':modules_group', $this->_group); |
| |
195 | 200 | | $Qinstall->execute(); |
  |
| 201 | + | |
| |
| 202 | + | foreach ($osC_Language->getAll() as $key => $value) { |
| |
| 203 | + | if (file_exists(dirname(__FILE__) . '/../languages/' . $key . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) { |
| |
| 204 | + | foreach ($osC_Language->extractDefinitions($key . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) { |
| |
| 205 | + | $Qcheck = $osC_Database->query('select id from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id limit 1'); |
| |
| 206 | + | $Qcheck->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); |
| |
| 207 | + | $Qcheck->bindValue(':definition_key', $def['key']); |
| |
| 208 | + | $Qcheck->bindValue(':content_group', $def['group']); |
| |
| 209 | + | $Qcheck->bindInt(':languages_id', $value['id']); |
| |
| 210 | + | $Qcheck->execute(); |
| |
| 211 | + | |
| |
| 212 | + | if ($Qcheck->numberOfRows() === 1) { |
| |
| 213 | + | $Qdef = $osC_Database->query('update :table_languages_definitions set definition_value = :definition_value where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id'); |
| |
| 214 | + | } else { |
| |
| 215 | + | $Qdef = $osC_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)'); |
| |
| 216 | + | } |
| |
| 217 | + | $Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); |
| |
| 218 | + | $Qdef->bindInt(':languages_id', $value['id']); |
| |
| 219 | + | $Qdef->bindValue(':content_group', $def['group']); |
| |
| 220 | + | $Qdef->bindValue(':definition_key', $def['key']); |
| |
| 221 | + | $Qdef->bindValue(':definition_value', $def['value']); |
| |
| 222 | + | $Qdef->execute(); |
| |
| 223 | + | } |
| |
| 224 | + | } |
| |
| 225 | + | } |
| |
| 226 | + | |
| |
| 227 | + | osC_Cache::clear('languages'); |
|
196 | 228 | | } |
| |
197 | 229 | | |
| |
198 | 230 | | function remove() { |
  |
199 | | - | global $osC_Database; |
| |
| 231 | + | global $osC_Database, $osC_Language; |
|
200 | 232 | | |
| |
201 | 233 | | $Qmodule = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); |
| |
202 | 234 | | $Qmodule->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
|
|
 |
… |
|
221 | 253 | | $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys())); |
| |
222 | 254 | | $Qdel->execute(); |
| |
223 | 255 | | } |
  |
| 256 | + | |
| |
| 257 | + | if (file_exists(dirname(__FILE__) . '/../languages/' . $osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) { |
| |
| 258 | + | foreach ($osC_Language->extractDefinitions($osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) { |
| |
| 259 | + | $Qdel = $osC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group'); |
| |
| 260 | + | $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); |
| |
| 261 | + | $Qdel->bindValue(':definition_key', $def['key']); |
| |
| 262 | + | $Qdel->bindValue(':content_group', $def['group']); |
| |
| 263 | + | $Qdel->execute(); |
| |
| 264 | + | } |
| |
| 265 | + | |
| |
| 266 | + | osC_Cache::clear('languages'); |
| |
| 267 | + | } |
  |
224 | 268 | | } |
| |
225 | 269 | | } |
| |
226 | 270 | | ?> |