OSDN Git Service

「デフォルトメニュー」ウィジェット更新
authornaoki hirata <naoki@magic3.org>
Tue, 5 Nov 2013 01:25:26 +0000 (10:25 +0900)
committernaoki hirata <naoki@magic3.org>
Tue, 5 Nov 2013 01:25:26 +0000 (10:25 +0900)
widgets/default_menu/include/container/admin_default_menuWidgetContainer.php
widgets/default_menu/include/template/admin.tmpl.html
widgets/default_menu/include/template/admin_list.tmpl.html
widgets/default_menu/include/template/index.tmpl.html
widgets/default_menu/include/template/index_old.tmpl.html

index db52459..da705ff 100644 (file)
@@ -84,18 +84,13 @@ class admin_default_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
@@ -104,10 +99,7 @@ class admin_default_menuWidgetContainer extends BaseAdminWidgetContainer
                $limitUser = ($request->trimValueOf('item_limituser') == 'on') ? 1 : 0;         // ユーザを制限するかどうか
                $useVerticalMenu = ($request->trimValueOf('item_vertical_menu') == '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)){// 初期起動時
@@ -128,73 +120,44 @@ class admin_default_menuWidgetContainer extends BaseAdminWidgetContainer
                                $newObj->limitUser = $limitUser;                                        // ユーザを制限するかどうか
                                $newObj->useVerticalMenu = $useVerticalMenu;            // 縦型メニューデザインを使用するかどうか
                                
-                               $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->isHierMenu = $isHierMenu;           // 階層化メニューを使用するかどうか
-                                               }
-                                               $targetObj->limitUser = $limitUser;                                     // ユーザを制限するかどうか
-                                               $targetObj->useVerticalMenu = $useVerticalMenu;         // 縦型メニューデザインを使用するかどうか
-                                               
-                                               // ウィジェットパラメータオブジェクトを更新
-                                               $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->isHierMenu = $isHierMenu;           // 階層化メニューを使用するかどうか
+                                       $targetObj->limitUser = $limitUser;                                     // ユーザを制限するかどうか
+                                       $targetObj->useVerticalMenu = $useVerticalMenu;         // 縦型メニューデザインを使用するかどうか
                                }
 
+                               // 設定値を更新
+                               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;                     // データ再取得
@@ -203,35 +166,30 @@ class admin_default_menuWidgetContainer extends BaseAdminWidgetContainer
                // 表示用データを取得
                if (empty($this->configId)){            // 新規登録の場合
                        $this->tmpl->setAttribute('item_name_visible', 'visibility', 'visible');// 名前入力フィールド表示
-                       $name = $this->createDefaultName();                     // デフォルト登録項目名
-                       $$isHierMenu = 0;               // 階層化メニューを使用するかどうか
-                       $limitUser = 0;                                 // ユーザを制限するかどうか
-                       $useVerticalMenu = 0;           // 縦型メニューデザインを使用するかどうか
+                       
+                       if ($replaceNew){               // データ再取得時
+                               $this->menuId = self::DEFAULT_MENU_ID;
+                               $name = $this->createDefaultName();                     // デフォルト登録項目名
+                               $$isHierMenu = 0;               // 階層化メニューを使用するかどうか
+                               $limitUser = 0;                                 // ユーザを制限するかどうか
+                               $useVerticalMenu = 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;// 名前
                                        $isHierMenu             = $targetObj->isHierMenu;               // 階層化メニューを使用するかどうか
                                        $limitUser              = $targetObj->limitUser;                                        // ユーザを制限するかどうか
                                        $useVerticalMenu = $targetObj->useVerticalMenu;         // 縦型メニューデザインを使用するかどうか
                                }
-                               $this->serialNo = $this->configId;
-                               
-                               // 新規作成でないときは、メニューを変更不可にする(画面作成から呼ばれている場合のみ)
-                               if (!empty($defConfigId) && !empty($defSerial)){
-                                       $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
-                                       $this->tmpl->addVar("_widget", "is_hier_disabled", 'disabled'); // ユーザを制限するかどうかを使用不可
-                               }
                        }
+                       $this->serialNo = $this->configId;
+                               
+                       // 新規作成でないときは、メニューを変更不可にする(画面作成から呼ばれている場合のみ)
+                       if (!empty($defConfigId) && !empty($defSerial)) $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
                }
                // 設定項目選択メニュー作成
                $this->createItemMenu();
@@ -255,10 +213,6 @@ class admin_default_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');// 「新規追加」ボタン
@@ -268,6 +222,9 @@ class admin_default_menuWidgetContainer extends BaseAdminWidgetContainer
                // タブの選択状態を設定
                // 一度設定を保存している場合は、メニュー定義を前面にする(初期起動時のみ)
                if (empty($act) && !empty($this->configId)) $this->tmpl->setAttribute('select_menu_def', 'visibility', 'visible');
+               
+               // ページ定義IDとページ定義のレコードシリアル番号を更新
+               $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
        }
        /**
         * 選択用メニューを作成
@@ -347,25 +304,17 @@ class admin_default_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');
                $isHierMenu = ($request->trimValueOf('is_hier') == 'on') ? 1 : 0;               // 階層化メニューを使用するかどうか
                
-               // パラメータオブジェクトを取得
-               $this->paramObj = $this->getWidgetParamObjectWithId();
-               
                if ($act == 'delete'){          // メニュー項目の削除
                        $listedItem = explode(',', $request->trimValueOf('seriallist'));
                        $delItems = array();
@@ -379,30 +328,17 @@ class admin_default_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 = 'menudef';
@@ -415,9 +351,8 @@ class admin_default_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 7c26c93..bb9ae0f 100644 (file)
@@ -1,3 +1,15 @@
+/**\r
+ * 表示データ作成用テンプレート(patTemplate)\r
+ *\r
+ * LICENSE: This source file is licensed under the terms of the GNU General Public License.\r
+ *\r
+ * @package    Magic3 Framework\r
+ * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>\r
+ * @copyright  Copyright 2006-2013 Magic3 Project.\r
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License\r
+ * @version    SVN: $Id$\r
+ * @link       http://www.magic3.org\r
+ */\r
 <patTemplate:tmpl name="_widget">\r
 <script type="text/javascript">\r
 //<![CDATA[\r
