OSDN Git Service

テストプログラム追加。
authornaoki hirata <naoki@magic3.org>
Sat, 5 Sep 2015 07:45:02 +0000 (16:45 +0900)
committernaoki hirata <naoki@magic3.org>
Sat, 5 Sep 2015 07:45:02 +0000 (16:45 +0900)
include/manager/launchManager.php
widgets/admin_main/include/container/admin_mainBaseWidgetContainer.php
widgets/admin_main/include/container/admin_mainTest_configWidgetContainer.php
widgets/admin_main/include/container/admin_mainWidgetContainer.php
widgets/admin_main/include/container/test/admin_mainTest_scriptWidgetContainer.php [new file with mode: 0644]
widgets/admin_main/include/template/test/test_script.tmpl.html [new file with mode: 0644]

index c38c16d..7cc9614 100644 (file)
@@ -20,6 +20,7 @@ require_once(M3_SYSTEM_INCLUDE_PATH . '/common/core.php');
 
 class LaunchManager extends Core
 {
+       private $loadPath;                                                              // クラス検索ロード用のパス
        const DEFAULT_RSS_CLASS_PREFIX = 'rss_';                // RSS実行用クラスの先頭文字列
        
        /**
@@ -29,6 +30,8 @@ class LaunchManager extends Core
        {
                // 親クラスを呼び出す
                parent::__construct();
+               
+               $this->loadPath = array();                                                              // クラス検索ロード用のパス
        }
 
        /**
@@ -247,6 +250,14 @@ class LaunchManager extends Core
                                $gEnvManager->setCurrentWidgetObj($widgetContainer);                            // 実行するウィジェットコンテナオブジェクトを登録
                                $widgetContainer->process($gRequestManager);
                                $gEnvManager->setCurrentWidgetObj(null);
+                       } else if (!empty($this->loadPath)){            // クラス検索用パスが設定されているとき
+                               require_once($containerClass . '.php');
+                               
+                               // コンテナクラスを起動
+                               $widgetContainer = new $containerClass();
+                               $gEnvManager->setCurrentWidgetObj($widgetContainer);                            // 実行するウィジェットコンテナオブジェクトを登録
+                               $widgetContainer->process($gRequestManager);
+                               $gEnvManager->setCurrentWidgetObj(null);
                        } else {
                                if (empty($defaultWidgetId)){
                                        echo 'file not found error: ' . $containerPath;
@@ -397,5 +408,18 @@ class LaunchManager extends Core
                $mainContainer = new $class();
                $mainContainer->process($gRequestManager);
        }
+       /**
+        * クラス検索ロード用のパスを追加
+        *
+        * @param string $path          追加パス
+        * @return                                      なし
+        */
+       function addLoadPath($path)
+       {
+               if (!empty($path) && !in_array($path, $this->loadPath)){
+                       set_include_path(get_include_path() . PATH_SEPARATOR . $path);
+                       $this->loadPath[] = $path;
+               }
+       }
 }
 ?>
index 7cc28fe..541f483 100644 (file)
@@ -8,9 +8,9 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2012 Magic3 Project.
+ * @copyright  Copyright 2006-2015 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
- * @version    SVN: $Id: admin_mainBaseWidgetContainer.php 5107 2012-08-13 06:04:45Z fishbone $
+ * @version    SVN: $Id$
  * @link       http://www.magic3.org
  */
 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
@@ -27,6 +27,9 @@ class admin_mainBaseWidgetContainer extends BaseAdminWidgetContainer
        const CALENDAR_SETUP_FILE = '/jscalendar-1.0/calendar-setup.js';        // カレンダーセットアップファイル
        const CALENDAR_CSS_FILE = '/jscalendar-1.0/calendar-win2k-1.css';               // カレンダー用CSSファイル
        
+       // 画面
+       const TASK_TEST                         = 'test';                       // テスト画面
+       
        /**
         * コンストラクタ
         */
index 3c69069..5ace6e8 100644 (file)
@@ -19,7 +19,8 @@ require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_mainDb.php');
 class admin_mainTest_configWidgetContainer extends admin_mainBaseWidgetContainer
 {
        private $db;    // DB接続オブジェクト
-               
+       const SAMPLE_DIR = 'sample';                            // サンプルSQLディレクトリ名
+       
        /**
         * コンストラクタ
         */
@@ -64,9 +65,12 @@ class admin_mainTest_configWidgetContainer extends admin_mainBaseWidgetContainer
                $act = $request->trimValueOf('act');
                
                if ($act == 'update'){                          // 送信確認
-                       echo '<h4>Session value check</h4>';
+/*                     echo '<h4>Session value check</h4>';
                        echo 'old='.$postTicket.'<br>';
                        echo 'current='.$request->getSessionValue(M3_SESSION_POST_TICKET);
+                       */
+                       
+                       $this->testScript();
                } else {
                        // ハッシュキー作成
                        $postTicket = md5(time() . $this->gAccess->getAccessLogSerialNo());
@@ -74,5 +78,33 @@ class admin_mainTest_configWidgetContainer extends admin_mainBaseWidgetContainer
                        $this->tmpl->addVar("_widget", "ticket", $postTicket);                          // 画面に書き出し
                }
        }
