OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / blog_main / include / container / blog_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-2012 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: blog_mainBaseWidgetContainer.php 5145 2012-08-29 13:21:42Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/blog_mainCommonDef.php');
18 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blog_mainDb.php');
19
20 class blog_mainBaseWidgetContainer extends BaseWidgetContainer
21 {
22         protected static $_mainDb;                      // DB接続オブジェクト
23         protected static $_configArray;         // ブログ定義値
24         protected static $_paramObj;            // ウィジェットパラメータオブジェクト
25         protected static $_canEditEntry;        // 記事が編集可能かどうか
26         protected $_langId;                     // 現在の言語
27         protected $_userId;                     // 現在のユーザ
28         protected $_isMultiLang;                        // 多言語対応画面かどうか
29         const DEFAULT_COMMENT_LENGTH    = 300;                          // デフォルトのコメント最大文字数
30         const DEFAULT_CATEGORY_COUNT    = 2;                            // デフォルトのカテゴリ数
31         
32         // 画面
33         const TASK_TOP                  = 'top';                        // トップ画面
34         const TASK_ENTRY                = 'entry';                      // 記事編集画面
35         const TASK_ENTRY_DETAIL = 'entry_detail';                       // 記事編集画面詳細
36         const TASK_COMMENT              = 'comment';            // ブログ記事コメント管理
37         const TASK_COMMENT_DETAIL = 'comment_detail';           // ブログ記事コメント管理(詳細)
38         const DEFAULT_TASK              = 'top';
39                         
40         // アドオンオブジェクト用
41         const BLOG_OBJ_ID = 'bloglib';          // ブログオブジェクトID
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::$_localDb)) self::$_localDb = new blog_mainDb();
59                         
60                 // ブログ定義を読み込む
61                 if (!isset(self::$_configArray)) $this->_loadConfig();*/
62                 // DBオブジェクト作成
63                 if (!isset(self::$_mainDb)) self::$_mainDb = new blog_mainDb();
64                 
65                 // ブログ定義を読み込む
66                 if (!isset(self::$_configArray)) self::$_configArray = blog_mainCommonDef::loadConfig(self::$_mainDb);
67                 
68                 $this->_langId = $this->gEnv->getCurrentLanguage();                     // 現在の言語
69                 $this->_userId = $this->gEnv->getCurrentUserId();               // 現在のユーザ
70                 $this->_isMultiLang = $this->gEnv->isMultiLanguageSite();                       // 多言語対応画面かどうか
71         }
72         /**
73          * テンプレートにデータ埋め込む
74          *
75          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
76          *
77          * @param RequestManager $request               HTTPリクエスト処理クラス
78          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
79          * @return                                                              なし
80          */
81         function _postAssign($request, &$param)
82         {
83                 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);               // 実行コマンドを取得
84                 if ($cmd != M3_REQUEST_CMD_DO_WIDGET) return;           // 単体実行以外のときは終了
85                 
86                 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY);              // ウィンドウオープンタイプ
87                 //if (!empty($openBy)) $this->addOptionUrlParam(M3_REQUEST_PARAM_OPEN_BY, $openBy);
88                 if ($openBy == 'simple') return;                        // シンプルウィンドウのときはメニューを表示しない
89                 
90                 // 表示画面を決定
91                 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
92                 if (empty($task)) $task = self::DEFAULT_TASK;
93                 $blogId = $request->trimValueOf(M3_REQUEST_PARAM_BLOG_ID);              // 所属ブログ
94                 
95                 // パンくずリストを作成
96                 switch ($task){
97                         case 'entry':           // ブログ記事
98                         case 'entry_detail':    // ブログ記事詳細
99                                 $linkList = ' &gt;&gt; 記事';// パンくずリスト
100                                 break;
101                         case 'comment':         // ブログ記事コメント
102                         case 'comment_detail':  // ブログ記事コメント
103                                 $linkList = ' &gt;&gt; コメント';// パンくずリスト
104                                 break;
105 /*                      case 'user':            // ユーザ管理
106                         case 'user_detail':             // ユーザ管理(詳細)
107                                 $linkList = ' &gt;&gt; ユーザ管理 &gt;&gt; ユーザ一覧';// パンくずリスト
108                                 break;
109                         case 'config':          // ブログ設定
110                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; ブログ設定';// パンくずリスト
111                                 break;
112                         case 'category':                // カテゴリ設定
113                         case 'category_detail':         // カテゴリ設定
114                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; カテゴリ';// パンくずリスト
115                                 break;
116                         case 'blogid':          // マルチブログ設定
117                         case 'blogid_detail':           // マルチブログ設定
118                                 $linkList = ' &gt;&gt; 基本設定 &gt;&gt; マルチブログ';// パンくずリスト
119                                 break;*/
120                 }
121                 // ベースURL作成
122                 $urlparam  = M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET . '&';
123                 $urlparam .= M3_REQUEST_PARAM_WIDGET_ID . '=' . $this->gEnv->getCurrentWidgetId() .'&';
124                 $urlparam .= 'openby=other&' . M3_REQUEST_PARAM_BLOG_ID . '=' . $blogId;
125                 $baseUrl = $this->gEnv->getDefaultUrl() . '?' . $urlparam;
126                                 
127                 // ####### 上段メニューの作成 #######
128 /*              $menuText = '<div id="configmenu-upper">' . M3_NL;
129                 $menuText .= '<ul>' . M3_NL;
130                 
131                 $current = '';
132                 //$baseUrl = $this->getAdminUrlWithOptionParam();
133                 
134                 // ブログ記事管理
135                 $current = '';
136                 $link = $baseUrl . '&task=entry';
137                 if ($task == 'entry' ||
138                         $task == 'entry_detail' ||
139                         $task == 'comment' ||           // ブログ記事コメント管理
140                         $task == 'comment_detail'){
141                         $current = 'id="current"';
142                 }
143                 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>ブログ記事</span></a></li>' . M3_NL;
144                 
145                 // 基本設定
146                 $current = '';
147                 $link = $baseUrl . '&task=category';
148                 if ($task == 'category' ||              // カテゴリ設定
149                         $task == 'category_detail' ||           // カテゴリ設定
150                         $task == 'blogid' ||            // マルチブログ
151                         $task == 'blogid_detail' ||             // マルチブログ詳細
152                         $task == 'config'){             // ブログ設定
153                         $current = 'id="current"';
154                 }
155                 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>基本設定</span></a></li>' . M3_NL;
156                 
157                 // 上段メニュー終了
158                 $menuText .= '</ul>' . M3_NL;
159                 $menuText .= '</div>' . M3_NL;*/
160                 
161                 // ####### 下段メニューの作成 #######          
162                 $menuText .= '<div id="configmenu-lower">' . M3_NL;
163                 $menuText .= '<ul>' . M3_NL;
164
165                 if ($task == 'entry' ||         // ブログ記事管理
166                         $task == 'entry_detail' ||
167                         $task == 'comment' ||           // ブログ記事コメント管理
168                         $task == 'comment_detail'){
169                         
170                         // ブログ記事一覧
171                         $current = '';
172                         //$link = $baseUrl . '&task=entry';
173                         $link = $baseUrl . '&task=entry_detail';                // 詳細をデフォルトにする
174                         if ($task == 'entry' || $task == 'entry_detail') $current = 'id="current"';
175                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>記事</span></a></li>' . M3_NL;
176                         
177                         // ブログ記事コメント一覧
178                         $current = '';
179                         $link = $baseUrl . '&task=comment';
180                         if ($task == 'comment' || $task == 'comment_detail') $current = 'id="current"';
181                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>コメント</span></a></li>' . M3_NL;
182 /*              } else if ($task == 'category' ||               // カテゴリ設定
183                         $task == 'category_detail' ||           // カテゴリ設定
184                         $task == 'blogid' ||            // マルチブログ
185                         $task == 'blogid_detail' ||             // マルチブログ詳細
186                         $task == 'config'){             // ブログ設定
187                         
188                         // カテゴリ設定
189                         $current = '';
190                         $link = $baseUrl . '&task=category';
191                         if ($task == 'category' || $task == 'category_detail') $current = 'id="current"';
192                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>カテゴリ</span></a></li>' . M3_NL;
193                         
194                         // マルチブログ
195                         $current = '';
196                         $link = $baseUrl . '&task=blogid';
197                         if ($task == 'blogid' || $task == 'blogid_detail') $current = 'id="current"';
198                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>マルチブログ</span></a></li>' . M3_NL;
199                         
200                         // その他設定
201                         $current = '';
202                         $link = $baseUrl . '&task=config';
203                         if ($task == 'config') $current = 'id="current"';
204                         $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>ブログ設定</span></a></li>' . M3_NL;
205         */
206                 }
207                 
208                 // 下段メニュー終了
209                 $menuText .= '</ul>' . M3_NL;
210                 $menuText .= '</div>' . M3_NL;
211
212                 // 作成データの埋め込み
213                 $linkList = '<div id="configmenu-top"><label>' . 'ブログ' . $linkList . '</div>';
214                 $outputText .= '<table width="90%"><tr><td>' . $linkList . $menuText . '</td></tr></table>' . M3_NL;
215                 $this->tmpl->addVar("_widget", "menu_items", $outputText);
216         }
217         /**
218          * ブログ定義値をDBから取得
219          *
220          * @return bool                 true=取得成功、false=取得失敗
221          */
222 /*      function _loadConfig()
223         {
224                 self::$_configArray = array();
225
226                 // ブログ定義を読み込み
227                 //$ret = $this->_db->getAllConfig($rows);
228                 $ret = self::$_localDb->getAllConfig($rows);
229                 if ($ret){
230                         // 取得データを連想配列にする
231                         $configCount = count($rows);
232                         for ($i = 0; $i < $configCount; $i++){
233                                 $key = $rows[$i]['bg_id'];
234                                 $value = $rows[$i]['bg_value'];
235                                 self::$_configArray[$key] = $value;
236                         }
237                 }
238                 return $ret;
239         }*/
240 }
241 ?>