OSDN Git Service

「新着情報-簡易」ウィジェットをインスタンスタイプウィジェットに変更。
authornaoki hirata <naoki@magic3.org>
Tue, 1 Jul 2014 06:18:04 +0000 (15:18 +0900)
committernaoki hirata <naoki@magic3.org>
Tue, 1 Jul 2014 06:18:04 +0000 (15:18 +0900)
templates/_admin4/css/style.css
widgets/admin_main/include/template/menudef.tmpl.html
widgets/admin_main/include/template/smenudef.tmpl.html
widgets/whatsnew/include/container/admin_whatsnewWidgetContainer.php [new file with mode: 0644]
widgets/whatsnew/include/container/whatsnewWidgetContainer.php [new file with mode: 0644]
widgets/whatsnew/include/template/admin.tmpl.html [new file with mode: 0644]
widgets/whatsnew/include/template/admin_list.tmpl.html [new file with mode: 0644]

index 6038072..1793f40 100644 (file)
@@ -607,6 +607,11 @@ background-color: #0081c2;
        font:11px/1.5 Arial, sans-serif;
 }*/
 /*** config window ***/
+/* 外枠 */
+.m3config_container {
+       display: table;
+       margin: 10px auto;
+}
 .m3config_tabs {
        width:95%;
        margin: 10px auto;
@@ -615,10 +620,6 @@ background-color: #0081c2;
        width:95%;
        margin: 10px auto;
 }
