Skip to content

Commit ef10cd2

Browse files
committed
[ADD] Icon module in installation.
1 parent 8465a9d commit ef10cd2

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

assets/modules/store/installer/index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content
4545
$moduleSnippets = array (); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties
4646
$modulePlugins = array (); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid
47-
$moduleModules = array (); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid
47+
$moduleModules = array (); // modules - array : name, description, type - 0:file or 1:content, file or content, properties, guid, icon
4848
$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content,properties
4949
$moduleTVs = array (); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties
5050

@@ -63,7 +63,7 @@
6363

6464

6565
if (!@include ($modulePath.'/action.' . $action . '.php')) {
66-
die ('Invalid install action attempted. [action=' . $action . ']');
66+
die ('Invalid install action attempted. [action=' . $action . ']');
6767
}
6868

6969
echo "</div><!-- // content --></div><!-- // contentarea --><br /></body></html>";

assets/modules/store/installer/instprocessor-fast.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content
3636
$moduleSnippets = array(); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties
3737
$modulePlugins = array(); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid
38-
$moduleModules = array(); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid
38+
$moduleModules = array(); // modules - array : name, description, type - 0:file or 1:content, file or content, properties, guid, icon
3939
$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content,properties
4040
$moduleTVs = array(); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties
4141

@@ -279,6 +279,7 @@ function propertiesNameValue($propertyString)
279279
$guid = $moduleModule[4];
280280
$shared = $moduleModule[5];
281281
$category = $moduleModule[6];
282+
$icon = $moduleModule[8];
282283
if (!file_exists($filecontent))
283284
echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
284285
else {
@@ -292,12 +293,12 @@ function propertiesNameValue($propertyString)
292293
$moduleDb = \EvolutionCMS\Models\SiteModule::query()->where('name', $name)->first();
293294
if (!is_null($moduleDb)) {
294295
$properties = propUpdate($properties, $moduleDb->properties);
295-
\EvolutionCMS\Models\SiteModule::query()->where('name', $name)->update(['modulecode' => $module, 'description' => $desc, 'properties' => $properties, 'enable_sharedparams' => $shared]);
296+
\EvolutionCMS\Models\SiteModule::query()->where('name', $name)->update(['modulecode' => $module, 'description' => $desc, 'properties' => $properties, 'enable_sharedparams' => $shared, 'icon' => $icon]);
296297

297298
echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
298299
} else {
299300
$properties = parseProperties($properties, true);
300-
\EvolutionCMS\Models\SiteModule::query()->create(['name' => $name, 'guid' => $guid, 'category' => $category, 'modulecode' => $module, 'description' => $desc, 'properties' => $properties, 'enable_sharedparams' => $shared]);
301+
\EvolutionCMS\Models\SiteModule::query()->create(['name' => $name, 'guid' => $guid, 'category' => $category, 'modulecode' => $module, 'description' => $desc, 'properties' => $properties, 'enable_sharedparams' => $shared, 'icon' => $icon]);
301302
echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
302303
}
303304
}
@@ -464,7 +465,6 @@ function propertiesNameValue($propertyString)
464465
}
465466

