7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
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
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/blog_mainCommonDef.php');
18 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blog_mainDb.php');
20 class blog_mainBaseWidgetContainer extends BaseWidgetContainer
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; // デフォルトのカテゴリ数
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';
41 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
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ファイル
52 function __construct()
55 parent::__construct();
58 if (!isset(self::$_localDb)) self::$_localDb = new blog_mainDb();
61 if (!isset(self::$_configArray)) $this->_loadConfig();*/
63 if (!isset(self::$_mainDb)) self::$_mainDb = new blog_mainDb();
66 if (!isset(self::$_configArray)) self::$_configArray = blog_mainCommonDef::loadConfig(self::$_mainDb);
68 $this->_langId = $this->gEnv->getCurrentLanguage(); // 現在の言語
69 $this->_userId = $this->gEnv->getCurrentUserId(); // 現在のユーザ
70 $this->_isMultiLang = $this->gEnv->isMultiLanguageSite(); // 多言語対応画面かどうか
75 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
77 * @param RequestManager $request HTTPリクエスト処理クラス
78 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
81 function _postAssign($request, &$param)
83 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND); // 実行コマンドを取得
84 if ($cmd != M3_REQUEST_CMD_DO_WIDGET) return; // 単体実行以外のときは終了
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; // シンプルウィンドウのときはメニューを表示しない
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); // 所属ブログ
97 case 'entry': // ブログ記事
98 case 'entry_detail': // ブログ記事詳細
99 $linkList = ' >> 記事';// パンくずリスト
101 case 'comment': // ブログ記事コメント
102 case 'comment_detail': // ブログ記事コメント
103 $linkList = ' >> コメント';// パンくずリスト
105 /* case 'user': // ユーザ管理
106 case 'user_detail': // ユーザ管理(詳細)
107 $linkList = ' >> ユーザ管理 >> ユーザ一覧';// パンくずリスト
109 case 'config': // ブログ設定
110 $linkList = ' >> 基本設定 >> ブログ設定';// パンくずリスト
112 case 'category': // カテゴリ設定
113 case 'category_detail': // カテゴリ設定
114 $linkList = ' >> 基本設定 >> カテゴリ';// パンくずリスト
116 case 'blogid': // マルチブログ設定
117 case 'blogid_detail': // マルチブログ設定
118 $linkList = ' >> 基本設定 >> マルチブログ';// パンくずリスト
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;
127 // ####### 上段メニューの作成 #######
128 /* $menuText = '<div id="configmenu-upper">' . M3_NL;
129 $menuText .= '<ul>' . M3_NL;
132 //$baseUrl = $this->getAdminUrlWithOptionParam();
136 $link = $baseUrl . '&task=entry';
137 if ($task == 'entry' ||
138 $task == 'entry_detail' ||
139 $task == 'comment' || // ブログ記事コメント管理
140 $task == 'comment_detail'){
141 $current = 'id="current"';
143 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>ブログ記事</span></a></li>' . M3_NL;
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"';
155 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link) .'"><span>基本設定</span></a></li>' . M3_NL;
158 $menuText .= '</ul>' . M3_NL;
159 $menuText .= '</div>' . M3_NL;*/
161 // ####### 下段メニューの作成 #######
162 $menuText .= '<div id="configmenu-lower">' . M3_NL;
163 $menuText .= '<ul>' . M3_NL;
165 if ($task == 'entry' || // ブログ記事管理
166 $task == 'entry_detail' ||
167 $task == 'comment' || // ブログ記事コメント管理
168 $task == 'comment_detail'){
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;
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'){ // ブログ設定
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;
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;
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;
209 $menuText .= '</ul>' . M3_NL;
210 $menuText .= '</div>' . M3_NL;
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);
220 * @return bool true=取得成功、false=取得失敗
222 /* function _loadConfig()
224 self::$_configArray = array();
227 //$ret = $this->_db->getAllConfig($rows);
228 $ret = self::$_localDb->getAllConfig($rows);
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;