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-2011 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: m_bbs_2chSubjectWidgetContainer.php 4033 2011-03-18 01:43:53Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/m_bbs_2chBaseWidgetContainer.php');
18 class m_bbs_2chSubjectWidgetContainer extends m_bbs_2chBaseWidgetContainer
20 private $isExistsThread; // スレッドが存在するかどうか
25 function __construct()
28 parent::__construct();
33 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
34 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
36 * @param RequestManager $request HTTPリクエスト処理クラス
37 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
38 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
40 function _setTemplate($request, &$param)
42 return 'subject.tmpl.html';
47 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
49 * @param RequestManager $request HTTPリクエスト処理クラス
50 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
53 function _assign($request, &$param)
56 $keyword = $request->trimValueOf(M3_REQUEST_PARAM_KEYWORD);
60 $this->_db->getThread(array($this, 'itemsLoop'), $this->_boardId, -1/*すべて取得*/);
62 $this->_db->getThreadByKeyword(array($this, 'itemsLoop'), $this->_boardId, -1/*すべて取得*/, $keyword);
65 // スレッドが存在しないときはタグを非表示にする
66 if (!$this->isExistsThread) $this->tmpl->setAttribute('itemlist', 'visibility', 'hidden');
69 * 取得したコンテンツ項目をテンプレートに設定する
71 * @param int $index 行番号
72 * @param array $fetchedRow 取得行
73 * @param object $param 任意使用パラメータ
74 * @return bool trueを返すとループ続行。falseを返すとその時点で終了。
76 function itemsLoop($index, $fetchedRow)
79 $threadId = $fetchedRow['th_id'];
81 $subject = $fetchedRow['th_subject'] . '(' . $fetchedRow['th_message_count'] . ')';
82 $url = $this->_currentPageUrl . '&' . M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $threadId;
85 'no' => $no, // インデックス番号
86 'url' => $this->convertUrlToHtmlEntity($this->getUrl($url, true)), // スレッド画面へのリンク
87 'subject' => $this->convertToDispString($subject) // スレッド件名
89 $this->tmpl->addVars('itemlist', $row);
90 $this->tmpl->parseTemplate('itemlist', 'a');
92 $this->isExistsThread = true; // スレッドが存在するかどうか