--- /dev/null
+<?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-2018 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');
+
+class BaseAdminTemplateContainer extends BaseAdminWidgetContainer
+{
+// const DEFAULT_WIDGET_TYPE = 'admin'; // ウィジェットタイプ
+// const TASK_CONFIG_LIST = 'list'; // 設定一覧
+
+ /**
+ * コンストラクタ
+ */
+ function __construct()
+ {
+ // 親クラスを呼び出す
+ parent::__construct();
+
+ // データ初期化
+// $this->_widgetType = self::DEFAULT_WIDGET_TYPE; // ウィジェットタイプ
+ }
+ /**
+ * 出力用の変数に値を設定する
+ * このクラスでは、共通項目を設定
+ */
+ function __assign()
+ {
+
+ }
+ /**
+ * テンプレートファイルの設定
+ *
+ * @param bool $useSystemTemplate システムの標準テンプレートを使用するかどうか
+ * @return なし
+ */
+ function __setTemplate($useSystemTemplate = false)
+ {
+ // テンプレートオブジェクト作成
+ $this->tmpl = new PatTemplate();
+
+ // ##### テンプレート読み込みディレクトリ #####
+ $dirArray = array();
+
+ // テンプレート管理画面のテンプレートディレクトリを追加
+ $templateId = $this->gRequest->trimValueOf(M3_REQUEST_PARAM_TEMPLATE_ID);// テンプレートID
+ $dir = $this->gEnv->getTemplatesPath() . '/' . $templateId . '/include/template';
+ if (file_exists($dir)) $dirArray[] = $dir;
+
+ $this->tmpl->setRoot($dirArray);
+
+ // エラーメッセージテンプレートを埋め込む
+ $this->tmpl->applyInputFilter('ErrorMessage');
+
+ // 機能付きタグを変換
+ //$this->tmpl->applyInputFilter('FunctionTag');
+
+ // コメントを削除
+ //$this->tmpl->applyInputFilter('StripComments');
+
+ // フォームチェック機能を使用するか、システム管理権限がある場合は、管理画面用パラメータを埋め込む
+// if ($this->_useFormCheck || $gEnvManager->isSystemManageUser()) $this->tmpl->applyInputFilter('PostParam');
+ $this->tmpl->applyInputFilter('PostParam');
+ }
+}
+?>
--- /dev/null
+<?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-2018 Magic3 Project.
+ * @license http://www.gnu.org/copyleft/gpl.html GPL License
+ * @version SVN: $Id$
+ * @link http://www.magic3.org
+ */
+require_once($gEnvManager->getContainerPath() . '/baseAdminTemplateContainer.php');
+//require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_analyticsDb.php');
+
+class admin_bootstrap4_customTemplateContainer extends BaseAdminTemplateContainer
+{
+ private $db; // DB接続オブジェクト
+ private $graphTypeArray; // グラフタイプ
+ private $termTypeArray; // 期間タイプ
+ private $graphType; // グラフ種別
+ private $path; // アクセスパス
+ private $termType; // 期間タイプ
+ const DEFAULT_ACCESS_PATH = 'index'; // デフォルトのアクセスパス(PC用アクセスポイント)
+ const ACCESS_PATH_ALL = '_all'; // アクセスパスすべて選択
+ const DEFAULT_TERM_TYPE = '30day'; // デフォルトの期間タイプ
+ const TERM_TYPE_ALL = '_all'; // 全データ表示選択
+ const DEFAULT_GRAPH_TYPE = 'pageview'; // デフォルトのグラフ種別
+ const DEFAULT_GRAPH_WIDTH = 800; // グラフ幅
+ const DEFAULT_GRAPH_HEIGHT = 280; // グラフ高さ
+
+ /**
+ * コンストラクタ
+ */
+ function __construct()
+ {
+ // 親クラスを呼び出す
+ parent::__construct();
+
+ // DBオブジェクト作成
+// $this->db = new admin_analyticsDb();
+
+ // グラフタイプ
+ $this->graphTypeArray = array( array( 'name' => 'ページビュー', 'value' => 'pageview'),
+ array( 'name' => '訪問数', 'value' => 'visit'),
+ array( 'name' => '訪問者数', 'value' => 'visitor'));
+
+ // 期間タイプ
+ $this->termTypeArray = array( array( 'name' => '10日', 'value' => '10day'),
+ array( 'name' => '30日', 'value' => '30day'),
+ array( 'name' => '3ヶ月', 'value' => '3month'),
+ array( 'name' => '6ヶ月', 'value' => '6month'),
+ array( 'name' => '1年', 'value' => '1year'),
+ array( 'name' => '2年', 'value' => '2year'),
+ array( 'name' => '3年', 'value' => '3year'),
+ array( 'name' => '5年', 'value' => '5year'),
+ array( 'name' => 'すべて', 'value' => self::TERM_TYPE_ALL));
+ }
+ /**
+ * テンプレートファイルを設定
+ *
+ * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+ * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+ *
+ * @param RequestManager $request HTTPリクエスト処理クラス
+ * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
+ * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+ */
+ function _setTemplate($request, &$param)
+ {
+ return 'admin.tmpl.html';
+ }
+ /**
+ * テンプレートの後処理
+ *
+ * テンプレートのデータ埋め込み(_assign())の後に実行される。
+ *
+ * @param RequestManager $request HTTPリクエスト処理クラス
+ * @param object $param 任意使用パラメータ。_setTemplate()と共有。
+ * @return なし
+ */
+ function _postAssign($request, &$param)
+ {
+ // メニューバー、パンくずリスト作成(簡易版)
+ $this->createBasicConfigMenubar($request);
+ }
+ /**
+ * テンプレートにデータ埋め込む
+ *
+ * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+ *
+ * @param RequestManager $request HTTPリクエスト処理クラス
+ * @param object $param 任意使用パラメータ。_setTemplate()と共有。
+ * @param なし
+ */
+ function _assign($request, &$param)
+ {
+ $act = $request->trimValueOf('act');
+
+ // 入力値を取得
+ $this->path = $request->trimValueOf('item_path'); // アクセスパス
+ $this->termType = $request->trimValueOf('item_term'); // 期間タイプ
+ $graphWidth = $request->trimValueOf('item_graph_width'); // グラフ幅
+ $graphHeight = $request->trimValueOf('item_graph_height'); // グラフ高さ
+
+ $replaceNew = false; // データを再取得するかどうか
+ if ($act == 'update'){ // 設定更新のとき
+ // 入力チェック
+ $this->checkNumeric($graphWidth, 'グラフ幅');
+ $this->checkNumeric($graphHeight, 'グラフ高さ');
+
+ if ($this->getMsgCount() == 0){ // エラーのないとき
+ $paramObj = new stdClass;
+ $paramObj->path = $this->path; // アクセスパス
+ $paramObj->termType = $this->termType; // 期間タイプ
+ $paramObj->graphWidth = $graphWidth; // グラフ幅
+ $paramObj->graphHeight = $graphHeight; // グラフ高さ
+ $ret = $this->updateWidgetParamObj($paramObj);
+ if ($ret){
+ $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
+ $replaceNew = true; // データ再取得
+ } else {
+ $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
+ }
+ $this->gPage->updateParentWindow();// 親ウィンドウを更新
+ }
+ } else { // 初期表示の場合
+ $replaceNew = true; // データ再取得
+ }
+
+ if ($replaceNew){ // データ再取得のとき
+ $paramObj = $this->getWidgetParamObj();
+ if (empty($paramObj)){ // 既存データなしのとき
+ // デフォルト値設定
+ $this->path = self::DEFAULT_ACCESS_PATH;
+ $this->termType = self::DEFAULT_TERM_TYPE;
+ $graphWidth = self::DEFAULT_GRAPH_WIDTH; // グラフ幅
+ $graphHeight = self::DEFAULT_GRAPH_HEIGHT; // グラフ高さ
+ } else {
+ $this->path = $paramObj->path; // アクセスパス
+ $this->termType = $paramObj->termType; // 期間タイプ
+ $graphWidth = $paramObj->graphWidth; // グラフ幅
+ $graphHeight = $paramObj->graphHeight; // グラフ高さ
+ }
+ }
+
+ // アクセスポイントメニュー作成
+// $this->createPathMenu();
+
+ // 期間メニュー作成
+// $this->createTermMenu();
+
+ // 値を埋め込む
+ $this->tmpl->addVar("_widget", "graph_width", $graphWidth);// グラフ幅
+ $this->tmpl->addVar("_widget", "graph_height", $graphHeight);// グラフ高さ
+ }
+ /**
+ * アクセスパスメニュー作成
+ *
+ * @return なし
+ */
+ function createPathMenu()
+ {
+ $selected = '';
+ if ($this->path == self::ACCESS_PATH_ALL){// アクセスパスすべて選択
+ $selected = 'selected';
+ }
+ $row = array(
+ 'value' => self::ACCESS_PATH_ALL, // アクセスパス
+ 'name' => 'すべて表示', // 表示文字列
+ 'selected' => $selected // 選択中かどうか
+ );
+ $this->tmpl->addVars('path_list', $row);
+ $this->tmpl->parseTemplate('path_list', 'a');
+
+ $this->db->getPageIdList(array($this, 'pageIdLoop'), 0/*ページID*/);
+ }
+ /**
+ * ページID、取得したデータをテンプレートに設定する
+ *
+ * @param int $index 行番号(0~)
+ * @param array $fetchedRow フェッチ取得した行
+ * @param object $param 未使用
+ * @return bool true=処理続行の場合、false=処理終了の場合
+ */
+ function pageIdLoop($index, $fetchedRow, $param)
+ {
+ $selected = '';
+ if ($fetchedRow['pg_path'] == $this->path){
+ $selected = 'selected';
+ }
+ $name = $this->convertToDispString($fetchedRow['pg_path']) . ' - ' . $this->convertToDispString($fetchedRow['pg_name']); // ページ名
+ $row = array(
+ 'value' => $this->convertToDispString($fetchedRow['pg_path']), // アクセスパス
+ 'name' => $name, // ページ名
+ 'selected' => $selected // 選択中かどうか
+ );
+ $this->tmpl->addVars('path_list', $row);
+ $this->tmpl->parseTemplate('path_list', 'a');
+ return true;
+ }
+ /**
+ * 期間タイプ選択メニュー作成
+ *
+ * @return なし
+ */
+ function createTermMenu()
+ {
+ for ($i = 0; $i < count($this->termTypeArray); $i++){
+ $value = $this->termTypeArray[$i]['value'];
+ $name = $this->termTypeArray[$i]['name'];
+
+ $selected = '';
+ if ($value == $this->termType) $selected = 'selected';
+
+ $row = array(
+ 'value' => $value, // ページID
+ 'name' => $name, // ページ名
+ 'selected' => $selected // 選択中かどうか
+ );
+ $this->tmpl->addVars('term_list', $row);
+ $this->tmpl->parseTemplate('term_list', 'a');
+ }
+ }
+}
+?>
--- /dev/null
+/**
+ * 表示データ作成用テンプレート(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('mainconfig');
+});
+//]]>
+</script>
+<div class="m3config_container">
+<!-- m3:ErrorMessage -->
+<form method="post" name="main" class="form">
+<input type="hidden" name="act" />
+<h3 class="m3config_h">基本設定</h3>
+<table id="mainconfig">
+ <tbody>
+ <tr>
+ <th>アクセスポイント</th>
+ <td>
+ <div class="m3config_item col-sm-6"><select name="item_path" class="form-control">
+ <patTemplate:tmpl name="path_list">
+ <option value="{VALUE}" {SELECTED}>{NAME}</option>
+ </patTemplate:tmpl>
+ </select></div>
+ </td>
+ </tr>
+ <tr>
+ <th>期間</th>
+ <td>
+ <div class="m3config_item col-sm-2"><select name="item_term" class="form-control">
+ <patTemplate:tmpl name="term_list">
+ <option value="{VALUE}" {SELECTED}>{NAME}</option>
+ </patTemplate:tmpl>
+ </select></div>
+ </td>
+ </tr>
+ <tr>
+ <th>グラフサイズ</th>
+ <td><div class="form-control-static m3config_item col-sm-1">幅:</div><div class="m3config_item col-sm-2"><input type="text" name="item_graph_width" class="form-control" value="{GRAPH_WIDTH}" size="4" maxlength="4" onkeypress="return m3_numericKey(event,true);" /></div><div class="form-control-static m3config_item col-sm-2">px</div>
+ <div class="form-control-static m3config_item col-sm-1">高さ:</div><div class="m3config_item col-sm-2"><input type="text" name="item_graph_height" class="form-control" value="{GRAPH_HEIGHT}" size="4" maxlength="4" onkeypress="return m3_numericKey(event,true);" /></div><div class="form-control-static m3config_item col-sm-2">px</div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<div class="well m3config_update_buttons">
+<input type="button" class="button" onclick="updateItem();" value="更新" />
+</div>
+</form>
+</div>
+</patTemplate:tmpl>