-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.defaultadmin.php
More file actions
58 lines (52 loc) · 2.34 KB
/
action.defaultadmin.php
File metadata and controls
58 lines (52 loc) · 2.34 KB
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
<?php
/** @var NetDesign $this */
if (!isset($gCms)) exit;
if (!$this->CheckPermission('NetDesign.usage')) exit;
// Form processing
if (array_key_exists('cancel', $params)) {
$this->Redirect($id, 'defaultadmin', '', array('module_error' => $this->Lang('undone')));
} elseif (array_key_exists('apply', $params)) {
foreach($params as $key => $value) {
if (in_array($key, array('apply', 'action'))) continue;
set_site_preference($key, trim($value));
}
// If the active site was changed we need to relink the language files
$mops = ModuleOperations::get_instance();
foreach($mops->GetInstalledModules() as $mod) {
$mod = $mops->get_module_instance($mod);
if (!($mod instanceof NetDesign)) continue;
$mod->IncludeSiteLang(true);
}
// Also, if the active site was changed we need to clear the cache so the admin menu gets updated
cmsms()->clear_cached_files(-1);
// All done, redirect
$this->Redirect($id, 'defaultadmin', '', array('module_message' => $this->Lang('applied')));
}
// Get a list of available site ids
$site_ids = glob(sprintf('%s/netdesign/*', $this->config['root_path']), GLOB_ONLYDIR);
array_walk($site_ids, function(&$item) {
$item = basename($item);
});
sort($site_ids);
$site_ids = array_combine($site_ids, $site_ids);
// Generate list of settings
$settings = array(
// NetDesign module
$this->Lang('general') => array(
array('caption' => $this->Lang('setting.site_id'), 'input' => $this->CreateInputDropdown($id, 'NetDesign_site_id', $site_ids, -1, get_site_preference('NetDesign_site_id')))
)
);
// Add settings registered by other modules
$settings = array_merge($settings, NetDesign::$settings);
// Generate form
$form = array(
'start' => $this->CreateFormStart($id, 'defaultadmin', ''),
'end' => $this->CreateFormEnd(),
'submit' => $this->CreateInputSubmit($id, 'apply', $this->Lang('apply'), sprintf('title="%s"', htmlentities($this->Lang('apply.title')))),
'cancel' => $this->CreateInputSubmit($id, 'cancel', $this->Lang('undo'), sprintf('title="%s"', htmlentities($this->Lang('undo.title'))))
);
// Show template
$this->AssignLang();
$this->smarty->assign('settings', $settings);
$this->smarty->assign('form', $form);
echo $this->smarty->fetch($this->GetFileResource('defaultadmin.tpl'));