OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / default_content / include / container / admin_default_contentOtherWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2013 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_default_contentOtherWidgetContainer.php 5893 2013-04-01 13:27:22Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getWidgetContainerPath('default_content') . '/admin_default_contentBaseWidgetContainer.php');
17
18 class admin_default_contentOtherWidgetContainer extends admin_default_contentBaseWidgetContainer
19 {
20         const DEFAULT_MESSAGE_DENY = 'コンテンツを表示できません';         // アクセス不可の場合のメッセージ
21                         
22         /**
23          * コンストラクタ
24          */
25         function __construct()
26         {
27                 // 親クラスを呼び出す
28                 parent::__construct();
29         }
30         /**
31          * テンプレートファイルを設定
32          *
33          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
34          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
35          *
36          * @param RequestManager $request               HTTPリクエスト処理クラス
37          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
38          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
39          */
40         function _setTemplate($request, &$param)
41         {
42                 return 'admin_other.tmpl.html';
43         }
44         /**
45          * テンプレートにデータ埋め込む
46          *
47          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
48          *
49          * @param RequestManager $request               HTTPリクエスト処理クラス
50          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
51          * @param                                                               なし
52          */
53         function _assign($request, &$param)
54         {
55                 $defaultLang    = $this->gEnv->getDefaultLanguage();
56                 $act = $request->trimValueOf('act');
57                 
58                 $showTitle      = ($request->trimValueOf('item_show_title') == 'on') ? 1 : 0;                   // コンテンツタイトルを表示するかどうか
59                 $showMessageDeny = $request->trimValueOf('item_show_message_deny');                                     // アクセス不可の場合にメッセージを表示するかどうか
60                 $messageDeny = $request->trimValueOf('item_message_deny');                                                      // アクセス不可の場合のメッセージ
61                 $showEdit       = ($request->trimValueOf('item_show_edit') == 'on') ? 1 : 0;                    // 編集ボタンを表示するかどうか
62                 
63                 $useJQuery      = ($request->trimValueOf('item_use_jquery') == 'on') ? 1 : 0;                   // jQueryスクリプトを作成するかどうか
64                 $useContentTemplate     = ($request->trimValueOf('item_use_content_template') == 'on') ? 1 : 0;                 // コンテンツ単位のテンプレート設定を行うかどうか
65                 $usePassword    = ($request->trimValueOf('item_use_password') == 'on') ? 1 : 0;         // パスワードを使用するかどうか
66                 $passwordContent = $request->valueOf('item_password_content');                                  // パスワード入力画面用コンテンツ
67                 $layoutViewDetail = $request->valueOf('item_layout_view_detail');                                       // コンテンツレイアウト(詳細表示)
68                 $outputHead     = ($request->trimValueOf('item_output_head') == 'on') ? 1 : 0;          // ヘッダ出力するかどうか
69                 $headViewDetail = $request->valueOf('item_head_view_detail');                                   // ヘッダ出力(詳細表示)
70                 
71                 // デバイスタイプごとの処理
72                 if (default_contentCommonDef::$_deviceType == 2){               // スマートフォンの場合
73                         $jQueryMobileFormat     = ($request->trimValueOf('item_jquery_mobile_format') == 'on') ? 1 : 0;                 // jQueryMobile用のフォーマットで出力するかどうか
74                 }
75                 
76                 if ($act == 'update'){          // 設定更新のとき
77                         // 入力値のエラーチェック
78                         
79                         if ($this->getMsgCount() == 0){                 // エラーのないとき
80                                 $paramObj = new stdClass;
81                                 $paramObj->showTitle    = $showTitle;                   // コンテンツタイトルを表示するかどうか
82                                 $paramObj->showMessageDeny = $showMessageDeny;                                  // アクセス不可の場合にメッセージを表示するかどうか
83                                 $paramObj->messageDeny = $messageDeny;                                                  // アクセス不可の場合のメッセージ
84                                 $paramObj->showEdit     = $showEdit;                    // 編集ボタンを表示するかどうか
85                                 
86                                 // デバイスタイプごとの処理
87                                 if (default_contentCommonDef::$_deviceType == 2){               // スマートフォンの場合
88                                         $paramObj->jQueryMobileFormat = $jQueryMobileFormat;                    // jQueryMobile用のフォーマットで出力するかどうか
89                                 }
90                                 $ret = $this->updateWidgetParamObj($paramObj);
91                                 
92                                 if (empty($layoutViewDetail)) $layoutViewDetail = default_contentCommonDef::DEFAULT_CONTENT_LAYOUT;
93                                 if (empty($headViewDetail)) $headViewDetail = default_contentCommonDef::DEFAULT_HEAD_VIEW_DETAIL;
94                                 
95                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_USE_JQUERY, $useJQuery);           // jQueryスクリプトを作成するかどうか
96                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_USE_CONTENT_TEMPLATE, $useContentTemplate);// コンテンツ単位のテンプレート設定を行うかどうか
97                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_USE_PASSWORD, $usePassword);               // パスワードを使用するかどうか
98                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_PASSWORD_CONTENT, $passwordContent);               // パスワード入力画面用コンテンツ
99                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_LAYOUT_VIEW_DETAIL, $layoutViewDetail);
100                                                                                                                                                                                                                                 // コンテンツレイアウト(詳細表示)
101                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_OUTPUT_HEAD, $outputHead);         // ヘッダ出力するかどうか                                                                                                                                                                                            
102                                 if ($ret) $ret = self::$_mainDb->updateConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_HEAD_VIEW_DETAIL, $headViewDetail);
103                                                                                                                                                                                                                                 // ヘッダ出力(詳細表示)
104                                 
105                                 if ($ret){
106                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
107                                 } else {
108                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
109                                 }
110                                 $this->gPage->updateParentWindow();// 親ウィンドウを更新
111                         }
112                 } else {                // 初期表示の場合
113                         // デフォルト値設定
114                         $showTitle = 0;                 // コンテンツタイトルを表示するかどうか
115                         $showMessageDeny = 1;                                   // アクセス不可の場合にメッセージを表示するかどうか
116                         $messageDeny = self::DEFAULT_MESSAGE_DENY;                                                      // アクセス不可の場合のメッセージ
117                         $showEdit = 1;                  // 編集ボタンを表示するかどうか
118                         $useJQuery = 0;         // jQueryスクリプトを作成するかどうか
119                         $useContentTemplate = 0;// コンテンツ単位のテンプレート設定を行うかどうか
120                         $usePassword = 0;               // パスワードを使用するかどうか
121                         $passwordContent = '';          // パスワード入力画面用コンテンツ
122                         $layoutViewDetail = default_contentCommonDef::DEFAULT_CONTENT_LAYOUT;                                   // コンテンツレイアウト(詳細表示)
123                         $outputHead = 0;                // ヘッダ出力するかどうか
124                         $headViewDetail = default_contentCommonDef::DEFAULT_HEAD_VIEW_DETAIL;                                   // ヘッダ出力(詳細表示)
125                         
126                         // デバイスタイプごとの処理
127                         if (default_contentCommonDef::$_deviceType == 2){               // スマートフォンの場合
128                                 $jQueryMobileFormat = 1;                        // jQueryMobile用のフォーマットで出力するかどうか
129                         }
130                         
131                         $paramObj = $this->getWidgetParamObj();
132                         if (!empty($paramObj)){
133                                 $showTitle = $paramObj->showTitle;                      // コンテンツタイトルを表示するかどうか
134                                 $showMessageDeny = $paramObj->showMessageDeny;                                  // アクセス不可の場合にメッセージを表示するかどうか
135                                 $messageDeny = $paramObj->messageDeny;                                                  // アクセス不可の場合のメッセージ
136                                 $showEdit = $paramObj->showEdit;                        // 編集ボタンを表示するかどうか
137                                 
138                                 // デバイスタイプごとの処理
139                                 if (default_contentCommonDef::$_deviceType == 2){               // スマートフォンの場合
140                                         $jQueryMobileFormat = $paramObj->jQueryMobileFormat;                    // jQueryMobile用のフォーマットで出力するかどうか
141                                 }
142                         }
143                         
144                         $useJQuery = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_USE_JQUERY);              // jQueryスクリプトを作成するかどうか
145                         $useContentTemplate = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_USE_CONTENT_TEMPLATE);// コンテンツ単位のテンプレート設定を行うかどうか
146                         $usePassword = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_USE_PASSWORD);          // パスワードを使用するかどうか
147                         $passwordContent = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_PASSWORD_CONTENT);          // パスワード入力画面用コンテンツ
148                         $layoutViewDetail = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_LAYOUT_VIEW_DETAIL);               // コンテンツレイアウト(詳細表示)
149                         $outputHead = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_OUTPUT_HEAD);            // ヘッダ出力するかどうか
150                         $headViewDetail = self::$_mainDb->getConfig(default_contentCommonDef::$_contentType, default_contentCommonDef::$CF_HEAD_VIEW_DETAIL);           // ヘッダ出力(詳細表示)
151                 }
152                 
153                 // 画面に書き戻す
154                 $checked = '';
155                 if (!empty($showTitle)) $checked = 'checked';
156                 $this->tmpl->addVar("_widget", "show_title", $checked);         // コンテンツタイトルを表示するかどうか
157                 $checked = '';
158                 if (!empty($showMessageDeny)) $checked = 'checked';
159                 $this->tmpl->addVar("_widget", "show_message_deny", $checked);          // アクセス不可の場合にメッセージを表示するかどうか
160                 $this->tmpl->addVar("_widget", "message_deny", $messageDeny);           // アクセス不可の場合のメッセージ
161                 $checked = '';
162                 if (!empty($showEdit)) $checked = 'checked';
163                 $this->tmpl->addVar("_widget", "show_edit", $checked);          // 編集ボタンを表示するかどうか
164                 
165                 $checked = '';
166                 if (!empty($useJQuery)) $checked = 'checked';
167                 $this->tmpl->addVar("_widget", "use_jquery", $checked);         // jQueryスクリプトを作成するかどうか
168                 $checked = '';
169                 if (!empty($useContentTemplate)) $checked = 'checked';
170                 $this->tmpl->addVar("_widget", "use_content_template", $checked);// コンテンツ単位のテンプレート設定を行うかどうか
171                 $checked = '';
172                 if (!empty($usePassword)) $checked = 'checked';
173                 $this->tmpl->addVar("_widget", "use_password", $checked);               // パスワードを使用するかどうか
174                 $this->tmpl->addVar("_widget", "password_content", $passwordContent);           // パスワード入力画面用コンテンツ
175                 $this->tmpl->addVar("_widget", "layout_view_detail", $layoutViewDetail);                // コンテンツレイアウト(詳細表示)
176                 $checked = '';
177                 if (!empty($outputHead)) $checked = 'checked';
178                 $this->tmpl->addVar("_widget", "output_head_checked", $checked);                // ヘッダ出力するかどうか
179                 $this->tmpl->addVar("_widget", "head_view_detail", $headViewDetail);            // ヘッダ出力(詳細表示)
180                 
181                 // デバイスタイプごとの画面作成
182                 switch (default_contentCommonDef::$_deviceType){
183                         case 0:         // PC
184                                 break;
185                         case 1:         // 携帯
186                                 break;
187                         case 2:         // スマートフォン
188                                 $this->tmpl->setAttribute('option_smartphone', 'visibility', 'visible');
189                                 
190                                 $checked = '';
191                                 if (!empty($jQueryMobileFormat)) $checked = 'checked';
192                                 $this->tmpl->addVar("option_smartphone", "jquery_mobile_format_checked", $checked);             // jQueryMobile用のフォーマットで出力するかどうか
193                                 break;
194                 }
195         }
196 }
197 ?>