OSDN Git Service

「スローガン」ウィジェット追加。
authornaoki hirata <naoki@magic3.org>
Sun, 1 Dec 2013 23:19:39 +0000 (08:19 +0900)
committernaoki hirata <naoki@magic3.org>
Sun, 1 Dec 2013 23:19:39 +0000 (08:19 +0900)
13 files changed:
include/common/scriptLibInfo.php
include/sql/update_widgets.sql
scripts/jquery/jquery.fittext.js [new file with mode: 0644]
widgets/photoslide2/include/template/default.tmpl.css
widgets/slogan/admin/index.php [new file with mode: 0644]
widgets/slogan/include/container/admin_sloganWidgetContainer.php [new file with mode: 0644]
widgets/slogan/include/container/sloganWidgetContainer.php [new file with mode: 0644]
widgets/slogan/include/help/index.php [new file with mode: 0644]
widgets/slogan/include/template/admin.tmpl.html [new file with mode: 0644]
widgets/slogan/include/template/admin_list.tmpl.html [new file with mode: 0644]
widgets/slogan/include/template/default.tmpl.css [new file with mode: 0644]
widgets/slogan/include/template/index.tmpl.html [new file with mode: 0644]
widgets/slogan/index.php [new file with mode: 0644]

index 5bbeab7..39b2907 100644 (file)
@@ -75,6 +75,7 @@ class ScriptLibInfo
        const LIB_JQUERY_FULLCALENDAR   = 'jquery.fullcalendar';
        const LIB_JQUERY_TIMEPICKER             = 'jquery.timepicker';
        const LIB_JQUERY_JSON                   = 'jquery.json';
+       const LIB_JQUERY_FITTEXT                = 'jquery.fittext';
        
        // CodeMirror
        const LIB_CODEMIRROR_JAVASCRIPT = 'codemirror.javascript';              // CodeMirror Javascript
@@ -177,6 +178,7 @@ const JQUERY_JQPLOT_CSS                             = 'jquery/jqplot1.0.7/jquery.jqplot.min.css';
        const JQUERY_TIMEPICKER_LANG_FILENAME   = 'jquery/timepicker/i18n/jquery.ui.timepicker-ja.js';
        const JQUERY_TIMEPICKER_CSS                     = 'jquery/timepicker/jquery.ui.timepicker.css';
        const JQUERY_JSON_FILENAME                      = 'jquery/jquery.json-2.4.min.js';
+       const JQUERY_FITTEXT_FILENAME           = 'jquery/jquery.fittext.js';
        
        // ライブラリの公式サイトのURL
        const JQUERY_JCAROUSEL_URL                      = 'http://sorgalla.com/projects/jcarousel/';
@@ -417,6 +419,7 @@ const JQUERY_JQPLOT_CSS                             = 'jquery/jqplot1.0.7/jquery.jqplot.min.css';
                                        self::LIB_JQUERY_JSON                   =>      array(  'script'        => array(self::JQUERY_JSON_FILENAME),   // jquery.json用のファイル
                                                                                                                                'url'           => self::JQUERY_JSON_URL,
                                                                                                                                'version'       => self::JQUERY_JSON_VER),
