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_archive_menuWidgetContainer.php 5270 2012-10-04 12:19:21Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blog_archive_menuDb.php');
19 class blog_archive_menuWidgetContainer extends BaseWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $langId; // 言語
23 const TARGET_WIDGET = 'blog_main'; // 呼び出しウィジェットID
24 const DEFAULT_TITLE = 'ブログアーカイブ'; // デフォルトのウィジェットタイトル名
29 function __construct()
32 parent::__construct();
35 $this->db = new blog_archive_menuDb();
40 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
41 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
43 * @param RequestManager $request HTTPリクエスト処理クラス
44 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
45 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
47 function _setTemplate($request, &$param)
49 return 'menu.tmpl.html';
54 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
56 * @param RequestManager $request HTTPリクエスト処理クラス
57 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
60 function _assign($request, &$param)
62 $this->langId = $this->gEnv->getCurrentLanguage(); // 表示言語を取得
64 // #### カテゴリーリストを作成 ####
65 $ret = $this->db->getAllEntry($this->langId, $rows);// デフォルト言語で取得
69 $entryCount = 0; // 記事数
70 $rowCount = count($rows);
71 for ($i = 0; $i < $rowCount; $i++){
73 $this->timestampToYearMonthDay($rows[$i]['be_regist_dt'], $year, $month, $day);
75 if ($year == $foreYear && $month == $foreMonth){ // 年月が変わらないとき
79 if ($entryCount > 0){ // 記事数が0以上のとき
80 $name = $foreYear . '年' . $foreMonth . '月(' . $entryCount . ')';
81 $linkUrl = $this->createCmdUrlToWidget(self::TARGET_WIDGET, 'act=view&year=' . $foreYear . '&month=' . $foreMonth);
83 'link_url' => $this->convertUrlToHtmlEntity($this->getUrl($linkUrl, true/*リンク用*/)), // リンク
84 'name' => $this->convertToDispString($name) // タイトル
86 $this->tmpl->addVars('itemlist', $row);
87 $this->tmpl->parseTemplate('itemlist', 'a');
93 $entryCount = 1; // 記事数
97 if ($entryCount > 0){ // 記事数が0以上のとき
98 $name = $foreYear . '年' . $foreMonth . '月(' . $entryCount . ')';
99 $linkUrl = $this->createCmdUrlToWidget(self::TARGET_WIDGET, 'act=view&year=' . $foreYear . '&month=' . $foreMonth);
101 'link_url' => $this->convertUrlToHtmlEntity($this->getUrl($linkUrl, true/*リンク用*/)), // リンク
102 'name' => $this->convertToDispString($name) // タイトル
104 $this->tmpl->addVars('itemlist', $row);
105 $this->tmpl->parseTemplate('itemlist', 'a');
112 * @param RequestManager $request HTTPリクエスト処理クラス
113 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
114 * @return string ウィジェットのタイトル名
116 function _setTitle($request, &$param)
118 return self::DEFAULT_TITLE;