OSDN Git Service

「携帯用デフォルトメニュー」ウィジェット更新
authornaoki hirata <naoki@magic3.org>
Tue, 5 Nov 2013 02:56:30 +0000 (11:56 +0900)
committernaoki hirata <naoki@magic3.org>
Tue, 5 Nov 2013 02:56:30 +0000 (11:56 +0900)
widgets/m/menu/include/container/admin_m_menuWidgetContainer.php
widgets/m/menu/include/template/admin.tmpl.html
widgets/m/menu/include/template/admin_list.tmpl.html

index 1804255..196d2db 100644 (file)
@@ -26,7 +26,7 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
        private $paramObj;              // パラメータ保存用オブジェクト
        private $menuId;                // メニューID
        const DEFAULT_NAME_HEAD = '名称未設定';                    // デフォルトの設定名
-       const DEFAULT_MENU_ID = 'main_menu';                    // デフォルトメニューID
+       const DEFAULT_MENU_ID = 'm_main_menu';                  // デフォルトメニューID
        
        /**
         * コンストラクタ
@@ -84,28 +84,20 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
         */
        function createDetail($request)
        {
+               // ページ定義IDとページ定義のレコードシリアル番号を取得
+               $this->startPageDefParam($defSerial, $defConfigId, $this->paramObj);
+               
                $userId         = $this->gEnv->getCurrentUserId();
                $this->langId   = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
                $act = $request->trimValueOf('act');
                $this->serialNo = $request->trimValueOf('serial');              // 選択項目のシリアル番号
-               
-               // ページ定義IDとページ定義のレコードシリアル番号
-               $defConfigId = $this->getPageDefConfigId($request);                             // 定義ID取得
-               $defSerial = $this->getPageDefSerial($request);         // ページ定義のレコードシリアル番号
-               $value = $request->trimValueOf('defconfig');            // ページ定義の定義ID
-               if (!empty($value)) $defConfigId = $value;
-               $value = $request->trimValueOf('defserial');            // ページ定義のレコードシリアル番号
-               if (!empty($value)) $defSerial = $value;
 
                $this->configId = $request->trimValueOf('item_id');             // 定義ID
                if (empty($this->configId)) $this->configId = $defConfigId;             // 呼び出しウィンドウから引き継いだ定義ID
                $name   = $request->trimValueOf('item_name');                   // ヘッダタイトル
                $limitUser = ($request->trimValueOf('item_limituser') == 'on') ? 1 : 0;         // ユーザを制限するかどうか
                $this->menuId = $request->trimValueOf('menuid');
-               if ($this->menuId == '') $this->menuId = self::DEFAULT_MENU_ID;
-
-               // パラメータオブジェクトを取得
-               $this->paramObj = $this->getWidgetParamObjectWithId();
+               if (empty($this->menuId)) $this->menuId = self::DEFAULT_MENU_ID;
                
                $replaceNew = false;            // データを再取得するかどうか
                if (empty($act)){// 初期起動時
@@ -124,71 +116,42 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
                                $newObj->name   = $name;// 表示名
                                $newObj->limitUser = $limitUser;                                        // ユーザを制限するかどうか
                                
-                               $newParam = new stdClass;
-                               $newParam->id = -1;             // 新規追加
-                               $newParam->object = $newObj;
-                       
-                               // ウィジェットパラメータオブジェクト更新
-                               $ret = $this->updateWidgetParamObjectWithId($newParam);
-                               if ($ret) $this->paramObj[] = $newParam;                // 新規定義を追加
-                               
-                               // 画面定義更新
-                               if ($ret && !empty($defSerial)){                // 画面作成から呼ばれている場合のみ更新
-                                       $newConfigId = $newParam->id;
-                                       $ret = $this->_db->updateWidgetConfigId($this->gEnv->getCurrentWidgetId(), $defSerial, $newConfigId, $name, $this->menuId);
-                               }
-                               
+                               $ret = $this->addPageDefParam($defSerial, $defConfigId, $this->paramObj, $newObj);
                                if ($ret){
                                        $this->setGuidanceMsg('データを追加しました');
                                        
-                                       $defConfigId = $newConfigId;            // 定義定義IDを更新
-                                       $this->configId = $newConfigId;         // 定義定義IDを更新
+                                       $this->configId = $defConfigId;         // 定義定義IDを更新
                                        $replaceNew = true;                     // データ再取得
                                } else {
                                        $this->setAppErrorMsg('データ追加に失敗しました');
                                }
-                               $this->gPage->updateParentWindow($defSerial);// 親ウィンドウを更新
                        }
                } else if ($act == 'update'){           // 設定更新のとき
                        // 入力値のエラーチェック
                        
                        if ($this->getMsgCount() == 0){                 // エラーのないとき
-                               // 該当項目を更新
-                               $ret = false;
-                               for ($i = 0; $i < count($this->paramObj); $i++){
-                                       $id                     = $this->paramObj[$i]->id;// 定義ID
-                                       $targetObj      = $this->paramObj[$i]->object;
-                                       if ($id == $this->configId){
-                                               // ウィジェットオブジェクト更新。更新値のみ再設定。
-                                               if (!empty($defConfigId) && !empty($defSerial)){                // 設定再選択不可の場合
-                                                       // 取得値で更新
-                                                       $this->menuId = $targetObj->menuId;             // メニューID
-                                               } else {                        // 新規で既存設定の更新
-                                                       $targetObj->menuId      = $this->menuId;                // メニューID
-                                               }
-                                               $targetObj->limitUser = $limitUser;                                     // ユーザを制限するかどうか
-                                               
-                                               // ウィジェットパラメータオブジェクトを更新
-                                               $ret = $this->updateWidgetParamObjectWithId($this->paramObj[$i]);
-                                               break;
+                               // 現在の設定値を取得
+                               $ret = $this->getPageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
+                               if ($ret){
+                                       // ウィジェットオブジェクト更新。更新値のみ再設定。
+                                       if (!empty($defConfigId) && !empty($defSerial)){                // 設定再選択不可の場合
+                                               // 取得値で更新
+                                               $this->menuId = $targetObj->menuId;             // メニューID
+                                       } else {                        // 新規で既存設定の更新
+                                               $targetObj->menuId      = $this->menuId;                // メニューID
                                        }
-                               }
-                               // 画面定義更新
-                               if (!empty($defSerial)){                // 画面作成から呼ばれている場合のみ更新
-                                       if ($ret) $ret = $this->_db->updateWidgetConfigId($this->gEnv->getCurrentWidgetId(), $defSerial, $this->configId, $targetObj->name, $this->menuId);
+                                       $targetObj->limitUser = $limitUser;                                     // ユーザを制限するかどうか
                                }
 
+                               // 設定値を更新
+                               if ($ret) $ret = $this->updatePageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
                                if ($ret){
                                        $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
                                        
-                                       if (empty($defConfigId)){               // 画面定義の定義IDが設定されていないときは設定
-                                               $defConfigId = $this->configId;         // 定義定義IDを更新
-                                       }
                                        $replaceNew = true;                     // データ再取得
                                } else {
                                        $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
                                }
-                               $this->gPage->updateParentWindow($defSerial);// 親ウィンドウを更新
                        }
                } else if ($act == 'select'){   // 定義IDを変更
                        $replaceNew = true;                     // データ再取得
@@ -197,30 +160,26 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
                // 表示用データを取得
                if (empty($this->configId)){            // 新規登録の場合
                        $this->tmpl->setAttribute('item_name_visible', 'visibility', 'visible');// 名前入力フィールド表示
-                       $name = $this->createDefaultName();                     // デフォルト登録項目名
-                       $limitUser = 0;                                 // ユーザを制限するかどうか
+                       
+                       if ($replaceNew){               // データ再取得時
+                               $this->menuId = self::DEFAULT_MENU_ID;
+                               $name = $this->createDefaultName();                     // デフォルト登録項目名
+                               $limitUser = 0;                                 // ユーザを制限するかどうか
+                       }
                        $this->serialNo = 0;
                } else {
-                       // 定義からウィジェットパラメータを検索して、定義データを取得
-                       for ($i = 0; $i < count($this->paramObj); $i++){
-                               $id                     = $this->paramObj[$i]->id;// 定義ID
-                               $targetObj      = $this->paramObj[$i]->object;
-                               if ($id == $this->configId) break;
-                       }
-                       if ($i < count($this->paramObj)){               // 該当項目があるとき
-                               // ウィジェットオブジェクトから値を取得
-                               if ($replaceNew){               // データ再取得のとき
+                       if ($replaceNew){
+                               $ret = $this->getPageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
+                               if ($ret){
                                        $this->menuId   = $targetObj->menuId;           // メニューID
                                        $name                   = $targetObj->name;// 名前
                                        $limitUser              = $targetObj->limitUser;                                        // ユーザを制限するかどうか
                                }
-                               $this->serialNo = $this->configId;
-                               
-                               // 新規作成でないときは、メニューを変更不可にする(画面作成から呼ばれている場合のみ)
-                               if (!empty($defConfigId) && !empty($defSerial)){
-                                       $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
-                               }
                        }
+                       $this->serialNo = $this->configId;
+                               
+                       // 新規作成でないときは、メニューを変更不可にする(画面作成から呼ばれている場合のみ)
+                       if (!empty($defConfigId) && !empty($defSerial)) $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
                }
                // 設定項目選択メニュー作成
                $this->createItemMenu();
@@ -238,10 +197,6 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
                
                $this->tmpl->addVar("_widget", "serial", $this->serialNo);// 選択中のシリアル番号、IDを設定
                
-               // 画面定義用の情報を戻す
-               $this->tmpl->addVar("_widget", "def_serial", $defSerial);       // ページ定義のレコードシリアル番号
-               $this->tmpl->addVar("_widget", "def_config", $defConfigId);     // ページ定義の定義ID
-               
                // ボタンの表示制御
                if (empty($this->serialNo)){            // 新規追加項目を選択しているとき
                        $this->tmpl->setAttribute('add_button', 'visibility', 'visible');// 「新規追加」ボタン
@@ -251,6 +206,9 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
                // タブの選択状態を設定
                // 一度設定を保存している場合は、メニュー定義を前面にする(初期起動時のみ)
                if (empty($act) && !empty($this->configId)) $this->tmpl->setAttribute('select_menu_def', 'visibility', 'visible');
+               
+               // ページ定義IDとページ定義のレコードシリアル番号を更新
+               $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
        }
        /**
         * 選択用メニューを作成
@@ -330,24 +288,16 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
         */
        function createList($request)
        {
+               // ページ定義IDとページ定義のレコードシリアル番号を取得
+               $this->startPageDefParam($defSerial, $defConfigId, $this->paramObj);
+               
                $userId         = $this->gEnv->getCurrentUserId();
                $langId = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
                $act = $request->trimValueOf('act');
-               
-               // ページ定義IDとページ定義のレコードシリアル番号
-               $defConfigId = $this->getPageDefConfigId($request);                             // 定義ID取得
-               $defSerial = $this->getPageDefSerial($request);         // ページ定義のレコードシリアル番号
-               $value = $request->trimValueOf('defconfig');            // ページ定義の定義ID
-               if (!empty($value)) $defConfigId = $value;
-               $value = $request->trimValueOf('defserial');            // ページ定義のレコードシリアル番号
-               if (!empty($value)) $defSerial = $value;
 
                // 詳細画面からの引継ぎデータ
                $menuId = $request->trimValueOf('menuid');
                
-               // パラメータオブジェクトを取得
-               $this->paramObj = $this->getWidgetParamObjectWithId();
-               
                if ($act == 'delete'){          // メニュー項目の削除
                        $listedItem = explode(',', $request->trimValueOf('seriallist'));
                        $delItems = array();
@@ -361,30 +311,17 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
                                }
                        }
                        if (count($delItems) > 0){
-                               for ($i = 0; $i < count($this->paramObj); $i++){
-                                       $id                     = $this->paramObj[$i]->id;// 定義ID
-                                       if (in_array($id, $delItems)){          // 削除対象のとき
-                                               $newParam = new stdClass;
-                                               $newParam->id = $id;
-                                               $newParam->object = null;               // 削除処理
-                                               $ret = $this->updateWidgetParamObjectWithId($newParam);
-                                               if (!$ret) break;
-                                       }
-                               }
-                               
-                               // ウィジェットパラメータオブジェクト更新
+                               $ret = $this->delPageDefParam($defSerial, $defConfigId, $this->paramObj, $delItems);
                                if ($ret){              // データ削除成功のとき
                                        $this->setGuidanceMsg('データを削除しました');
                                } else {
                                        $this->setAppErrorMsg('データ削除に失敗しました');
                                }
-                               // パラメータオブジェクトを取得
-                               $this->paramObj = $this->getWidgetParamObjectWithId();
                        }
                }
                // 定義一覧作成
                $this->createItemList();
-               if ($this->db->getEffectedRowCount() <= 0) $this->tmpl->setAttribute('itemlist', 'visibility', 'hidden');// 一覧非表示
+               if (count($this->serialArray) <= 0) $this->tmpl->setAttribute('itemlist', 'visibility', 'hidden');// 一覧非表示
                
                // メニュー定義画面のURLを作成
                $taskValue = 'smenudef';
@@ -394,9 +331,8 @@ class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
                                        
                $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
                
-               // 画面定義用の情報を戻す
-               $this->tmpl->addVar("_widget", "def_serial", $defSerial);       // ページ定義のレコードシリアル番号
-               $this->tmpl->addVar("_widget", "def_config", $defConfigId);     // ページ定義の定義ID
+               // ページ定義IDとページ定義のレコードシリアル番号を更新
+               $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
        }
        /**
         * 定義一覧作成
index b0c3c26..bcc1995 100644 (file)
@@ -68,8 +68,7 @@ $(function(){
 <input type="hidden" name="task" />
 <input type="hidden" name="act" />
 <input type="hidden" name="serial" value="{SERIAL}" />
-<input type="hidden" name="defserial" value="{DEF_SERIAL}" />
-<input type="hidden" name="defconfig" value="{DEF_CONFIG}" />
+<!-- m3:PostParam -->
 <table width="95%" style="margin: 0 auto;">
 <tr><td><span {_HELP_MENU_DETAIL}><label>メニュー設定</label></span></td>
 <td align="right"><span {_HELP_MENU_LIST_BTN}><input type="button" class="button" onclick="listItem();" value="設定一覧" /></span>
@@ -103,7 +102,7 @@ $(function(){
                <option value="{VALUE}" {SELECTED}>{NAME}</option>
                </patTemplate:tmpl>
            </select>
-           <span {_HELP_MENU_EDIT_DEF_BTN}><input id="edit_menu" type="button" class="button" value="メニュー定義を編集" /></span>
+           <!--<span {_HELP_MENU_EDIT_DEF_BTN}><input id="edit_menu" type="button" class="button" value="メニュー定義を編集" /></span>-->
            </td>
        </tr>
         <tr>
index 5876dfc..0b571b0 100644 (file)
@@ -71,10 +71,9 @@ $(function(){
 <input type="hidden" name="act" />
 <input type="hidden" name="serial" />
 <input type="hidden" name="seriallist" value="{SERIAL_LIST}" />
-<input type="hidden" name="defserial" value="{DEF_SERIAL}" />
-<input type="hidden" name="defconfig" value="{DEF_CONFIG}" />
 <input type="hidden" name="menuid" value="{MENU_ID}" />
 <input type="hidden" name="is_hier" value="{IS_HIER}" />
+<!-- m3:PostParam -->
 <table width="95%" style="margin: 0 auto;">
 <tr><td>
 <span {_HELP_MENU_LIST}><label>メニュー設定一覧</label></span>