@@ -60,8 +72,7 @@ $(function(){
 <input type="hidden" name="task" />\r
 <input type="hidden" name="act" />\r
 <input type="hidden" name="serial" value="{SERIAL}" />\r
-<input type="hidden" name="defserial" value="{DEF_SERIAL}" />\r
-<input type="hidden" name="defconfig" value="{DEF_CONFIG}" />\r
+<!-- m3:PostParam -->\r
 <table width="95%" style="margin: 0 auto;">\r
 <tr><td><span {_HELP_MENU_DETAIL}><label>メニュー設定</label></span></td>\r
 <td align="right"><span {_HELP_MENU_LIST_BTN}><input type="button" class="button" onclick="listItem();" value="設定一覧" /></span>\r
@@ -90,13 +101,12 @@ $(function(){
         <tr class="even">\r
            <td class="table-headside"><span {_HELP_MENU_DEF}>メニュー定義</span></td>\r
            <td colspan="3">\r
-           <input type="checkbox" name="is_hier" {IS_HIER} {IS_HIER_DISABLED} />階層化あり&nbsp;&nbsp;\r
            <select name="menuid" {ID_DISABLED}>\r
                <patTemplate:tmpl name="menu_id_list">\r
                <option value="{VALUE}" {SELECTED}>{NAME}</option>\r
                </patTemplate:tmpl>\r
            </select>\r
-           <span {_HELP_MENU_EDIT_DEF_BTN}><input id="edit_menu" type="button" class="button" value="メニュー定義を編集" /></span>\r
+           <!--<span {_HELP_MENU_EDIT_DEF_BTN}><input id="edit_menu" type="button" class="button" value="メニュー定義を編集" /></span>-->\r
            </td>\r
        </tr>\r
         <tr>\r
@@ -106,7 +116,7 @@ $(function(){
        </tr>\r
         <tr class="even">\r
            <td class="table-headside"><span {_HELP_MENU_DESIGN}>デザイン</span></td>\r
-           <td colspan="3"><input type="checkbox" name="item_vertical_menu" {VERTICAL_MENU} />縦型メニュー\r
+           <td colspan="3"><label class="item_list_inline"><input type="checkbox" name="is_hier" {IS_HIER} {IS_HIER_DISABLED} />階層化あり</label><label class="item_list_inline"><input type="checkbox" name="item_vertical_menu" {VERTICAL_MENU} />縦型メニュー</label>\r
            </td>\r
        </tr>\r
        <tr>\r
index ef60a29..5a5c56a 100644 (file)
@@ -1,3 +1,15 @@
+/**\r
+ * 表示データ作成用テンプレート(patTemplate)\r
+ *\r
+ * LICENSE: This source file is licensed under the terms of the GNU General Public License.\r
+ *\r
+ * @package    Magic3 Framework\r
+ * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>\r
+ * @copyright  Copyright 2006-2013 Magic3 Project.\r
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License\r
+ * @version    SVN: $Id$\r
+ * @link       http://www.magic3.org\r
+ */\r
 <patTemplate:tmpl name="_widget">\r
 <script type="text/javascript">\r
 //<![CDATA[\r
@@ -59,10 +71,9 @@ $(function(){
 <input type="hidden" name="act" />\r
 <input type="hidden" name="serial" />\r
 <input type="hidden" name="seriallist" value="{SERIAL_LIST}" />\r
-<input type="hidden" name="defserial" value="{DEF_SERIAL}" />\r
-<input type="hidden" name="defconfig" value="{DEF_CONFIG}" />\r
 <input type="hidden" name="menuid" value="{MENU_ID}" />\r
 <input type="hidden" name="is_hier" value="{IS_HIER}" />\r
+<!-- m3:PostParam -->\r
 <table width="95%" style="margin: 0 auto;">\r
 <tr><td>\r
 <span {_HELP_MENU_LIST}><label>メニュー設定一覧</label></span>\r
index f0173ec..7c808f4 100644 (file)
@@ -1,3 +1,15 @@
+/**
+ * 表示データ作成用テンプレート(patTemplate)
+ *
+ * LICENSE: This source file is licensed under the terms of the GNU General Public License.
+ *
+ * @package    Magic3 Framework
+ * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
+ * @copyright  Copyright 2006-2013 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
 <patTemplate:tmpl name="_widget">
 <ul class="menu">{MENU_HTML}</ul>
 </patTemplate:tmpl>
index c0ee618..750c0af 100644 (file)
@@ -1,3 +1,15 @@
+/**
+ * 表示データ作成用テンプレート(patTemplate)
+ *
+ * LICENSE: This source file is licensed under the terms of the GNU General Public License.
+ *
+ * @package    Magic3 Framework
+ * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
+ * @copyright  Copyright 2006-2013 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
 <patTemplate:tmpl name="_widget">
 <table width="100%">
   <patTemplate:tmpl name="itemlist"><tr><td><a href="{LINK_URL}" {OPTION}><span>{NAME}</span></a></td></tr></patTemplate:tmpl>