+       function testScript()
+       {
+               // スクリプトファイルを読み込み
+               $scriptPath = $this->gEnv->getSqlPath() . '/' . self::SAMPLE_DIR . '/_test.sql';
+//             $fileData = fread(fopen($scriptPath, 'r'), filesize($scriptPath));
+               $fileData = file_get_contents($scriptPath);
+                               
+               // ファイル内容を解析
+//             $ret = $this->_db->_splitSql($lines, $fileData);
+$ret = $this->_splitMultibyteSql($fileData, $lines);
+               if ($ret){
+                       var_dump($lines);
+               }
+               
+/*             $scriptPath = $this->gEnv->getSqlPath() . '/' . self::SAMPLE_DIR . '/' . $this->sampleId;
+       
+               // スクリプト実行
+               if ($this->gInstance->getDbManager()->execScriptWithConvert($scriptPath, $errors)){// 正常終了の場合
+                       $this->setMsg(self::MSG_GUIDANCE, 'スクリプト実行完了しました');
+               } else {
+                       $this->setMsg(self::MSG_APP_ERR, "スクリプト実行に失敗しました");
+               }
+               if (!empty($errors)){
+                       foreach ($errors as $error) {
+                               $this->setMsg(self::MSG_APP_ERR, $error);
+                       }
+               }*/
+       }
 }
 ?>
