OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / admin / loginuser / include / container / admin_loginuserWidgetContainer.php
1 <?php
2 /**
3  * index.php用コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
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
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_loginuserDb.php');
18
19 class admin_loginuserWidgetContainer extends BaseWidgetContainer
20 {
21         private $db;                    // DB接続オブジェクト
22         private $langId;                // 言語
23         const DEFAULT_TITLE = 'ログインユーザ';          // デフォルトのウィジェットタイトル名
24 //      const ICON_SIZE = 128;          // アイコンのサイズ
25                 
26         /**
27          * コンストラクタ
28          */
29         function __construct()
30         {
31                 // 親クラスを呼び出す
32                 parent::__construct();
33                 
34                 // DBオブジェクト作成
35                 $this->db = new admin_loginuserDb();
36         }
37         /**
38          * テンプレートファイルを設定
39          *
40          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
41          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
42          *
43          * @param RequestManager $request               HTTPリクエスト処理クラス
44          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
45          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
46          */
47         function _setTemplate($request, &$param)
48         {
49                 return 'index.tmpl.html';
50         }
51         /**
52          * テンプレートにデータ埋め込む
53          *
54          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
55          *
56          * @param RequestManager $request               HTTPリクエスト処理クラス
57          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
58          * @param                                                               なし
59          */
60         function _assign($request, &$param)
61         {
62                 $userId = $this->gEnv->getCurrentUserId();
63                 $avatarFormat = $this->gInstance->getImageManager()->getDefaultAvatarFormat();          // 画像フォーマット取得
64                 
65                 // ユーザ情報取得
66                 $ret = $this->db->getLoginUserInfo($userId, $row);
67                 if ($ret){
68                         $name           = $row['lu_name'];      // ユーザ名
69                         $avatar         = $row['lu_avatar'];            // アバター
70                         $loginCount = $row['ll_login_count'];   // ログイン回数
71                         $loginDt        = $row['ll_pre_login_dt'];      // 前回ログイン日時
72                         
73                         $userDetailUrl  = '?task=userlist_detail&' . M3_REQUEST_PARAM_USER_ID . '=' . $row['lu_id'];            // ユーザ詳細画面URL
74                         $loginStatusUrl = '?task=loginstatus_history&account=' . $row['lu_account'];// ログイン状況画面URL
75                 }
76                 
77                 // アバター画像取得
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 . '" />';
82                 
83                 // 画面に埋め込む
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/*時分表示*/));
90                 } else {
91                         $this->tmpl->addVar("_widget", "login_dt", $this->convertToDispDateTime($loginDt, 0, 10/*時分表示*/));
92                 }
93                 
94                 $this->tmpl->addVar("_widget", "user_detail_url", $this->convertUrlToHtmlEntity($userDetailUrl));       // ユーザ詳細画面URL
95                 $this->tmpl->addVar("_widget", "login_status_url", $this->convertUrlToHtmlEntity($loginStatusUrl));     // ログイン状況画面URL
96         }
97         /**
98          * ウィジェットのタイトルを設定
99          *
100          * @param RequestManager $request               HTTPリクエスト処理クラス
101          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
102          * @return string                                               ウィジェットのタイトル名
103          */
104         function _setTitle($request, &$param)
105         {
106                 return self::DEFAULT_TITLE;
107         }
108 }
109 ?>