Ejemplo n.º 1
0
        </h2>
    </div>
    <div class="panel-body">
        <ul class="avatar-list">
        	<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $tfocus, 'itemView' => '_tview', 'template' => "{items}\n{pager}"));
?>
        </ul>
    </div>
</div>

<div class="panel panel-default low">
    <div class="panel-heading">
        <h2 class="panel-title">粉丝 
        	<span class="badge"><?php 
echo Focus::countTfocus($model->id);
?>
</span>
        	<span class="pull-right"><a href="<?php 
echo Yii::app()->createUrl('/set/profile', array('id' => $model->id, 'type' => 'fans'));
?>
">全部粉丝</a></span>
        </h2>
    </div>
    <div class="panel-body">
        <ul class="avatar-list">
        	<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $ffocus, 'itemView' => '_fview', 'template' => "{items}\n{pager}"));
?>
        </ul>
    </div>
Ejemplo n.º 2
0
 public function getFocus($user_id = 0)
 {
     if (isset($user_id) && $user_id) {
         $focus_arr = array();
         $cache = Yii::app()->cache;
         if ($focus_users = $cache->get('Focus.User.' . $user_id)) {
             $focus_arr = json_decode($focus_users);
             return $focus_arr;
         } else {
             $focus_user = Focus::model()->with('user')->findAll('user_id=:user_id and focus_type=:type and is_focus=:focus', array(':user_id' => $user_id, ':type' => '0', ':focus' => '1'));
             if ($focus_user) {
                 //个人关注
                 foreach ($focus_user as $key => $val) {
                     $focus_arr[$val->focus_id] = array('user_name' => $val->user->nickname, 'image' => Yii::app()->params['qiniu']['host'] . $val->user->image, 'type' => 0);
                 }
             }
             $focus_alliance = Focus::model()->with('alliance')->findAll('user_id=:user_id and focus_type = :type and is_focus = :focus', array(':user_id' => $user_id, ':type' => '1', ':focus' => '1'));
             if ($focus_alliance) {
                 //联盟关注
                 foreach ($focus_alliance as $key => $val) {
                     $focus_arr[$val->focus_id] = array('user_name' => $val->alliance->name, 'image' => Yii::app()->params['qiniu']['host'] . $val->alliance->image, 'type' => 1);
                 }
             }
             $focus_store = Focus::model()->with('store')->findAll('user_id=:user_id and focus_type = :type and is_focus = :focus', array(':user_id' => $user_id, ':type' => '2', ':focus' => '1'));
             if ($focus_store) {
                 //联盟关注
                 foreach ($focus_store as $key => $val) {
                     $focus_arr[$val->focus_id] = array('user_name' => $val->store->name, 'image' => Yii::app()->params['qiniu']['host'] . $val->store->image, 'type' => 2);
                 }
             }
             if ($focus_arr) {
                 $cache->set(json_encode($focus_arr));
             }
             return $focus_arr;
         }
     }
 }
Ejemplo n.º 3
0
 public function getFocus($params = array())
 {
     extract($params);
     if (isset($user_id) && $user_id) {
         $focus_arr = array();
         $focus_user = Focus::model()->with('user')->findAll('user_id=:user_id and focus_type=:type and is_focus=:focus', array(':user_id' => $user_id, ':type' => '0', ':focus' => '1'));
         if ($focus_user) {
             //个人关注
             foreach ($focus_user as $key => $val) {
                 $focus_arr[] = array('user_name' => $val->user->nickname, 'image' => Yii::app()->params['qiniu']['host'] . $val->user->image, 'focus_id' => $val->focus_id, 'type' => 0);
             }
         }
         $focus_alliance = Focus::model()->with('alliance')->findAll('user_id=:user_id and focus_type = :type and is_focus = :focus', array(':user_id' => $user_id, ':type' => '1', ':focus' => '1'));
         if ($focus_alliance) {
             //联盟关注
             foreach ($focus_alliance as $key => $val) {
                 $focus_arr[] = array('user_name' => $val->alliance->name, 'image' => Yii::app()->params['qiniu']['host'] . $val->alliance->image, 'focus_id' => $val->focus_id, 'type' => 0);
             }
         }
         $focus_store = Focus::model()->with('store')->findAll('user_id=:user_id and focus_type = :type and is_focus = :focus', array(':user_id' => $user_id, ':type' => '2', ':focus' => '1'));
         if ($focus_store) {
             //联盟关注
             foreach ($focus_store as $key => $val) {
                 $focus_arr[] = array('user_name' => $val->store->name, 'image' => Yii::app()->params['qiniu']['host'] . $val->store->image, 'focus_id' => $val->focus_id, 'type' => 0);
             }
         }
         if ($focus_arr) {
             $result = $focus_arr;
             $ret = $this->notice('OK', 0, '成功', $result);
         } else {
             $ret = $this->notice('OK', 0, '没有关注对象', []);
         }
     } else {
         $ret = $this->notice('ERR', 301, '缺少参数', []);
     }
     return $ret;
 }
Ejemplo n.º 4
0
 public static function existByImage($image)
 {
     return Focus::find()->select('id')->where(['image' => $image])->one();
 }
Ejemplo n.º 5
0
 public function getFocus()
 {
     return Focus::isFocus($this->t_user_id, 0, 'no');
 }
Ejemplo n.º 6
0
 public function actionInfo($id)
 {
     $model = $this->loadModel($id);
     $isFocus = Focus::isFocus($id, 0, 'no');
     $html = '<div class="media media-user"><div class="media-left">';
     $html .= '<a href="' . $model->url . '">';
     $html .= '<img src="' . Profile::avatarByUserId($id) . '" alt="' . $model->username . '"/></a></div>';
     $html .= '<div class="media-body"><h2 class="media-heading"><span class="fa fa-mars"></span> ';
     $html .= '<a href="' . $model->url . '">' . User::getNameById($model->id) . '</a>';
     $html .= '<div class="time">最后登录:' . date('Y-m-d H:i:s', $model->profile->last_visit_time) . '<br>';
     $html .= '粉丝:' . Focus::countTfocus($id) . ' (排名:' . Focus::fansRank($id) . ')</div></div>';
     $html .= '<div class="media-footer"><a class="btn btn-xs ' . ($isFocus ? "btn-danger" : "btn-success") . ' btn-follow" href="' . Yii::app()->createUrl('/set/FocusEasy/', array('id' => $id)) . '">';
     $html .= '<span class="glyphicon glyphicon-plus"></span>' . ($isFocus ? "已關注" : "關注") . '</a></div>';
     echo $html;
 }