OSDN Git Service

「上へ参ります」ウィジェットのアイコンを任意設定可能にした。
authornaoki hirata <naoki@magic3.org>
Mon, 18 Nov 2013 23:31:14 +0000 (08:31 +0900)
committernaoki hirata <naoki@magic3.org>
Mon, 18 Nov 2013 23:31:14 +0000 (08:31 +0900)
include/sql/update_widgets.sql
widgets/g_analytics/include/container/admin_g_analyticsWidgetContainer.php
widgets/gotop/admin/index.php [new file with mode: 0644]
widgets/gotop/include/container/admin_gotopWidgetContainer.php [new file with mode: 0644]
widgets/gotop/include/container/gotopWidgetContainer.php
widgets/gotop/include/template/admin.tmpl.html [new file with mode: 0644]
widgets/gotop/include/template/index.tmpl.html

index 7586526..a576425 100644 (file)
@@ -251,8 +251,8 @@ INSERT INTO _widgets
 ('googlemaps', 'Googleマップ', '3.0.0',    '株式会社 毎日メディアサービス', '株式会社 毎日メディアサービス', 'GPL', 10, 'Goolgeマップを表示。', 'jquery', 'jquery',        false,           false,       true,        false,               true,true,           3, 1, '2012-03-19', now(), now());\r
 DELETE FROM _widgets WHERE wd_id = 'gotop';\r
 INSERT INTO _widgets\r