-.m3config_body {
-       display: table;
-       margin: 10px auto;
-}
 .m3config_fullwidth {
        position: fixed;
        left: 0px;
index ba1ae7a..1c30504 100644 (file)
@@ -147,7 +147,7 @@ $(function(){
 });\r
 //]]>\r
 </script>\r
-<div class="m3config_body">\r
+<div class="m3config_container">\r
 <!-- m3:ErrorMessage -->\r
 <form method="post" name="main">\r
 <input type="hidden" name="fixed_mode" value="{FIXED_MODE}" />\r
index 45aa288..d9f092b 100644 (file)
@@ -108,7 +108,7 @@ $(function(){
 });\r
 //]]>\r
 </script>\r
-<div class="m3config_body">\r
+<div class="m3config_container">\r
 <!-- m3:ErrorMessage -->\r
 <form method="post" name="main">\r
 <input type="hidden" name="fixed_mode" value="{FIXED_MODE}" />\r
diff --git a/widgets/whatsnew/include/container/admin_whatsnewWidgetContainer.php b/widgets/whatsnew/include/container/admin_whatsnewWidgetContainer.php
new file mode 100644 (file)
index 0000000..579165d
--- /dev/null
@@ -0,0 +1,392 @@
+<?php
+/**
+ * コンテナクラス
+ *
+ * PHP versions 5
+ *
+ * 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-2014 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
+require_once($gEnvManager->getCurrentWidgetDbPath() . '/whatsnewDb.php');
+
+class admin_whatsnewWidgetContainer extends BaseAdminWidgetContainer
+{
+       private $db;    // DB接続オブジェクト
+       private $serialNo;              // 選択中の項目のシリアル番号
+       private $serialArray = array();                 // 表示中のシリアル番号
+       private $langId;
+       private $paramObj;              // パラメータ保存用オブジェクト
+       const CONTENT_TYPE = 'news';                    // コンテンツタイプ
+       const DEFAULT_NAME_HEAD = '名称未設定';                    // デフォルトの設定名
+       
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+               
+               // DBオブジェクト作成
+               $this->db = new whatsnewDb();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+        * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
+        * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+        */
+       function _setTemplate($request, &$param)
+       {
+               $task = $request->trimValueOf('task');
+               if ($task == 'list'){           // 一覧画面
+                       return 'admin_list.tmpl.html';
+               } else {                        // 一覧画面
+                       return 'admin.tmpl.html';
+               }
+       }
+       /**
+        * テンプレートにデータ埋め込む
+        *
+        * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
+        * @param                                                               なし
+        */
+       function _assign($request, &$param)
+       {
+               $task = $request->trimValueOf('task');
+               if ($task == 'list'){           // 一覧画面
+                       return $this->createList($request);
+               } else {                        // 詳細設定画面
+                       return $this->createDetail($request);
+               }
+       }
+       /**
+        * 詳細画面作成
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param                                                               なし
+        */
+       function createDetail($request)
+       {
+               $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;
+               
+               $name = $request->trimValueOf('item_name');
+               $html = $request->valueOf('item_html');         // ヘッダコンテンツ
+               $this->configId = $request->trimValueOf('item_id');             // 定義ID
+               if (empty($this->configId)) $this->configId = $defConfigId;             // 呼び出しウィンドウから引き継いだ定義ID
+               
+               // パラメータオブジェクトを取得
+               $this->paramObj = $this->getWidgetParamObj();
+               
+               if (empty($act)){// 初期起動時
+                       $name = '';
+                       $this->configId = $defConfigId;         // 呼び出しウィンドウから引き継いだ定義ID
+                       $html = '';             // コンテンツ
+               } else if ($act == 'add'){// 新規追加
+                       // 入力チェック
+                       $this->checkInput($name, '名前');
+
+                       // 設定名の重複チェック
+                       for ($i = 0; $i < count($this->paramObj); $i++){
+                               $targetObj = $this->paramObj[$i];
+                               if ($name == $targetObj->name){         // 定義名
+                                       $this->setUserErrorMsg('名前が重複しています');
+                                       break;
+                               }
+                       }
+                       
+                       // エラーなしの場合は、データを登録
+                       if ($this->getMsgCount() == 0){
+                               // コンテンツ登録
+                               $contentId = 0;// コンテンツID新規追加
+                               $default = 0;
+                               $key = '';
+                               $ret = $this->db->updateContentItem(self::CONTENT_TYPE, $contentId, $this->langId, $name, $html, 1/*コンテンツ表示*/, $default, $key, $userId, $newContentId, $newSerial);
+                               if ($ret) $contentId = $newContentId;// コンテンツID更新
+                               
+                               // 最大の定義ID取得
+                               $newConfigId = 1;
+                               if (count($this->paramObj) > 0){
+                                       $targetObj = $this->paramObj[count($this->paramObj) -1];
+                                       $newConfigId = $targetObj->id + 1;
+                               }
+                               // 追加オブジェクト作成
+                               $newObj = new stdClass;
+                               $newObj->name   = $name;// 表示名
+                               $newObj->id     = $newConfigId;// 定義ID
+                               $newObj->contentId = $contentId;                // コンテンツID
+                               $this->paramObj[] = $newObj;
+                       
+                               // ウィジェットパラメータオブジェクト更新
+                               $ret = $this->updateWidgetParamObj($this->paramObj);
+                               
+                               // 画面定義更新
+                               if ($ret && !empty($defSerial)){
+                                       $ret = $this->_db->updateWidgetConfigId($this->gEnv->getCurrentWidgetId(), $defSerial, $newConfigId, $name);
+                               }
+                               if ($ret){
+                                       $this->setGuidanceMsg('データを追加しました');
+                                       
+                                       if (!empty($defSerial)) $defConfigId = $newConfigId;            // 定義定義IDを更新
+                                       $this->configId = $newConfigId;         // 定義定義IDを更新
+                               } else {
+                                       $this->setAppErrorMsg('データ追加に失敗しました');
+                               }
+                               $this->gPage->updateParentWindow($defSerial);// 親ウィンドウを更新
+                       }
+               } else if ($act == 'update'){           // 項目更新の場合
+                       // エラーなしの場合は、データを更新
+                       if ($this->getMsgCount() == 0){
+                               // コンテンツIDを取得
+                               $contentId = 0;
+                               for ($i = 0; $i < count($this->paramObj); $i++){
+                                       $targetObj = $this->paramObj[$i];
+                                       $id = $targetObj->id;// 定義ID
+                                       $name = $targetObj->name;// 定義名
+                                       if ($id == $this->configId){
+                                               $contentId = $targetObj->contentId;
+                                               break;
+                                       }
+                               }
+                               // ウィジェットパラメータオブジェクトを更新
+                               $ret = $this->updateWidgetParamObj($this->paramObj);
+                               
+                               // コンテンツを更新
+                               $default = 0;
+                               $key = '';
+                               $ret = $this->db->updateContentItem(self::CONTENT_TYPE, $contentId, $this->langId, $name, $html, 1/*コンテンツ表示*/, $default, $key, $userId, $newContentId, $newSerial);
+                               
+                               if (empty($defConfigId) && !empty($defSerial)){         // 画面定義の定義IDが設定されていないときは設定
+                                       // 画面定義更新
+                                       if ($ret) $ret = $this->_db->updateWidgetConfigId($this->gEnv->getCurrentWidgetId(), $defSerial, $this->configId, $name);
+                               }
+                               if ($ret){
+                                       $this->setGuidanceMsg('データを更新しました');
+                                       
+                                       if (empty($defConfigId) && !empty($defSerial)){         // 画面定義の定義IDが設定されていないときは設定
+                                               $defConfigId = $this->configId;         // 定義定義IDを更新
+                                       }
+                               } else {
+                                       $this->setAppErrorMsg('データ更新に失敗しました');
+                               }
+                               $this->gPage->updateParentWindow($defSerial);// 親ウィンドウを更新
+                       }
+               } else if ($act == 'select'){   // 定義IDを変更
+               }
+
+               // お知らせ選択メニュー作成
+               $this->createNewsListMenu();
+
+               if (empty($this->configId)){            // 新規登録の場合
+                       $this->tmpl->setAttribute('item_name_visible', 'visibility', 'visible');// 名前入力フィールド表示
+                       $name = $this->createDefaultName();                     // デフォルト登録項目名
+                       $html = '';
+                       $this->serialNo = 0;
+               } else {
+                       // 定義からウィジェットパラメータを検索して、定義データを取得
+                       for ($i = 0; $i < count($this->paramObj); $i++){
+                               $targetObj = $this->paramObj[$i];
+                               $id = $targetObj->id;// 定義ID
+                               if ($id == $this->configId) break;
+                       }
+                       if ($i < count($this->paramObj)){               // 該当項目があるとき
+                               // コンテンツを取得
+                               $contentId = $targetObj->contentId;
+                               $ret = $this->db->getContentByContentId(self::CONTENT_TYPE, $contentId, $this->langId, $row);
+                               if ($ret){
+                                       $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $row['cn_html']);// アプリケーションルートを変換
+                                       $this->serialNo = $row['cn_serial'];
+                                       
+                                       $name = $targetObj->name;// 名前
+                                       
+                                       // 新規作成でないときは、メニューを変更不可にする
+                                       if (!empty($defConfigId) && !empty($defSerial)) $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
+                               }
+                       }
+               }
+               
+               // ### 入力値を再設定 ###
+               $this->tmpl->addVar("item_name_visible", "name", $name);                // 名前
+               $this->tmpl->addVar("_widget", "content", $html);               // コンテンツ
+               
+               $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');// 「新規追加」ボタン
+               } else {
+                       $this->tmpl->setAttribute('del_button', 'visibility', 'visible');// 「削除」ボタン
+               }
+       }
+       /**
+        * お知らせ選択用メニュー
+        *
+        * @return なし                                               
+        */
+       function createNewsListMenu()
+       {
+               for ($i = 0; $i < count($this->paramObj); $i++){
+                       $targetObj = $this->paramObj[$i];
+                       $id = $targetObj->id;// 定義ID
+                       $name = $targetObj->name;// 定義名
+                       $selected = '';
+                       if ($this->configId == $id) $selected = 'selected';
+                       $row = array(
+                               'name' => $name,                // 名前
+                               'value' => $id,         // 定義ID
+                               'selected' => $selected // 選択中の項目かどうか
+                       );
+                       $this->tmpl->addVars('news_list', $row);
+                       $this->tmpl->parseTemplate('news_list', 'a');
+               }
+       }
+       /**
+        * 一覧画面作成
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param                                                               なし
+        */
+       function createList($request)
+       {
+               $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;
+
+               // パラメータオブジェクトを取得
+               $this->paramObj = $this->getWidgetParamObj();
+               
+               if ($act == 'delete'){          // メニュー項目の削除
+                       $listedItem = explode(',', $request->trimValueOf('seriallist'));
+                       $delItems = array();
+                       for ($i = 0; $i < count($listedItem); $i++){
+                               // 項目がチェックされているかを取得
+                               $itemName = 'item' . $i . '_selected';
+                               $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
+                               
+                               if ($itemValue){                // チェック項目
+                                       $delItems[] = $listedItem[$i];
+                               }
+                       }
+                       if (count($delItems) > 0){
+                               // 更新オブジェクト作成
+                               $newParamObj = array();
+
+                               for ($i = 0; $i < count($this->paramObj); $i++){
+                                       $targetObj = $this->paramObj[$i];
+                                       $id = $targetObj->id;// 定義ID
+                                       if (!in_array($id, $delItems)){         // 削除対象でないときは追加
+                                               $newParamObj[] = $targetObj;
+                                       }
+                               }
+                               
+                               // ウィジェットパラメータオブジェクト更新
+                               $ret = $this->updateWidgetParamObj($newParamObj);
+                               if ($ret){              // データ削除成功のとき
+                                       $this->setGuidanceMsg('データを削除しました');
+                                       $this->paramObj = $newParamObj;
+                               } else {
+                                       $this->setAppErrorMsg('データ削除に失敗しました');
+                               }
+                       }
+               }
+               // お知らせ選択リスト作成
+               $this->createNewsList();
+               
+               $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
+               
+               // 画面定義用の情報を戻す
+               $this->tmpl->addVar("_widget", "def_serial", $defSerial);       // ページ定義のレコードシリアル番号
+               $this->tmpl->addVar("_widget", "def_config", $defConfigId);     // ページ定義の定義ID
+       }
+       /**
+        * お知らせ一覧用リスト
+        *
+        * @return なし                                               
+        */
+       function createNewsList()
+       {
+               for ($i = 0; $i < count($this->paramObj); $i++){
+                       $targetObj = $this->paramObj[$i];
+                       $id = $targetObj->id;// 定義ID
+                       $name = $targetObj->name;// 定義名
+                       
+                       $defCount = 0;
+                       if (!empty($id)){
+                               $defCount = $this->_db->getPageDefCount($this->gEnv->getCurrentWidgetId(), $id);
+                       }
+                       $operationDisagled = '';
+                       if ($defCount > 0) $operationDisagled = 'disabled';
+                       $row = array(
+                               'index' => $i,
+                               'ope_disabled' => $operationDisagled,                   // 選択可能かどうか
+                               'name' => $this->convertToDispString($name),            // 名前
+                               'def_count' => $defCount                                                        // 使用数
+                       );
+                       $this->tmpl->addVars('itemlist', $row);
+                       $this->tmpl->parseTemplate('itemlist', 'a');
+                       
+                       // シリアル番号を保存
+                       $this->serialArray[] = $id;
+               }
+       }
+       /**
+        * デフォルトの名前を取得
+        *
+        * @return string       デフォルト名                                              
+        */
+       function createDefaultName()
+       {
+               $name = self::DEFAULT_NAME_HEAD;
+               for ($j = 1; $j < 100; $j++){
+                       $name = self::DEFAULT_NAME_HEAD . $j;
+                       // 設定名の重複チェック
+                       for ($i = 0; $i < count($this->paramObj); $i++){
+                               $targetObj = $this->paramObj[$i];
+                               if ($name == $targetObj->name){         // 定義名
+                                       break;
+                               }
+                       }
+                       // 重複なしのときは終了
+                       if ($i == count($this->paramObj)) break;
+               }
+               return $name;
+       }
+}
+?>
diff --git a/widgets/whatsnew/include/container/whatsnewWidgetContainer.php b/widgets/whatsnew/include/container/whatsnewWidgetContainer.php
new file mode 100644 (file)
index 0000000..f924293
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+/**
+ * index.php用コンテナクラス
+ *
+ * PHP versions 5
+ *
+ * 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-2014 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
+require_once($gEnvManager->getCurrentWidgetDbPath() . '/whatsnewDb.php');
+
+class whatsnewWidgetContainer extends BaseWidgetContainer
+{
+       private $db;                    // DB接続オブジェクト
+       private $langId;                // 現在の言語
+       const DEFAULT_CONFIG_ID = 0;
+       const CONTENT_TYPE = 'news';                    // コンテンツタイプ
+               
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+               
+               // DBオブジェクト作成
+               $this->db = new whatsnewDb();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+        * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
+        * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+        */
+       function _setTemplate($request, &$param)
+       {
+               return 'index.tmpl.html';
+       }
+       /**
+        * テンプレートにデータ埋め込む
+        *
+        * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
+        * @param                                                               なし
+        */
+       function _assign($request, &$param)
+       {
+               $this->langId = $this->gEnv->getCurrentLanguage();
+               
+               // 定義ID取得
+               $configId = $this->gEnv->getCurrentWidgetConfigId();
+               if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
+               
+               // パラメータオブジェクトを取得
+               $paramObj = $this->getWidgetParamObj();
+               
+               // コンテンツIDを取得
+               $contentId = 0;
+               $name = '';
+               for ($i = 0; $i < count($paramObj); $i++){
+                       $targetObj = $paramObj[$i];
+                       $id = $targetObj->id;// 定義ID
+                       if ($id == $configId){
+                               $contentId = $targetObj->contentId;
+                               $name = $targetObj->name;// 定義名
+                               break;
+                       }
+               }
+               
+               // コンテンツを取得
+               $ret = $this->db->getContentByContentId(self::CONTENT_TYPE, $contentId, $this->langId, $row);
+               if ($ret){
+                       $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $row['cn_html']);// アプリケーションルートを変換
+               }
+               
+               // コンテンツを設定
+               $this->tmpl->addVar("_widget", "content", $html);
+       }
+}
+?>
diff --git a/widgets/whatsnew/include/template/admin.tmpl.html b/widgets/whatsnew/include/template/admin.tmpl.html
new file mode 100644 (file)
index 0000000..afbbc67
--- /dev/null
@@ -0,0 +1,106 @@
+/**
+ * 表示データ作成用テンプレート(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-2014 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+<patTemplate:tmpl name="_widget">
+<script type="text/javascript">
+//<![CDATA[
+function addItem(){
+       if (!window.confirm('項目を新規追加しますか?')) return false;
+       document.main.act.value = 'add';
+       document.main.submit();
+       return true;
+}
+function updateItem(serialNo){
+       if (!window.confirm('項目を更新しますか?')) return false;
+       document.main.act.value = 'update';
+       document.main.submit();
+       return true;
+}
+function delItem(serialNo){
+       if (!window.confirm('項目を削除しますか?')) return false;
+       document.main.act.value = 'delete';
+       document.main.submit();
+       return true;
+}
+function selectItem()
+{
+       document.main.act.value = 'select';
+       document.main.submit();
+       return true;
+}
+function listItem(){
+       document.main.task.value = 'list';
+       document.main.submit();
+       return true;
+}
+$(function(){
+       // WYSIWYGエディター作成
+       m3SetWysiwygEditor('item_html', 300);
+});
+//]]>
+</script>
+<div class="m3config_container">
+<!-- m3:ErrorMessage -->
+<form method="post" name="main">
+<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}" />
+
+<table width="90%">
+<tr><td><label>お知らせ項目</label></td>
+<td align="right"><input type="button" class="button" onclick="listItem();" value="一覧" />
+</td></tr>
+<tr><td colspan="2">
+
+<table class="simple-table" style="margin: 0 auto;width:950px;">
+    <tbody>
+        <tr>
+           <td class="table-headside" width="150">名前</td>
+           <td>
+           <select name="item_id" onchange="selectItem();" {ID_DISABLED}>
+               <option value="0">-- 新規登録 --</option>
+               <patTemplate:tmpl name="news_list">
+               <option value="{VALUE}" {SELECTED}>{NAME}</option>
+               </patTemplate:tmpl>
+           </select>
+           <patTemplate:tmpl name="item_name_visible" visibility="hidden">
+           <input type="text" name="item_name" value="{NAME}" size="40" maxlength="40" />
+           </patTemplate:tmpl>
+           </td>
+       </tr>
+        <tr class="even">
+           <td class="table-headside">お知らせ内容</td>
+           <td>
+           <textarea name="item_html">{CONTENT}</textarea>
+           </td>
+       </tr>
+       <tr>
+       <td align="right" colspan="2">
+<patTemplate:tmpl name="del_button" visibility="hidden">
+               <input type="button" class="button" onclick="updateItem();" value="更新" />
+</patTemplate:tmpl>
+<patTemplate:tmpl name="add_button" visibility="hidden">
+               <input type="button" class="button" onclick="addItem();" value="新規追加" />
+</patTemplate:tmpl>
+       </td>
+       </tr>
+    </tbody>
+</table>
+
+</td></tr>
+</table>
+
+</form>
+</div>
+</patTemplate:tmpl>
diff --git a/widgets/whatsnew/include/template/admin_list.tmpl.html b/widgets/whatsnew/include/template/admin_list.tmpl.html
new file mode 100644 (file)
index 0000000..2c8228c
--- /dev/null
@@ -0,0 +1,73 @@
+<patTemplate:tmpl name="_widget">
+<script type="text/javascript">
+<!--
+function delItem(){
+    if (document.main.seriallist.value){
+        var items = document.main.seriallist.value.split(",");
+       for (var i = 0; i < items.length; i++){
+           var name = "document.main.item" + i + "_selected";
+           var itemObj = eval(name);
+           // チェックありのときは終了
+           if (itemObj && itemObj.checked) break;
+       }
+       if (i == items.length){                 
+           window.alert('削除する項目を選択してください');
+       } else {
+            if (!window.confirm('選択項目を削除しますか?')) return false;
+            document.main.act.value = 'delete';
+            document.main.submit();
+       }
+    }
+    return true;
+}
+function cancelItem(){
+    document.main.task.value = '';
+    document.main.submit();
+    return true;
+}
+$(function(){
+       // スクロールバー付きのテーブルを作成
+       m3_tableWithScrollbar('itemlist', -1, 0);
+});
+// -->
+</script>
+<div class="m3config_container">
+<!-- m3:ErrorMessage -->
+<form method="post" name="main">
+<input type="hidden" name="task" value="list" />
+<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}" />
+<table width="90%">
+<tr><td>
+<label>お知らせ定義一覧</label>
+</td><td align="right"><input type="button" class="button" onclick="delItem();" value="削除" /><input type="button" class="button" onclick="cancelItem();" value="戻る" />
+</td></tr>
+<tr><td colspan="2">
+<table id="itemlist" class="simple-table" width="100%">
+    <thead>
+        <tr>
+           <th width="35" align="center">選択</th>
+           <th width="80%" align="center">名前</th>
+           <th align="center">使用</th>
+       </tr>
+    </thead>
+    <tbody>
+        <patTemplate:tmpl name="itemlist">
+        <tr>
+            <td align="center"><input type="checkbox" name="item{INDEX}_selected" {OPE_DISABLED} /></td>
+           <td>{NAME}</td>
+           <td align="center">{DEF_COUNT}</td>
+       </tr>
+       </patTemplate:tmpl>
+    </tbody>
+</table>
+
+</td></tr>
+</table>
+
+</form>
+</div>
+</patTemplate:tmpl>