index 855682e..5c318b5 100644 (file)
@@ -303,6 +303,14 @@ class admin_mainWidgetContainer extends admin_mainBaseWidgetContainer
                                                default:
                                                        foreach ($this->permitTask as $taskStart){
                                                                if (strStartsWith($task, $taskStart)){  // 「taskA」「taskA_」パターン
+                                                                       // テストタスクの場合はクラスロード用ディレクトリ追加
+                                                                       switch ($taskStart){
+                                                                       case self::TASK_TEST:
+                                                                               $path = $this->gEnv->getCurrentWidgetContainerPath() . '/' . self::TASK_TEST;
+                                                                               $this->gLaunch->addLoadPath($path);
+                                                                               break;
+                                                                       }
+                                                               
                                                                        $this->gLaunch->goSubWidget($taskStart);
                                                                        return false;
                                                                }
diff --git a/widgets/admin_main/include/container/test/admin_mainTest_scriptWidgetContainer.php b/widgets/admin_main/include/container/test/admin_mainTest_scriptWidgetContainer.php
new file mode 100644 (file)
index 0000000..2bfbab9
--- /dev/null
@@ -0,0 +1,99 @@
+<?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-2015 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+require_once($gEnvManager->getCurrentWidgetContainerPath() .   '/admin_mainBaseWidgetContainer.php');
+require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_mainDb.php');
+
+class admin_mainTest_scriptWidgetContainer extends admin_mainBaseWidgetContainer
+{
+       private $db;    // DB接続オブジェクト
+       const SAMPLE_DIR = 'sample';                            // サンプルSQLディレクトリ名
+       
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+               
+               // DB接続オブジェクト作成
+               $this->db = new admin_mainDb();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+        * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
+        * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+        */
+       function _setTemplate($request, &$param)
+       {       
+               return 'test/test_script.tmpl.html';
+       }
+       /**
+        * テンプレートにデータ埋め込む
+        *
+        * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
+        * @param                                                               なし
+        */
+       function _assign($request, &$param)
+       {
+               $act = $request->trimValueOf('act');
+               
+               if ($act == 'update'){                          // 送信確認
+
+                       
+                       $this->testScript();
+               } else {
+
+               }
+       }
+       function testScript()
+       {
+               // スクリプトファイルを読み込み
+               $scriptPath = $this->gEnv->getSqlPath() . '/' . self::SAMPLE_DIR . '/_test.sql';
+//             $fileData = fread(fopen($scriptPath, 'r'), filesize($scriptPath));
+               $fileData = file_get_contents($scriptPath);
+                               
+               // ファイル内容を解析
+//             $ret = $this->_db->_splitSql($lines, $fileData);
+$ret = $this->_splitMultibyteSql($fileData, $lines);
+               if ($ret){
+                       var_dump($lines);
+               }
+               
+/*             $scriptPath = $this->gEnv->getSqlPath() . '/' . self::SAMPLE_DIR . '/' . $this->sampleId;
+       
+               // スクリプト実行
+               if ($this->gInstance->getDbManager()->execScriptWithConvert($scriptPath, $errors)){// 正常終了の場合
+                       $this->setMsg(self::MSG_GUIDANCE, 'スクリプト実行完了しました');
+               } else {
+                       $this->setMsg(self::MSG_APP_ERR, "スクリプト実行に失敗しました");
+               }
+               if (!empty($errors)){
+                       foreach ($errors as $error) {
+                               $this->setMsg(self::MSG_APP_ERR, $error);
+                       }
+               }*/
+       }
+}
+?>
diff --git a/widgets/admin_main/include/template/test/test_script.tmpl.html b/widgets/admin_main/include/template/test/test_script.tmpl.html
new file mode 100644 (file)
index 0000000..a39070f
--- /dev/null
@@ -0,0 +1,103 @@
+/**
+ * 表示データ作成用テンプレート(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-2015 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 updateItem(){
+       if (!window.confirm('設定を更新しますか?')) return false;
+       document.main.act.value='update';
+       document.main.submit();
+       return true;
+}
+
+$(function(){
+       m3SetConfigTable('config_table');
+});
+//]]>
+</script>
+
+<div class="m3config_container">
+<!-- m3:ErrorMessage -->
+<form method="post" name="main">
+<input type="hidden" name="act" />
+<input type="hidden" name="ticket" value="{TICKET}" />
+<!--<h3><span {_HELP_UNTITLED_TEST}>ウィジェット設定画面テスト</span></h3>-->
+<h3 class="m3config_h"><span {_HELP_EVENT_LIST}>受付イベント一覧</span>
+<!--<a href="javascript:void(0);" class="btn btn-sm btn-warning" role="button" rel="m3help" data-container="body" title="記事を検索" onclick="showSearchArea();"><i class="glyphicon glyphicon-search"></i></a>-->
+</h3>
+<div class="m3config_h_side_buttons pull-right"><div {_HELP_EVENT_BUTTONS}><div class="btn-group">
+<input type="button" class="button" data-toggle="modal" data-target="#uploadModal" value="アップロード" />
+<input type="button" class="button" onclick="selectEvent();" value="新規" /><input type="button" class="button" onclick="editItem();" value="編集" /><input type="button" class="button" onclick="delItem();" value="削除" />
+</div></div></div>
+
+<table id="config_table">
+    <tbody>
+       <tr>
+           <th><span {_HELP_ENTRY_ID}>イベントID</span></th>
+           <td style="width:200px;"><div class="form-control-static m3config_item col-sm-6">{EVENT_ID}</div><div class="pull-right">{EYECATCH_IMAGE}</div></td>
+           <th><span {_HELP_EVENT_STATUS}>受付状態</span></th>
+           <td id="status_field" class="warning">
+               <div class="col-sm-6 m3config_item">
+               <select id="item_status" name="item_status" class="form-control">
+               <patTemplate:tmpl name="status_list">
+               <option value="{VALUE}" {SELECTED}>{NAME}</option>
+               </patTemplate:tmpl>
+           </select>
+               </div>
+               </td>
+       </tr>
+       <tr>
+           <th><span {_HELP_ENTRY_NAME}>イベント名</span></th>
+           <td colspan="3"><i class="glyphicon glyphicon-question-sign text-warning" style="font-size:150%;"></i><div class="form-control-static m3config_item">{EVENT_NAME}</div></td>
+       </tr>
+    <tr>
+           <th><span {_HELP_EVENT_URL}>説明</span><div class="pull-right"><a id="selimage" href="javascript:void(0);" class="btn btn-sm btn-warning" role="button" data-container="body"><i class="glyphicon glyphicon-edit"></i></a></div></th>
+           <td class="ckeditor" colspan="3"><textarea id="item_html" name="item_html">{HTML}</textarea></td>
+       </tr>
+       <tr>
+           <th><span {_HELP_ENTRY_NAME}>入力</span></th>
+           <td colspan="3"><input type="text" id="item_input" name="item_input" class="form-control" size="30" maxlength="30" /></td>
+       </tr>
+    </tbody>
+</table>
+<div class="well m3config_update_buttons"><input type="button" class="button" onclick="updateItem();" value="更新" /></div>
+</form>
+</div>
+
+<!-- File upload dialog -->
+<div id="uploadModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="uploadModalLabel" aria-hidden="true">
+    <div class="modal-dialog">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                <h4 class="modal-title" id="uploadModalLabel">Wikiページファイルアップロード</h4>
+            </div>
+            <div class="modal-body">
+                           <p>アップロードするWikiページファイルを選択してください</p>
+                <form enctype="multipart/form-data" method="post" name="upload">
+                    <input type="hidden" name="act" />
+                                       <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
+                    <div class="input-group">
+                        <span class="input-group-addon btn-file"><i class="glyphicon glyphicon-folder-open"></i><input type="file" name="upfile"></span>
+                        <input type="text" class="form-control">
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-default" data-dismiss="modal">キャンセル</button>
+                <button type="button" class="btn btn-success" onclick="uploadCheck();">アップロード</button>
+            </div>
+        </div>
+    </div>
+</div>
+</patTemplate:tmpl>
\ No newline at end of file