public static function getById($nid)
 {
     $news = new NewsModel();
     $nextNews = Yii::$app->businesslayer->news->getById($nid);
     $news->setAttributes(['newsId' => $nextNews['ID'], 'newsDate' => $nextNews['NewsDate'], 'newsFormatId' => $nextNews['NewsFormatID'], 'textPreview' => $nextNews['TextPreview'], 'bannerPicture' => $nextNews['BannerPicture'], 'hyperLinkTypeId' => $nextNews['HyperLinkTypeID'], 'hyperLinkUrl' => $nextNews['HyperLinkUrl'], 'textFull' => $nextNews['TextFull'], 'pictureTop' => $nextNews['PictureTopInFull'], 'pictureBottom' => $nextNews['PictureBottomInFull'], 'author' => $nextNews['NewsAuthorID']]);
     if (!$news->hyperLinkUrl) {
         $news->hyperLinkUrl = "";
     }
     return $news;
 }
 public function actionNews()
 {
     if (Yii::$app->request->isAjax && $_POST['id']) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $model = NewsModel::getById($_POST['id']);
         return $model;
     }
 }
示例#3
0
 /**
  * @param $newsLink
  * @return array
  */
 public function getNewsDetail($newsLink)
 {
     $localCode = strtoupper(App::getLocale());
     /* Load Mode */
     $headerModel = new Models\HeaderModel();
     $breadCrumbModel = new Models\breadCrumbsModel();
     $newsModel = new Models\NewsModel();
     $commonModel = new Models\CommonModel();
     /* Init Data */
     $headerData = $headerModel->index($localCode);
     $newsDetailData = $newsModel->getNewsDetailIndex($localCode, $newsLink);
     $breadCrumbData = $breadCrumbModel->getBreadCrumbData($localCode, "news", "N", $newsLink, null);
     /* Update Views */
     $commonModel->updateViews("tb_news", "NEWS_TEXT_LINK", $newsLink);
     $newsListArr = array("headerData" => $headerData, "breadCrumb" => $breadCrumbData, "newsDetail" => $newsDetailData);
     return view('newsDetail', $newsListArr);
 }
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index()
 {
     $localCode = strtoupper(App::getLocale());
     /* Load Model */
     $headerModel = new Models\HeaderModel();
     $sldModel = new Models\SliderModel();
     $cateModel = new Models\TourCategoryModel();
     $tourModel = new Models\TourModel();
     $newsModel = new Models\NewsModel();
     /* Init Data */
     $headerData = $headerModel->index($localCode);
     $sliderData = $sldModel->index($localCode);
     $cateData = $cateModel->index($localCode);
     $tourRcm = $tourModel->indexTourRecommended($localCode);
     $latestNews = $newsModel->latestNewsIndex($localCode);
     $indexData = array("headerData" => $headerData, "sliderData" => $sliderData, "cateData" => $cateData, "tourRcm" => $tourRcm, "latestNews" => $latestNews);
     return view('index', $indexData);
 }
 /**
  * @inheritdoc
  */
 protected function prepareModels()
 {
     $models = [];
     $pagination = $this->getPagination();
     if ($pagination === false) {
         foreach (Yii::$app->businesslayer->schools->getNews($this->sid) as $nextNews) {
             $nextModel = new NewsModel();
             $nextModel->setAttributes(['newsId' => $nextNews['ID'], 'newsDate' => $nextNews['NewsDate'], 'newsFormatId' => $nextNews['NewsFormatID'], 'textPreview' => $nextNews['TextPreview'], 'bannerPicture' => $nextNews['BannerPicture'], 'hyperLinkTypeId' => $nextNews['HyperLinkTypeID'], 'hyperLinkUrl' => $nextNews['HyperLinkUrl']]);
             $models[] = $nextModel;
         }
     } else {
         // $pagination->totalCount = $this->getTotalCount();
         // $this->fileObject->seek($pagination->getOffset());
         // $limit = $pagination->getLimit();
         // for ($count = 0; $count < $limit; ++$count) {
         // $models[] = $this->fileObject->fgetcsv();
         // $this->fileObject->next();
         // }
     }
     return $models;
 }