Title1

Title2

Title3

13-1 write_Slider_html()

write_Slider_html()

###############################################################################
#  產生 slider.html
###############################################################################
function write_Slider_html() {
	global $ugmKind, $xoopsDB, $DIRNAME;
	$tbl = $ugmKind->get_tbl();
	$kind = $ugmKind->get_kind();
	$dir_name = "/photo";

	//sn  ofsn  title sort  enable  kind  url target  col_sn
	$sql = "select a.sn,a.title,a.content,a.url,a.target,b.file_name,b.sub_dir
          from      " . $xoopsDB->prefix($tbl) . "                      as a
          left join " . $xoopsDB->prefix("ugm_creative_files_center") . " as b on a.sn = b.col_sn and b.col_name = '{$kind}' and b.sort='1'
          where a.kind='{$kind}' and a.enable='1'
          order by a.sort"; //die($sql);
	$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
	//---- 過濾資料 ------------------------*/
	$myts = &MyTextSanitizer::getInstance();
	$item = "";
	$i = 0;
	while ($row = $xoopsDB->fetchArray($result)) {
		$row['target'] = $row['target'] ? " target='_blank'" : "";
		$row['title'] = $myts->htmlSpecialChars($row['title']);
		$row['url'] = $myts->htmlSpecialChars($row['url']);
		$row['file_name'] = $myts->htmlSpecialChars($row['file_name']);
		$row['sub_dir'] = $myts->htmlSpecialChars($row['sub_dir']);
		$html = 0;
		$br = 1;
		$row['content'] = $myts->displayTarea($row['content'], $html, 1, 0, 1, $br);
		#大圖
		if ($row['file_name'] and file_exists(XOOPS_ROOT_PATH . "/uploads/{$DIRNAME}{$row['sub_dir']}/{$row['file_name']}")) {
			$row['file_name'] = XOOPS_URL . "/uploads/{$DIRNAME}{$row['sub_dir']}/{$row['file_name']}";
		} else {
			#無圖處理
			$row['file_name'] = XOOPS_URL . "/modules/ugm_tools/images/no_pic/pic_1920_500.jpg";
		}
		#相片展示
		$item .= "			<div class='col-lg-4 col-sm-6'>\n";
		$item .= "				 <a href='{$row['file_name']}' class='portfolio-box'>\n";
		$item .= "					<img src='{$row['file_name']}' class='img-responsive' alt=''>\n";
		$item .= "					<div class='portfolio-box-caption'>\n";
		$item .= "						<div class='portfolio-box-caption-content'>\n";
		$item .= "							<div class='project-category text-faded'>\n";
		$item .= "								{$row['url']}\n";
		$item .= "							</div>\n";
		$item .= "							<div class='project-name'>\n";
		$item .= "								{$row['title']}\n";
		$item .= "							</div>\n";
		$item .= "						</div>\n";
		$item .= "					</div>\n";
		$item .= "				</a>\n";

		$item .= "			</div>\n";
	}
	/*

	*/

	$content = "<section class='no-padding' id='portfolio'>\n";
	$content .= "	<div class='container-fluid'>\n";
	$content .= "		<div class='row no-gutter popup-gallery'>\n";
	$content .= $item;
	$content .= "		</div>\n";
	$content .= "	</div>\n";
	$content .= "</section>\n";

	#---- 檢查資料夾
	mk_dir(XOOPS_ROOT_PATH . "/uploads/{$DIRNAME}/tpl");
	$file = XOOPS_ROOT_PATH . "/uploads/{$DIRNAME}/tpl/creative_portfolio.html";
	$f = fopen($file, 'w'); //以寫入方式開啟文件
	fwrite($f, $content); //將新的資料寫入到原始的文件中
	fclose($f);
}