-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathnooMenusFilesDownload.json
115 lines (115 loc) · 6.51 KB
/
nooMenusFilesDownload.json
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
"name": "nooMenusFilesDownload",
"isActive": "1",
"group": "Gestion Design",
"mode": "provoke",
"schedule": "",
"trigger": [
""
],
"timeout": "0",
"isVisible": "0",
"display": {
"name": "",
"icon": ""
},
"order": "9999",
"description": "- Télécharge le fichier \/data\/menusNoodom\/.htAccess nécessaire au bon fonctionnement des menus\n- Télécharge les fichiers nécessaires pour un menu noodom donné",
"configuration": {
"timeDependency": 0,
"has_return": 0,
"logmode": "default",
"allowMultiInstance": "0",
"syncmode": "0",
"timeline::enable": "0",
"timeline::folder": ""
},
"state": "stop",
"elements": [
{
"name": null,
"type": "comment",
"options": [],
"order": "0",
"subElements": [
{
"name": null,
"type": "comment",
"subtype": "comment",
"options": {
"collapse": "0"
},
"order": "0",
"expressions": [
{
"type": "comment",
"subtype": null,
"expression": "Scénario de recopie des fichiers nécessaires à la construction d'un menu noodom :\n- Télécharge le fichier \/data\/menusNoodom\/.htAccess nécessaire au bon fonctionnement des menus\n- Télécharge les fichiers nécessaires pour un menu noodom donné\n\n1. Préciser le menu en précisant son nom au niveau du tag \"menuName\" en début de scénario parmi la liste suivante : \n menuJsonFsb33Frame, menuAnimation, menuNooNeumorphism, menuVerticalTom, menuMobileSubMenuFrame, menuFloattingDraggable, menuHoverShow, menuInTheAir\n\n2. Exécuter le scénario => Les fichiers nécessaires au menu seront alors copiés sous \/data\/menusNoodom\n\n3. Continuer l'installation du menu à l'aide du README sous github du menu souhaité\n\nhttps:\/\/github.com\/noodom\/jeedom_menus",
"options": [],
"order": "0"
}
]
}
]
},
{
"name": null,
"type": "action",
"options": [],
"order": "0",
"subElements": [
{
"name": null,
"type": "action",
"subtype": "action",
"options": {
"collapse": "0",
"enable": "1"
},
"order": "0",
"expressions": [
{
"type": "action",
"subtype": null,
"expression": "tag",
"options": {
"enable": "1",
"background": "0",
"name": "menuName",
"value": "menuJsonFsb33Frame"
},
"order": "0"
}
]
}
]
},
{
"name": null,
"type": "code",
"options": [],
"order": "0",
"subElements": [
{
"name": null,
"type": "code",
"subtype": "action",
"options": {
"collapse": "0",
"enable": "1"
},
"order": "0",
"expressions": [
{
"type": "code",
"subtype": null,
"expression": "\/\/ Noodom menus installation\n\/\/ - Download file \/data\/menusNoodom\/.htAccess\n\/\/ - Download menu files\n \n\/\/ Menu name\n\/\/ => menuJsonFsb33Frame, menuAnimation, menuNooNeumorphism, menuVerticalTom, menuMobileSubMenuFrame, menuFloattingDraggable, menuHoverShow, menuInTheAir\n$tags = $scenario->getTags();\n(!isset($tags['#menuName#'])) ? $tags['#menuName#'] = 'menuJsonFsb33Frame' : null;\n$menuName = $tags['#menuName#']; \n\n\/\/ Menus folder\n$menusFolder = 'menusNoodom';\n\/\/ Origin folder\n$originDir = 'https:\/\/raw.githubusercontent.com\/noodom\/jeedom_menus\/master\/' . $menuName . '\/data\/' . $menusFolder; \n\/\/ Destination folder\n$destinationDir = '\/var\/www\/html\/data\/' . $menusFolder;\n\/\/ Zip menu file\n$menuZipFile = $originDir . '\/' . $menuName . '.zip'; \n\n\/\/ Create menus folder \/menusNoodom\nif (!is_file($destinationDir) && !is_dir($destinationDir)) {\n $scenario->setLog('Destination dir creation (menus folder) : ' . $destinationDir);\n mkdir($destinationDir);\n}\n\n\/\/ Get .htaccess file\nif (is_dir($destinationDir) . '\/.') {\n $scenario->setLog('** Get .htaccess file');\n $originUrl = $originDir . '\/.htaccess';\n\n $filename = basename($originUrl); \n $save = $destinationDir . '\/' . $filename;\n $scenario->setLog('- Origin filename : ' . $originUrl);\n $scenario->setLog('- Destination filename : ' . $save);\n if (file_put_contents($save,file_get_contents($originUrl))) {\n $scenario->setLog('- .htaccess downloaded !');\n }\n}\n\n\/\/ Get menu files\n$destinationMenu = $destinationDir . '\/' .$menuName;\nif (is_dir($destinationMenu . '\/.')) {\n \/\/ Delete existing menu folder\n $scenario->setLog('** Delete existing menu folder : ' . $destinationMenu);\n rrmdir($destinationMenu);\n}\n\nif (is_dir($destinationDir)) {\n $scenario->setLog('** Get files for menu ' . $menuName);\n $scenario->setLog('- Get menu zip file : ' . $menuZipFile);\n $destination = $destinationDir . '\/temp.zip';\n $scenario->setLog('- Destination menu zip file : ' . $destination);\n if (!copy($menuZipFile, $destination)) {\n $scenario->setLog('\/!\\ Menu zip file download failed !');\n }\n else {\n $zip = new ZipArchive();\n if ($zip->open($destination) === TRUE) {\n $scenario->setLog('- Extract files from menu : ' . $menuName);\n $zip->extractTo($destinationDir . '\/');\n $zip->close();\n unlink($destination);\n }\n }\n}",
"options": [],
"order": "0"
}
]
}
]
}
]
}