-(wd_id,   wd_name,        wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description,     wd_add_script_lib, wd_add_script_lib_a, wd_read_scripts, wd_read_css, wd_available, wd_editable, wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_install_dt, wd_create_dt) VALUES\r
-('gotop', '上へ参ります', '1.0.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                '画面トップへ移動', 'jquery',          '',                  false,           false,       true,         true,        false,        false,               false,               true,           1,             -1, now(), now());\r
+(wd_id,   wd_name,        wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description,     wd_add_script_lib, wd_add_script_lib_a, wd_available, wd_editable, wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
+('gotop', '上へ参ります', '1.1.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                '画面トップへ移動', 'jquery',          'elfinder',                  true,         true,        true,        false,               false,               true,           1,             -1, '2013-11-18', now(), now());\r
 DELETE FROM _widgets WHERE wd_id = 'slide_menu';\r
 INSERT INTO _widgets\r
 (wd_id,        wd_name,           wd_type, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_add_script_lib, wd_add_script_lib_a,                         wd_has_admin, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
index 5a73a27..3fbbac6 100644 (file)
@@ -8,9 +8,9 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2009 Magic3 Project.
+ * @copyright  Copyright 2006-2013 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
- * @version    SVN: $Id: admin_g_analyticsWidgetContainer.php 2266 2009-08-28 08:25:59Z fishbone $
+ * @version    SVN: $Id$
  * @link       http://www.magic3.org
  */
 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
@@ -56,6 +56,7 @@ class admin_g_analyticsWidgetContainer extends BaseAdminWidgetContainer
                        $account        = $request->valueOf('account_no');                      // Google Analyticsアカウント番号
                        
                        if ($this->getMsgCount() == 0){                 // エラーのないとき
+                               $paramObj = new stdClass;
                                $paramObj->account      = $account;
                                $ret = $this->updateWidgetParamObj($paramObj);
                                if ($ret){
diff --git a/widgets/gotop/admin/index.php b/widgets/gotop/admin/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__);
+?>
diff --git a/widgets/gotop/include/container/admin_gotopWidgetContainer.php b/widgets/gotop/include/container/admin_gotopWidgetContainer.php
new file mode 100644 (file)
index 0000000..5a39af8
--- /dev/null
@@ -0,0 +1,87 @@
+<?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');
+
+class admin_gotopWidgetContainer extends BaseAdminWidgetContainer
+{
+       const DEFAULT_IMAGE_FILE = '/up.png';           // デフォルトの矢印アイコン
+               
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+        * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
+        * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+        */
+       function _setTemplate($request, &$param)
+       {       
+               return 'admin.tmpl.html';
+       }
+       /**
+        * テンプレートにデータ埋め込む
+        *
+        * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
+        * @param                                                               なし
+        */
+       function _assign($request, &$param)
+       {
+               // 入力値を取得
+               $imageUrl = $request->trimValueOf('item_image_url');            // 画像のURL
+               if (empty($imageUrl)) $imageUrl = $this->gEnv->getCurrentWidgetImagesUrl() . self::DEFAULT_IMAGE_FILE;
+               $act = $request->trimValueOf('act');
+               
+               if ($act == 'update'){          // 設定更新のとき
+                       
+                       if ($this->getMsgCount() == 0){                 // エラーのないとき
+                               $paramObj = new stdClass;
+                               $paramObj->imageUrl     = $this->gEnv->getMacroPath($imageUrl);
+                               $ret = $this->updateWidgetParamObj($paramObj);
+                               if ($ret){
+                                       $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
+                               } else {
+                                       $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
+                               }
+                               $this->gPage->updateParentWindow();// 親ウィンドウを更新
+                       }
+               } else {                // 初期表示の場合
+                       // デフォルト値設定
+                       $imageUrl = $this->gEnv->getCurrentWidgetImagesUrl() . self::DEFAULT_IMAGE_FILE;
+                       $paramObj = $this->getWidgetParamObj();
+                       if (!empty($paramObj)){
+                               $imageUrl       = $paramObj->imageUrl;
+                               $imageUrl = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $imageUrl);
+                       }
+               }
+
+               // 画面にデータを埋め込む
+               $this->tmpl->addVar("_widget", "image_url",     $imageUrl);// 画像のURL
+       }
+}
+?>
index 7c93db5..703c7e6 100644 (file)
@@ -8,15 +8,17 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2009 Magic3 Project.
+ * @copyright  Copyright 2006-2013 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
- * @version    SVN: $Id: gotopWidgetContainer.php 2506 2009-11-02 10:20:26Z fishbone $
+ * @version    SVN: $Id$
  * @link       http://www.magic3.org
  */
 require_once($gEnvManager->getContainerPath()          . '/baseWidgetContainer.php');
 
 class gotopWidgetContainer extends BaseWidgetContainer
 {
+       const DEFAULT_IMAGE_FILE = '/up.png';   // デフォルトの矢印アイコン
+       
        /**
         * コンストラクタ
         */
@@ -50,6 +52,13 @@ class gotopWidgetContainer extends BaseWidgetContainer
         */
        function _assign($request, &$param)
        {
+               $imageUrl = $this->gEnv->getCurrentWidgetImagesUrl() . self::DEFAULT_IMAGE_FILE;
+               $paramObj = $this->getWidgetParamObj();
+               if (!empty($paramObj)){
+                       $imageUrl       = $paramObj->imageUrl;
+                       $imageUrl = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $imageUrl);
+               }
+               $this->tmpl->addVar("_widget", "image_url",     $imageUrl);
        }
 }
 ?>
diff --git a/widgets/gotop/include/template/admin.tmpl.html b/widgets/gotop/include/template/admin.tmpl.html
new file mode 100644 (file)
index 0000000..b5df465
--- /dev/null
@@ -0,0 +1,71 @@
+/**
+ * 表示データ作成用テンプレート(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 updateItem(){
+       if (!window.confirm('設定を更新しますか?')) return false;
+       document.main.act.value='update';
+       document.main.submit();
+       return true;
+}
+// ファイルブラウザ起動
+function selectImage()
+{
+       m3OpenImageFileBrowser(SetUrl);
+}
+// ファイルブラウザからの設定用
+function SetUrl(url)
+{
+       // URL設定
+       $('#item_image_url').val(url);
+       
+       // 画像表示
+       updateImage();
+}
+function updateImage()
+{
+       // プレビュー画像設定
+       var url = $('#item_image_url').val();
+       var preOuter = $('#preview_outer');
+       var innerText = '<img id="preview_img" src="' + url + '"';
+       innerText += ' />';
+       preOuter.html(innerText);
+}
+$(function(){
+       // 画像表示
+       updateImage();
+});
+//]]>
+</script>
+<div align="center">
+<br />
+<!-- m3:ErrorMessage -->
+<form method="post" name="main">
+<input type="hidden" name="act" />
+<input type="hidden" id="item_image_url" name="item_image_url" value="{IMAGE_URL}" />
+<table class="simple-table">
+    <caption>「上へ参ります」設定</caption>
+    <tbody>
+    <tr>
+           <td class="table-headside" width="150">画像<br />(48x48)</td>
+           <td width="500"><div id="preview_outer">{IMAGE}</div><div><input type="button" class="button" onclick="selectImage();" value="変更" /></div></td>
+       </tr>
+    <tr class="even">
+           <td colspan="2" align="right"><input type="button" class="button" onclick="updateItem();" value="更新" /></td>
+       </tr>
+    </tbody>
+</table>
+</form>
+</div>
+</patTemplate:tmpl>
index d4953e7..0fa73fb 100644 (file)
@@ -1,3 +1,15 @@
+/**
+ * \95\\8e¦\83f\81[\83^\8dì\90¬\97p\83e\83\93\83v\83\8c\81[\83g(patTemplate)
+ *
+ * LICENSE: This source file is licensed under the terms of the GNU General Public License.
+ *
+ * @package    Magic3 Framework
+ * @author     \95½\93c\92¼\8bB(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[
@@ -11,7 +23,7 @@ var scrolltotop={
        //startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
        //scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
        setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
-       controlHTML: '<img src="{_WIDGET_URL}/images/up.png" style="width:48px; height:48px" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
+       controlHTML: '<img src="{IMAGE_URL}" style="width:48px; height:48px" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
        controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
        anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links