-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUseLanguagesController.php
More file actions
106 lines (91 loc) · 2.54 KB
/
UseLanguagesController.php
File metadata and controls
106 lines (91 loc) · 2.54 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
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
<?php
/**
* SiteManagerApp Controller
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('SiteManagerAppController', 'SiteManager.Controller');
App::uses('Plugin', 'PluginManager.Model');
/**
* サイト管理【利用言語設定】
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\SiteManager\Controller
*/
class UseLanguagesController extends SiteManagerAppController {
/**
* 使用するモデル
*
* @var array
*/
public $uses = array(
'M17n.Language',
'SiteManager.SiteSetting',
'PluginManager.Plugin',
);
/**
* Helpers
*/
public $helpers = array(
'M17n.M17n',
);
/**
* edit
*
* @return void
*/
public function edit() {
list($activeLangs, $enableLangs) = $this->Language->getLanguagesWithName();
if ($this->request->is('post')) {
try {
$this->Language->begin();
$this->Plugin->begin();
$result = $this->Language->saveActive($this->data);
if (! $result) {
$this->NetCommons->handleValidationError($this->Language->validationErrors);
$this->set('validationErrors', $this->Language->validationErrors);
$activeLangs = array();
}
$this->Plugin->saveEnableM17n($this->data);
$this->Language->commit();
$this->Plugin->commit();
} catch (Exception $ex) {
$this->Language->rollback($ex);
$this->Plugin->rollback();
}
if ($result) {
$this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array(
'class' => 'success',
));
return $this->redirect($this->referer());
}
}
$plugins = $this->Plugin->cacheFindQuery('list', array(
'recursive' => -1,
'fields' => array('key', 'name'),
'conditions' => array(
'type' => Plugin::PLUGIN_TYPE_FOR_FRAME,
'language_id' => Current::read('Language.id'),
),
'order' => array('weight' => 'asc', 'id' => 'asc'),
));
$this->set('plugins', $plugins);
$plugins = $this->Plugin->cacheFindQuery('list', array(
'recursive' => -1,
'fields' => array('key', 'key'),
'conditions' => array(
'type' => Plugin::PLUGIN_TYPE_FOR_FRAME,
'language_id' => Current::read('Language.id'),
'is_m17n' => true,
),
'order' => array('weight' => 'asc', 'id' => 'asc'),
));
$this->set('isM17nPlugins', array_keys($plugins));
$this->set('activeLangs', $activeLangs);
$this->set('enableLangs', $enableLangs);
}
}