OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / admin_main / include / container / admin_mainEditmenuWidgetContainer.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-2013 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_mainEditmenuWidgetContainer.php 5568 2013-01-18 08:50:56Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() .    '/admin_mainBaseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_mainDb.php');
18
19 class admin_mainEditmenuWidgetContainer extends admin_mainBaseWidgetContainer
20 {
21         private $menuBasicItems;                        // 元となるメニュー項目
22         private $adminPages;                    // 管理機能ウィジェットの選択可能画面
23         private $widgets = array();                             // ウィジェット情報
24         private $widgetInfoStr;                 // ウィジェット情報文字列
25         private $pageInfoStr;                   // 管理画面情報文字列
26         private $menuItemExists;                        // メニュー項目があるかどうか
27         const TOPPAGE_IMAGE_PATH = 'toppage_image_path';                                // トップページ画像
28         const DEFAULT_NAV_ID = 'admin_menu';            // メニューID
29         const DEFAULT_IMAGE_SIZE = 32;  // アイコンサイズ
30         const TASK_ID_HEADE_WIDGET = 'configwidget_';           // ウィジェット管理画面
31         const TASK_ID_HEAD_TITLE = '_';                                         // タイトル表示
32         const DEF_FILE_HEAD = 'menu_';          // メニュー定義ファイル名
33         
34         // メニュー項目タイプ
35         const ITEM_TYPE_TITLE           = 'type_title';         // タイトル
36         const ITEM_TYPE_CR                      = 'type_cr';                    // 改行
37         const ITEM_TYPE_ADMIN_PAGE      = 'type_admin'; // 管理ウィジェットの管理画面
38         const ITEM_TYPE_WIDGET_PAGE     = 'type_widget';        // ウィジェットの管理画面
39         
40         /**
41          * コンストラクタ
42          */
43         function __construct()
44         {
45                 // 親クラスを呼び出す
46                 parent::__construct();
47                 
48                 // DB接続オブジェクト作成
49                 $this->db = new admin_mainDb();
50                 
51                 // 元となるメニュー項目
52                 $this->menuBasicItems = array(  array('type' => self::ITEM_TYPE_ADMIN_PAGE,             'name' => $this->_('Administration Page'),                              // 管理機能の画面
53                                                                                                                                                                                 'desc' => $this->_('Page of administration widget.')),// 管理機能の画面を表示します。
54                                                                                 array('type' => self::ITEM_TYPE_WIDGET_PAGE,    'name' => $this->_('Widget Page'),                                              // ウィジェットの管理画面
55                                                                                                                                                                                 'desc' => $this->_('Administration page of widgets.')), // ウィジェットの管理画面を表示します。
56                                                                                 array('type' => self::ITEM_TYPE_TITLE,                  'name' => $this->_('Title'),                                                    // タイトル
57                                                                                                                                                                                 'desc' => $this->_('Title of menu category.')),                 // メニューカテゴリのタイトル名を作成します。
58                                                                                 array('type' => self::ITEM_TYPE_CR,                             'name' => $this->_('Newline'),                                                  // 改行
59                                                                                                                                                                                 'desc' => $this->_('Separate menu categories.'))                // メニューの項目ブロックを改行します。
60                                                                 );
61                 // 管理機能ウィジェットの選択可能画面
62                 $this->adminPages = array(      array('task' => 'pagedef',                              'name' => $this->_('PC Page'),          // PC用画面編集
63                                                                                                                                                         'desc' => $this->_('Edit page for PC.')),               // PC用Webサイトの画面を作成します。
64                                                                         array('task' => 'pagedef_mobile',               'name' => $this->_('Mobile Page'),              // 携帯用画面編集
65                                                                                                                                                         'desc' => $this->_('Edit page for Mobile.')),           // 携帯用Webサイトの画面を作成します。
66                                                                         array('task' => 'pagedef_smartphone',   'name' => $this->_('Smartphone Page'),          // スマートフォン用画面編集
67                                                                                                                                                         'desc' => $this->_('Edit page for Smartphone.')),               // スマートフォン用Webサイトの画面を作成します。
68                                                                         array('task' => 'widgetlist',                   'name' => $this->_('Widget Administration'),            // ウィジェット管理
69                                                                                                                                                         'desc' => $this->_('Manage widgets to be installed.')),         // ウィジェットの管理を行います。
70                                                                         array('task' => 'templist',                             'name' => $this->_('Template Administration'),          // テンプレート管理
71                                                                                                                                                         'desc' => $this->_('Manage templates to be installed.')),               // テンプレートの管理を行います。
72                                                                         array('task' => 'menudef',                              'name' => $this->_('Menu Administration (Tree)'),               // メニュー定義(多階層)
73                                                                                                                                                         'desc' => $this->_('Manage menus with tree type.')),            // 多階層でメニューを定義します。
74                                                                         array('task' => 'smenudef',                             'name' => $this->_('Menu Administration (Single)'),             // メニュー定義(単一階層)
75                                                                                                                                                         'desc' => $this->_('Manage menus with single type.')),          // 単一階層でメニューを定義します。
76                                                                         array('task' => 'master',                               'name' => $this->_('System Master'),            // システムマスター管理
77                                                                                                                                                         'desc' => $this->_('Administrate system master data.')),                // システムに関するマスターデータの管理を行います。
78                                                                         array('task' => 'tenantserver',                 'name' => $this->_('Tenant Server Administration'),             // テナントサーバ管理
79                                                                                                                                                         'desc' => $this->_('Manage tenant server.')),           // テナントサーバを管理します。
80                                                                         array('task' => 'userlist',                             'name' => $this->_('User List'),                // ユーザ一覧
81                                                                                                                                                         'desc' => $this->_('Manage user to login.')),           // ログイン可能なユーザを管理します。
82                                                                         array('task' => 'loginstatus',                  'name' => $this->_('Login Status'),             // ログイン状況
83                                                                                                                                                         'desc' => $this->_('View user login status.')),         // ユーザのログイン状況を表示します。
84                                                                         array('task' => 'configsite',                   'name' => $this->_('Site Information'),         // 基本情報
85                                                                                                                                                         'desc' => $this->_('Configure site information.')),             // サイトの設定を行います。
86                                                                         array('task' => 'usercustom',                   'name' => $this->_('User Custom Parameter'),            // ユーザ定義変数管理
87                                                                                                                                                         'desc' => $this->_('Configure user defined paramater.')),               // ユーザ定義の変数を管理します。
88                                                                         array('task' => 'configsys',                    'name' => $this->_('System Information'),               // システム情報
89                                                                                                                                                         'desc' => $this->_('Configure sytem information.')),    // システム全体の設定、運用状況を管理します。
90                                                                         array('task' => 'analyzecalc',                  'name' => $this->_('Access Analytics'), // アクセス解析
91                                                                                                                                                         'desc' => $this->_('Analyze site access.')),    // サイトへのアクセス状況を参照します。
92                                                                         array('task' => 'opelog',                               'name' => $this->_('Operation Log'),    // 運用ログ参照
93                                                                                                                                                         'desc' => $this->_('View system operation log.')),      // 運用ログを参照します。
94                                                                         array('task' => 'accesslog',                    'name' => $this->_('Access Log'),       // アクセスログ参照
95                                                                                                                                                         'desc' => $this->_('View site access log.')),   // アクセスログを参照します。
96                                                                         array('task' => 'searchwordlog',                'name' => $this->_('Search Word Log'),  // 検索語ログ参照
97                                                                                                                                                         'desc' => $this->_('View words to search.')),   // 検索語ログを参照します。
98                                                                         array('task' => 'resbrowse',                    'name' => $this->_('Resource Browse'),  // リソースブラウズ
99                                                                                                                                                         'desc' => $this->_('Administrate resource files.')),    // リソースファイルを管理します。
100                                                                         array('task' => 'initsystem',                   'name' => $this->_('Database Maintenance'),     // DBメンテナンス
101                                                                                                                                                         'desc' => $this->_('Database maintenance such as data initializing.')), // データの初期化などDBのメンテナンスを行います。
102                                                                         array('task' => 'editmenu',                             'name' => $this->_('Edit Administration Menu'), // 管理メニュー編集
103                                                                                                                                                         'desc' => $this->_('Configure administration menu.')),  // 管理メニューの編集を行います。
104                                                                         array('task' => 'createtable',                  'name' => $this->_('Create User Table'),        // ユーザ定義テーブル
105                                                                                                                                                         'desc' => $this->_('Manage user original table.')),     // ユーザ定義のテーブルの作成、データの編集を行います。
106                                                                         array('task' => 'logout',                               'name' => $this->_('Logout'),   // ログアウト
107                                                                                                                                                         'desc' => $this->_('Logout from system.'))      // ログアウト処理を行います。
108                                                                 );
109         }
110         /**
111          * テンプレートファイルを設定
112          *
113          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
114          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
115          *
116          * @param RequestManager $request               HTTPリクエスト処理クラス
117          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
118          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
119          */
120         function _setTemplate($request, &$param)
121         {
122                 $task = $request->trimValueOf('task');
123                 if ($task == 'editmenu_others'){                // その他設定画面
124                         return 'editmenu_others.tmpl.html';
125                 } else {
126                         return 'editmenu.tmpl.html';
127                 }
128         }
129         /**
130          * ヘルプデータを設定
131          *
132          * ヘルプの設定を行う場合はヘルプIDを返す。
133          * ヘルプデータの読み込むディレクトリは「自ウィジェットディレクトリ/include/help」に固定。
134          *
135          * @param RequestManager $request               HTTPリクエスト処理クラス
136          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
137          * @return string                                               ヘルプID。ヘルプデータはファイル名「help_[ヘルプID].php」で作成。ヘルプを使用しない場合は空文字列「''」を返す。
138          */
139         function _setHelp($request, &$param)
140         {       
141                 return 'editmenu';
142         }
143         /**
144          * テンプレートにデータ埋め込む
145          *
146          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
147          *
148          * @param RequestManager $request               HTTPリクエスト処理クラス
149          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
150          * @param                                                               なし
151          */
152         function _assign($request, &$param)
153         {
154                 $localeText = array();
155                                 
156                 $task = $request->trimValueOf('task');
157                 if ($task == 'editmenu_others'){        // その他設定画面
158                         $this->configOthers($request);
159                 
160                         // テキストをローカライズ
161                         $localeText['msg_update'] = $this->_('Update configration?');           // 設定を更新しますか?
162                         $localeText['label_others'] = $this->_('Administration Menu Others');   // 管理メニューその他
163                         $localeText['label_go_back'] = $this->_('Go back');     // 戻る
164                         $localeText['label_image'] = $this->_('Image'); // 画像
165                         $localeText['label_change'] = $this->_('Change');       // 変更
166                         $localeText['label_update'] = $this->_('Update');       // 更新
167                 } else {                        // メニュー項目編集
168                         $this->editMenuItems($request);
169                         
170                         // テキストをローカライズ
171                         $localeText['msg_update'] = $this->_('Update menu definition?');                // 項目を更新しますか?
172                         $localeText['msg_upload_file_not_selected'] = $this->_('Files to upload not selected.');                // アップロードするファイルが選択されていません
173                         $localeText['msg_upload'] = $this->_('Upload files.');          // ファイルをアップロードします
174                         $localeText['label_admin'] = $this->_('Administration');                // 管理機能
175                         $localeText['label_widget'] = $this->_('Widget');               // ウィジェット
176                         $localeText['label_untitled'] = $this->_('Untitled');           // 未設定
177                         $localeText['label_name'] = $this->_('Name');           // 名前
178                         $localeText['label_option'] = $this->_('Option');               // オプション
179                         $localeText['label_desc'] = $this->_('Description');            // 説明
180                         $localeText['label_edit_menu'] = $this->_('Edit Administration Menu');          // 管理メニュー編集
181                         $localeText['label_others'] = $this->_('Others');               // その他
182                         $localeText['label_menu_item'] = $this->_('Menu Item');         // メニュー項目
183                         $localeText['label_configured_menu_item'] = $this->_('Configured Menu Item');// 設定されたメニュー項目
184                         $localeText['label_update'] = $this->_('Update');// 更新
185                         $localeText['label_menu_script'] = $this->_('Menu Definition Script');// 管理メニュー定義ファイル
186                         $localeText['label_upload'] = $this->_('Upload');// アップロード
187                         $localeText['label_download'] = $this->_('Download');// ダウンロード
188                 }
189                 $this->setLocaleText($localeText);
190         }
191         /**
192          * メニュー項目編集
193          *
194          * @param RequestManager $request               HTTPリクエスト処理クラス
195          * @param                                                               なし
196          */
197         function editMenuItems($request)
198         {
199                 $langId = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
200                 
201                 // 現在の言語からメニューIDを作成
202                 // メニューは表示する言語ごとに作成する
203                 $menuId = self::DEFAULT_NAV_ID;
204                 if ($langId != $this->gEnv->getDefaultLanguage()){              // デフォルト言語でないときは拡張子を付加
205                          $menuId .= '.' . $langId;
206                 }
207
208                 $act = $request->trimValueOf('act');
209                 if ($act == 'update'){          // 設定更新のとき
210                         $valuesType = $request->trimValueOf('items_type');
211                         $valuesName = $request->trimValueOf('items_name');
212                         $valuesOption = $request->trimValueOf('items_option');
213                         $valuesParam = $request->trimValueOf('items_param');
214                         $valuesDesc = $request->trimValueOf('items_desc');
215                         
216                         // トランザクション開始
217                         $this->db->startTransaction();
218                 
219                         // 一旦すべて削除
220                         $ret = $this->db->DelNavItems($menuId);
221                 
222                         // IDを求める
223                         $maxId = $this->db->getNavItemsMaxId();
224                         if (empty($maxId)){
225                                 $maxId = 1;
226                         } else {
227                                 $maxId++;
228                         }
229                         $parentId = $maxId;
230                         $id = $maxId;
231                         $index = 0;             // 表示順
232                         for ($i = 0; $i < count($valuesType); $i++){
233                                 $type = $valuesType[$i];
234                                 $name = $valuesName[$i];                // 表示名
235                                 $param = $valuesParam[$i];
236                                 $taskId = '';
237                                 $control = 0;
238                                 $helpTitle = $name;
239                                 $helpBody = $valuesDesc[$i];// ヘルプ本文
240                                 if ($type == self::ITEM_TYPE_ADMIN_PAGE){               // 管理機能ページ
241                                         $index++;               // 表示順更新
242                                         $taskId = $valuesOption[$i];            // 管理機能画面
243                                 } else if ($type == self::ITEM_TYPE_WIDGET_PAGE){       // ウィジェットの管理画面
244                                         $index++;               // 表示順更新
245                                         $taskId = self::TASK_ID_HEADE_WIDGET . $valuesOption[$i];               // ウィジェット管理画面
246                                 } else if ($type == self::ITEM_TYPE_TITLE){                     // タイトル
247                                         $parentId = 0;
248                                         $index = 0;
249                                         $taskId = self::TASK_ID_HEAD_TITLE . $id;                                               // 「_」付きのIDはリンクなし
250                                 } else if ($type == self::ITEM_TYPE_CR){                        // 改行
251                                         $parentId = 0;
252                                         $index = 0;
253                                         $taskId = self::TASK_ID_HEAD_TITLE . $id;                                               // 「_」付きのIDはリンクなし
254                                         $control = 1;
255                                 }
256                                 // キーの存在チェック
257                                 $ret = $this->db->isExistsNavItemKey($menuId, $taskId, $param);
258                                 if ($ret){                      // キーが存在する場合は終了
259                                         //$this->setMsg(self::MSG_USER_ERR, '項目「' . $name . '」は重複しています');
260                                         $this->setMsg(self::MSG_USER_ERR, sprintf($this->_('\'%s\' is duplicated.'), $name));           // 項目「%s」は重複しています
261                                         
262                                         // トランザクション中止
263                                         $this->db->cancelTransaction();
264                                         break;
265                                 } else {
266                                         $ret = $this->db->addNavItems($menuId, $id, $parentId, $index, $taskId, $param, $control, $name, $helpTitle, $helpBody);
267                                         // 項目ID更新
268                                         if ($type == self::ITEM_TYPE_TITLE){                    // タイトル
269                                                 $parentId = $id;
270                                         }
271                                         $id++;
272                                 }
273                         }
274                         
275                         // トランザクション終了
276                         $ret = $this->db->endTransaction();
277                         if ($ret){
278                                 //$this->setMsg(self::MSG_GUIDANCE, '管理メニューを更新しました');
279                                 $this->setMsg(self::MSG_GUIDANCE, $this->_('Administration menu updated.'));                    // 管理メニューを更新しました
280                         } else {
281                                 //if ($this->getMsgCount() == 0) $this->setMsg(self::MSG_APP_ERR, '管理メニュー更新に失敗しました');
282                                 if ($this->getMsgCount() == 0) $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in updating administration menu.'));           // 管理メニュー更新に失敗しました
283                         }
284                 } else if ($act == 'upload'){           // メニュー定義ファイルアップロード
285                         if (is_uploaded_file($_FILES['upfile']['tmp_name'])) {
286                                 $uploadFilename = $_FILES['upfile']['name'];            // アップロードされたファイルのファイル名取得
287                                 
288                                 // ファイルを保存するサーバディレクトリを指定
289                                 $tmpFile = tempnam($this->gEnv->getWorkDirPath(), M3_SYSTEM_WORK_UPLOAD_FILENAME_HEAD);
290
291                                 // アップされたテンポラリファイルを保存ディレクトリにコピー
292                                 $ret = move_uploaded_file($_FILES['upfile']['tmp_name'], $tmpFile);
293                                 if ($ret){
294                                         // スクリプト実行
295                                         if ($this->gInstance->getDbManager()->execScriptWithConvert($tmpFile, $errors)){// 正常終了の場合
296                                                 //$this->setMsg(self::MSG_GUIDANCE, 'スクリプト実行完了しました');
297                                                 $this->setMsg(self::MSG_GUIDANCE, $this->_('Script run successfully.'));                // スクリプト実行完了しました
298                                         } else {
299                                                 //$this->setMsg(self::MSG_APP_ERR, "スクリプト実行に失敗しました");
300                                                 $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in running script.'));                // スクリプト実行に失敗しました
301                                         }
302                                         if (!empty($errors)){
303                                                 foreach ($errors as $error) {
304                                                         $this->setMsg(self::MSG_APP_ERR, $error);
305                                                 }
306                                         }
307                                 }
308                                 // テンポラリファイル削除
309                                 unlink($tmpFile);
310                         } else {
311                                 //$msg = 'アップロードファイルが見つかりません(要因:アップロード可能なファイルのMaxサイズを超えている可能性があります - ' . $gSystemManager->getMaxFileSizeForUpload() . 'バイト)';
312                                 $msg = sprintf($this->_('Uploded file not found. (detail: The file may be over maximum size to be allowed to upload. Size %s bytes.'), $this->gSystem->getMaxFileSizeForUpload());      // アップロードファイルが見つかりません(要因:アップロード可能なファイルのMaxサイズを超えている可能性があります。%sバイト)
313                                 $this->setAppErrorMsg($msg);
314                         }
315                 } else if ($act == 'download'){         // メニュー定義ファイルダウンロード
316                         // メニュー定義ファイル作成
317                         $ret = $this->db->getNavItemsAllRecords(self::DEFAULT_NAV_ID, $rows);
318                         if ($ret){
319                                 $writeData  = 'DELETE FROM _nav_item WHERE ni_nav_id = \'' . self::DEFAULT_NAV_ID . '\';' . M3_NL;                      // データを削除
320                                 $writeData .= 'INSERT INTO _nav_item ' . M3_NL;
321                                 $writeData .= '(ni_id, ni_parent_id, ni_index, ni_nav_id, ni_task_id, ni_group_id, ni_view_control, ni_param, ni_name, ni_help_title, ni_help_body, ni_visible) VALUES ' . M3_NL;
322                                 $lineCount = count($rows);
323                                 for ($i = 0; $i < $lineCount; $i++){
324                                         $line = $rows[$i];
325                                         $writeData .= '(';
326                                         $writeData .= $line['ni_id'] . ', ';
327                                         $writeData .= $line['ni_parent_id'] . ', ';
328                                         $writeData .= $line['ni_index'] . ', ';
329                                         $writeData .= '\'' . addslashes($line['ni_nav_id']) . '\', ';
330                                         $writeData .= '\'' . addslashes($line['ni_task_id']) . '\', ';
331                                         $writeData .= '\'' . addslashes($line['ni_group_id']) . '\', ';
332                                         $writeData .= '\'' . addslashes($line['ni_view_control']) . '\', ';
333                                         $writeData .= '\'' . addslashes($line['ni_param']) . '\', ';
334                                         $writeData .= '\'' . addslashes($line['ni_name']) . '\', ';
335                                         $writeData .= '\'' . addslashes($line['ni_help_title']) . '\', ';
336                                         $writeData .= '\'' . addslashes($line['ni_help_body']) . '\', ';
337                                         if (empty($line['ni_visible'])){
338                                                 $writeData .= 'false';
339                                         } else {
340                                                 $writeData .= 'true';
341                                         }
342                                         if ($i < $lineCount -1){
343                                                 $writeData .= '),' . M3_NL;
344                                         } else {
345                                                 $writeData .= ');' . M3_NL;
346                                         }
347                                 }
348                                 
349                                 // テンポラリファイル作成
350                                 $tmpFile = tempnam($this->gEnv->getWorkDirPath(), M3_SYSTEM_WORK_UPLOAD_FILENAME_HEAD);
351                                 if ($tmpFile !== false){
352                                         $ret = writeFile($tmpFile, $writeData);
353                                         if ($ret){
354                                                 // ページ作成処理中断
355                                                 $this->gPage->abortPage();
356                                 
357                                                 // ダウンロード処理
358                                                 $downloadFilename = self::DEF_FILE_HEAD . date("YmdHi") . '.sql';// ダウンロード時のデフォルトファイル名
359                                                 $ret = $this->gPage->downloadFile($tmpFile, $downloadFilename, true/*実行後ファイル削除*/);
360                                 
361                                                 // システム強制終了
362                                                 $this->gPage->exitSystem();
363                                         }
364                                 }
365                         }
366                 }
367                 // 管理画面メニュー作成
368                 $this->pageInfoStr = '';                        // 管理画面情報
369                 $this->createAdminPageMenu();
370                 
371                 // ウィジェットメニュー作成
372                 $this->widgetInfoStr = '';
373                 $this->db->getAvailableWidgetListForEditMenu(array($this, 'widgetListLoop'));
374                 
375                 // メニュー基本項目一覧作成
376                 $this->createMenuBasicItemList();
377                 
378                 // メニュー設定項目作成
379                 $this->db->getNavItemsAll(self::DEFAULT_NAV_ID, array($this, 'menuItemListLoop'));
380                 if (!$this->menuItemExists) $this->tmpl->setAttribute('menuassignedlist', 'visibility', 'hidden');// メニュー項目を非表示
381                 
382                 // ウィジェット情報を設定
383                 $this->widgetInfoStr = rtrim($this->widgetInfoStr, ',');
384                 $this->widgetInfoStr = '[' . $this->widgetInfoStr . ']';
385                 $this->tmpl->addVar("_widget", "widget_info", $this->widgetInfoStr);
386                 // 管理画面情報を設定
387                 $this->pageInfoStr = rtrim($this->pageInfoStr, ',');
388                 $this->pageInfoStr = '[' . $this->pageInfoStr . ']';
389                 $this->tmpl->addVar("_widget", "page_info", $this->pageInfoStr);
390                 
391                 // パスを設定
392                 $this->tmpl->addVar("_widget", "top_url", $this->getUrl($this->gEnv->getDefaultAdminUrl()));            // トップメニュー画面URL
393         }
394         /**
395          * その他の設定
396          *
397          * @param RequestManager $request               HTTPリクエスト処理クラス
398          * @param                                                               なし
399          */
400         function configOthers($request)
401         {
402                 $reloadData = false;
403                 $act = $request->trimValueOf('act');
404                 if ($act == 'update'){          // 行更新のとき
405                         $imageUrl = $request->trimValueOf('item_image');                // 管理メニュー画像
406                         if (!empty($imageUrl)) $imageUrl = $this->gEnv->getMacroPath($imageUrl);
407                         
408                         // 入力チェック
409                         // エラーなしの場合は、データを登録
410                         if ($this->getMsgCount() == 0){
411                                 $isErr = false;
412                                 if (!$isErr){
413                                         if (!$this->db->updateSystemConfig(self::TOPPAGE_IMAGE_PATH, $imageUrl)) $isErr = true;
414                                 }
415                                 if ($isErr){            // エラーのとき
416                                         //$this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
417                                         $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in updating configration.'));         // データ更新に失敗しました
418                                 } else {
419                                         //$this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
420                                         $this->setMsg(self::MSG_GUIDANCE, $this->_('Configration updated.'));           // データを更新しました
421                                         $reloadData = true;             // データの再読み込み                                  
422                                 }
423                         }
424                 } else {
425                         $reloadData = true;
426                 }
427                 if ($reloadData){               // データ再取得のとき
428                         $imageUrl = $this->db->getSystemConfig(self::TOPPAGE_IMAGE_PATH);
429                         $imageUrl = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $imageUrl);
430                 }
431                 $this->tmpl->addVar('_widget', 'image_url', $imageUrl);
432         }
433         /**
434          * ウィジェットリスト、取得したデータをテンプレートに設定する
435          *
436          * @param int $index                    行番号(0~)
437          * @param array $fetchedRow             フェッチ取得した行
438          * @param object $param                 未使用
439          * @return bool                                 true=処理続行の場合、false=処理終了の場合
440          */
441         function widgetListLoop($index, $fetchedRow, $param)
442         {
443                 $id = $fetchedRow['wd_id'];
444                 $name = $this->convertToDispString($fetchedRow['wd_name']);
445                 $selected = '';
446                 $row = array(
447                         'value'    => $this->convertToDispString($id),                  // ウィジェットID
448                         'name'     => $name,                    // ウィジェット名
449                         'selected' => $selected                                                                                                         // 選択中かどうか
450                 );
451                 $this->tmpl->addVars('widget_list', $row);
452                 $this->tmpl->parseTemplate('widget_list', 'a');
453                 
454                 $this->widgets[] = $row;                                // ウィジェット情報
455                 $image = $this->getUrl($this->gDesign->getWidgetIconUrl($id, self::DEFAULT_IMAGE_SIZE));
456                 $desc = $this->convertToDispString($fetchedRow['wd_description']);
457                 $this->widgetInfoStr .= '{id:"' . $id . '",image:"' . $image . '",desc:"' . $desc . '"},';
458                 return true;
459         }
460         /**
461          * 管理画面メニュー作成
462          *
463          * @return なし                                               
464          */
465         function createAdminPageMenu()
466         {
467                 for ($j = 0; $j < count($this->adminPages); $j++){
468                         $task = $this->adminPages[$j]['task'];
469                         $name = $this->adminPages[$j]['name'];
470                         $selected = '';
471                         $menurow = array(
472                                 'value'         => $task,                       // 機能値
473                                 'name'          => $name,                       // 機能名
474                                 'selected' => $selected                                                                                                         // 選択中かどうか
475                         );
476                         $this->tmpl->addVars('admin_list', $menurow);
477                         $this->tmpl->parseTemplate('admin_list', 'a');
478                         
479                         $desc = $this->convertToDispString($this->adminPages[$j]['desc']);
480                         $this->pageInfoStr .= '{id:"' . $task . '",desc:"' . $desc . '"},';
481                 }
482         }
483         /**
484          * メニュー基本項目一覧作成
485          *
486          * @return なし                                               
487          */
488         function createMenuBasicItemList()
489         {
490                 for ($i = 0; $i < count($this->menuBasicItems); $i++){
491                         $targetObj = $this->menuBasicItems[$i];
492
493                         if ($targetObj['type'] == self::ITEM_TYPE_ADMIN_PAGE){          // 管理機能画面への遷移項目のとき
494                                 $this->tmpl->addVar('menuavailablelist', 'type', 'admin_page');// 管理機能画面
495                         } else if ($targetObj['type'] == self::ITEM_TYPE_WIDGET_PAGE){          // ウィジェット管理画面への遷移項目のとき
496                                 $this->tmpl->addVar('menuavailablelist', 'type', 'widget');// ウィジェット管理画面
497                         } else {
498                         }
499                         $row = array(
500                                 'item_type' => $targetObj['type'],              // メニュー項目タイプ
501                                 'name' => $targetObj['name'],           // 名前
502                                 'desc' => $targetObj['desc']            // 説明
503                         );
504                         $this->tmpl->addVars('menuavailablelist', $row);
505                         $this->tmpl->parseTemplate('menuavailablelist', 'a');
506                 }
507         }
508         /**
509          * メニュー項目リスト、取得したデータをテンプレートに設定する
510          *
511          * @param int $index                    行番号(0~)
512          * @param array $fetchedRow             フェッチ取得した行
513          * @param object $param                 未使用
514          * @return bool                                 true=処理続行の場合、false=処理終了の場合
515          */
516         function menuItemListLoop($index, $fetchedRow, $param)
517         {
518                 $id = $fetchedRow['ni_id'];
519                 $name = $this->convertToDispString($fetchedRow['ni_name']);
520                 $task = $fetchedRow['ni_task_id'];
521                 $param = $fetchedRow['ni_param'];
522                 $desc = $fetchedRow['ni_help_body'];
523                 $title = '';    // 項目タイトル
524                 $option = '';   // 追加情報
525                 if (empty($fetchedRow['ni_view_control'])){                     // 通常項目のとき
526                         if (strncmp($task, '_', strlen('_')) == 0){             // タイトル項目
527                                 $type = 'type_title';           // 項目タイプ
528                                 $title = 'タイトル';        // 項目タイトル
529                                 $this->tmpl->addVar('menuassignedlist', 'type', 'title');               // タイトル、
530                         } else if (strncmp($task, self::TASK_ID_HEADE_WIDGET, strlen(self::TASK_ID_HEADE_WIDGET)) == 0){                // ウィジェット管理画面
531                                 $widgetId = str_replace(self::TASK_ID_HEADE_WIDGET, '', $task);
532                                 $widgetName = '';
533                                 for ($i = 0; $i < count($this->widgets); $i++){
534                                         if ($this->widgets[$i]['value'] == $widgetId){
535                                                 $widgetName = $this->widgets[$i]['name'];
536                                                 break;
537                                         }
538                                 }
539                                 $type = 'type_widget';          // 項目タイプ
540                                 $option = $widgetId;    // 追加情報
541                                 $title = $this->_('Widget') . '[' . $widgetName . ']';          // ウィジェット
542                                 $this->tmpl->addVar('menuassignedlist', 'type', 'subitem');// 管理機能、ウィジェット管理画面
543                         } else {                // 管理機能画面
544                                 // 管理機能画面情報取得
545                                 $taskName = '';
546                                 for ($i = 0; $i < count($this->adminPages); $i++){
547                                         if ($this->adminPages[$i]['task'] == $task){
548                                                 $taskName = $this->adminPages[$i]['name'];
549                                                 break;
550                                         }
551                                 }
552                                 $type = 'type_admin';           // 項目タイプ
553                                 $option = $task;        // 追加情報
554                                 $title = $this->_('Administration') . '[' . $taskName . ']';                    // 管理機能
555                                 $this->tmpl->addVar('menuassignedlist', 'type', 'subitem');// 管理機能、ウィジェット管理画面
556                         }
557                 } else {        // 改行項目のとき
558                         $type = 'type_cr';              // 項目タイプ
559                         $title = $this->_('Newline');   // 項目タイトル(改行)
560                 }
561                 $row = array(
562                         'item_type'             => $type,
563                         'option'        => $option,
564                         'title'         => $this->convertToDispString($title),
565                         'name'          => $name,                       // 表示名
566                         'desc'          => $desc,                       // 説明
567                         'param'         => $param,                      // 追加パラメータ
568                         'label_name' => $this->_('Name'),                       // 名前
569                         'label_option' => $this->_('Option'),           // オプション
570                         'label_desc' => $this->_('Description')         // 説明
571                 );
572                 $this->tmpl->addVars('menuassignedlist', $row);
573                 $this->tmpl->parseTemplate('menuassignedlist', 'a');
574                 
575                 $this->menuItemExists = true;                   // メニュー項目があるかどうか
576                 return true;
577         }
578 }
579 ?>