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-2010 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: m_blogBaseWidgetContainer.php 3836 2010-11-17 06:05:07Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseMobileWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blogDb.php');
19 class m_blogBaseWidgetContainer extends BaseMobileWidgetContainer
21 protected $_db; // DB接続オブジェクト
22 protected $_mobileId; // 携帯ID
23 protected $_blogId; // ブログID
24 protected $_spacer; // スペーサ
25 protected $_currentPageUrl;// 現在のページのURL(携帯用のパラメータ付き)
27 const ERR_MESSAGE_COLOR = '#ff0000'; // エラーメッセージカラー
28 const SPACER_FORMAT = '<div style="background-color:#aaaaaa;margin:1px 0;height:1px;"><img src="%s/images/system/spacer.gif" width="1" height="1" /></div>'; // スペーサフォーマット
29 const LINK_PAGE_COUNT = 5; // リンクページ数
30 const SEARCH_BODY_SIZE = 200; // 検索結果の記事本文の文字列最大長
33 const CF_ENTRY_VIEW_COUNT = 'm:entry_view_count'; // 記事表示数
34 const CF_ENTRY_VIEW_ORDER = 'm:entry_view_order'; // 記事表示方向
35 const CF_SEARCH_COUNT = 'm:search_count'; // 検索記事数
36 const CF_SEARCH_ORDER = 'm:search_order'; // 検索記事表示方向
37 const CF_TITLE_COLOR = 'm:title_color'; // タイトルの背景色
40 const DEFAULT_TASK = 'read'; // デフォルトの画面
41 const TASK_READ = 'read'; // スレッド表示
43 // const URL_PARAM_MEMBER_ID = 'memberid'; // 会員ID
44 // const URL_PARAM_MESSAGE_ID = 'messageid'; // メッセージID
46 const CSS_LINK_STYLE_BOTTOM = 'text-align:center;'; // 下のリンク部のスタイル
47 const CSS_LINK_STYLE_INNER_BOTTOM = 'text-align:right;'; // 内枠の下のリンク部のスタイル
49 const DEFAULT_TITLE_SEARCH = '検索'; // 検索時のデフォルトタイトル
51 const MESSAGE_NO_ENTRY_TITLE = 'ブログ記事未登録';
52 const MESSAGE_NO_ENTRY = 'ブログ記事は登録されていません'; // ブログ記事が登録されていないメッセージ
53 const MESSAGE_FIND_NO_ENTRY = 'ブログ記事が見つかりません';
54 const MESSAGE_EXT_ENTRY = '続きを読む'; // 投稿記事に続きがある場合の表示
55 const MESSAGE_EXT_ENTRY_PRE = '… '; // 投稿記事に続きがある場合の表示
56 const MESSAGE_SEARCH_KEYWORD = '検索キーワード: '; // 検索キーワード用ラベル
58 const CONTENT_TYPE = 'bg'; // 参照数カウント用
63 function __construct()
66 parent::__construct();
69 $this->_mobileId = $this->gEnv->getMobileId();
71 // サブウィジェット起動のときだけ初期処理実行
72 if ($this->gEnv->getIsSubWidget()){
74 $this->_db = new blogDb();
78 $configId = $this->gEnv->getCurrentWidgetConfigId();
82 $this->_loadConfig($this->_blogId);
84 //$this->_currentPageUrl = $this->gEnv->createCurrentPageUrl(); // 現在のページのURL
85 $this->_currentPageUrl = $this->gEnv->createCurrentPageUrlForMobile();// 現在のページのURL(携帯用のパラメータ付き)
88 $this->_spacer = sprintf(self::SPACER_FORMAT, $this->getUrl($this->gEnv->getRootUrl()));
94 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
96 * @param RequestManager $request HTTPリクエスト処理クラス
97 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
100 function _postAssign($request, &$param)
103 $this->tmpl->addVar("_widget", "link_style_bottom", self::CSS_LINK_STYLE_BOTTOM);// 下のリンク部のスタイル
104 $this->tmpl->addVar("_widget", "link_style_inner_bottom", self::CSS_LINK_STYLE_INNER_BOTTOM);// 内枠下のリンク部のスタイル
105 $this->tmpl->addVar('_widget', 'top_url', $this->gEnv->createCurrentPageUrlForMobile(''));
108 if ($this->getMsgCount(1) > 0 || $this->getMsgCount(2) > 0){ // エラーメッセージが出力されているとき
109 $errMessageColor = self::ERR_MESSAGE_COLOR; // エラーメッセージ色
110 $errMessageStyle = '';
111 if (!empty($errMessageColor)) $errMessageStyle .= 'color:' . $errMessageColor . ';';
112 $attr = 'style="' . $errMessageStyle . 'text-align:center;"';
113 $this->setMessageAttr($attr);
114 } else if ($this->getMsgCount(3) > 0){ // ガイダンスメッセージが出力されているとき
115 $attr = 'style="text-align:center;"';
116 $this->setMessageAttr($attr);
122 * @param string $blogId ブログID
123 * @return bool true=取得成功、false=取得失敗
125 function _loadConfig($blogId)
127 $this->_configArray = array();
130 $ret = $this->_db->getAllConfig($rows, $blogId);
133 $configCount = count($rows);
134 for ($i = 0; $i < $configCount; $i++){
135 $key = $rows[$i]['bg_id'];
136 $value = $rows[$i]['bg_value'];
137 $this->_configArray[$key] = $value;
145 * @param string $message 変換元メッセージ
146 * @param string $threadId スレッドID
147 * @return string 変換後メッセージ
149 function convDispMessage($message, $threadId)
152 /*if (!empty($this->_autolink)){ // 自動リンク作成のとき
153 $message = preg_replace("/(https?):\/\/([\w;\/\?:\@&=\+\$,\-\.!~\*'\(\)%#]+)/", "<a href=\"$1://$2\" target=\"_blank\">$1://$2</a>", $message);
156 // $baseUrl = $this->convertUrlToHtmlEntity($this->getUrl($this->_currentPageUrl . '&' . M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $threadId, true));
157 $messageUrl = $baseUrl . $this->convertUrlToHtmlEntity('&' . M3_REQUEST_PARAM_ITEM_NO . '=');
158 $messageListUrl = $baseUrl . $this->convertUrlToHtmlEntity('&' . M3_REQUEST_PARAM_LIST_NO . '=');
159 $message = preg_replace("/>>([0-9]+)(?![-\d])/", '<a href="' . $messageUrl . '$1" target="_blank">>>$1</a>', $message);
160 $message = preg_replace("/>>([0-9]+)\-([0-9]+)/", '<a href="' . $messageListUrl . '$1-$2" target="_blank">>>$1-$2</a>', $message);
165 * テキストデータを表示用のテキストに変換
167 * 変換内容 ・改行コードをスペース「 」に変換
169 * @param string $src 変換するデータ
170 * @return string 変換後データ
172 function _convertToPreviewTextWithSpace($src)
174 return preg_replace("/(\015\012)|(\015)|(\012)/", " ", $src);