+                                       self::LIB_JQUERY_FITTEXT                =>      array(  'script'        => array(self::JQUERY_FITTEXT_FILENAME)),       // jquery.fittext用のファイル
 /*                                     self::LIB_JQUERY_JQEASYPANEL    =>      array(  'script'        => array(self::JQUERY_JQEASYPANEL_FILENAME),    // jquery.jqEasyPanel用のファイル
                                                                                                                                'css'           => array(self::JQUERY_JQEASYPANEL_CSS),
                                                                                                                                'url'           => self::JQUERY_JQEASYPANEL_URL,
index a576425..ba98276 100644 (file)
@@ -393,6 +393,10 @@ DELETE FROM _widgets WHERE wd_id = 'event_category';
 INSERT INTO _widgets\r
 (wd_id,            wd_name,                     wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description,             wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_has_rss, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
 ('event_category', 'イベント情報 - 選択カテゴリー', '1.1.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'イベント記事の1カテゴリに属する記事の一覧を表示。', true,        false,               true,true,               1, -1, true, '2013-10-06', now(),    now());\r
+DELETE FROM _widgets WHERE wd_id = 'slogan';\r
+INSERT INTO _widgets\r
+(wd_id,   wd_name, wd_version, wd_params, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_add_script_lib, wd_add_script_lib_a,   wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
+('slogan', 'スローガン',  '1.0.0',    '',        'Naoki Hirata', 'Magic3.org', 'GPL',      10, 'ヘッダ等の前面にメッセージテキストを表示。レスポンシブウェブ対応。',                      'jquery.fittext',         '',        true,         false,                                true,                true,              '2012-11-01', now(),         now());\r
 \r
 -- ウィジェット情報(携帯用)\r
 DELETE FROM _widgets WHERE wd_id = 'm/mainmenu';\r
diff --git a/scripts/jquery/jquery.fittext.js b/scripts/jquery/jquery.fittext.js
new file mode 100644 (file)
index 0000000..080b82e
--- /dev/null
@@ -0,0 +1,43 @@
+/*global jQuery */
+/*!
+* FitText.js 1.1
+*
+* Copyright 2011, Dave Rupert http://daverupert.com
+* Released under the WTFPL license
+* http://sam.zoy.org/wtfpl/
+*
+* Date: Thu May 05 14:23:00 2011 -0600
+*/
+
+(function( $ ){
+
+  $.fn.fitText = function( kompressor, options ) {
+
+    // Setup options
+    var compressor = kompressor || 1,
+        settings = $.extend({
+          'minFontSize' : Number.NEGATIVE_INFINITY,
+          'maxFontSize' : Number.POSITIVE_INFINITY
+        }, options);
+
+    return this.each(function(){
+
+      // Store the object
+      var $this = $(this);
+
+      // Resizer() resizes items based on the object width divided by the compressor * 10
+      var resizer = function () {
+        $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
+      };
+
+      // Call once to set.
+      resizer();
+
+      // Call on resize. Opera debounces their resize by default.
+      $(window).on('resize.fittext orientationchange.fittext', resizer);
+
+    });
+
+  };
+
+})( jQuery );
index a8de9d5..a24278d 100644 (file)
@@ -1,10 +1,10 @@
 /**
- * CSS\8dì\90¬\97p\83e\83\93\83v\83\8c\81[\83g(patTemplate)
+ * CSS作成用テンプレート(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>
+ * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
  * @copyright  Copyright 2006-2012 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    SVN: $Id: default.tmpl.css 4696 2012-02-19 03:31:35Z fishbone $
diff --git a/widgets/slogan/admin/index.php b/widgets/slogan/admin/index.php
new file mode 100644 (file)
index 0000000..5c33e9d
--- /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-203 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/slogan/include/container/admin_sloganWidgetContainer.php b/widgets/slogan/include/container/admin_sloganWidgetContainer.php
new file mode 100644 (file)
index 0000000..bfb2d5f
--- /dev/null
@@ -0,0 +1,363 @@
+<?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_sloganWidgetContainer extends BaseAdminWidgetContainer
+{
+       private $serialNo;              // 選択中の項目のシリアル番号
+       private $serialArray = array();                 // 表示中のシリアル番号
+       private $langId;
+       private $configId;              // 定義ID
+       private $paramObj;              // パラメータ保存用オブジェクト
+       private $cssId;                 // CSS用ID
+       private $css;                   // CSS
+       const DEFAULT_NAME_HEAD = '名称未設定';                    // デフォルトの設定名
+       const DEFAULT_MESSAGE = 'Default Message';              // デフォルトメッセージ
+       const DEFAULT_SIZE = '3.0';             // デフォルトサイズ
+       
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+               
+               // DBオブジェクト作成
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+        * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
+        * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+        */
+       function _setTemplate($request, &$param)
+       {
+               $task = $request->trimValueOf('task');
+               if ($task == 'list'){           // 一覧画面
+                       return 'admin_list.tmpl.html';
+               } else {                        // 一覧画面
+                       return 'admin.tmpl.html';
+               }
+       }
+       /**
+        * テンプレートにデータ埋め込む
+        *
+        * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
+        * @param                                                               なし
+        */
+       function _assign($request, &$param)
+       {
+               $task = $request->trimValueOf('task');
+               if ($task == 'list'){           // 一覧画面
+                       return $this->createList($request);
+               } else {                        // 詳細設定画面
+                       return $this->createDetail($request);
+               }
+       }
+       /**
+        * 詳細画面作成
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param                                                               なし
+        */
+       function createDetail($request)
+       {
+               // ページ定義IDとページ定義のレコードシリアル番号を取得
+               $this->startPageDefParam($defSerial, $defConfigId, $this->paramObj);
+               
+               $userId         = $this->gEnv->getCurrentUserId();
+               $this->langId   = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
+               
+               $act = $request->trimValueOf('act');
+               $this->serialNo = $request->trimValueOf('serial');              // 選択項目のシリアル番号
+               $this->configId = $request->trimValueOf('item_id');             // 定義ID
+               if (empty($this->configId)) $this->configId = $defConfigId;             // 呼び出しウィンドウから引き継いだ定義ID
+               
+               // 入力値を取得
+               $name   = $request->trimValueOf('item_name');                   // 定義名
+               $message        = $request->trimValueOf('item_message');        // メッセージ
+               $size           = $request->trimValueOf('item_size');   // メッセージサイズ
+               $this->cssId    = $request->trimValueOf('item_css_id');         // CSS用ID
+               $this->css      = $request->valueOf('item_css');                        // CSS
+
+               $replaceNew = false;            // データを再取得するかどうか
+               if ($act == 'add'){// 新規追加
+                       // 入力チェック
+                       $this->checkInput($name, '名前');
+                       $this->checkInput($this->css, 'CSS');
+                       
+                       // 設定名の重複チェック
+                       for ($i = 0; $i < count($this->paramObj); $i++){
+                               $targetObj = $this->paramObj[$i]->object;
+                               if ($name == $targetObj->name){         // 定義名
+                                       $this->setUserErrorMsg('名前が重複しています');
+                                       break;
+                               }
+                       }
+                       
+                       // エラーなしの場合は、データを登録
+                       if ($this->getMsgCount() == 0){
+                               // 追加オブジェクト作成
+                               $newObj = new stdClass;
+                               $newObj->name   = $name;// 表示名
+                               $newObj->message = $message;                    // メッセージ
+                               $newObj->size   = $size;                                        // メッセージサイズ
+                               $newObj->cssId  = $this->cssId;                                 // CSS用ID
+                               $newObj->css    = $this->css;                                   // CSS
+                               
+                               $ret = $this->addPageDefParam($defSerial, $defConfigId, $this->paramObj, $newObj);
+                               if ($ret){
+                                       $this->setGuidanceMsg('データを追加しました');
+                                       
+                                       $this->configId = $defConfigId;         // 定義定義IDを更新
+                                       $replaceNew = true;                     // データ再取得
+                               } else {
+                                       $this->setAppErrorMsg('データ追加に失敗しました');
+                               }
+                       }
+               } else if ($act == 'update'){           // 設定更新のとき
+                       // 入力値のエラーチェック
+                       $this->checkInput($this->css, 'CSS');
+                       
+                       if ($this->getMsgCount() == 0){                 // エラーのないとき
+                               // 現在の設定値を取得
+                               $ret = $this->getPageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
+                               if ($ret){
+                                       // ウィジェットオブジェクト更新
+                                       $targetObj->message = $message;                 // メッセージ
+                                       $targetObj->size        = $size;                                        // メッセージサイズ
+                                       $targetObj->cssId       = $this->cssId;                                 // CSS用ID
+                                       $targetObj->css         = $this->css;                                   // CSS
+                               }
+                               
+                               // 設定値を更新
+                               if ($ret) $ret = $this->updatePageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
+                               if ($ret){
+                                       $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
+                                       $replaceNew = true;                     // データ再取得
+                               } else {
+                                       $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
+                               }
+                       }
+               } else if ($act == 'select'){   // 定義IDを変更
+                       $replaceNew = true;                     // データ再取得
+               } else {        // 初期起動時、または上記以外の場合
+                       // デフォルト値設定
+                       $this->configId = $defConfigId;         // 呼び出しウィンドウから引き継いだ定義ID
+                       $replaceNew = true;                     // データ再取得
+               }
+               // 表示用データを取得
+               if (empty($this->configId)){            // 新規登録の場合
+                       $this->tmpl->setAttribute('item_name_visible', 'visibility', 'visible');// 名前入力フィールド表示
+                       if ($replaceNew){               // データ再取得時
+                               $name = $this->createDefaultName();                     // デフォルト登録項目名
+                               $message = self::DEFAULT_MESSAGE;                       // メッセージ
+                               $size   = self::DEFAULT_SIZE;                                   // メッセージサイズ
+                               $this->cssId = $this->createDefaultCssId();     // CSS用ID
+                               $this->css = $this->getParsedTemplateData('default.tmpl.css', array($this, 'makeCss'));
+                       }
+                       $this->serialNo = 0;
+               } else {
+                       if ($replaceNew){// データ再取得時
+                               $ret = $this->getPageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
+                               if ($ret){
+                                       $name           = $targetObj->name;     // 名前
+                                       $message        = $targetObj->message;                  // メッセージ
+                                       $size           = $targetObj->size;                                     // メッセージサイズ
+                                       $this->cssId    = $targetObj->cssId;                                    // CSS用ID
+                                       $this->css      = $targetObj->css;      // CSS
+                               }
+                       }
+                       $this->serialNo = $this->configId;
+                               
+                       // 新規作成でないときは、メニューを変更不可にする(画面作成から呼ばれている場合のみ)
+                       if (!empty($defConfigId) && !empty($defSerial)) $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
+               }
+
+               // 設定項目選択メニュー作成
+               $this->createItemMenu();
+               
+               // 画面にデータを埋め込む
+               if (!empty($this->configId)) $this->tmpl->addVar("_widget", "id", $this->configId);             // 定義ID
+               $this->tmpl->addVar("item_name_visible", "name",        $this->convertToDispString($name));
+               $this->tmpl->addVar("_widget", "message", $this->convertToDispString($message));        // メッセージ
+               $this->tmpl->addVar("_widget", "size", $this->convertToDispString($size));      // メッセージサイズ
+               $this->tmpl->addVar("_widget", "css_id",        $this->convertToDispString($this->cssId));      // CSS用ID
+               $this->tmpl->addVar("_widget", "css",   $this->css);
+               $this->tmpl->addVar("_widget", "serial", $this->serialNo);// 選択中のシリアル番号、IDを設定
+               
+               // ボタンの表示制御
+               if (empty($this->serialNo)){            // 新規追加項目を選択しているとき
+                       $this->tmpl->setAttribute('add_button', 'visibility', 'visible');// 「新規追加」ボタン
+               } else {
+                       $this->tmpl->setAttribute('update_button', 'visibility', 'visible');// 「更新」ボタン
+               }
+               
+               // ページ定義IDとページ定義のレコードシリアル番号を更新
+               $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
+       }
+       /**
+        * 選択用メニューを作成
+        *
+        * @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 RequestManager $request               HTTPリクエスト処理クラス
+        * @param                                                               なし
+        */
+       function createList($request)
+       {
+               // ページ定義IDとページ定義のレコードシリアル番号を取得
+               $this->startPageDefParam($defSerial, $defConfigId, $this->paramObj);
+               
+               $userId         = $this->gEnv->getCurrentUserId();
+               $langId = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
+               $act = $request->trimValueOf('act');
+               
+               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){
+                               $ret = $this->delPageDefParam($defSerial, $defConfigId, $this->paramObj, $delItems);
+                               if ($ret){              // データ削除成功のとき
+                                       $this->setGuidanceMsg('データを削除しました');
+                               } else {
+                                       $this->setAppErrorMsg('データ削除に失敗しました');
+                               }
+                       }
+               }
+               // 定義一覧作成
+               $this->createItemList();
+               
+               $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
+               
+               // ページ定義IDとページ定義のレコードシリアル番号を更新
+               $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
+       }
+       /**
+        * 定義一覧作成
+        *
+        * @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;// 定義名
+               
+                       // 使用数
+                       $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),            // 名前
+                               'def_count' => $defCount                                                        // 使用数
+                       );
+                       $this->tmpl->addVars('itemlist', $row);
+                       $this->tmpl->parseTemplate('itemlist', 'a');
+                       
+                       // シリアル番号を保存
+                       $this->serialArray[] = $id;
+               }
+       }
+       /**
+        * CSS用のデフォルトのIDを取得
+        *
+        * @return string       ID                                              
+        */
+       function createDefaultCssId()
+       {
+               return $this->gEnv->getCurrentWidgetId() . '_' . $this->getTempConfigId($this->paramObj);
+       }
+       /**
+        * CSSデータ作成処理コールバック
+        *
+        * @param object         $tmpl                  テンプレートオブジェクト
+        * @param                                                               なし
+        */
+       function makeCss($tmpl)
+       {
+               $tmpl->addVar('_tmpl', 'id', '#' . $this->cssId);
+       }
+}
+?>
diff --git a/widgets/slogan/include/container/sloganWidgetContainer.php b/widgets/slogan/include/container/sloganWidgetContainer.php
new file mode 100644 (file)
index 0000000..794a2c2
--- /dev/null
@@ -0,0 +1,95 @@
+<?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');
+
+class sloganWidgetContainer extends BaseWidgetContainer
+{
+       private $langId;                // 現在の言語
+       private $paramObj;              // 定義取得用
+       private $headCss;                       // ヘッダ出力用CSS
+       const DEFAULT_CONFIG_ID = 0;
+       const DEFAULT_MESSAGE = 'Default Message';              // デフォルトメッセージ
+       
+       /**
+        * コンストラクタ
+        */
+       function __construct()
+       {
+               // 親クラスを呼び出す
+               parent::__construct();
+       }
+       /**
+        * テンプレートファイルを設定
+        *
+        * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
+        * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
+        * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
+        */
+       function _setTemplate($request, &$param)
+       {
+               return 'index.tmpl.html';
+       }
+       /**
+        * テンプレートにデータ埋め込む
+        *
+        * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
+        * @param                                                               なし
+        */
+       function _assign($request, &$param)
+       {
+               $this->langId = $this->gEnv->getCurrentLanguage();
+               
+               // 定義ID取得
+               $configId = $this->gEnv->getCurrentWidgetConfigId();
+               if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
+               
+               // 初期値設定
+               $message = self::DEFAULT_MESSAGE;               // メッセージ
+               
+               // パラメータオブジェクトを取得
+               $targetObj = $this->getWidgetParamObjByConfigId($configId);
+               if (!empty($targetObj)){                // 定義データが取得できたとき
+                       $message = $targetObj->message;                 // メッセージ
+                       $size           = $targetObj->size;                                     // メッセージサイズ
+                       $cssId          = $targetObj->cssId;                                    // CSS用ID
+                       $this->headCss = $this->convertM3ToText($targetObj->css);       // 標準マクロ変換してCSSを作成
+               }
+               $this->tmpl->addVar('_widget', 'css_id', $this->convertToDispString($cssId));
+               $this->tmpl->addVar("_widget", "message", $this->convertToDispString($message));        // メッセージ
+               $this->tmpl->addVar("_widget", "size", $this->convertToDispString($size));      // メッセージサイズ
+       }
+       /**
+        * CSSデータをHTMLヘッダ部に設定
+        *
+        * CSSデータをHTMLのheadタグ内に追加出力する。
+        * _assign()よりも後に実行される。
+        *
+        * @param RequestManager $request               HTTPリクエスト処理クラス
+        * @param object         $param                 任意使用パラメータ。
+        * @return string                                               CSS文字列。出力しない場合は空文字列を設定。
+        */
+       function _addCssToHead($request, &$param)
+       {
+               return $this->headCss;
+       }
+}
+?>
diff --git a/widgets/slogan/include/help/index.php b/widgets/slogan/include/help/index.php
new file mode 100644 (file)
index 0000000..50b782c
--- /dev/null
@@ -0,0 +1,49 @@
+<?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;
+
+// ########## CSS項目一覧 ##########
+$HELP['item_list']['title'] = 'CSS設定一覧';
+$HELP['item_list']['body'] = '登録されているCSS設定の一覧です。';
+$HELP['item_detail']['title'] = 'CSS設定';
+$HELP['item_detail']['body'] = 'CSSについての設定を行います。';
+$HELP['item_check']['title'] = '選択用チェックボックス';
+$HELP['item_check']['body'] = '削除を行う項目を選択します。';
+$HELP['item_name']['title'] = '名前';
+$HELP['item_name']['body'] = 'CSS設定名です。';
+$HELP['item_name_input']['title'] = '名前';
+$HELP['item_name_input']['body'] = 'CSS設定名です。新規に登録するか、登録済みの設定を選択します。';
+$HELP['item_css_id']['title'] = 'CSS用ID';
+$HELP['item_css_id']['body'] = '表示項目のHTMLタグに設定されるIDです。';
+$HELP['item_css']['title'] = 'CSS';
+$HELP['item_css']['body'] = 'CSSの設定内容です。HTMLのヘッダ部に出力されます。';
+$HELP['item_message']['title'] = 'メッセージ';
+$HELP['item_message']['body'] = '表示するメッセージです。';
+$HELP['item_id']['title'] = 'CSS設定ID';
+$HELP['item_id']['body'] = '自動的に振られるCSS設定IDです。';
+$HELP['item_ref']['title'] = '使用';
+$HELP['item_ref']['body'] = 'CSS設定を使用しているウィジェット数を示します。使用が0のCSS設定のみ削除可能です。';
+$HELP['item_list_btn']['title'] = '一覧ボタン';
+$HELP['item_list_btn']['body'] = 'CSS設定一覧を表示します。';
+$HELP['item_del_btn']['title'] = '削除ボタン';
+$HELP['item_del_btn']['body'] = '選択されているCSS設定を削除します。<br />項目を選択するには、一覧の左端のチェックボックスにチェックを入れます。';
+$HELP['item_ret_btn']['title'] = '戻るボタン';
+$HELP['item_ret_btn']['body'] = 'CSS詳細へ戻ります。';
+?>
diff --git a/widgets/slogan/include/template/admin.tmpl.html b/widgets/slogan/include/template/admin.tmpl.html
new file mode 100644 (file)
index 0000000..dbfba0d
--- /dev/null
@@ -0,0 +1,108 @@
+/**
+ * 表示データ作成用テンプレート(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;
+}
+//]]>
+</script>
+<div align="center">
+<br />
+<!-- m3:ErrorMessage -->
+<form method="post" name="main">
+<input type="hidden" name="task" />
+<input type="hidden" name="act" />
+<input type="hidden" name="serial" value="{SERIAL}" />
+<!-- m3:PostParam -->
+<table width="90%">
+<tr><td><span {_HELP_ITEM_DETAIL}><label>スローガン設定</label></span></td>
+<td align="right"><span {_HELP_ITEM_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="150"><span {_HELP_ITEM_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_ITEM_ID}>ID</span></td>
+           <td align="center">{ID}</td>
+       </tr>
+    <tr class="even">
+           <td class="table-headside"><span {_HELP_ITEM_MESSAGE}>メッセージ</span></td>
+           <td colspan="3"><input type="text" name="item_message" value="{MESSAGE}" maxlength="200" style="width:100%;" />
+           </td>
+       </tr>
+       <tr>
+           <td class="table-headside"><span {_HELP_ITEM_SIZE}>サイズ</span></td>
+               <td colspan="3"><input type="text" name="item_size" value="{SIZE}" size="3" maxlength="3" onkeypress="return m3_numericKey(event,true);" /></td>
+       </tr>
+    <tr class="even">
+           <td class="table-headside"><span {_HELP_ITEM_CSS_ID}>CSS用ID</span></td>
+           <td colspan="3">{CSS_ID}<input type="hidden" name="item_css_id" value="{CSS_ID}" />
+           </td>
+       </tr>
+    <tr>
+           <td class="table-headside"><span {_HELP_ITEM_CSS}>CSS</span></td>
+           <td colspan="3"><textarea name="item_css" rows="10" style="width:100%;">{CSS}</textarea>
+           </td>
+       </tr>
+       <tr class="even">
+           <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>
+</patTemplate:tmpl>
diff --git a/widgets/slogan/include/template/admin_list.tmpl.html b/widgets/slogan/include/template/admin_list.tmpl.html
new file mode 100644 (file)
index 0000000..b683711
--- /dev/null
@@ -0,0 +1,86 @@
+/**
+ * 表示データ作成用テンプレート(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(){
+       // スクロールバー付きのテーブルを作成
+       m3_tableWithScrollbar('itemlist', -1, 0);
+});
+//]]>
+</script>
+<div align="center">
+<br />
+<!-- 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}" />
+<!-- m3:PostParam -->
+<table width="90%">
+<tr><td>
+<span {_HELP_CSS_LIST}><label>スローガン設定一覧</label></span>
+</td><td align="right"><span {_HELP_CSS_DEL_BTN}><input type="button" class="button" onclick="delItem();" value="削除" /></span>
+<span {_HELP_CSS_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_CSS_CHECK}>選択</span></th>
+           <th width="35" align="center"><span {_HELP_CSS_ID}>ID</span></th>
+           <th width="40%" align="center"><span {_HELP_CSS_NAME}>名前</span></th>
+           <th align="center"><span {_HELP_CSS_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 align="center">{DEF_COUNT}</td>
+       </tr>
+       </patTemplate:tmpl>
+    </tbody>
+</table>
+</td></tr>
+</table>
+</form>
+</div>
+</patTemplate:tmpl>
diff --git a/widgets/slogan/include/template/default.tmpl.css b/widgets/slogan/include/template/default.tmpl.css
new file mode 100644 (file)
index 0000000..2f97552
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * CSS作成用テンプレート(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="_tmpl">
+{ID} {
+    position:relative;
+    color:black;
+    z-index:200;
+    top:-1.2em;
+    left:5em;
+    height:0;
+}
+</patTemplate:tmpl>
diff --git a/widgets/slogan/include/template/index.tmpl.html b/widgets/slogan/include/template/index.tmpl.html
new file mode 100644 (file)
index 0000000..05f1a5f
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * 表示データ作成用テンプレート(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(){
+       $("#{CSS_ID}").fitText({SIZE});
+});
+//]]>
+</script>
+<div id="{CSS_ID}">{MESSAGE}</div>
+</patTemplate:tmpl>
diff --git a/widgets/slogan/index.php b/widgets/slogan/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__);
+?>