<commit_before><?php
/**
 * Created by PhpStorm.
 * User : xin.zhang
 * Date : 15/4/30
 * Time : 下午7:06
 * Email: <EMAIL>
 */

namespace frontend\controllers;


use backend\components\Page;
use backend\components\TableResult;
use common\components\Code;
use common\components\Common;
use common\components\LogUtils;
use common\components\PageResult;
use common\components\TagUtil;
use common\entity\TravelTrip;
use common\entity\TravelTripComment;
use common\entity\UserAttention;
use frontend\services\PublisherService;
use frontend\services\TravelTripCommentService;
use frontend\services\TripService;
use frontend\services\UserAttentionService;
use frontend\services\UserBaseService;
use yii\base\Exception;
use yii\debug\models\search\Log;

class ViewTripController extends UnCController{


    public $tripService;
    public $tripCommentSer;
    public $AttentionService;

    public $isTripList;
    public $search;


    public function __construct($id, $module = null)
    {
        $this->tripService=new TripService();
        $this->AttentionService=new UserAttentionService();
        $this->tripCommentSer=new TravelTripCommentService();
        parent::__construct($id, $module);
    }

    /**
     * 跳转到随游列表页面
     * @return string
     * @throws Exception
     * @throws \Exception
     */
    public function actionList()
    {
        $search=\Yii::$app->request->get("s",null);
        $type=\Yii::$app->request->get("t",null);
        $activity=\Yii::$app->request->get("a",null);

        $typeArray=null;
        //查询热门推荐
        $tagList = TagUtil::getInstance()->getTagList();
        $page=new Page();
        $page->setCurrentPage(1);
        $page->pageSize=4;

        //$recommendTravel =$this->AttentionService->getRecommendTravel($page);
        //查询基本
        $tripPage=new Page();
        $tripPage->pageSize=16;
        $tripPage->setCurrentPage(1);
        $this->tripService=new TripService();
        if(!empty($type)){
            $typeArray=[$type];
        }
        $tripPage= $this->tripService->getList($tripPage,$search,null,null,null,null,null,null,null,$typeArray,$activity);

        $pageHtml=Common::pageHtml($tripPage->currentPage,$tripPage->pageSize,$tripPage->totalCount);
        $pageResult=new PageResult($tripPage);
        $pageResult->pageHtml=$pageHtml;

        $this->isTripList=true;
        $this->search=$search;
        return $this->render("list",[
            'tagList' => $tagList,
            //'rTravel'=>$recommendTravel['data'],
            'pageResult'=>$pageResult,
            'search'=>$search,
            'type'=>$type
        ]);
    }

    public function actionGetRecommendTrip()
    {
        try{
            $cPage=\Yii::$app->request->post('p');
            if(empty($cPage)||$cPage<1)
            {
                $cPage=1;
            }
            $numb=4;
            $page=new Page();
            $page->currentPage=$cPage;
            $page->pageSize=$numb;
            $page->startRow = (($page->currentPage - 1) * $page->pageSize);
            $recommendTravel =$this->AttentionService->getRecommendTravel($page);
            return json_encode(Code::statusDataReturn(Code::SUCCESS,$recommendTravel));
         }catch (Exception $e){
            LogUtils::log($e);
            return json_encode(Code::statusDataReturn(Code::FAIL));
        }
    }

