forked from abantecart/abantecart-languages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
64 lines (52 loc) · 2.08 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
if (! defined ( 'DIR_CORE' )) {
header ( 'Location: static_pages/' );
}
//before install validate it is unique
$lng_code = "ga";
$lng_name = "Gaeilge";
$lng_directory = "irish";
$lng_locale = "ga_IE.UTF-8,ga_IE,ga-ie,irish";
$lng_flag_path = "extensions/default_irish/storefront/language/irish/flag.png";
$lng_sort = 2; // sorting order with other languages
$lng_status = 0; // Status on installation of extension
$query = $this->db->query("SELECT language_id
FROM ".$this->db->table("languages")."
WHERE code='".$this->db->escape($lng_code)."'");
if ($query->row["language_id"]) {
$this->session->data["error"] = "Error: Language with ".$lng_code." code is already installed! Can not install duplicate languages! Uninstall this extension before attempting again.";
$error = new AError ($this->session->data["error"]);
$error->toLog()->toDebug();
return false;
}
$this->db->query("INSERT INTO ".$this->db->table("languages")."
(`name`,`code`,`locale`,`image`,`directory`,`filename`,`sort_order`, `status`)
VALUES (
'".$this->db->escape($lng_name)."',
'".$this->db->escape($lng_code)."',
'".$this->db->escape($lng_locale)."',
'".$this->db->escape($lng_flag_path)."',
'".$this->db->escape($lng_directory)."',
'".$lng_directory."',
".(int)$lng_sort.",
".(int)$lng_status.");");
$new_language_id = $this->db->getLastId();
//Load language specific data
$xml = simplexml_load_file(DIR_EXT . 'default_irish/menu.xml');
$routes = array(
'text_index_home_menu'=>'index/home',
'text_product_special_menu'=>'product/special',
'text_account_login_menu'=>'account/login',
'text_account_logout_menu'=>'account/logout',
'text_account_account_menu'=>'account/account',
'text_account_invoice_menu'=>'account/invoice',
'text_checkout_cart_menu'=>'checkout/cart',
'text_checkout_shipping_menu'=>'checkout/shipping'
);
if($xml){
foreach($xml->definition as $item){
$translates[$routes[(string)$item->key]] = (string)$item->value;
}
$storefront_menu = new AMenu_Storefront();
$storefront_menu->addLanguage($new_language_id,$translates);
}