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-2013 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: admin_loginuserWidgetContainer.php 5816 2013-03-11 13:24:26Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_loginuserDb.php');
19 class admin_loginuserWidgetContainer extends BaseWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $langId; // 言語
23 const DEFAULT_TITLE = 'ログインユーザ'; // デフォルトのウィジェットタイトル名
24 // const ICON_SIZE = 128; // アイコンのサイズ
29 function __construct()
32 parent::__construct();
35 $this->db = new admin_loginuserDb();
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 'index.tmpl.html';
54 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
56 * @param RequestManager $request HTTPリクエスト処理クラス
57 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
60 function _assign($request, &$param)
62 $userId = $this->gEnv->getCurrentUserId();
63 $avatarFormat = $this->gInstance->getImageManager()->getDefaultAvatarFormat(); // 画像フォーマット取得
66 $ret = $this->db->getLoginUserInfo($userId, $row);
68 $name = $row['lu_name']; // ユーザ名
69 $avatar = $row['lu_avatar']; // アバター
70 $loginCount = $row['ll_login_count']; // ログイン回数
71 $loginDt = $row['ll_pre_login_dt']; // 前回ログイン日時
73 $userDetailUrl = '?task=userlist_detail&' . M3_REQUEST_PARAM_USER_ID . '=' . $row['lu_id']; // ユーザ詳細画面URL
74 $loginStatusUrl = '?task=loginstatus_history&account=' . $row['lu_account'];// ログイン状況画面URL
78 $this->gInstance->getImageManager()->parseImageFormat($avatarFormat, $imageType, $imageAttr, $imageSize); // 画像情報取得
79 $avatarUrl = $this->gInstance->getImageManager()->getAvatarUrl($avatar);
80 $iconTitle = 'アバター画像';
81 $iconTag = '<img src="' . $this->getUrl($avatarUrl) . '" width="' . $imageSize . '" height="' . $imageSize . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
84 $this->tmpl->addVar("_widget", "name", $this->convertToDispString($name));
85 $this->tmpl->addVar("_widget", "login_count", $loginCount);
86 $this->tmpl->addVar("_widget", "avatar_image", $iconTag);
87 // 前回ログイン日時。年が同じ場合は省略。
88 if (intval(date('Y', strtotime($loginDt))) == intval(date('Y'))){
89 $this->tmpl->addVar("_widget", "login_dt", $this->convertToDispDateTime($loginDt, 11/*年省略,0なし年月*/, 10/*時分表示*/));
91 $this->tmpl->addVar("_widget", "login_dt", $this->convertToDispDateTime($loginDt, 0, 10/*時分表示*/));
94 $this->tmpl->addVar("_widget", "user_detail_url", $this->convertUrlToHtmlEntity($userDetailUrl)); // ユーザ詳細画面URL
95 $this->tmpl->addVar("_widget", "login_status_url", $this->convertUrlToHtmlEntity($loginStatusUrl)); // ログイン状況画面URL
100 * @param RequestManager $request HTTPリクエスト処理クラス
101 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
102 * @return string ウィジェットのタイトル名
104 function _setTitle($request, &$param)
106 return self::DEFAULT_TITLE;