    /**
     * 跳转到详情页面
     * @return string
     * @throws Exception
     * @throws \Exception
     */
    public function actionInfo()
    {
        $tripId=\Yii::$app->request->get("trip");
        $returnUrl="info";$travelInfo=null;
        $travelInfo=$this->tripService->getTravelTripInfoById($tripId);
        if($travelInfo['info']['type']==TravelTrip::TRAVEL_TRIP_TYPE_TRAFFIC){
            $returnUrl="trafficInfo";
        }
        $applyList=$this->tripService->getPublisherApplyList($tripId);
        $recommendPage=new Page();
        $recommendPage->pageSize=3;
        $recommendPage->sortName="score";
        $recommendPage->sortType="DESC";
        $recommendPage=$this->tripService->getRelateRecommendTrip($recommendPage,$travelInfo['info']['countryId'],$travelInfo['info']['cityId']);

        $tripInfo=$travelInfo['info'];
        $userService=new UserBaseService();
        $publisherService=new PublisherService();
        $tripPublisherId=$tripInfo['createPublisherId'];
        $createPublisherId=$publisherService->findById($tripPublisherId);
        $createUserInfo=$userService->findUserByUserSign($createPublisherId->userId);

        $userRecommend=$this->tripService->findTravelTripRecommendByTripId($tripId);

        $attention =new UserAttentionService();
        if(empty($this->userObj))
        {
            $userSign='';
        }else
        {
            $userSign=$this->userObj->userSign;
        }

        $rst=$attention->getAttentionResult(UserAttention::TYPE_COLLECT_FOR_TRAVEL,$tripId,$userSign);

        return $this->render($returnUrl,[
            'travelInfo'=>$travelInfo,
            'createUserInfo'=>$createUserInfo,
            'createPublisherInfo'=>$createPublisherId,
            'attention'=>$rst,
            'relateRecommend'=>$recommendPage->getList(),
            'applyList'=>$applyList,
            'userRecommend'=>$userRecommend
        ]);<commit_msg>随游详情页面title更改<commit_after><?php
/**
 * Created by PhpStorm.
 * User : xin.zhang
 * Date : 15/4/30
 * Time : 下午7:06
 * Email: <EMAIL>
 */

namespace frontend\controllers;


use backend\components\Page;
use backend\components\TableResult;
use common\components\Code;
use common\components\Common;
use common\components\LogUtils;
use common\components\PageResult;
use common\components\TagUtil;
use common\entity\TravelTrip;
use common\entity\TravelTripComment;
use common\entity\UserAttention;
use frontend\services\PublisherService;
use frontend\services\TravelTripCommentService;
use frontend\services\TripService;
use frontend\services\UserAttentionService;
use frontend\services\UserBaseService;
use yii\base\Exception;
use yii\debug\models\search\Log;

class ViewTripController extends UnCController{


    public $tripService;
    public $tripCommentSer;
    public $AttentionService;

    public $isTripList;
    public $search;


    public function __construct($id, $module = null)
    {
        $this->tripService=new TripService();
        $this->AttentionService=new UserAttentionService();
        $this->tripCommentSer=new TravelTripCommentService();
        parent::__construct($id, $module);
    }

    /**
     * 跳转到随游列表页面
     * @return string
     * @throws Exception
     * @throws \Exception
     */
    public function actionList()
    {
        $search=\Yii::$app->request->get("s",null);
        $type=\Yii::$app->request->get("t",null);
        $activity=\Yii::$app->request->get("a",null);

        $typeArray=null;
        //查询热门推荐
        $tagList = TagUtil::getInstance()->getTagList();
        $page=new Page();
        $page->setCurrentPage(1);
        $page->pageSize=4;

        //$recommendTravel =$this->AttentionService->getRecommendTravel($page);
        //查询基本
        $tripPage=new Page();
        $tripPage->pageSize=16;
        $tripPage->setCurrentPage(1);
        $this->tripService=new TripService();
        if(!empty($type)){
            $typeArray=[$type];
        }
        $tripPage= $this->tripService->getList($tripPage,$search,null,null,null,null,null,null,null,$typeArray,$activity);

        $pageHtml=Common::pageHtml($tripPage->currentPage,$tripPage->pageSize,$tripPage->totalCount);
        $pageResult=new PageResult($tripPage);
        $pageResult->pageHtml=$pageHtml;

        $this->isTripList=true;
        $this->search=$search;
        return $this->render("list",[
            'tagList' => $tagList,
            //'rTravel'=>$recommendTravel['data'],
            'pageResult'=>$pageResult,
            'search'=>$search,
            'type'=>$type
        ]);
    }

    public function actionGetRecommendTrip()
    {
        try{
            $cPage=\Yii::$app->request->post('p');
            if(empty($cPage)||$cPage<1)
            {
                $cPage=1;
            }
            $numb=4;
            $page=new Page();
            $page->currentPage=$cPage;
            $page->pageSize=$numb;
            $page->startRow = (($page->currentPage - 1) * $page->pageSize);
            $recommendTravel =$this->AttentionService->getRecommendTravel($page);
            return json_encode(Code::statusDataReturn(Code::SUCCESS,$recommendTravel));
         }catch (Exception $e){
            LogUtils::log($e);
            return json_encode(Code::statusDataReturn(Code::FAIL));
        }
    }

    /**
     * 跳转到详情页面
     * @return string
     * @throws Exception
     * @throws \Exception
     */
    public function actionInfo()
    {
        $tripId=\Yii::$app->request->get("trip");
        $returnUrl="info";$travelInfo=null;
        $travelInfo=$this->tripService->getTravelTripInfoById($tripId);
        if($travelInfo['info']['type']==TravelTrip::TRAVEL_TRIP_TYPE_TRAFFIC){
            $returnUrl="trafficInfo";
        }
        $applyList=$this->tripService->getPublisherApplyList($tripId);
        $recommendPage=new Page();
        $recommendPage->pageSize=3;
        $recommendPage->sortName="score";
        $recommendPage->sortType="DESC";
        $recommendPage=$this->tripService->getRelateRecommendTrip($recommendPage,$travelInfo['info']['countryId'],$travelInfo['info']['cityId']);

        $tripInfo=$travelInfo['info'];
        $userService=new UserBaseService();
        $publisherService=new PublisherService();
        $tripPublisherId=$tripInfo['createPublisherId'];
        $createPublisherId=$publisherService->findById($tripPublisherId);
        $createUserInfo=$userService->findUserByUserSign($createPublisherId->userId);

        $userRecommend=$this->tripService->findTravelTripRecommendByTripId($tripId);

        $attention =new UserAttentionService();
        if(empty($this->userObj))
        {
            $userSign='';
        }else
        {
            $userSign=$this->userObj->userSign;
        }

        $rst=$attention->getAttentionResult(UserAttention::TYPE_COLLECT_FOR_TRAVEL,$tripId,$userSign);

        $this->getView()->title = $travelInfo['info']['title'];
        return $this->render($returnUrl,[
            'travelInfo'=>$travelInfo,
            'createUserInfo'=>$createUserInfo,
            'createPublisherInfo'=>$createPublisherId,
            'attention'=>$rst,
            'relateRecommend'=>$recommendPage->getList(),
            'applyList'=>$applyList,
            'userRecommend'=>$userRecommend
        ]);
{'fraction_non_alphanumeric': 0.15177224736048264, 'fraction_numerical': 0.003393665158371041, 'mean_word_length': 2.917651403249631, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 145, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6804925', 'n_tokens_mistral': 3374, 'n_tokens_neox': 3182, 'n_words': 396}