OSDN Git Service

携帯関係のウィジェット、テンプレートを削除。
[magic3/magic3.git] / widgets / admin_main / include / container / admin_mainConfigsysWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2018 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id$
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() .    '/admin_mainConfigsystemBaseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_mainDb.php');
18 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/scriptLibInfo.php');
19
20 class admin_mainConfigsysWidgetContainer extends admin_mainConfigsystemBaseWidgetContainer
21 {
22         private $db;    // DB接続オブジェクト
23         private $adminTheme;            // 管理画面用jQueryUIテーマ
24         private $defaultTheme;          // フロント画面用jQueryUIテーマ
25         private $systemTemplate;// システム画面用テンプレート
26         private $jqueryVersion;                 // jQueryバージョン
27         private $wysiwygMenuData;               // WYSIWYGエディター選択メニューデータ
28         private $wysiwygEditor;                 // 管理画面用WYSIWYGエディター
29         const DEFAULT_THEME_DIR = '/ui/themes';                         // jQueryUIテーマ格納ディレクトリ
30         const DEFAULT_SYSTEM_TEMPLATE_ID = '_system';                           // デフォルトのシステム画面用テンプレート
31         const DEFAULT_JQUERY_VERSION = '1.8';                           // デフォルトのjQueryバージョン
32         
33         // DB定義値
34         const CF_USE_SSL = 'use_ssl';           // SSL機能を使用するかどうか
35         const CF_USE_SSL_ADMIN = 'use_ssl_admin';               // 管理画面にSSL機能を使用するかどうか
36         const CF_SITE_IN_PUBLIC = 'site_in_public';                     // サイト公開状況
37         const CF_SITE_PC_IN_PUBLIC = 'site_pc_in_public';                               // PC用サイトの公開状況
38         const CF_SITE_MOBILE_IN_PUBLIC = 'site_mobile_in_public';               // 携帯用サイトの公開状況
39         const CF_SITE_SMARTPHONE_IN_PUBLIC = 'site_smartphone_in_public';               // スマートフォン用サイトの公開状況
40         const CF_SMARTPHONE_AUTO_REDIRECT = 'smartphone_auto_redirect';                 // スマートフォンの自動遷移
41         const CF_SITE_SMARTPHONE_URL = 'site_smartphone_url';           // スマートフォン用サイトURL
42         const CF_SITE_OPERATION_MODE = 'site_operation_mode';                   // サイト運用モード
43         const CF_ACCESS_IN_INTRANET = 'access_in_intranet';             // イントラネット運用
44         const CF_MULTI_DOMAIN = 'multi_domain';         // マルチドメイン運用
45         const CF_USE_LANDING_PAGE = 'use_landing_page';         // ランディングページ機能を使用するかどうか
46         const CF_SITE_ACCESS_EXCEPTION_IP = 'site_access_exception_ip';         // アクセス制御、例外とするIP
47         const CF_USE_PAGE_CACHE = 'use_page_cache';             // 画面キャッシュ機能を使用するかどうか
48         const CF_USE_TEMPLATE_ID_IN_SESSION = 'use_template_id_in_session';                     // セッションにテンプレートIDを保存
49         const CF_SSL_URL = 'ssl_root_url';                              // SSL用のルートURL
50         const CF_CONNECT_SERVER_URL = 'default_connect_server_url';                     // ポータル接続先URL
51         const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type';           // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
52         const CF_SYSTEM_TEMPLATE = 'msg_template';                      // メッセージ用テンプレート取得キー
53         const CF_ADMIN_DEFAULT_THEME = 'admin_default_theme';           // 管理画面用jQueryUIテーマ
54         const CF_DEFAULT_THEME = 'default_theme';               // フロント画面用jQueryUIテーマ
55         const CF_HIERARCHICAL_PAGE = 'hierarchical_page';               // 階層化ページを使用するかどうか
56         const CF_MULTI_LANGUAGE = 'multi_language';                     // 多言語対応
57         const CF_JQUERY_VERSION = 'jquery_version';                     // jQueryバージョン
58         const CF_EXTERNAL_JQUERY = 'external_jquery';                   // システム外部のjQueryを使用するかどうか
59 //      const CF_USE_JQUERY = 'use_jquery';                     // jQueryを常に使用するかどうか
60         const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile';         // スマートフォン画面でjQuery Mobileを使用
61         const CF_WYSIWYG_EDITOR = 'wysiwyg_editor';             // 管理画面用WYSIWYGエディター
62         const CF_MULTI_DEVICE_ADMIN = 'multi_device_admin';                     // マルチデバイス最適化管理画面
63         const CF_PERMIT_DETAIL_CONFIG   = 'permit_detail_config';                               // 詳細設定が可能かどうか
64         const CF_DEFAULT_LANG           = 'default_lang';                                       // デフォルト言語
65         const CF_WORK_DIR = 'work_dir';                 // 作業ディレクトリ
66         
67         /**
68          * コンストラクタ
69          */
70         function __construct()
71         {
72                 // 親クラスを呼び出す
73                 parent::__construct();
74                 
75                 // DB接続オブジェクト作成
76                 $this->db = new admin_mainDb();
77                 
78                 $this->wysiwygMenuData = array('ckeditor' => 'CKEditor 4.4.2');         // WYSIWYGエディター選択メニューデータ
79         }
80         /**
81          * テンプレートファイルを設定
82          *
83          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
84          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
85          *
86          * @param RequestManager $request               HTTPリクエスト処理クラス
87          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
88          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
89          */
90         function _setTemplate($request, &$param)
91         {       
92                 return 'configsystem.tmpl.html';
93         }
94         /**
95          * ヘルプデータを設定
96          *
97          * ヘルプの設定を行う場合はヘルプIDを返す。
98          * ヘルプデータの読み込むディレクトリは「自ウィジェットディレクトリ/include/help」に固定。
99          *
100          * @param RequestManager $request               HTTPリクエスト処理クラス
101          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
102          * @return string                                               ヘルプID。ヘルプデータはファイル名「help_[ヘルプID].php」で作成。ヘルプを使用しない場合は空文字列「''」を返す。
103          */
104         function _setHelp($request, &$param)
105         {       
106                 return 'configsys';
107         }
108         /**
109          * テンプレートにデータ埋め込む
110          *
111          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
112          *
113          * @param RequestManager $request               HTTPリクエスト処理クラス
114          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
115          * @param                                                               なし
116          */
117         function _assign($request, &$param)
118         {
119                 $this->defaultLang              = $this->gEnv->getDefaultLanguage();
120                 
121                 $act = $request->trimValueOf('act');
122                 $useSsl = ($request->trimValueOf('item_use_ssl') == 'on') ? 1 : 0;              // SSL機能を使用するかどうか
123                 $useSslAdmin = ($request->trimValueOf('item_use_ssl_admin') == 'on') ? 1 : 0;           // 管理画面にSSL機能を使用するかどうか
124                 $useHierPage = ($request->trimValueOf('item_use_hier_page') == 'on') ? 1 : 0;           // 階層化ページを使用するかどうか
125                 $sslUrl = $request->trimValueOf('item_ssl_url');                        // SSL用のURL
126                 $connectServerUrl = $request->trimValueOf('item_connect_server_url');                   // ポータル接続先URL
127                 $siteSmartphoneUrl = $request->trimValueOf('item_site_smartphone_url');         // スマートフォン用サイトURL
128                 $usePageCache = ($request->trimValueOf('item_use_page_cache') == 'on') ? 1 : 0;         // 表示キャッシュ機能を使用するかどうか
129                 $canChangeTemplate = ($request->trimValueOf('item_can_change_template') == 'on') ? 1 : 0;               // ユーザによるテンプレート変更を許可するかどうか
130                 $canDetailConfig = ($request->trimValueOf('item_can_detail_config') == 'on') ? 1 : 0;           // 詳細システム設定が可能かどうか
131                 $multiDeviceAdmin = ($request->trimValueOf('item_multi_device_admin') == 'on') ? 1 : 0;// マルチデバイス最適化管理画面
132                 $smartphoneAutoRedirect = ($request->trimValueOf('item_smartphone_auto_redirect') == 'on') ? 1 : 0;             // スマートフォンの自動遷移
133                 $sitePcInPublic = ($request->trimValueOf('item_site_pc_in_public') == 'on') ? 1 : 0;                    // PC用サイトの公開状況
134                 $siteMobileInPublic = ($request->trimValueOf('item_site_mobile_in_public') == 'on') ? 1 : 0;    // 携帯用サイトの公開状況
135                 $siteSmartphoneInPublic = ($request->trimValueOf('item_site_smartphone_in_public') == 'on') ? 1 : 0;    // スマートフォン用サイトの公開状況
136                 $accessInIntranet       = $request->trimCheckedValueOf('item_access_in_intranet');              // イントラネット運用
137                 $multiDomain = ($request->trimValueOf('item_multi_domain') == 'on') ? 1 : 0;// マルチドメイン運用
138                 $useLandingPage         = $request->trimCheckedValueOf('item_use_landing_page');        // ランディングページ機能を使用するかどうか
139                 $isActiveSitePc = ($request->trimValueOf('item_is_active_site_pc') == 'on') ? 1 : 0;    // PC用サイト有効
140                 $isActiveSiteSmartphone = ($request->trimValueOf('item_is_active_site_smartphone') == 'on') ? 1 : 0;    // スマートフォン用サイト有効
141                 $configWindowOpenByTab = ($request->trimValueOf('item_config_window_open_by_tab') == 'on') ? 1 : 0;                     // ウィジェット設定画面をタブで開くかどうか
142                 $multiLanguage = ($request->trimValueOf('item_multi_language') == 'on') ? 1 : 0;                        // 多言語対応
143                 $lang = $request->trimValueOf('item_lang');
144                 $workDir = $request->trimValueOf('item_work_dir');
145                 $this->systemTemplate = $request->trimValueOf('item_systemplate');      // システム画面用テンプレート
146                 $this->adminTheme = $request->trimValueOf('item_admin_theme');          // 管理画面用jQueryUIテーマ
147                 $this->defaultTheme = $request->trimValueOf('item_default_theme');              // フロント画面用jQueryUIテーマ
148                 $this->jqueryVersion = $request->trimValueOf('item_jquery_version');            // jQueryバージョン
149                 $externalJquery = $request->trimCheckedValueOf('item_external_jquery');         // システム外部のjQueryを使用するかどうか
150 //              $useJquery = ($request->trimValueOf('item_use_jquery') == 'on') ? 1 : 0;                        // 常にjQueryを使用するかどうか
151                 $smartphoneUseJqueryMobile = ($request->trimValueOf('item_smartphone_use_jquery_mobile') == 'on') ? 1 : 0;// スマートフォン画面でjQuery Mobileを使用
152                 $this->wysiwygEditor = $request->trimValueOf('item_wysiwyg_editor');                    // 管理画面用WYSIWYGエディター
153                 $uploadImageAutoresize = $request->trimCheckedValueOf('item_upload_image_autoresize');          // アップロード画像の自動リサイズを行うかどうか
154                 $uploadImageAutoresizeMaxWidth = $request->trimValueOf('item_upload_image_autoresize_max_width');               // アップロード画像の自動リサイズ、画像最大幅
155                 $uploadImageAutoresizeMaxHeight = $request->trimValueOf('item_upload_image_autoresize_max_height');             // アップロード画像の自動リサイズ、画像最大高さ
156                 $isHier = $request->trimValueOf('menu_type');
157                 
158                 if ($act == 'update'){          // 設定更新のとき
159                         $isErr = false;
160                         if (!$isErr && !empty($lang)){
161                                 if (!$this->db->updateSystemConfig(self::CF_DEFAULT_LANG, $lang)) $isErr = true;
162                         }
163                         if (!$isErr){
164                                 if (!$this->db->updateSystemConfig(self::CF_USE_SSL, $useSsl)) $isErr = true;                   // SSL機能を使用するかどうか
165                         }
166                         if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_USE_SSL_ADMIN, $useSslAdmin)) $isErr = true;                   // SSL機能を使用するかどうか
167                         if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_HIERARCHICAL_PAGE, $useHierPage)) $isErr = true;                       // 階層化ページを使用するかどうか
168                         if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_USE_PAGE_CACHE, $usePageCache)) $isErr = true;                 // 表示キャッシュ機能を使用するかどうか
169                         if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_USE_TEMPLATE_ID_IN_SESSION, $canChangeTemplate)) $isErr = true;// ユーザによるテンプレート変更を許可するかどうか
170                         if (!$isErr){
171                                 if (!$this->db->updateSystemConfig(self::CF_PERMIT_DETAIL_CONFIG, $canDetailConfig)) $isErr = true;
172                         }
173                         if (!$isErr){
174                                 if (!$this->db->updateSystemConfig(self::CF_MULTI_DEVICE_ADMIN, $multiDeviceAdmin)) $isErr = true;// マルチデバイス最適化管理画面
175                         }
176                         if (!$isErr){
177                                 if (!$this->db->updateSystemConfig(self::CF_SMARTPHONE_AUTO_REDIRECT, $smartphoneAutoRedirect)) $isErr = true;
178                         }
179                         if (!$isErr){
180                                 if (!$this->db->updateSystemConfig(self::CF_SITE_PC_IN_PUBLIC, $sitePcInPublic)) $isErr = true;
181                         }
182                         if (!$isErr){
183                                 if (!$this->db->updateSystemConfig(self::CF_SITE_MOBILE_IN_PUBLIC, $siteMobileInPublic)) $isErr = true;
184                         }
185                         if (!$isErr){
186                                 if (!$this->db->updateSystemConfig(self::CF_SITE_SMARTPHONE_IN_PUBLIC, $siteSmartphoneInPublic)) $isErr = true;
187                         }
188                         if (!$isErr){
189                                 if (!$this->db->updateSystemConfig(self::CF_ACCESS_IN_INTRANET, $accessInIntranet)) $isErr = true;// イントラネット運用
190                         }
191                         if (!$isErr){
192                                 if (!$this->db->updateSystemConfig(self::CF_MULTI_DOMAIN, $multiDomain)) $isErr = true;// マルチドメイン運用
193                         }
194                         if (!$isErr){
195                                 if (!$this->db->updateSystemConfig(self::CF_USE_LANDING_PAGE, $useLandingPage)) $isErr = true;// ランディングページ機能を使用するかどうか
196                         }
197                         if (!$isErr){
198                                 if (!$this->updateActiveAccessPoint(0/*PC*/, $isActiveSitePc)) $isErr = true;// PC用サイト有効
199                         }
200                         if (!$isErr){
201                                 if (!$this->updateActiveAccessPoint(2/*スマートフォン*/, $isActiveSiteSmartphone)) $isErr = true;// スマートフォン用サイト有効
202                         }
203                         if (!$isErr){
204                                 if (!$this->db->updateSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE, $configWindowOpenByTab)) $isErr = true;                    // ウィジェット設定画面をタブで開くかどうか
205                         }
206                         if (!$isErr){
207                                 if (!$this->db->updateSystemConfig(self::CF_MULTI_LANGUAGE, $multiLanguage)) $isErr = true;                     // 多言語対応
208                         }
209                         if (!$isErr){
210                                 $sslUrl = rtrim($sslUrl, '/');// 最後の「/」を除く
211                                 $sslUrl = str_replace('http://', 'https://', $sslUrl);// httpの場合はhttpsに変更
212                                 if (!$this->db->updateSystemConfig(self::CF_SSL_URL, $sslUrl)) $isErr = true;
213                         }
214                         if (!$isErr){
215                                 $connectServerUrl = rtrim($connectServerUrl, '/');// 最後の「/」を除く
216                                 if (!$this->db->updateSystemConfig(self::CF_CONNECT_SERVER_URL, $connectServerUrl)) $isErr = true;// ポータル接続先URL
217                         }
218                         if (!$isErr){
219                                 $siteSmartphoneUrl = rtrim($siteSmartphoneUrl, '/');// 最後の「/」を除く
220                                 if (!$this->db->updateSystemConfig(self::CF_SITE_SMARTPHONE_URL, $siteSmartphoneUrl)) $isErr = true;// スマートフォン用サイトURL
221                         }
222                         if (!$isErr){
223                                 $workDir = rtrim($workDir, '/');// 最後の「/」を除く
224                                 if (!$this->db->updateSystemConfig(self::CF_WORK_DIR, $workDir)) $isErr = true;
225                         }
226                         if (!$isErr){
227                                 if (!$this->db->updateSystemConfig(self::CF_SYSTEM_TEMPLATE, $this->systemTemplate)) $isErr = true;// システム画面用テンプレート
228                         }
229                         // 管理画面用jQueryUIテーマは「smoothness」に固定(2017/4/25)
230 //                      if (!$isErr){
231 //                              if (!$this->db->updateSystemConfig(self::CF_ADMIN_DEFAULT_THEME, $this->adminTheme)) $isErr = true;// 管理画面用jQueryUIテーマ
232 //                      }
233                         if (!$isErr){
234                                 if (!$this->db->updateSystemConfig(self::CF_DEFAULT_THEME, $this->defaultTheme)) $isErr = true;// フロント画面用jQueryUIテーマ
235                         }
236                         if (!$isErr){
237                                 if (!$this->db->updateSystemConfig(self::CF_JQUERY_VERSION, $this->jqueryVersion)) $isErr = true;// jQueryバージョン
238                         }
239                         if (!$isErr){
240                                 if (!$this->db->updateSystemConfig(self::CF_EXTERNAL_JQUERY, $externalJquery)) $isErr = true;// システム外部のjQueryを使用するかどうか
241                         }
242 /*                      if (!$isErr){
243                                 if (!$this->db->updateSystemConfig(self::CF_USE_JQUERY, $useJquery)) $isErr = true;// 常にjQueryを使用するかどうか
244                         }*/
245                         if (!$isErr){
246                                 if (!$this->db->updateSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE, $smartphoneUseJqueryMobile)) $isErr = true;// スマートフォン画面でjQuery Mobileを使用
247                         }
248                         if (!$isErr){
249                                 if (!$this->db->updateSystemConfig(self::CF_WYSIWYG_EDITOR, $this->wysiwygEditor)) $isErr = true;// 管理画面用WYSIWYGエディター
250                         }               
251                         if (!$isErr){
252                                 if (!$this->db->updateSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE, $uploadImageAutoresize)) $isErr = true;           // アップロード画像の自動リサイズを行うかどうか
253                         }
254                         if (!$isErr){
255                                 if (!$this->db->updateSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_WIDTH, $uploadImageAutoresizeMaxWidth)) $isErr = true;         // アップロード画像の自動リサイズ、画像最大幅
256                         }
257                         if (!$isErr){
258                                 if (!$this->db->updateSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_HEIGHT, $uploadImageAutoresizeMaxHeight)) $isErr = true;               // アップロード画像の自動リサイズ、画像最大高さ
259                         }
260                         if (!$isErr){
261                                 if (!$this->gSystem->changeSiteMenuHier($isHier)) $isErr = true;// メニュー管理画面を変更
262                         }
263                         
264                         if ($isErr){
265                                 $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
266                         } else {
267                                 $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
268                         }
269                         // システムパラメータを更新
270                         $this->gEnv->loadSystemParams();
271                         
272                         // 値を再取得
273                         $this->defaultLang              = $this->gEnv->getDefaultLanguage();
274                         $useSsl                         = $this->db->getSystemConfig(self::CF_USE_SSL);                 // SSL機能を使用するかどうか
275                         $useSslAdmin            = $this->db->getSystemConfig(self::CF_USE_SSL_ADMIN);                   // SSL機能を使用するかどうか
276                         $useHierPage            = $this->db->getSystemConfig(self::CF_HIERARCHICAL_PAGE);                       // 階層化ページを使用するかどうか
277                         $sslUrl                         = $this->db->getSystemConfig(self::CF_SSL_URL);                 // SSLのURL
278                         $connectServerUrl       = $this->db->getSystemConfig(self::CF_CONNECT_SERVER_URL);// ポータル接続先URL
279                         $usePageCache           = $this->db->getSystemConfig(self::CF_USE_PAGE_CACHE);                  // 表示キャッシュ機能を使用するかどうか
280                         $canChangeTemplate      = $this->db->getSystemConfig(self::CF_USE_TEMPLATE_ID_IN_SESSION);// ユーザによるテンプレート変更を許可するかどうか
281                         $canDetailConfig        = $this->db->getSystemConfig(self::CF_PERMIT_DETAIL_CONFIG);
282                         $multiDeviceAdmin       = $this->db->getSystemConfig(self::CF_MULTI_DEVICE_ADMIN);              // マルチデバイス最適化管理画面
283                         $smartphoneAutoRedirect = $this->gSystem->smartphoneAutoRedirect(true/*再取得*/);            // スマートフォンの自動遷移
284                         $workDir = $this->db->getSystemConfig(self::CF_WORK_DIR);
285                         $sitePcInPublic = $this->gSystem->sitePcInPublic(true/*再取得*/);                    // PC用サイトの公開状況
286                         $siteMobileInPublic = $this->gSystem->siteMobileInPublic(true/*再取得*/);    // 携帯用サイトの公開状況
287                         $siteSmartphoneInPublic = $this->gSystem->siteSmartphoneInPublic(true/*再取得*/);    // スマートフォン用サイトの公開状況
288                         $accessInIntranet       = $this->db->getSystemConfig(self::CF_ACCESS_IN_INTRANET);              // イントラネット運用
289                         $multiDomain            = $this->db->getSystemConfig(self::CF_MULTI_DOMAIN);                    // マルチドメイン運用
290                         $useLandingPage         = $this->db->getSystemConfig(self::CF_USE_LANDING_PAGE);// ランディングページ機能を使用するかどうか
291                         $isActiveSitePc                 = $this->isActiveAccessPoint(0/*PC*/);                                  // PC用サイト有効かどうか
292                         $isActiveSiteSmartphone = $this->isActiveAccessPoint(2/*スマートフォン*/);               // スマートフォン用サイト有効かどうか
293                         $siteSmartphoneUrl = $this->db->getSystemConfig(self::CF_SITE_SMARTPHONE_URL);          // スマートフォン用サイトURL
294                         $configWindowOpenByTab = $this->db->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);                  // ウィジェット設定画面をタブで開くかどうか
295                         $multiLanguage = $this->gSystem->getSystemConfig(self::CF_MULTI_LANGUAGE);              // 多言語対応かどうか
296                         $this->systemTemplate           = $this->db->getSystemConfig(self::CF_SYSTEM_TEMPLATE);// システム画面用テンプレート
297                         $this->adminTheme = $this->db->getSystemConfig(self::CF_ADMIN_DEFAULT_THEME);           // 管理画面用jQueryUIテーマ
298                         $this->defaultTheme = $this->db->getSystemConfig(self::CF_DEFAULT_THEME);               // フロント画面用jQueryUIテーマ
299                         $this->jqueryVersion = $this->db->getSystemConfig(self::CF_JQUERY_VERSION);             // jQueryバージョン
300                         if (empty($this->jqueryVersion)) $this->jqueryVersion = self::DEFAULT_JQUERY_VERSION;
301                         $externalJquery = $this->db->getSystemConfig(self::CF_EXTERNAL_JQUERY);// システム外部のjQueryを使用するかどうか
302 //                      $useJquery = $this->db->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
303                         $smartphoneUseJqueryMobile = $this->db->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面でjQuery Mobileを使用
304                         $this->wysiwygEditor = $this->db->getSystemConfig(self::CF_WYSIWYG_EDITOR);                     // 管理画面用WYSIWYGエディター
305                         $uploadImageAutoresize = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE);         // アップロード画像の自動リサイズを行うかどうか
306                         $uploadImageAutoresizeMaxWidth = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_WIDTH);       // アップロード画像の自動リサイズ、画像最大幅
307                         $uploadImageAutoresizeMaxHeight = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_HEIGHT);     // アップロード画像の自動リサイズ、画像最大高さ
308                         $isHier = $this->gSystem->isSiteMenuHier();             // メニューを階層化するかどうかを取得
309                         
310                         // ### サイト定義ファイル(siteDef.php)にオプション定義を追加 ###
311                         $adminUrl = $this->gEnv->getAdminUrl();                 // 管理機能URL
312                         $params = array();
313                         $params['M3_SYSTEM_ADMIN_URL'] = $adminUrl;
314                         $ret = $this->gConfig->updateOptionParam($params, $msg);
315                         if (!$ret) var_dump($msg);
316                         
317                 } else if ($act == 'updateip'){         // IPアドレスを更新のとき
318                         $exceptIp = $request->trimValueOf('except_ip');
319
320                         // 入力チェック
321                         $this->checkIp($exceptIp, 'IP', true);
322                         
323                         // エラーなしの場合は、データを更新
324                         if ($this->getMsgCount() == 0){
325                                 $isErr = false;
326                                 if (!$this->db->updateSystemConfig(self::CF_SITE_ACCESS_EXCEPTION_IP, $exceptIp)) $isErr = true;
327                                 if ($isErr){
328                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
329                                 } else {
330                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
331                                 }
332                         }
333                 } else if ($act == 'siteopen'){         // サイト運用開始のとき
334                         $this->db->updateSystemConfig(self::CF_SITE_IN_PUBLIC, 1);
335                 } else if ($act == 'siteclose'){                // サイト運用停止のとき
336                         $this->db->updateSystemConfig(self::CF_SITE_IN_PUBLIC, 0);
337                 } else if ($act == 'site_operation_mode_on'){                   // サイト運用モード変更
338                         // システム制御マネージャーの値を更新
339                         $this->gSystem->updateSystemConfig(self::CF_SITE_OPERATION_MODE, 1);
340                 } else if ($act == 'site_operation_mode_off'){                  // サイト運用モード変更
341                         // システム制御マネージャーの値を更新
342                         $this->gSystem->updateSystemConfig(self::CF_SITE_OPERATION_MODE, 0);
343                 } else if ($act == 'clearcache'){               // キャッシュクリアのとき
344                         $ret = $this->gCache->clearAllCache();
345                         if ($ret){
346                                 $this->setMsg(self::MSG_GUIDANCE, 'キャッシュをクリアしました');
347                         } else {
348                                 $this->setMsg(self::MSG_APP_ERR, 'キャッシュをクリアに失敗しました');
349                         }
350                 } else {                // 初期表示の場合
351                         $useSsl                         = $this->db->getSystemConfig(self::CF_USE_SSL);                 // SSL機能を使用するかどうか
352                         $useSslAdmin            = $this->db->getSystemConfig(self::CF_USE_SSL_ADMIN);                   // SSL機能を使用するかどうか
353                         $useHierPage            = $this->db->getSystemConfig(self::CF_HIERARCHICAL_PAGE);               // 階層化ページを使用するかどうか
354                         $sslUrl                         = $this->db->getSystemConfig(self::CF_SSL_URL);                 // SSLのURL
355                         $connectServerUrl       = $this->db->getSystemConfig(self::CF_CONNECT_SERVER_URL);// ポータル接続先URL
356                         $usePageCache           = $this->db->getSystemConfig(self::CF_USE_PAGE_CACHE);                  // 表示キャッシュ機能を使用するかどうか
357                         $canChangeTemplate      = $this->db->getSystemConfig(self::CF_USE_TEMPLATE_ID_IN_SESSION);// ユーザによるテンプレート変更を許可するかどうか
358                         $canDetailConfig        = $this->db->getSystemConfig(self::CF_PERMIT_DETAIL_CONFIG);
359                         $multiDeviceAdmin       = $this->db->getSystemConfig(self::CF_MULTI_DEVICE_ADMIN);              // マルチデバイス最適化管理画面
360                         $smartphoneAutoRedirect = $this->gSystem->smartphoneAutoRedirect(true/*再取得*/);            // スマートフォンの自動遷移
361                         $workDir                                = $this->db->getSystemConfig(self::CF_WORK_DIR);
362                         $sitePcInPublic = $this->gSystem->sitePcInPublic(true/*再取得*/);                    // PC用サイトの公開状況
363                         $siteMobileInPublic = $this->gSystem->siteMobileInPublic(true/*再取得*/);    // 携帯用サイトの公開状況
364                         $siteSmartphoneInPublic = $this->gSystem->siteSmartphoneInPublic(true/*再取得*/);    // スマートフォン用サイトの公開状況
365                         $accessInIntranet       = $this->db->getSystemConfig(self::CF_ACCESS_IN_INTRANET);              // イントラネット運用
366                         $multiDomain            = $this->db->getSystemConfig(self::CF_MULTI_DOMAIN);// マルチドメイン運用
367                         $useLandingPage         = $this->db->getSystemConfig(self::CF_USE_LANDING_PAGE);// ランディングページ機能を使用するかどうか
368                         $isActiveSitePc                 = $this->isActiveAccessPoint(0/*PC*/);                                  // PC用サイト有効かどうか
369                         $isActiveSiteSmartphone = $this->isActiveAccessPoint(2/*スマートフォン*/);               // スマートフォン用サイト有効かどうか
370                         $siteSmartphoneUrl = $this->db->getSystemConfig(self::CF_SITE_SMARTPHONE_URL);          // スマートフォン用サイトURL
371                         $configWindowOpenByTab = $this->db->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);                  // ウィジェット設定画面をタブで開くかどうか
372                         $multiLanguage = $this->gSystem->getSystemConfig(self::CF_MULTI_LANGUAGE);              // 多言語対応かどうか
373                         $this->systemTemplate           = $this->db->getSystemConfig(self::CF_SYSTEM_TEMPLATE);// システム画面用テンプレート
374                         $this->adminTheme = $this->db->getSystemConfig(self::CF_ADMIN_DEFAULT_THEME);           // 管理画面用jQueryUIテーマ
375                         $this->defaultTheme = $this->db->getSystemConfig(self::CF_DEFAULT_THEME);               // フロント画面用jQueryUIテーマ
376                         $this->jqueryVersion = $this->db->getSystemConfig(self::CF_JQUERY_VERSION);             // jQueryバージョン
377                         if (empty($this->jqueryVersion)) $this->jqueryVersion = self::DEFAULT_JQUERY_VERSION;
378                         $externalJquery = $this->db->getSystemConfig(self::CF_EXTERNAL_JQUERY);// システム外部のjQueryを使用するかどうか
379 //                      $useJquery = $this->db->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
380                         $smartphoneUseJqueryMobile = $this->db->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面でjQuery Mobileを使用
381                         $this->wysiwygEditor = $this->db->getSystemConfig(self::CF_WYSIWYG_EDITOR);                     // 管理画面用WYSIWYGエディター
382                         $uploadImageAutoresize = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE);         // アップロード画像の自動リサイズを行うかどうか
383                         $uploadImageAutoresizeMaxWidth = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_WIDTH);       // アップロード画像の自動リサイズ、画像最大幅
384                         $uploadImageAutoresizeMaxHeight = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_HEIGHT);     // アップロード画像の自動リサイズ、画像最大高さ
385                         $isHier = $this->gSystem->isSiteMenuHier();             // メニューを階層化するかどうかを取得
386                 }
387                 // 言語選択メニューを作成
388                 $this->db->getLangs($this->gSystem->getSystemLanguages(), array($this, 'langLoop'));
389                 
390                 // システム画面用テンプレート作成
391                 $this->db->getAllTemplateList(0/*PC用*/, array($this, 'sysTemplateLoop'), false/*利用不可も表示*/);
392                 
393                 // jQueryUIテーマ選択メニュー作成
394                 $this->createAdminThemeMenu($this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR);
395                 $this->createDefaultThemeMenu($this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR);
396                 
397                 // jQueryバージョン選択メニュー作成
398                 $this->createJqueryVerMenu(ScriptLibInfo::getJQueryVersionInfo());
399                 
400                 // WYSIWYGエディター選択メニュー作成
401                 $this->createWysiwygMenu();
402                 
403                 // サイトURL
404                 $this->tmpl->addVar("_widget", "site_url", $this->gEnv->getRootUrl());
405                 $this->tmpl->addVar("show_site_pc_open", "pc_access_url", $this->gEnv->getDefaultUrl());
406                 $this->tmpl->addVar("show_site_smartphone_open", "smartphone_access_url", $this->gEnv->getDefaultSmartphoneUrl());
407                 $this->tmpl->addVar("_widget", "admin_access_url", $this->gEnv->getDefaultAdminUrl());
408                 
409                 // サイト運用状況を設定
410                 $checked = '';
411                 if ($this->gSystem->siteInPublic(true/*再取得*/)) $checked = 'checked';              // 運用中のとき
412                 $this->tmpl->addVar("_widget", "site_status_checked", $checked);
413                 $this->tmpl->addVar("_widget", "except_ip", $this->db->getSystemConfig(self::CF_SITE_ACCESS_EXCEPTION_IP));
414                 $checked = '';
415                 if ($this->db->getSystemConfig(self::CF_SITE_OPERATION_MODE) == '1') $checked = 'checked';              // サイト運用モードのとき
416                 $this->tmpl->addVar("_widget", "site_operation_mode_checked", $checked);
417                 
418                 // 項目の表示制御
419                 $isActiveSite = $this->gSystem->getSiteActiveStatus(0);         // PC用サイト
420                 if ($isActiveSite){
421                         $this->tmpl->setAttribute('show_site_pc_open', 'visibility', 'visible');
422                 } else {
423                         $this->tmpl->setAttribute('show_site_pc_close', 'visibility', 'visible');
424                 }
425                 $isActiveSite = $this->gSystem->getSiteActiveStatus(2);         // スマートフォン用サイト
426                 if ($isActiveSite){
427                         $this->tmpl->setAttribute('show_site_smartphone_open', 'visibility', 'visible');
428                 } else {
429                         $this->tmpl->setAttribute('show_site_smartphone_close', 'visibility', 'visible');
430                 }
431                 
432                 // SSL証明書期限を取得
433                 if (!empty($sslUrl)){
434                         $expireDt = $this->_getSslExpireDt($sslUrl, $sslDomain);
435                         if (empty($expireDt)){
436                                 $expireDtTag = '未取得';
437                         } else {
438                                 if (time() <= $expireDt){
439                                         $expireDt = date("Y/m/d H:i:s", $expireDt);
440                                         $expireDtTag = '<span class="available">' . $this->convertToDispDateTime($expireDt) . '</span>';
441                                 } else {
442                                         $expireDt = date("Y/m/d H:i:s", $expireDt);
443                                         $expireDtTag = '<span class="stopped">' . $this->convertToDispDateTime($expireDt) . '</span>';
444                                 }
445                         }
446                 }
447                 
448                 // 画面に書き戻す
449                 $checked = '';
450                 if ($sitePcInPublic) $checked = 'checked';
451                 $this->tmpl->addVar("show_site_pc_open", "site_pc_in_public", $checked);// PC用サイトの公開状況
452                 $checked = '';
453                 if ($siteSmartphoneInPublic) $checked = 'checked';
454                 $this->tmpl->addVar("show_site_smartphone_open", "site_smartphone_in_public", $checked);// スマートフォン用サイトの公開状況
455                 $this->tmpl->addVar("_widget", "access_in_intranet", $this->convertToCheckedString($accessInIntranet));// イントラネット運用
456                 $checked = '';
457                 if ($multiDomain) $checked = 'checked';
458                 $this->tmpl->addVar("_widget", "multi_domain", $checked);// マルチドメイン運用
459                 $this->tmpl->addVar("_widget", "use_landing_page_checked", $this->convertToCheckedString($useLandingPage));// ランディングページ機能を使用するかどうか
460                 $checked = '';
461                 if ($isActiveSitePc) $checked = 'checked';
462                 $this->tmpl->addVar("_widget", "is_active_site_pc", $checked);// PC用サイト有効
463                 $checked = '';
464                 if ($isActiveSiteSmartphone) $checked = 'checked';
465                 $this->tmpl->addVar("_widget", "is_active_site_smartphone", $checked);// スマートフォン用サイト有効
466                 $checked = '';
467                 if ($useSsl) $checked = 'checked';
468                 $this->tmpl->addVar("_widget", "use_ssl", $checked);// SSL機能を使用するかどうか
469                 $checked = '';
470                 if ($useSslAdmin) $checked = 'checked';
471                 $this->tmpl->addVar("_widget", "use_ssl_admin", $checked);// 管理画面にSSL機能を使用するかどうか
472                 $checked = '';
473                 if ($useHierPage) $checked = 'checked';
474                 $this->tmpl->addVar("_widget", "use_hier_page", $checked);// 階層化ページを使用するかどうか
475                 $checked = '';
476                 if ($usePageCache) $checked = 'checked';
477                 $this->tmpl->addVar("_widget", "use_page_cache", $checked);     // 表示キャッシュ機能を使用するかどうか
478                 $checked = '';
479                 if ($canChangeTemplate) $checked = 'checked';
480                 $this->tmpl->addVar("_widget", "can_change_template", $checked);        // ユーザによるテンプレート変更を許可するかどうか
481                 $checked = '';
482                 if ($multiLanguage) $checked = 'checked';
483                 $this->tmpl->addVar("_widget", "multi_language", $checked);     // 多言語対応かどうか
484                 $this->tmpl->addVar("_widget", "external_jquery", $this->convertToCheckedString($externalJquery));// システム外部のjQueryを使用するかどうか
485 //              $checked = '';
486 //              if ($useJquery) $checked = 'checked';
487 //              $this->tmpl->addVar("_widget", "use_jquery", $checked);         // 常にjQueryを使用するかどうか
488                 $checked = '';
489                 if ($smartphoneUseJqueryMobile) $checked = 'checked';
490                 $this->tmpl->addVar("_widget", "smartphone_use_jquery_mobile", $checked);               // スマートフォン画面でjQuery Mobileを使用
491                 if ($isHier){           // 階層化メニューのとき
492                         $this->tmpl->addVar("_widget", "menu_type_tree", 'checked');            // 多階層メニュー
493                 } else {
494                         $this->tmpl->addVar("_widget", "menu_type_single", 'checked');          // 単階層メニュー
495                 }
496                 
497                 // URL
498                 $this->tmpl->addVar("_widget", "root_url", $this->gEnv->getRootUrl());
499                 $this->tmpl->addVar("_widget", "connect_server_url", $connectServerUrl);// ポータル接続先URL
500                 $this->tmpl->addVar("_widget", "site_smartphone_url", $siteSmartphoneUrl);              // スマートフォン用サイトURL
501                 
502                 // 共有SSL用のURL
503                 if (!empty($sslUrl)){
504                         $this->tmpl->setAttribute('show_ssl_url', 'visibility', 'hidden');
505                         $this->tmpl->setAttribute('show_ssl_url_expiredt', 'visibility', 'visible');            // SSLの期限を表示
506                         
507                         $this->tmpl->addVar("show_ssl_url_expiredt", "ssl_url", $sslUrl);// SSLのURL
508                         $this->tmpl->addVar('show_ssl_url_expiredt', 'ssl_expire_dt',   $expireDtTag);          // SSL証明書期限
509                 }
510                                 
511                 $checked = '';
512                 if ($canDetailConfig) $checked = 'checked';
513                 $this->tmpl->addVar("_widget", "can_detail_config", $checked);
514                 $this->tmpl->addVar("_widget", "multi_device_admin", $this->convertToCheckedString($multiDeviceAdmin));// マルチデバイス最適化管理画面
515                 $checked = '';
516                 if (!empty($smartphoneAutoRedirect)) $checked = 'checked';
517                 $this->tmpl->addVar("_widget", "smartphone_auto_redirect", $checked);// スマートフォンの自動遷移
518                 $checked = '';
519                 if (!empty($configWindowOpenByTab)) $checked = 'checked';                       // ウィジェット設定画面をタブで開くかどうか
520                 $this->tmpl->addVar("_widget", "config_window_open_by_tab", $checked);
521
522                 $this->tmpl->addVar("_widget", "upload_image_autoresize", $this->convertToCheckedString($uploadImageAutoresize));                       // アップロード画像の自動リサイズを行うかどうか
523                 $this->tmpl->addVar("_widget", "upload_image_autoresize_max_width", $uploadImageAutoresizeMaxWidth);            // アップロード画像の自動リサイズ、画像最大幅
524                 $this->tmpl->addVar("_widget", "upload_image_autoresize_max_height", $uploadImageAutoresizeMaxHeight);          // アップロード画像の自動リサイズ、画像最大高さ
525                         
526                 // 一時ディレクトリ
527                 $this->tmpl->addVar("_widget", "work_dir", $workDir);
528                 if (is_writable($workDir)){
529                         if (checkWritableDir($workDir)){
530                                 $data = '<b><font color="green">書き込み可能</font></b>';
531                         } else {
532                                 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
533                         }
534                 } else {
535                         $data = '<b><font color="red">書き込み不可</font></b>';
536                 }
537                 $this->tmpl->addVar("_widget","work_dir_access", $data);                // 一時ディレクトリの書き込み権限
538                 $this->tmpl->addVar("_widget", "system_db_version", $this->db->getSystemConfig(M3_TB_FIELD_DB_VERSION));                // Magic3システムDBバージョン
539                 $this->tmpl->addVar("_widget", "system_db_update_dt", $this->db->getSystemConfig(M3_TB_FIELD_DB_UPDATE_DT));    // Magic3システムDB更新日時
540
541                 // リソース格納ディレクトリパス
542                 $path = $this->gEnv->getResourcePath();
543                 $this->tmpl->addVar("_widget", "resource_dir", $path);
544                 if (is_writable($path)){
545                         if (checkWritableDir($path)){
546                                 $data = '<b><font color="green">書き込み可能</font></b>';
547                         } else {
548                                 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
549                         }
550                 } else {
551                         $data = '<b><font color="red">書き込み不可</font></b>';
552                 }
553                 $this->tmpl->addVar("_widget", "resource_dir_access", $data);
554
555                 // テンプレートディレクトリ
556                 $path = $this->gEnv->getTemplatesPath();
557                 $this->tmpl->addVar("_widget", "templates_dir", $path);
558                 if (is_writable($path)){
559                         if (checkWritableDir($path)){
560                                 $data = '<b><font color="green">書き込み可能</font></b>';
561                         } else {
562                                 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
563                         }
564                 } else {
565                         $data = '<b><font color="red">書き込み不可</font></b>';
566                 }
567                 $this->tmpl->addVar("_widget", "templates_dir_access", $data);
568                 
569                 // ウィジェットディレクトリ
570                 $path = $this->gEnv->getWidgetsPath();
571                 $this->tmpl->addVar("_widget", "widgets_dir", $path);
572                 if (is_writable($path)){
573                         if (checkWritableDir($path)){
574                                 $data = '<b><font color="green">書き込み可能</font></b>';
575                         } else {
576                                 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
577                         }
578                 } else {
579                         $data = '<b><font color="red">書き込み不可</font></b>';
580                 }
581                 $this->tmpl->addVar("_widget", "widgets_dir_access", $data);
582                 
583                 // 非公開リソースディレクトリ
584                 $path = $this->gEnv->getPrivateResourcePath();
585                 $this->tmpl->addVar("_widget", "private_resource_dir", $path);
586                 if (is_writable($path)){
587                         if (checkWritableDir($path)){
588                                 $data = '<b><font color="green">書き込み可能</font></b>';
589                         } else {
590                                 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
591                         }
592                 } else {
593                         $data = '<b><font color="red">書き込み不可</font></b>';
594                 }
595                 $this->tmpl->addVar("_widget", "private_resource_dir_access", $data);
596                 
597                 // ディレクトリサイズ
598                 $size = convFromBytes(calcDirSize($this->gEnv->getResourcePath()));
599                 $this->tmpl->addVar("_widget", "resource_dir_size", $size);
600         }
601         /**
602          * 取得した言語をテンプレートに設定する
603          *
604          * @param int $index                    行番号(0~)
605          * @param array $fetchedRow             フェッチ取得した行
606          * @param object $param                 未使用
607          * @return bool                                 true=処理続行の場合、false=処理終了の場合
608          */
609         function langLoop($index, $fetchedRow, $param)
610         {
611                 $selected = '';
612                 if ($fetchedRow['ln_id'] == $this->defaultLang){
613                         $selected = 'selected';
614                 }
615                 //if ($this->gEnv->getCurrentLanguage() == 'ja'){               // 日本語表示の場合
616                         $name = $this->convertToDispString($fetchedRow['ln_name']) . ' - ';
617                 //} else {
618                         $name .= $this->convertToDispString($fetchedRow['ln_name_en']);
619                 //}
620
621                 $row = array(
622                         'value'    => $this->convertToDispString($fetchedRow['ln_id']),                 // 言語ID
623                         'name'     => $name,                    // 言語名
624                         'selected' => $selected                                                                                                         // 選択中かどうか
625                 );
626                 $this->tmpl->addVars('lang_list', $row);
627                 $this->tmpl->parseTemplate('lang_list', 'a');
628                 return true;
629         }
630         /**
631          * jQueryUIテーマの選択メニューを作成
632          *
633          * @param string $dir           テーマのディレクトリ
634          * @return                                      なし
635          */
636         function createAdminThemeMenu($themeDir)
637         {
638                 if (is_dir($themeDir)){
639                         $dir = dir($themeDir);
640                         while (($file = $dir->read()) !== false){
641                                 $filePath = $themeDir . '/' . $file;
642                                 // ディレクトリかどうかチェック
643                                 if (strncmp($file, '.', 1) != 0 && $file != '..' && is_dir($filePath) &&
644                                         strncmp($file, '_', 1) != 0){   // 「_」で始まる名前のディレクトリは読み込まない
645
646                                         $selected = '';
647                                         if ($file == $this->adminTheme) $selected = 'selected';
648                                         
649                                         $row = array(
650                                                 'value'    => $this->convertToDispString($file),                        // テーマID
651                                                 'name'     => $this->convertToDispString($file),
652                                                 'selected' => $selected                 // 選択中かどうか
653                                         );
654                                         $this->tmpl->addVars('admin_theme_list', $row);
655                                         $this->tmpl->parseTemplate('admin_theme_list', 'a');
656                                 }
657                         }
658                         $dir->close();
659                 }
660         }
661         /**
662          * jQueryUIテーマの選択メニューを作成
663          *
664          * @param string $dir           テーマのディレクトリ
665          * @return                                      なし
666          */
667         function createDefaultThemeMenu($themeDir)
668         {
669                 $selected = '';
670                 if (empty($this->defaultTheme)) $selected = 'selected';
671                 
672                 $row = array(
673                         'value'    => '',                       // テーマID
674                         'name'     => '-- 指定なし --',
675                         'selected' => $selected                 // 選択中かどうか
676                 );
677                 $this->tmpl->addVars('theme_list', $row);
678                 $this->tmpl->parseTemplate('theme_list', 'a');
679                                         
680                 if (is_dir($themeDir)){
681                         $dir = dir($themeDir);
682                         while (($file = $dir->read()) !== false){
683                                 $filePath = $themeDir . '/' . $file;
684                                 // ディレクトリかどうかチェック
685                                 if (strncmp($file, '.', 1) != 0 && $file != '..' && is_dir($filePath) &&
686                                         strncmp($file, '_', 1) != 0){   // 「_」で始まる名前のディレクトリは読み込まない
687
688                                         $selected = '';
689                                         if ($file == $this->defaultTheme) $selected = 'selected';
690                                         
691                                         $row = array(
692                                                 'value'    => $this->convertToDispString($file),                        // テーマID
693                                                 'name'     => $this->convertToDispString($file),
694                                                 'selected' => $selected                 // 選択中かどうか
695                                         );
696                                         $this->tmpl->addVars('theme_list', $row);
697                                         $this->tmpl->parseTemplate('theme_list', 'a');
698                                 }
699                         }
700                         $dir->close();
701                 }
702         }
703         /**
704          * システム画面用テンプレート一覧を作成
705          *
706          * @param int $index                    行番号(0~)
707          * @param array $fetchedRow             フェッチ取得した行
708          * @param object $param                 未使用
709          * @return bool                                 true=処理続行の場合、false=処理終了の場合
710          */
711         function sysTemplateLoop($index, $fetchedRow, $param)
712         {
713                 $selected = '';
714                 if ($fetchedRow['tm_id'] == $this->systemTemplate){
715                         $selected = 'selected';
716                 }
717                 $name = $fetchedRow['tm_name'];
718                 if ($fetchedRow['tm_id'] == self::DEFAULT_SYSTEM_TEMPLATE_ID) $name = '[デフォルト]';
719                 
720                 $row = array(
721                         'value'    => $this->convertToDispString($fetchedRow['tm_id']),                 // テンプレートID
722                         'name'     => $this->convertToDispString($name),                        // テンプレート名名
723                         'selected' => $selected                                                                                                         // 選択中かどうか
724                 );
725                 $this->tmpl->addVars('systemplate_list', $row);
726                 $this->tmpl->parseTemplate('systemplate_list', 'a');
727                 return true;
728         }
729         /**
730          * jQueryのバージョン選択メニューを作成
731          *
732          * @param array         $versionInfo    jQueryバージョン情報
733          * @return                                                      なし
734          */
735         function createJqueryVerMenu($versionInfo)
736         {
737                 foreach ($versionInfo as $key => $value){
738                         $value = $key;
739                         $name = $key;
740                         
741                         $selected = '';
742                         if ($value == $this->jqueryVersion) $selected = 'selected';
743                         
744                         $row = array(
745                                 'value'    => $this->convertToDispString($value),
746                                 'name'     => $this->convertToDispString($name),
747                                 'selected' => $selected                 // 選択中かどうか
748                         );
749                         $this->tmpl->addVars('jquery_version_list', $row);
750                         $this->tmpl->parseTemplate('jquery_version_list', 'a');
751                 }
752         }
753         /**
754          * WYSIWYGエディター選択メニュー作成
755          *
756          * @return                                                      なし
757          */
758         function createWysiwygMenu()
759         {
760                 foreach ($this->wysiwygMenuData as $key => $value){
761                         $name = $value;
762                         
763                         $selected = '';
764                         if ($key == $this->wysiwygEditor) $selected = 'selected';
765                         
766                         $row = array(
767                                 'value'    => $this->convertToDispString($key),
768                                 'name'     => $this->convertToDispString($name),
769                                 'selected' => $selected                 // 選択中かどうか
770                         );
771                         $this->tmpl->addVars('wysiwyg_editor_list', $row);
772                         $this->tmpl->parseTemplate('wysiwyg_editor_list', 'a');
773                 }
774         }
775         /**
776          * アクセスポイントが有効かどうか
777          *
778          * @param int   $deviceType デバイスタイプ(0=PC,1=携帯,2=スマートフォン)
779          * @return bool                         true=有効、false=無効
780          */
781         function isActiveAccessPoint($deviceType)
782         {
783                 // ページID作成
784                 switch ($deviceType){
785                         case 0:         // PC
786                                 $pageId = 'index';
787                                 break;
788                         case 1:         // 携帯
789                                 $pageId = M3_DIR_NAME_MOBILE . '_index';
790                                 break;
791                         case 2:         // スマートフォン
792                                 $pageId = M3_DIR_NAME_SMARTPHONE . '_index';
793                                 break;
794                 }
795                 
796                 $isActive = false;
797                 $ret = $this->db->getPageIdRecord(0/*アクセスポイント*/, $pageId, $row);
798                 if ($ret){
799                         $isActive = $row['pg_active'];
800                 }
801                 return $isActive;
802         }
803         /**
804          * アクセスポイントの有効状態を更新
805          *
806          * @param int   $deviceType デバイスタイプ(0=PC,1=携帯,2=スマートフォン)
807          * @param bool  $status         有効状態
808          * @return bool                         true=成功、false=失敗
809          */
810         function updateActiveAccessPoint($deviceType, $status)
811         {
812                 // ページID作成
813                 switch ($deviceType){
814                         case 0:         // PC
815                                 $pageId = 'index';
816                                 break;
817                         case 1:         // 携帯
818                                 $pageId = M3_DIR_NAME_MOBILE . '_index';
819                                 break;
820                         case 2:         // スマートフォン
821                                 $pageId = M3_DIR_NAME_SMARTPHONE . '_index';
822                                 break;
823                 }
824                 
825                 $ret = $this->db->getPageIdRecord(0/*アクセスポイント*/, $pageId, $row);
826                 if ($ret){
827                         $ret = $this->db->updatePageId(0/*アクセスポイント*/, $pageId, $row['pg_name'], $row['pg_description'], $row['pg_priority'], $status, $row['pg_visible']);
828                 }
829                 return $ret;
830         }
831         /**
832          * SSLの期限を取得
833          *
834          * @param string $url           SSL証明書を取得するURL
835          * @param string $sslDomain     SSLの対象となるドメイン名
836          * @return int                          UNIXタイムスタンプ。取得できない場合は0。
837          */
838         function _getSslExpireDt($url, &$sslDomain)
839         {
840                 $arr = parse_url($url);
841                 if ($arr == false)  return '';
842                 
843                 $hostname = $arr['host'];
844
845                 $stream_context = stream_context_create(array(
846                         'ssl' => array('capture_peer_cert' => true)
847                 ));
848                 $fp = @stream_socket_client(
849                         'ssl://' . $hostname . ':443',
850                         $errno,
851                         $errstr,
852                         30,
853                         STREAM_CLIENT_CONNECT,
854                         $stream_context
855                 );
856                 if (!$fp) return 0;             // 取得不可の場合は終了
857                 
858                 $cont = stream_context_get_params($fp);
859                 $parsed = openssl_x509_parse($cont['options']['ssl']['peer_certificate']);
860 //              $expireDt = date("Y/m/d H:i:s", $parsed['validTo_time_t']);
861                 $expireDt = $parsed['validTo_time_t'];
862                 $sslDomain = $parsed['subject']['CN'];          // ドメイン名
863                 
864                 // ファイルポインタ閉じる
865                 fclose($fp);
866                 
867                 // ドメイン名のチェック
868                 if (strStartsWith($sslDomain, '*.')){           // ワイルドカードSSLの場合
869                         if (!strEndsWith($hostname, substr($sslDomain, 1))) $expireDt = 0;
870                 } else {
871                         if (!strEndsWith($hostname, '.' . $sslDomain)) $expireDt = 0;
872                 }
873                 return $expireDt;
874         }
875 }
876 ?>