/**
  * Searches for stuff
  */
 public function actionSearch()
 {
     $query = isset($_GET['q']) ? $_GET['q'] : null;
     // Scope
     $users = null;
     $shares = null;
     if ($query != null) {
         // Make the criteria object
         $userCriteria = new CDbCriteria();
         $searchCriteria = new CDbCriteria();
         // If there is a @ symbol, do a user search
         preg_match_all('/@([A-Za-z0-9\\/\\.]*)/', $query, $matches);
         $mentions = implode(',', $matches[1]);
         if (!empty($matches[1])) {
             $userCriteria->addInCondition('username', $matches[1]);
             $users = User::model()->findAll($userCriteria);
             // Remove the @users from the remaining query
             foreach ($matches[1] as $u) {
                 $query = str_replace('@' . $u, '', $query);
             }
         }
         // Do a like Query
         $searchCriteria->addSearchCondition('text', $query);
         $searchCriteria->limit = 30;
         $shares = Share::model()->findAll($searchCriteria);
     }
     // Render the search
     $this->render('search', array('users' => $users, 'shares' => $shares));
 }
 public function actionIndex()
 {
     //   $refreshTime= UserRefreshForm::model()->findByPk(Yii::app()->user->userId)->refreshTime;
     $currentTime = time();
     //   UserRefreshForm::model()->updateByPk(Yii::app()->user->userId, array('refreshTime'=>$currentTime));
     $criteria = new CDbCriteria();
     $mFriends = new MFriends();
     $friendsList = $mFriends->getFriendsList();
     array_push($friendsList, Yii::app()->user->userId);
     $criteria->select = 't.*,count(tbl_myr_share_comment.shareId) as count';
     $criteria->join = 'LEFT JOIN tbl_myr_share_comment ON tbl_myr_share_comment.shareId=t.shareId';
     // $criteria->addCondition('t.createTime>='.$refreshTime);
     $criteria->addInCondition('t.userId', $friendsList);
     $criteria->group = 't.shareId';
     $criteria->order = 't.shareId DESC';
     $share = Share::model();
     $total = $share->count($criteria);
     $pager = new CPagination($total);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $shareList = $share->findAll($criteria);
     $dataFormat = new DataFormat();
     $format = array();
     $format = $dataFormat->format($shareList);
     $data = array('shareList' => $format, 'pages' => $pager);
     if ($total > 0) {
         $clientFlash = new ClientFlash();
         $clientFlash->pushMobile(0, $format);
     } else {
         _echo(3, 'data empty');
     }
     $this->render('index', $data);
 }
Beispiel #3
0
 public function actionShares($id = null)
 {
     if ($id == null) {
         if (Yii::app()->user->isGuest) {
             $this->redirect($this->createUrl('site/login'));
         }
         $id = Yii::app()->user->id;
     }
     $shares = Share::model()->findAllByAttributes(array('author_id' => $id));
     $this->render('shares', array('shares' => $shares));
 }
Beispiel #4
0
               <span style="cursor: pointer" class="fa fa-heart <?php 
echo $data->isLiked() ? 'liked' : NULL;
?>
"></span>
               <?php 
if ($data->author_id != Yii::app()->user->id) {
    ?>
                   <span style="cursor: pointer" class="fa fa-mail-forward"></span>
               <?php 
}
?>
               <?php 
if ($data->reshare_id != NULL) {
    ?>
                   <span style="cursor: pointer" class="fa fa-share liked"></span> by <?php 
    echo CHtml::link(Share::model()->findByPk($data->reshare_id)->author->username, $this->createUrl('share/view', array('id' => $data->reshare_id)));
    ?>
               <?php 
}
?>
               <?php 
if (!Yii::app()->user->isGuest) {
    ?>
                   <?php 
    echo CHtml::link(NULL, $this->createUrl('share/hybrid', array('id' => $data->id)), array('class' => 'fa fa-twitter'));
    ?>
               <?php 
}
?>
			   <?php 
echo CHtml::link(NULL, $this->createUrl('share/view', array('id' => $data->id)), array('class' => 'fa fa-eye'));