You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.0 KiB
68 lines
2.0 KiB
<?php
|
|
/**
|
|
* 最新消息內頁
|
|
*/
|
|
require_once('../../conf/NewsEnum.php');
|
|
require_once('../../conf/ParametersException.php');
|
|
require_once('../../db/NewsDAO.php');
|
|
|
|
try{
|
|
$result = array();
|
|
$dataNum = 0;
|
|
$dbDao = new NewsDAO();
|
|
$dbDao->transaction();
|
|
$dataId = 0;
|
|
$returnArr = array();
|
|
|
|
if ( isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] != 0 ){
|
|
$dataId = trim($_GET['id']);
|
|
}
|
|
if ( $dataId == 0 ){
|
|
throw new ParametersException('無資料');
|
|
}
|
|
$newsData = $dbDao->getNewsContent($dataId);
|
|
if ( !is_array($newsData) || count($newsData) != 1 ){
|
|
throw new ParametersException('無此則最新消息');
|
|
}
|
|
|
|
$newsData = $newsData[0];
|
|
$sourceHtml = '';
|
|
// $sourceHtml = '<h4>資料來源:</h4><p><a href="javascript:void(0)" class="media-source">'.$newsData['news_source'].'</a></p>';
|
|
$returnArr['content'] = array();
|
|
$returnArr['content']['browserTitle'] = $newsData['title'].' - 永佳捷電梯';
|
|
$returnArr['content']['title'] = $newsData['title'];
|
|
$returnArr['content']['publishDate'] = $newsData['publish_date'];
|
|
|
|
$returnArr['content']['imageUrl'] = '';
|
|
$returnArr['content']['imageAlt'] = '';
|
|
if ( !is_null($newsData['news_image']) ){
|
|
$returnArr['content']['imageUrl'] = '../img/news/'.$newsData['news_image'];
|
|
$returnArr['content']['imageAlt'] = $newsData['news_image_alt'];
|
|
}
|
|
$returnArr['content']['imageUrl2'] = '';
|
|
$returnArr['content']['imageAlt2'] = '';
|
|
if ( !is_null($newsData['news_image2']) ){
|
|
$returnArr['content']['imageUrl2'] = '../img/news/'.$newsData['news_image2'];
|
|
$returnArr['content']['imageAlt2'] = $newsData['news_image_alt2'];
|
|
}
|
|
$returnArr['content']['content'] = $newsData['news_content'].$sourceHtml;
|
|
$dbDao->commitDB();
|
|
http_response_code(200);
|
|
|
|
} catch ( ParametersException $pe ){
|
|
echo $pe->getMessage();
|
|
http_response_code(400);
|
|
|
|
} catch ( Exception $e ){
|
|
if($dbDao != null) {
|
|
$dbDao->rollbackDB();
|
|
}
|
|
http_response_code(500);
|
|
} finally {
|
|
echo json_encode($returnArr, JSON_UNESCAPED_UNICODE);
|
|
if($dbDao != null) {
|
|
$dbDao->closeDB();
|
|
}
|
|
}
|
|
|
|
?>
|