466467
// install data
467-
468468
if (is_file($installPath . '/' . $moduleSQLDataFile)) {
469469
echo "<p>" . $_lang['installing_demo_site'];
470470
$sqlParser->process($installPath . '/' . $moduleSQLDataFile);

assets/modules/store/installer/instprocessor.php

+18-17
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function propertiesNameValue($propertyString) {
176176
$tRow = EvolutionCms()->getDatabase()->getRow($ts,'assoc');
177177
$templateId = $tRow['id'];
178178
EvolutionCms()->getDatabase()->query("INSERT INTO `" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES('$id', '$templateId');");
179-
}
179+
}
180180
}
181181
}
182182
}
@@ -242,16 +242,17 @@ function propertiesNameValue($propertyString) {
242242
if (isset ($_POST['module']) || $installData) {
243243
echo "<h3>" . $_lang['modules'] . ":</h3> ";
244244
$selModules = $_POST['module'];
245-
foreach ($moduleModules as $k=>$moduleModule) {
245+
foreach ($moduleModules as $k => $moduleModule) {
246246
$installSample = in_array('sample', $moduleModule[7]) && $installData == 1;
247-
if($installSample || in_array($k, $selModules)) {
248-
$name = EvolutionCms()->getDatabase()->escape($moduleModule[0]);
249-
$desc = EvolutionCms()->getDatabase()->escape($moduleModule[1]);
247+
if ($installSample || in_array($k, $selModules)) {
248+
$name = evo()->getDatabase()->escape($moduleModule[0]);
249+
$desc = evo()->getDatabase()->escape($moduleModule[1]);
250250
$filecontent = $moduleModule[2];
251251
$properties = $moduleModule[3];
252-
$guid = EvolutionCms()->getDatabase()->escape($moduleModule[4]);
253-
$shared = EvolutionCms()->getDatabase()->escape($moduleModule[5]);
254-
$category = EvolutionCms()->getDatabase()->escape($moduleModule[6]);
252+
$guid = evo()->getDatabase()->escape($moduleModule[4]);
253+
$shared = evo()->getDatabase()->escape($moduleModule[5]);
254+
$category = evo()->getDatabase()->escape($moduleModule[6]);
255+
$icon = evo()->getDatabase()->escape($moduleModule[8]);
255256
if (!file_exists($filecontent))
256257
echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
257258
else {
@@ -262,19 +263,19 @@ function propertiesNameValue($propertyString) {
262263
$module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
263264
// remove installer docblock
264265
$module = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $module, 1);
265-
$module = EvolutionCms()->getDatabase()->escape($module);
266-
$rs = EvolutionCms()->getDatabase()->query("SELECT * FROM `" . $table_prefix . "site_modules` WHERE name='$name'");
267-
if (EvolutionCms()->getDatabase()->getRecordCount($rs)) {
268-
$row = EvolutionCms()->getDatabase()->getRow($rs,'assoc');
269-
$props = EvolutionCms()->getDatabase()->escape(propUpdate($properties,$row['properties']));
270-
if (!@ EvolutionCms()->getDatabase()->query("UPDATE `" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
266+
$module = evo()->getDatabase()->escape($module);
267+
$rs = evo()->getDatabase()->query("SELECT * FROM `" . $table_prefix . "site_modules` WHERE name='$name'");
268+
if (evo()->getDatabase()->getRecordCount($rs)) {
269+
$row = evo()->getDatabase()->getRow($rs,'assoc');
270+
$props = evo()->getDatabase()->escape(propUpdate($properties,$row['properties']));
271+
if (!@ evo()->getDatabase()->query("UPDATE `" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared', icon='$icon' WHERE name='$name';")) {
271272
echo "<p>" . mysql_error() . "</p>";
272273
return;
273274
}
274275
echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
275276
} else {
276-
$properties = EvolutionCms()->getDatabase()->escape(parseProperties($properties, true));
277-
if (!@ EvolutionCms()->getDatabase()->query("INSERT INTO `" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', '$category');")) {
277+
$properties = evo()->getDatabase()->escape(parseProperties($properties, true));
278+
if (!@ evo()->getDatabase()->query("INSERT INTO `" . $table_prefix . "site_modules` (name, description, modulecode, properties, guid, enable_sharedparams, category, icon) VALUES('$name', '$desc', '$module', '$properties', '$guid', '$shared', '$category', '$icon');")) {
278279
echo "<p>" . mysql_error() . "</p>";
279280
return;
280281
}
@@ -531,7 +532,7 @@ function parseProperties($propertyString, $json=false) {
531532
}
532533

533534
}
534-
// new json-format
535+
// new json-format
535536
} else if(!empty($jsonFormat)){
536537
$property = $jsonFormat;
537538
}

assets/modules/store/installer/setup.info.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157

158158
}
159159

160-
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
160+
// setup modules - array : name, description, type - 0:file or 1:content, file or content, properties, guid, enable_sharedparams, icon
161161
$mm = &$moduleModules;
162162
if (is_dir($modulePath) && is_readable($modulePath)) {
163163
$d = dir($modulePath);
@@ -176,7 +176,8 @@
176176
$params['guid'] ?? '',
177177
(int)($params['shareparams'] ?? 0),
178178
$params['modx_category'] ?? '',
179-
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
179+
array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
180+
$params['icon'] ?? ''
180181
);
181182
}
182183
}

0 commit comments

Comments
 (0)