OSDN Git Service

「携帯用デフォルトメニュー」ウィジェット追加。
authornaoki hirata <naoki@magic3.org>
Sun, 3 Nov 2013 13:54:13 +0000 (22:54 +0900)
committernaoki hirata <naoki@magic3.org>
Sun, 3 Nov 2013 13:54:13 +0000 (22:54 +0900)
widgets/m/menu/admin/index.php [new file with mode: 0644]
widgets/m/menu/images/icon32.png [new file with mode: 0644]
widgets/m/menu/images/icon64.png [new file with mode: 0644]
widgets/m/menu/include/container/admin_m_menuWidgetContainer.php [new file with mode: 0644]
widgets/m/menu/include/container/m_menuWidgetContainer.php [new file with mode: 0644]
widgets/m/menu/include/db/menuDb.php [new file with mode: 0644]
widgets/m/menu/include/help/index.php [new file with mode: 0644]
widgets/m/menu/include/template/admin.tmpl.html [new file with mode: 0644]
widgets/m/menu/include/template/admin_list.tmpl.html [new file with mode: 0644]
widgets/m/menu/include/template/index.tmpl.html [new file with mode: 0644]
widgets/m/menu/index.php [new file with mode: 0644]

diff --git a/widgets/m/menu/admin/index.php b/widgets/m/menu/admin/index.php
new file mode 100644 (file)
index 0000000..7329894
--- /dev/null
@@ -0,0 +1,23 @@
+<?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-2007 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id: index.php 1345 2008-12-12 10:02:42Z fishbone $
+ * @link       http://www.magic3.org
+ */
+// 直接アクセスの防止
+defined('M3_SYSTEM') or die('Access error: Direct access denied.');
+
+// ウィジェット実行
+global $gLaunchManager;
+$gLaunchManager->goWidget(__FILE__);
+?>
diff --git a/widgets/m/menu/images/icon32.png b/widgets/m/menu/images/icon32.png
new file mode 100644 (file)
index 0000000..58c1d16
Binary files /dev/null and b/widgets/m/menu/images/icon32.png differ
diff --git a/widgets/m/menu/images/icon64.png b/widgets/m/menu/images/icon64.png
new file mode 100644 (file)
index 0000000..ce70280
Binary files /dev/null and b/widgets/m/menu/images/icon64.png differ
diff --git a/widgets/m/menu/include/container/admin_m_menuWidgetContainer.php b/widgets/m/menu/include/container/admin_m_menuWidgetContainer.php
new file mode 100644 (file)
index 0000000..2917b6c
--- /dev/null
@@ -0,0 +1,461 @@
+<?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-2013 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() . '/menuDb.php');
+
+class admin_m_menuWidgetContainer extends BaseAdminWidgetContainer
+{
+       private $db;    // DB接続オブジェクト
+       private $serialNo;              // 選択中の項目のシリアル番号
+       private $serialArray = array();                 // 表示中のシリアル番号
+       private $langId;
+       private $configId;              // 定義ID
+       private $paramObj;              // パラメータ保存用オブジェクト
+       private $menuId;                // メニューID
+       const DEFAULT_NAME_HEAD = '名称未設定';                    // デフォルトの設定名
+       const DEFAULT_MENU_ID = 'main_menu';                    // デフォルトメニューID
+       
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+               
+               // DBオブジェクト作成
+               $this->db = new menuDb();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _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'){           // 一覧画面
+                       $this->createList($request);
+               } else {                        // 詳細設定画面
+                       $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;
+
+               $this->configId = $request->trimValueOf('item_id');             // 定義ID
+               if (empty($this->configId)) $this->configId = $defConfigId;             // 呼び出しウィンドウから引き継いだ定義ID
+               $name   = $request->trimValueOf('item_name');                   // ヘッダタイトル
+               $isHierMenu = ($request->trimValueOf('is_hier') == 'on') ? 1 : 0;               // 階層化メニューを使用するかどうか
+               $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();
+               
+               $replaceNew = false;            // データを再取得するかどうか
+               if (empty($act)){// 初期起動時
+                       // デフォルト値設定
+                       $this->configId = $defConfigId;         // 呼び出しウィンドウから引き継いだ定義ID
+                       $replaceNew = true;                     // データ再取得
+               } else if ($act == 'add'){// 新規追加
+                       // 入力チェック
+                       $this->checkInput($name, '名前');
+                       
+                       // エラーなしの場合は、データを登録
+                       if ($this->getMsgCount() == 0){
+                               // 追加オブジェクト作成
+                               $newObj = new stdClass;
+                               $newObj->menuId = $this->menuId;                // メニューID
+                               $newObj->name   = $name;// 表示名
+                               $newObj->isHierMenu = $isHierMenu;              // 階層化メニューを使用するかどうか
+                               $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);
+                               }
+                               
+                               if ($ret){
+                                       $this->setGuidanceMsg('データを追加しました');
+                                       
+                                       $defConfigId = $newConfigId;            // 定義定義IDを更新
+                                       $this->configId = $newConfigId;         // 定義定義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;
+                                       }
+                               }
+                               // 画面定義更新
+                               if (!empty($defSerial)){                // 画面作成から呼ばれている場合のみ更新
+                                       if ($ret) $ret = $this->_db->updateWidgetConfigId($this->gEnv->getCurrentWidgetId(), $defSerial, $this->configId, $targetObj->name, $this->menuId);
+                               }
+
+                               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;                     // データ再取得
+               }
+               
+               // 表示用データを取得
+               if (empty($this->configId)){            // 新規登録の場合
+                       $this->tmpl->setAttribute('item_name_visible', 'visibility', 'visible');// 名前入力フィールド表示
+                       $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){               // データ再取得のとき
+                                       $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->createItemMenu();
+               
+               // メニューID選択メニュー作成
+               $this->db->getMenuIdList(array($this, 'menuIdListLoop'));
+               
+               // 画面にデータを埋め込む
+               $this->tmpl->addVar("item_name_visible", "name", $name);                // 名前
+               if (!empty($this->configId)) $this->tmpl->addVar("_widget", "id", $this->configId);             // 定義ID
+               
+               $checked = '';
+               if ($isHierMenu) $checked = 'checked';
+               $this->tmpl->addVar("_widget", "is_hier", $checked);    // 階層化メニューを使用するかどうか
+               $checked = '';
+               if ($limitUser) $checked = 'checked';
+               $this->tmpl->addVar("_widget", "limit_user", $checked); // ユーザを制限するかどうか
+               $checked = '';
+               if ($useVerticalMenu) $checked = 'checked';
+               $this->tmpl->addVar("_widget", "vertical_menu", $checked);              // 縦型メニューデザインを使用するかどうか
+               
+               $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('update_button', 'visibility', 'visible');// 「更新」ボタン
+               }
+               // タブの選択状態を設定
+               // 一度設定を保存している場合は、メニュー定義を前面にする(初期起動時のみ)
+               if (empty($act) && !empty($this->configId)) $this->tmpl->setAttribute('select_menu_def', 'visibility', 'visible');
+       }
+       /**
+        * 選択用メニューを作成
+        *
+        * @return なし                                               
+        */
+       function createItemMenu()
+       {
+               for ($i = 0; $i < count($this->paramObj); $i++){
+                       $id = $this->paramObj[$i]->id;// 定義ID
+                       $targetObj = $this->paramObj[$i]->object;
+                       $name = $targetObj->name;// 定義名
+                       $selected = '';
+                       if ($this->configId == $id) $selected = 'selected';
+
+                       $row = array(
+                               'name' => $name,                // 名前
+                               'value' => $id,         // 定義ID
+                               'selected' => $selected // 選択中の項目かどうか
+                       );
+                       $this->tmpl->addVars('title_list', $row);
+                       $this->tmpl->parseTemplate('title_list', 'a');
+               }
+       }
+       /**
+        * デフォルトの名前を取得
+        *
+        * @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]->object;
+                               if ($name == $targetObj->name){         // 定義名
+                                       break;
+                               }
+                       }
+                       // 重複なしのときは終了
+                       if ($i == count($this->paramObj)) break;
+               }
+               return $name;
+       }
+       /**
+        * 取得したデータをテンプレートに設定する
+        *
+        * @param int $index                    行番号(0~)
+        * @param array $fetchedRow             フェッチ取得した行
+        * @param object $param                 未使用
+        * @return bool                                 true=処理続行の場合、false=処理終了の場合
+        */
+       function menuIdListLoop($index, $fetchedRow, $param)
+       {
+               $value = $fetchedRow['mn_id'];
+               $name = $fetchedRow['mn_name'] . '(' . $value . ')';
+                       
+               $selected = '';
+               if ($value == $this->menuId) $selected = 'selected';
+               
+               $row = array(
+                       'value'    => $value,                   // ページID
+                       'name'     => $name,                    // ページ名
+                       'selected' => $selected                                                                                                         // 選択中かどうか
+               );
+               $this->tmpl->addVars('menu_id_list', $row);
+               $this->tmpl->parseTemplate('menu_id_list', 'a');
+               return true;
+       }
+       /**
+        * 一覧画面作成
+        *
+        * @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;
+
+               // 詳細画面からの引継ぎデータ
+               $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();
+                       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){
+                               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;
+                                       }
+                               }
+                               
+                               // ウィジェットパラメータオブジェクト更新
+                               if ($ret){              // データ削除成功のとき
+                                       $this->setGuidanceMsg('データを削除しました');
+                               } else {
+                                       $this->setAppErrorMsg('データ削除に失敗しました');
+                               }
+                               // パラメータオブジェクトを取得
+                               $this->paramObj = $this->getWidgetParamObjectWithId();
+                       }
+               }
+               // 定義一覧作成
+               $this->createItemList();
+               
+               // メニュー定義画面のURLを作成
+               $taskValue = 'menudef';
+               if (empty($isHierMenu)) $taskValue = 'smenudef';
+               $menuDefUrl = $this->gEnv->getDefaultAdminUrl() . '?' . 'task=' . $taskValue . '&openby=tabs&menuid=' . $menuId;
+               $this->tmpl->addVar("_widget", "url", $this->getUrl($menuDefUrl));
+               $this->tmpl->addVar("_widget", "menu_id", $menuId);
+               if ($isHierMenu) $checked = 'on';
+               $this->tmpl->addVar("_widget", "is_hier", $checked);    // 階層化メニューを使用するかどうか
+                                       
+               $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 createItemList()
+       {
+               for ($i = 0; $i < count($this->paramObj); $i++){
+                       $id                     = $this->paramObj[$i]->id;// 定義ID
+                       $targetObj      = $this->paramObj[$i]->object;
+                       $name = $targetObj->name;// 定義名
+                       
+                       // メニュー定義名を取得
+                       $menuName = '';
+                       if ($this->db->getMenu($targetObj->menuId, $row)){
+                               $menuName = $row['mn_name'] . '(' . $row['mn_id'] . ')';
+                       }
+                       
+                       $defCount = 0;
+                       if (!empty($id)){
+                               $defCount = $this->_db->getPageDefCount($this->gEnv->getCurrentWidgetId(), $id);
+                       }
+                       $operationDisagled = '';
+                       if ($defCount > 0) $operationDisagled = 'disabled';
+                       $row = array(
+                               'index' => $i,
+                               'id' => $id,
+                               'ope_disabled' => $operationDisagled,                   // 選択可能かどうか
+                               'name' => $this->convertToDispString($name),            // 名前
+                               'menu_name' => $this->convertToDispString($menuName),           // メニュー定義名
+                               'def_count' => $defCount                                                        // 使用数
+                       );
+                       $this->tmpl->addVars('itemlist', $row);
+                       $this->tmpl->parseTemplate('itemlist', 'a');
+                       
+                       // シリアル番号を保存
+                       $this->serialArray[] = $id;
+               }
+       }
+}
+?>
diff --git a/widgets/m/menu/include/container/m_menuWidgetContainer.php b/widgets/m/menu/include/container/m_menuWidgetContainer.php
new file mode 100644 (file)
index 0000000..19e06ff
--- /dev/null
@@ -0,0 +1,377 @@
+<?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-2013 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() . '/menuDb.php');
+
+class m_menuWidgetContainer extends BaseWidgetContainer
+{
+       private $db;                    // DB接続オブジェクト
+       private $langId;                // 現在の言語
+       private $paramObj;              // 定義取得用
+       private $templateType;          // テンプレートのタイプ
+       private $isHierMenu;            // 階層化メニューを使用するかどうか
+       private $currentUserLogined;    // 現在のユーザはログイン中かどうか
+       private $menuData = array();                    // Joomla用のメニューデータ
+       private $menuTree = array();                    // Joomla用のメニュー階層データ
+       const DEFAULT_CONFIG_ID = 0;
+       const MAX_MENU_TREE_LEVEL = 5;                  // メニュー階層最大数
+       
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+               
+               // DBオブジェクト作成
+               $this->db = new menuDb();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _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();
+               $this->currentUserLogined = $this->gEnv->isCurrentUserLogined();        // 現在のユーザはログイン中かどうか
+               
+               // 定義ID取得
+               $configId = $this->gEnv->getCurrentWidgetConfigId();
+               if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
+               
+               // パラメータオブジェクトを取得
+               $targetObj = $this->getWidgetParamObjByConfigId($configId);
+               if (empty($targetObj)){         // 定義データが取得できないとき
+                       // 出力抑止
+                       $this->cancelParse();
+               } else {
+                       $menuId         = $targetObj->menuId;   // メニューID
+                       $name           = $targetObj->name;// 定義名
+                       $this->isHierMenu       = $targetObj->isHierMenu;               // 階層化メニューを使用するかどうか
+                       $limitUser      = $targetObj->limitUser;// ユーザを制限するかどうか
+                       $useVerticalMenu = $targetObj->useVerticalMenu;         // 縦型メニューデザインを使用するかどうか
+                       
+                       // 縦型メニューデザイン使用の場合はJoomla用パラメータを設定
+                       if (!empty($useVerticalMenu)) $this->gEnv->setCurrentWidgetJoomlaParam(array('moduleclass_sfx' => 'art-vmenu'));
+
+                       // ユーザ制限があるときはログイン時のみ表示
+                       if (!$limitUser || $this->currentUserLogined){
+                               // メニュー作成
+                               $this->menuData['path'] = array();
+                               $this->menuData['active_id'] = 0;
+                               $parentTree = array();                  // 選択されている項目までの階層パス
+                               $menuHtml = $this->createMenu($menuId, 0, 0, $tmp, $parentTree);
+                               
+                               if (!empty($menuHtml)) $this->tmpl->addVar("_widget", "menu_html", $menuHtml);
+                               
+                               // Joomla用のメニュー階層データを設定
+                               $this->menuData['tree'] = $this->menuTree;
+                               $this->gEnv->setJoomlaMenuData($this->menuData);
+                       } else {
+                               // 出力抑止
+                               $this->cancelParse();
+                       }
+               }
+       }
+       /**
+        * メニューツリー作成
+        *
+        * @param string        $menuId         メニューID
+        * @param int           $parantId       親メニュー項目ID
+        * @param int           $level          階層数
+        * @param bool          $hasSelectedChild       現在選択状態の子項目があるかどうか
+        * @param array     $parentTree 現在の階層パス
+        * @return string                               ツリーメニュータグ
+        */
+       function createMenu($menuId, $parantId, $level, &$hasSelectedChild, &$parentTree)
+       {
+               static $index = 0;              // インデックス番号
+               $hasSelectedChild = false;
+
+               // メニューの階層を制限
+               if ($level >= self::MAX_MENU_TREE_LEVEL) return '';
+               
+               $treeHtml = '';
+               if ($this->db->getChildMenuItems($menuId, $parantId, $this->langId, $rows)){
+                       $itemCount = count($rows);
+                       for ($i = 0; $i < $itemCount; $i++){
+                               $row = $rows[$i];
+                               $classArray = array();
+                               $linkClassArray = array();
+                               $attr = '';
+                               // Joomla用メニューデータ(デフォルト値)
+                               $menuItem = new stdClass;               // Joomla用メニューデータ
+                               $menuItem->type = 'alias';              // 内部リンク。外部リンク(url)
+                               $menuItem->id = $index + 1;
+                               $menuItem->level = $level + 1;
+                               $menuItem->active = false;
+                               $menuItem->parent = false;
+                               // 階層作成用
+                               $menuItem->deeper = false;
+                               $menuItem->shallower = false;
+                               $menuItem->level_diff = 0;
+                               $menuTreeCount = count($this->menuTree);
+                               if ($menuTreeCount > 0){                // 前データがあるときは取得
+                                       $menuLastItem = $this->menuTree[$menuTreeCount -1];
+                                       $menuLastItem->deeper = ($menuItem->level > $menuLastItem->level);
+                                       $menuLastItem->shallower = ($menuItem->level < $menuLastItem->level);
+                                       $menuLastItem->level_diff = $menuLastItem->level - $menuItem->level;
+                               }
+                                                                       
+                               // 非表示のときは処理を飛ばす
+                               if (!$row['md_visible']) continue;
+                               
+                               // ユーザ制限がある場合はログイン状態をチェック
+                               if ($row['md_user_limited'] && !$this->currentUserLogined) continue;
+               
+                               // リンク先のコンテンツの表示状況に合わせる
+                               if ($row['md_content_type'] == M3_VIEW_TYPE_CONTENT){           // 汎用コンテンツの場合
+                                       // ログインユーザに表示制限されている場合はメニューを追加しない
+                                       if (!empty($row['cn_user_limited']) && !$this->currentUserLogined) continue;
+                               }
+                                               
+                               // Joomla1.0対応
+                               if ($this->templateType == 0) $linkClassArray[] = 'mainlevel';
+                               
+                               // リンク先の作成
+                               $linkUrl = $row['md_link_url'];
+                               $linkUrl = $this->getUrl($linkUrl, true/*リンク用*/);
+                               if (empty($linkUrl)) $linkUrl = '#';
+                               
+                               // 選択状態の設定
+                               if ($this->checkMenuItemUrl($linkUrl)){
+                                       $attr = ' id="current"';                // メニュー項目を選択状態にする
+                                       $classArray[] = 'active';
+                                       $hasSelectedChild = true;
+                                       
+                                       // Joomla用メニュー階層データ
+                                       $pathTree = $parentTree;                        // パスを取得
+                                       $pathTree[] = $index + 1;
+                                       $this->menuData['path'] = $pathTree;
+                                       $this->menuData['active_id'] = $index + 1;
+                                       $menuItem->active = true;
+                               }
+                               
+                               // リンクタイプに合わせてタグを生成
+                               $linkOption = '';
+                               if (count($linkClassArray) > 0) $linkOption .= 'class="' . implode(' ', $linkClassArray) . '"';
+                               switch ($row['md_link_type']){
+                                       case 0:                 // 同ウィンドウで開くリンク
+                                       default:
+                                               $menuItem->browserNav = 0;              // ウィンドウオープン方法(0=同じウィンドウ、1=別タブ、2=別ウィンドウ)
+                                               break;
+                                       case 1:                 // 別ウィンドウで開くリンク
+                                               $linkOption .= ' target="_blank"';
+                                               $menuItem->browserNav = 1;              // ウィンドウオープン方法(0=同じウィンドウ、1=別タブ、2=別ウィンドウ)
+                                               break;
+                               }
+                               
+                               // メニュー項目を作成
+                               //$name = $row['md_name'];
+                               $name = $this->getCurrentLangString($row['md_name']);
+                               //if (empty($name)) continue;
+                               $title = $this->getCurrentLangString($row['md_title']);         // タイトル(HTML可)
+                               if (empty($title)) $title = $name;
+                               if (empty($title)) continue;
+                               
+                               // メニュータイトルの処理。タグが含まれていない場合は文字をエスケープする。
+                               $stripName = strip_tags($title);
+                               if (strlen($stripName) == strlen($title)) $title = $this->convertToDispString($title);          // 文字列長が同じとき
+                               
+                               $index++;               // インデックス番号更新
+                                                               
+                               switch ($row['md_type']){
+                                       case 0:                 // リンク項目のとき
+                                               // Joomla用メニューデータ作成
+                                               //$menuItem->title = $name;
+                                               $menuItem->title = $title;
+                                               $menuItem->flink = $linkUrl;
+                                               
+                                               // ##### Joomla用メニュー階層更新 #####
+                                               $this->menuTree[] = $menuItem;
+                                               
+                                               // ##### タグ作成 #####
+                                               if (count($classArray) > 0) $attr .= ' class="' . implode(' ', $classArray) . '"';
+                                               //$treeHtml .= '<li' . $attr . '><a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '" ' . $linkOption . '><span>' . $this->convertToDispString($name) . '</span></a></li>' . M3_NL;
+                                               $treeHtml .= '<li' . $attr . '><a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '" ' . $linkOption . '><span>' . $title . '</span></a></li>' . M3_NL;
+                                               break;
+                                       case 1:                 // フォルダのとき
+                                               if (!empty($this->isHierMenu)){ // 階層化メニューを使用する場合
+                                                       // Joomla用メニューデータ作成
+                                                       //$menuItem->title = $name;
+                                                       $menuItem->title = $title;
+                                                       $menuItem->flink = $linkUrl;
+                                                       $menuItem->parent = true;
+                                                       // 階層作成用
+                                                       //$menuItem->deeper = true;
+                                                       //$menuItem->level_diff = 1;
+
+                                                       // ##### Joomla用メニュー階層更新 #####
+                                                       $this->menuTree[] = $menuItem;
+                                               
+                                                       // 階層を更新
+                                                       //array_push($parentTree, $index + 1);
+                                                       array_push($parentTree, $index);
+                                                       
+                                                       // サブメニュー作成
+                                                       $menuText = $this->createMenu($menuId, $row['md_id'], $level + 1, $hasSelectedChild, $parentTree);
+                                                       
+                                                       // 階層を戻す
+                                                       array_pop($parentTree);
+                                                       
+                                                       // 子項目が選択中のときは「active」に設定
+                                                       if ($hasSelectedChild) $classArray[] = 'active';
+
+                                                       // 先頭に「parent」クラスを追加
+                                                       array_unshift($classArray, 'parent');
+                                                       
+                                                       // ##### タグ作成 #####
+                                                       if (count($classArray) > 0) $attr .= ' class="' . implode(' ', $classArray) . '"';
+                                                       //$treeHtml .= '<li' . $attr . '><a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '"><span>' . $this->convertToDispString($name) . '</span></a>' . M3_NL;
+                                                       $treeHtml .= '<li' . $attr . '><a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '"><span>' . $title . '</span></a>' . M3_NL;
+                                                       if (!empty($menuText)){
+                                                               $treeHtml .= '<ul>' . M3_NL;
+                                                               $treeHtml .= $menuText;
+                                                               $treeHtml .= '</ul>' . M3_NL;
+                                                       }
+                                                       $treeHtml .= '</li>' . M3_NL;
+                                               }
+                                               break;
+                                       case 2:                 // テキストのとき
+                                               //$treeHtml .= '<li><span>' . $this->convertToDispString($name) . '</span></li>' . M3_NL;
+                                               $treeHtml .= '<li><span>' . $title . '</span></li>' . M3_NL;
+                                               break;
+                                       case 3:                 // セパレータのとき
+                                               // Joomla用メニューデータ作成
+                                               $menuItem->type = 'separator';
+                                               //$menuItem->title = $name;
+                                               $menuItem->title = $title;
+                                               $menuItem->flink = '';
+                                               
+                                               // ##### Joomla用メニュー階層更新 #####
+                                               $this->menuTree[] = $menuItem;
+                                               
+                                               // ##### タグ作成 #####
+                                               //$treeHtml .= '<li><span class="separator">' . $this->convertToDispString($name) . '</span></li>' . M3_NL;
+                                               $treeHtml .= '<li><span class="separator">' . $title . '</span></li>' . M3_NL;
+                                               break;
+                               }
+                               
+                               if ($this->templateType == 0){                  // Joomla!v1.0のとき
+                                       $itemRow = array(
+                                               'link_url' => $this->convertUrlToHtmlEntity($linkUrl),          // リンク
+                                               //'name' => $this->convertToDispString($name),                  // タイトル
+                                               'name' => $title,                       // タイトル
+                                               'attr' => $attr,                        // liタグ追加属性
+                                               'option' => $linkOption                 // Aタグ追加属性
+                                       );
+                                       $this->tmpl->addVars('itemlist', $itemRow);
+                                       $this->tmpl->parseTemplate('itemlist', 'a');
+                               }
+                               $menuTreeCount = count($this->menuTree);
+                               if ($menuTreeCount > 0){                // 前データがあるときは取得
+                                       $menuLastItem = $this->menuTree[$menuTreeCount -1];
+                                       $menuLastItem->deeper = (1 > $menuLastItem->level);
+                                       $menuLastItem->shallower = (1 < $menuLastItem->level);
+                                       $menuLastItem->level_diff = $menuLastItem->level - 1;
+                               }
+                       }
+               }
+               return $treeHtml;
+       }
+       /**
+        * メニュー項目の選択条件をチェック
+        *
+        * @param string $url   チェック対象のURL
+        * @return bool                 true=アクティブ、false=非アクティブ
+        */
+       function checkMenuItemUrl($url)
+       {
+               $currentUrl = $this->gEnv->getCurrentRequestUri();
+               
+               // 同じURLのとき
+               if ($url == $currentUrl) return true;
+               
+               // URLを解析
+               $queryArray = array();
+               $parsedUrl = parse_url($url);
+               if (!empty($parsedUrl['query'])) parse_str($parsedUrl['query'], $queryArray);           // クエリーの解析
+               
+               // ルートかどうかチェック(クエリー文字列なし)
+               if ($this->isRootUrl($url)){
+                       // ページサブIDで比較
+                       if ($this->gEnv->getCurrentPageSubId() == $this->gEnv->getDefaultPageSubId()) return true;
+               }
+               
+               // パラメータがサブページIDだけの場合はページサブIDで比較
+               if (count($queryArray) == 1 && isset($queryArray[M3_REQUEST_PARAM_PAGE_SUB_ID])){
+                       if ($this->gEnv->getCurrentPageSubId() == $queryArray[M3_REQUEST_PARAM_PAGE_SUB_ID]) return true;
+               }
+               return false;
+       }
+       /**
+        * URLがルートを指しているかどうか取得
+        *
+        * @param string $url   チェック対象のURL
+        * @return bool                 true=ルート、false=ルート以外
+        */
+       function isRootUrl($url)
+       {
+               $url = str_replace('https://', 'http://', $url);                // 一旦httpに統一
+               $systemUrl = str_replace('https://', 'http://', $this->gEnv->getRootUrl());             // 一旦httpに統一
+               $systemSslUrl = str_replace('https://', 'http://', $this->gEnv->getSslRootUrl());               // 一旦httpに統一
+
+               $parsedUrl = parse_url($url);
+               if (empty($parsedUrl['query'])){                // クエリ文字列がないことが条件。「#」はあっても良い。
+                       // パスを解析
+                       $relativePath = str_replace($systemUrl, '', $url);              // ルートURLからの相対パスを取得
+                       if (empty($relativePath)){                      // Magic3のルートURLの場合
+                               return true;
+                       } else if (strStartsWith($relativePath, '/') || strStartsWith($relativePath, '/' . M3_FILENAME_INDEX)){         // ルートURL配下のとき
+                               return true;
+                       } else {                // ルートURL以外のURLのとき(SSL用のURL以下かどうかチェック)
+                               $relativePath = str_replace($systemSslUrl, '', $url);           // ルートURLからの相対パスを取得
+                               if (empty($relativePath)){                      // Magic3のルートURLの場合
+                                       return true;
+                               } else if (strStartsWith($relativePath, '/') || strStartsWith($relativePath, '/' . M3_FILENAME_INDEX)){         // ルートURL配下のとき
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+}
+?>
diff --git a/widgets/m/menu/include/db/menuDb.php b/widgets/m/menu/include/db/menuDb.php
new file mode 100644 (file)
index 0000000..b9c8df2
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/**
+ * DBクラス
+ *
+ * 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-2013 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+require_once($gEnvManager->getDbPath() . '/baseDb.php');
+
+class menuDb extends BaseDb
+{
+       /**
+        * メニューIDのリストを取得
+        *
+        * @param function $callback    コールバック関数
+        * @return                                              なし
+        */
+       function getMenuIdList($callback)
+       {
+               $queryStr  = 'SELECT * FROM _menu_id ';
+               $queryStr .=   'WHERE mn_widget_id = \'\' ';            // ウィジェット制限されていないメニュー
+               $queryStr .=   'ORDER BY mn_sort_order';
+               $this->selectLoop($queryStr, array(), $callback);
+       }
+       /**
+        * メニュー項目を取得
+        *
+        * @param string $menuId                メニュー識別ID
+        * @param string $parentId              親項目ID
+        * @param string $langId                言語ID
+        * @param array  $rows                  取得レコード
+        * @return                                              true=取得、false=取得せず
+        */
+       function getChildMenuItems($menuId, $parentId, $langId, &$rows)
+       {
+               $now = date("Y/m/d H:i:s");     // 現在日時
+               $initDt = $this->gEnv->getInitValueOfTimestamp();
+               $params = array();
+               
+               //$queryStr  = 'SELECT md_id, md_name, md_type, md_link_type, md_link_url, md_visible, md_content_type, cn_user_limited FROM _menu_def ';
+               $queryStr  = 'SELECT * FROM _menu_def ';
+               if ($this->getDbType() == M3_DB_TYPE_PGSQL){            // PostgreSQLの場合
+                       $queryStr .=   'LEFT JOIN content ON md_content_type = ? AND md_content_id = cn_id::text AND cn_type = ? AND cn_language_id = ? AND cn_deleted = false ';
+               } else {                // MySQLの場合
+                       $queryStr .=   'LEFT JOIN content ON md_content_type = ? AND md_content_id = cn_id AND cn_type = ? AND cn_language_id = ? AND cn_deleted = false ';
+               }
+               $params[] = M3_VIEW_TYPE_CONTENT;               // 汎用コンテンツ
+               $params[] = '';                         // PC用コンテンツ
+               $params[] = $langId;
+               
+               // 共通の取得条件
+               $queryStr .=   'WHERE md_menu_id = ? ';
+               $queryStr .=     'AND md_parent_id = ? ';
+               $params[] = $menuId;
+               $params[] = $parentId;
+               
+               // 汎用コンテンツの表示条件
+               $queryStr .=    'AND (md_content_type != ? OR (md_content_type = ? ';
+               $queryStr .=    'AND cn_visible = true ';
+               $queryStr .=    'AND (cn_active_start_dt = ? OR (cn_active_start_dt != ? AND cn_active_start_dt <= ?)) ';
+               $queryStr .=    'AND (cn_active_end_dt = ? OR (cn_active_end_dt != ? AND cn_active_end_dt > ?)))) ';
+               $params[] = M3_VIEW_TYPE_CONTENT;               // 汎用コンテンツ
+               $params[] = M3_VIEW_TYPE_CONTENT;               // 汎用コンテンツ
+               $params[] = $initDt;
+               $params[] = $initDt;
+               $params[] = $now;
+               $params[] = $initDt;
+               $params[] = $initDt;
+               $params[] = $now;
+               
+               $queryStr .=   'ORDER BY md_index';
+               $retValue = $this->selectRecords($queryStr, $params, $rows);
+               return $retValue;
+       }
+       /**
+        * メニュー情報の取得
+        *
+        * @param string  $id                   メニューID
+        * @return                                              true=正常、false=異常
+        */
+       function getMenu($id, &$row)
+       {
+               $queryStr  = 'SELECT * FROM _menu_id ';
+               $queryStr .=   'WHERE mn_id = ? ';
+               $ret = $this->selectRecord($queryStr, array($id), $row);
+               return $ret;
+       }
+}
+?>
diff --git a/widgets/m/menu/include/help/index.php b/widgets/m/menu/include/help/index.php
new file mode 100644 (file)
index 0000000..b0b8fca
--- /dev/null
@@ -0,0 +1,53 @@
+<?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-2013 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+// 直接アクセスの防止
+defined('M3_SYSTEM') or die('Access error: Direct access denied.');
+
+global $HELP;
+
+// ########## メインメニュー項目一覧 ##########
+$HELP['menu_list']['title'] = 'メニュー設定一覧';
+$HELP['menu_list']['body'] = '登録されているメニュー設定の一覧です。';
+$HELP['menu_detail']['title'] = 'メニュー設定';
+$HELP['menu_detail']['body'] = 'メニューについての設定を行います。';
+$HELP['menu_check']['title'] = '選択用チェックボックス';
+$HELP['menu_check']['body'] = '削除を行う項目を選択します。';
+$HELP['menu_name']['title'] = '名前';
+$HELP['menu_name']['body'] = 'メニュー設定名です。メニューのタイトルにも使用されます。';
+$HELP['menu_name_input']['title'] = '名前';
+$HELP['menu_name_input']['body'] = 'メニュー設定名です。新規に登録するか、登録済みの設定を選択します。';
+$HELP['menu_id']['title'] = 'メニュー設定ID';
+$HELP['menu_id']['body'] = '自動的に振られるメニュー設定IDです。';
+$HELP['menu_show_title']['title'] = 'タイトル表示';
+$HELP['menu_show_title']['body'] = 'メニューにタイトルを表示するかどうかを設定します。タイトルは「名前」が使用されます。';
+$HELP['menu_limit_user']['title'] = 'ユーザ制限';
+$HELP['menu_limit_user']['body'] = 'メニューの表示をログインしたユーザに限定するかどうかを設定します。';
+$HELP['menu_design']['title'] = 'デザイン';
+$HELP['menu_design']['body'] = '●縦型メニュー<br />Artisteer 2.4から使用可能な「縦型メニュー」のデザインを使用するかどうかを設定します。';
+$HELP['menu_def']['title'] = 'メニュー定義';
+$HELP['menu_def']['body'] = 'メニュー項目で使用するメニュー定義を選択します。定義データはシステムで共通です。<br />1階層でメニューを定義するか、多階層でメニューを定義するかを選択します。<br />メニューIDは管理機能の「システムマスター管理/メニュー」で管理します。';
+$HELP['menu_ref']['title'] = '使用';
+$HELP['menu_ref']['body'] = 'メニュー設定を使用しているウィジェット数を示します。使用が0のメニュー設定のみ削除可能です。';
+$HELP['menu_list_btn']['title'] = '一覧ボタン';
+$HELP['menu_list_btn']['body'] = 'メニュー設定一覧を表示します。';
+$HELP['menu_del_btn']['title'] = '削除ボタン';
+$HELP['menu_del_btn']['body'] = '選択されているメニュー設定を削除します。<br />項目を選択するには、一覧の左端のチェックボックスにチェックを入れます。';
+$HELP['menu_ret_btn']['title'] = '戻るボタン';
+$HELP['menu_ret_btn']['body'] = 'メニュー設定へ戻ります。';
+$HELP['menu_edit_def_btn']['title'] = 'メニュー定義を編集ボタン';
+$HELP['menu_edit_def_btn']['body'] = '選択されているメニュー定義を編集します。';
+?>
diff --git a/widgets/m/menu/include/template/admin.tmpl.html b/widgets/m/menu/include/template/admin.tmpl.html
new file mode 100644 (file)
index 0000000..a678121
--- /dev/null
@@ -0,0 +1,145 @@
+/**
+ * 表示データ作成用テンプレート(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">
+<script type="text/javascript">
+//<![CDATA[
+function addItem(){
+       if (!window.confirm('項目を新規追加しますか?')) return false;
+       document.main.act.value = 'add';
+       document.main.submit();
+       return true;
+}
+function updateItem(){
+       if (!window.confirm('設定を更新しますか?')) return false;
+       document.main.act.value='update';
+       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(){
+       // タブ作成
+       $tabs = $("#main_area").tabs({
+               select: function(event, ui){
+                       if (ui.panel.id == 'menu_define'){
+                               var url = '';
+                               var id = document.main.menuid.value;
+                               if (document.main.is_hier.checked){
+                                       url = "?task=menudef&openby=tabs&menuid=" + id;
+                               } else {
+                                       url = "?task=smenudef&openby=tabs&menuid=" + id;
+                               }
+                               document.getElementById("menu_def").src = url;
+                       }
+                       return true;
+               }
+       });
+       $('#edit_menu').click(function() {
+               $tabs.tabs('select', 1);
+               return false;
+       });
+       <patTemplate:tmpl name="select_menu_def" visibility="hidden">$tabs.tabs('select', 1);</patTemplate:tmpl>
+});
+//]]>
+</script>
+<div id="main_area" class="m3config_tabs">
+            <ul>
+           <li><a href="#widget_config"><span>ウィジェット設定</span></a></li>
+           <li><a href="#menu_define"><span>メニュー定義</span></a></li>
+           </ul>
+           <div id="widget_config">
+<!-- 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="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>
+</td></tr>
+<tr><td colspan="2">
+
+<table class="simple-table" width="100%">
+    <tbody>
+        <tr>
+           <td class="table-headside" width="100"><span {_HELP_MENU_NAME_INPUT}>名前</span></td>
+           <td width="500">
+           <select name="item_id" onchange="selectItem();" {ID_DISABLED}>
+               <option value="0">-- 新規 --</option>
+               <patTemplate:tmpl name="title_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>
+           <td class="table-headside" width="100"><span {_HELP_MENU_ID}>ID</span></td>
+           <td align="center">{ID}
+           </td>
+       </tr>
+        <tr class="even">
+           <td class="table-headside"><span {_HELP_MENU_DEF}>メニュー定義</span></td>
+           <td colspan="3">
+           <input type="checkbox" name="is_hier" {IS_HIER} {IS_HIER_DISABLED} />階層化あり&nbsp;&nbsp;
+           <select name="menuid" {ID_DISABLED}>
+               <patTemplate:tmpl name="menu_id_list">
+               <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>
+           </td>
+       </tr>
+        <tr>
+           <td class="table-headside"><span {_HELP_MENU_LIMIT_USER}>ユーザ制限</span></td>
+           <td colspan="3"><input type="checkbox" name="item_limituser" {LIMIT_USER} />
+           </td>
+       </tr>
+        <tr class="even">
+           <td class="table-headside"><span {_HELP_MENU_DESIGN}>デザイン</span></td>
+           <td colspan="3"><input type="checkbox" name="item_vertical_menu" {VERTICAL_MENU} />縦型メニュー
+           </td>
+       </tr>
+       <tr>
+           <td align="right" colspan="4">
+<patTemplate:tmpl name="update_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>
+           <div id="menu_define">
+           <iframe id="menu_def" name="menu_def" style="width:100%; height:2000px; border:none;" allowTransparency="true" frameborder="0">{_LC_LABEL_NENU_DEF}</iframe>
+           </div>
+</div>
+</patTemplate:tmpl>
diff --git a/widgets/m/menu/include/template/admin_list.tmpl.html b/widgets/m/menu/include/template/admin_list.tmpl.html
new file mode 100644 (file)
index 0000000..5876dfc
--- /dev/null
@@ -0,0 +1,115 @@
+/**
+ * 表示データ作成用テンプレート(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">
+<script type="text/javascript">
+//<![CDATA[
+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(){
+       // タブ作成
+       $tabs = $("#main_area").tabs({
+               select: function(event, ui){
+                       if (ui.panel.id == 'menu_define'){
+                               document.getElementById("menu_def").src = '{URL}';
+                       }
+                       return true;
+               }
+       });
+       $('#edit_menu').click(function(){
+               $tabs.tabs('select', 1);
+               return false;
+       });
+       $('#tab_widget').click(function(){
+               window.location.href = window.location.href;
+       });
+       // スクロールバー付きのテーブルを作成
+       m3_tableWithScrollbar('itemlist', -1, 0);
+});
+//]]>
+</script>
+<div id="main_area" class="m3config_tabs">
+            <ul>
+           <li><a id="tab_widget" href="#widget_config"><span>ウィジェット設定</span></a></li>
+           <li><a href="#menu_define"><span>メニュー定義</span></a></li>
+           </ul>
+           <div id="widget_config">
+<!-- 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}" />
+<input type="hidden" name="menuid" value="{MENU_ID}" />
+<input type="hidden" name="is_hier" value="{IS_HIER}" />
+<table width="95%" style="margin: 0 auto;">
+<tr><td>
+<span {_HELP_MENU_LIST}><label>メニュー設定一覧</label></span>
+</td><td align="right"><span {_HELP_MENU_DEL_BTN}><input type="button" class="button" onclick="delItem();" value="削除" /></span>
+<span {_HELP_MENU_RET_BTN}><input type="button" class="button" onclick="cancelItem();" value="戻る" /></span>
+</td></tr>
+<tr><td colspan="2">
+<table id="itemlist" class="simple-table" width="100%">
+    <thead>
+        <tr>
+           <th width="35" align="center"><span {_HELP_MENU_CHECK}>選択</span></th>
+           <th width="35" align="center"><span {_HELP_MENU_ID}>ID</span></th>
+           <th width="40%" align="center"><span {_HELP_MENU_NAME}>名前</span></th>
+           <th width="40%" align="center"><span {_HELP_MENU_DEF}>メニュー定義</span></th>
+           <th align="center"><span {_HELP_MENU_REF}>使用</span></th>
+       </tr>
+    </thead>
+    <tbody>
+        <patTemplate:tmpl name="itemlist">
+        <tr>
+            <td align="center"><input type="checkbox" name="item{INDEX}_selected" {OPE_DISABLED} /></td>
+           <td align="center">{ID}</td>
+           <td>{NAME}</td>
+           <td>{MENU_NAME}</td>
+           <td align="center">{DEF_COUNT}</td>
+       </tr>
+       </patTemplate:tmpl>
+    </tbody>
+</table>
+</td></tr>
+</table>
+</form>
+           </div>
+           <div id="menu_define">
+           <iframe id="menu_def" name="menu_def" style="width:100%; height:2000px; border:none;" allowTransparency="true" frameborder="0">{_LC_LABEL_NENU_DEF}</iframe>
+           </div>
+</div>
+</patTemplate:tmpl>
diff --git a/widgets/m/menu/include/template/index.tmpl.html b/widgets/m/menu/include/template/index.tmpl.html
new file mode 100644 (file)
index 0000000..7c808f4
--- /dev/null
@@ -0,0 +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>
diff --git a/widgets/m/menu/index.php b/widgets/m/menu/index.php
new file mode 100644 (file)
index 0000000..ea816fa
--- /dev/null
@@ -0,0 +1,23 @@
+<?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-2013 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+// 直接アクセスの防止
+defined('M3_SYSTEM') or die('Access error: Direct access denied.');
+
+// ウィジェット実行
+global $gLaunchManager;
+$gLaunchManager->goWidget(__FILE__);
+?>