OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / photo_main / include / container / admin_photo_mainBaseWidgetContainer.php
1 <?php
2 /**
3  * index.php用コンテナクラス
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_photo_mainBaseWidgetContainer.php 5599 2013-02-06 11:47:30Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/photo_mainCommonDef.php');
17 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
18 require_once($gEnvManager->getCurrentWidgetDbPath() . '/photo_mainDb.php');
19
20 class admin_photo_mainBaseWidgetContainer extends BaseAdminWidgetContainer
21 {
22         protected static $_mainDb;                      // DB接続オブジェクト
23         protected static $_configArray;         // BBS定義値
24         protected static $_isLimitedUser;               // 使用制限ユーザ(画像投稿者)かどうか
25         protected $_openBy;                             // ウィンドウオープンタイプ
26         protected $_baseUrl;                    // 管理画面のベースURL
27         protected $_langId;                     // 現在の言語
28         protected $_userId;                     // 現在のユーザ
29         protected $_errMessage;         // エラーメッセージ
30 /*      const CF_RECEIVE_COMMENT                = 'receive_comment';            // コメントを受け付けるかどうか
31         const CF_RECEIVE_TRACKBACK              = 'receive_trackback';          // トラックバックを受け付けるかどうか
32         const CF_ENTRY_VIEW_COUNT               = 'entry_view_count';                   // 記事表示数
33         const CF_ENTRY_VIEW_ORDER               = 'entry_view_order';                   // 記事表示方向
34         const CF_MAX_COMMENT_LENGTH             = 'comment_max_length';         // コメント最大文字数
35         const CF_USE_MULTI_BLOG         = 'use_multi_blog';             // マルチブログ機能を使用するかどうか
36         const CF_MULTI_BLOG_TOP_CONTENT = 'multi_blog_top_content';             // マルチブログ時のトップコンテンツ
37         const CF_CATEGORY_COUNT                 = 'category_count';             // カテゴリ数
38         const DEFAULT_COMMENT_LENGTH    = 300;                          // デフォルトのコメント最大文字数
39         const DEFAULT_CATEGORY_COUNT    = 2;                            // デフォルトのカテゴリ数
40         */
41         const DEFAULT_TASK = 'imagebrowse';                     // デフォルトの画面
42         
43         // カレンダー用スクリプト
44         const CALENDAR_SCRIPT_FILE = '/jscalendar-1.0/calendar.js';             // カレンダースクリプトファイル
45         const CALENDAR_LANG_FILE = '/jscalendar-1.0/lang/calendar-ja.js';       // カレンダー言語ファイル
46         const CALENDAR_SETUP_FILE = '/jscalendar-1.0/calendar-setup.js';        // カレンダーセットアップファイル
47         const CALENDAR_CSS_FILE = '/jscalendar-1.0/calendar-win2k-1.css';               // カレンダー用CSSファイル
48         
49         /**
50          * コンストラクタ
51          */
52         function __construct()
53         {
54                 // 親クラスを呼び出す
55                 parent::__construct();
56                 
57                 // DBオブジェクト作成
58                 if (!isset(self::$_mainDb)) self::$_mainDb = new photo_mainDb();
59                         
60                 // ブログ定義を読み込む
61                 if (!isset(self::$_configArray)) self::$_configArray = photo_mainCommonDef::loadConfig(self::$_mainDb);
62                 
63                 // システム運用者の場合は、ユーザオプションがあればユーザ専用ディレクトリに制限
64                 if (!isset(self::$_isLimitedUser)){
65                         $ret = $this->gEnv->hasUserTypeOption(photo_mainCommonDef::USER_OPTION);
66                         if ($ret){
67                                 self::$_isLimitedUser = true;           // 使用制限ユーザ(画像投稿者)かどうか
68                         } else {
69                                 self::$_isLimitedUser = false;
70                         }
71                 }
72                 
73                 // 変数初期化
74                 $this->_langId  = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
75                 $this->_userId = $this->gEnv->getCurrentUserId();
76         }
77         /**
78          * テンプレートに前処理
79          *
80          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
81          *
82          * @param RequestManager $request               HTTPリクエスト処理クラス
83          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
84          * @return                                                              なし
85          */
86         function _preAssign($request, &$param)
87         {
88                 $this->openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY);                // ウィンドウオープンタイプ
89                 if (!empty($this->openBy)) $this->addOptionUrlParam(M3_REQUEST_PARAM_OPEN_BY, $this->openBy);
90                 
91                 // 管理画面ペースURL取得
92                 $this->_baseUrl = $this->getAdminUrlWithOptionParam();
93         }
94         /**
95          * テンプレートにデータ埋め込む
96          *
97          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
98          *
99          * @param RequestManager $request               HTTPリクエスト処理クラス
100          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
101          * @return                                                              なし
102          */
103         function _postAssign($request, &$param)
104         {
105                 if ($this->openBy == 'simple') return;                  // シンプルウィンドウのときはメニューを表示しない
106                 
107                 // 使用限定ユーザの場合はメニュー表示しない
108                 if (self::$_isLimitedUser) return;
109                 
110                 // 表示画面を決定
111                 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
112                 if (empty($task)) $task = self::DEFAULT_TASK;
113                 
114                 // 画像取得の場合は終了
115                 if ($task == 'imagebrowse_direct') return;
116                 
117                 // パンくずリストを作成
118                 switch ($task){
119                         case 'imagebrowse':             // 画像管理
120                         case 'imagebrowse_detail':      // 画像管理詳細
121                                 $linkList = ' &gt;&gt; 画像管理 &gt;&gt; 画像一覧';// パンくずリスト
122                                 break;
123                         case 'comment':         // 画像コメント
124                         case 'comment_detail':  // 画像コメント
125                                 $linkList = ' &gt;&gt; 画像管理 &gt;&gt; コメント一覧';// パンくずリスト
126                                 break;
127                         case 'author':          // 画像管理者一覧
128                         case 'author_detail':   // 画像管理者詳細
129                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; 画像管理者一覧';// パンくずリスト
130                                 break;
131                         case 'category':                // 画像カテゴリー一覧
132                         case 'category_detail': // 画像カテゴリー詳細
133                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; 画像カテゴリー一覧';// パンくずリスト
134                                 break;
135                         case 'search':          // 検索条件
136                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; 検索条件';// パンくずリスト
137                                 break;
138                         case 'config':          // フォトギャラリー設定
139                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; フォトギャラリー設定';// パンくずリスト
140                                 break;
141                 }
142
143                 // ####### 上段メニューの作成 #######
144                 $menuText = '<div id="configmenu-upper">' . M3_NL;
145                 $menuText .= '<ul>' . M3_NL;
146                 
147                 $current = '';
148                 
149                 // 画像管理
150                 $current = '';
151                 $link = $this->_baseUrl . '&task=imagebrowse';
152                 if ($task == 'imagebrowse' ||
153                         $task == 'imagebrowse_detail' ||
154                         $task == 'comment' ||           // 画像コメント一覧
155                         $task == 'comment_detail'){             // 画像コメント詳細
156                         $current = 'id="current"';
157                 }
158                 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>画像管理</span></a></li>' . M3_NL;
159                 
160                 // 基本設定
161                 $current = '';
162                 $link = $this->_baseUrl . '&task=author';
163                 if ($task == 'author' ||                // 画像管理者一覧
164                         $task == 'author_detail' ||             // 画像管理者詳細
165                         $task == 'category' ||          // 画像カテゴリー一覧
166                         $task == 'category_detail' ||           // 画像カテゴリー詳細
167                         $task == 'search' ||            // 検索条件
168                         $task == 'config'){             // ブログ設定
169                         $current = 'id="current"';
170                 }
171                 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>基本設定</span></a></li>' . M3_NL;
172                 
173                 // 上段メニュー終了
174                 $menuText .= '</ul>' . M3_NL;
175                 $menuText .= '</div>' . M3_NL;
176                 
177                 // ####### 下段メニューの作成 #######          
178                 $menuText .= '<div id="configmenu-lower">' . M3_NL;
179                 $menuText .= '<ul>' . M3_NL;
180
181                 if ($task == 'imagebrowse' ||
182                         $task == 'imagebrowse_detail' ||
183                         $task == 'comment' ||           // 画像コメント一覧
184                         $task == 'comment_detail'){             // 画像コメント詳細
185                         
186                         // 画像一覧
187                         $current = '';
188                         $link = $this->_baseUrl . '&task=imagebrowse';
189                         if ($task == 'imagebrowse' || $task == 'imagebrowse_detail') $current = 'id="current"';
190                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>画像一覧</span></a></li>' . M3_NL;
191                         
192                         // 画像コメント一覧
193                         $current = '';
194                         $link = $this->_baseUrl . '&task=comment';
195                         if ($task == 'comment' || $task == 'comment_detail') $current = 'id="current"';
196                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>コメント一覧</span></a></li>' . M3_NL;
197                 } else if ($task == 'author' ||         // 画像管理者一覧
198                         $task == 'author_detail' ||             // 画像管理者詳細
199                         $task == 'category' ||          // 画像カテゴリー一覧
200                         $task == 'category_detail' ||           // 画像カテゴリー詳細
201                         $task == 'search' ||            // 検索条件
202                         $task == 'config'){             // ブログ設定
203
204                         // 画像管理者
205                         $current = '';
206                         $link = $this->_baseUrl . '&task=author';
207                         if ($task == 'author' || $task == 'author_detail') $current = 'id="current"';
208                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>画像管理者</span></a></li>' . M3_NL;
209                         
210                         // 画像カテゴリー
211                         $current = '';
212                         $link = $this->_baseUrl . '&task=category';
213                         if ($task == 'category' || $task == 'category_detail') $current = 'id="current"';
214                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>画像カテゴリー</span></a></li>' . M3_NL;
215                         
216                         // 検索条件
217                         $current = '';
218                         $link = $this->_baseUrl . '&task=search';
219                         if ($task == 'search') $current = 'id="current"';
220                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>検索条件</span></a></li>' . M3_NL;
221                         
222                         // その他設定
223                         $current = '';
224                         $link = $this->_baseUrl . '&task=config';
225                         if ($task == 'config') $current = 'id="current"';
226                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>フォトギャラリー設定</span></a></li>' . M3_NL;
227                 }
228                 
229                 // 下段メニュー終了
230                 $menuText .= '</ul>' . M3_NL;
231                 $menuText .= '</div>' . M3_NL;
232
233                 // 作成データの埋め込み
234                 $linkList = '<div id="configmenu-top"><label>' . 'フォトギャラリー' . $linkList . '</div>';
235                 $outputText .= '<table width="90%"><tr><td>' . $linkList . $menuText . '</td></tr></table>' . M3_NL;
236                 $this->tmpl->addVar("_widget", "menu_items", $outputText);
237         }
238         /**
239          * DB定義値を更新
240          *
241          * @param array $values キーと値の連想配列
242          * @return bool                 true=成功、false=失敗
243          */
244         function _updateConfig($values)
245         {
246                 if (empty($values)) return false;
247                 
248                 foreach ($values as $key => $value){
249                         $ret = self::$_mainDb->updateConfig($key, $value);
250                         if (!$ret){
251                                 $this->_errMessage = $key;
252                                 break;
253                         }
254                 }
255                 return $ret;
256         }
257         /**
258          * エラーメッセージを取得
259          *
260          * @return string                       メッセージ
261          */
262         function _getErrMessage()
263         {
264                 return $this->_errMessage;              // エラーメッセージ
265         }
266 }
267 ?>