本文整理汇总了PHP中image::cropFromCenter方法的典型用法代码示例。如果您正苦于以下问题:PHP image::cropFromCenter方法的具体用法?PHP image::cropFromCenter怎么用?PHP image::cropFromCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::cropFromCenter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nv_resize_crop_image
function nv_resize_crop_image($img_path, $width, $height, $module_name = '', $id = 0)
{
$new_img_path = '';
if (file_exists($img_path)) {
$imginfo = nv_is_image($img_path);
$basename = basename($img_path);
if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
$basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $id . '_\\1_' . $width . '-' . $height . '\\2', $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
$img_path = new image($img_path, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$thumb_width = $width;
$thumb_height = $height;
$maxwh = max($thumb_width, $thumb_height);
if ($img_path->fileinfo['width'] > $img_path->fileinfo['height']) {
$width = 0;
$height = $maxwh;
} else {
$width = $maxwh;
$height = 0;
}
$img_path->resizeXY($width, $height);
$img_path->cropFromCenter($thumb_width, $thumb_height);
$img_path->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
}
return $new_img_path;
}
示例2: XTemplate
function nv_news_block_newscenter($block_config)
{
global $module_data, $module_name, $module_file, $global_array_cat, $global_config, $lang_module, $db, $module_config, $module_info;
$module_name = 'news';
$module_data = 'news';
$xtpl = new XTemplate('block_newscenter.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/blocks');
$xtpl->assign('lang', $lang_module);
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
$db->sqlreset()->select('id, catid, publtime, title, alias, hometext, homeimgthumb, homeimgfile')->from(NV_PREFIXLANG . '_' . $module_data . '_rows')->where('status= 1')->order('publtime DESC')->limit(5);
$list = nv_db_cache($db->sql(), 'id', $module_name);
$i = 1;
foreach ($list as $row) {
$row['publtime'] = nv_date('m/d/Y', $row['publtime']);
$row['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$row['catid']]['alias'] . '/' . $row['alias'] . '-' . $row['id'] . $global_config['rewrite_exturl'];
$row['title0'] = nv_clean60(strip_tags($row['title']), $i == 1 ? 50 : 30);
$row['hometext'] = nv_clean60(strip_tags($row['hometext']), 260);
$image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
if ($row['homeimgfile'] != '' and file_exists($image)) {
if ($i == 1) {
$width = 570;
$height = 490;
} else {
$width = 270;
$height = 230;
}
$row['imgsource'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
$imginfo = nv_is_image($image);
$basename = basename($image);
if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
$basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $row['id'] . '_\\1_' . $width . '-' . $height . '\\2', $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
require_once NV_ROOTDIR . '/includes/class/image.class.php';
$_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$_image->cropFromCenter($width, $height);
$_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
} elseif (nv_is_url($row['homeimgfile'])) {
$row['imgsource'] = $row['homeimgfile'];
} elseif (!empty($module_config[$module_name]['show_no_image'])) {
$row['imgsource'] = NV_BASE_SITEURL . $module_config[$module_name]['show_no_image'];
} else {
$row['imgsource'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no-image.png';
}
$xtpl->assign('main' . $i, $row);
++$i;
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例3: image
function creat_thumbs($id, $homeimgfile, $module_name, $width = 200, $height = 150)
{
if ($width >= $height) {
$rate = $width / $height;
} else {
$rate = $height / $width;
}
$image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $homeimgfile;
if ($homeimgfile != '' and file_exists($image)) {
$imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $homeimgfile;
$imginfo = nv_is_image($image);
$basename = $module_name . $width . 'x' . $height . '-' . $id . '-' . md5_file($image) . '.' . $imginfo['ext'];
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$imgsource = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
require_once NV_ROOTDIR . '/includes/class/image.class.php';
$_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
if ($imginfo['width'] <= $imginfo['height']) {
$_image->resizeXY($width, 0);
} elseif ($imginfo['width'] / $imginfo['height'] < $rate) {
$_image->resizeXY($width, 0);
} elseif ($imginfo['width'] / $imginfo['height'] >= $rate) {
$_image->resizeXY(0, $height);
}
$_image->cropFromCenter($width, $height);
$_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$imgsource = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
} elseif (nv_is_url($homeimgfile)) {
$imgsource = $homeimgfile;
} else {
$imgsource = '';
}
return $imgsource;
}
示例4: image
function photos_thumbs($id, $file, $module_upload, $width = 270, $height = 210, $quality = 90)
{
if ($width >= $height) {
$rate = $width / $height;
} else {
$rate = $height / $width;
}
$image = NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/images/' . $file;
if ($file != '' and file_exists($image)) {
$imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/images/' . $file;
$imginfo = nv_is_image($image);
$basename = $module_upload . '_' . $width . 'x' . $height . '-' . $id . '-' . md5_file($image) . '.' . $imginfo['ext'];
if (file_exists(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename)) {
$imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename;
} else {
$_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
if ($imginfo['width'] <= $imginfo['height']) {
$_image->resizeXY($width, 0);
} elseif ($imginfo['width'] / $imginfo['height'] < $rate) {
$_image->resizeXY($width, 0);
} elseif ($imginfo['width'] / $imginfo['height'] >= $rate) {
$_image->resizeXY(0, $height);
}
$_image->cropFromCenter($width, $height);
$_image->save(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/', $basename, $quality);
if (file_exists(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename)) {
$imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename;
}
}
} elseif (nv_is_url($file)) {
$imgsource = $file;
} else {
$imgsource = '';
}
return $imgsource;
}
示例5: nv_filter
function nv_filter($hinhanh)
{
if ($hinhanh) {
global $folder, $module, $module_config;
require_once NV_ROOTDIR . "/includes/class/image.class.php";
$basename = basename($hinhanh);
$image = new image($hinhanh, NV_MAX_WIDTH, NV_MAX_HEIGHT);
// Creat new folder
if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder)) {
nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module, $folder);
}
$thumb_w = $module_config[$module]['homewidth'];
$thumb_h = $module_config[$module]['homeheight'];
$block_w = $module_config[$module]['blockwidth'];
$block_h = $module_config[$module]['blockheight'];
$img_w = $module_config['getnews']['width'];
$img_h = $module_config['getnews']['height'];
$name = $basename;
$thumb_name = "";
$block_name = "";
$i = 1;
while (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder . '/' . $name)) {
$name = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
$i++;
}
$image_info1 = $image->fileinfo;
$image_info = array();
$homeimg = "";
$homeimgthumb = "";
// if( ( $image_info1['width'] / $image_info1['height'] ) < ( $img_w / $img_h ) )
// {
// $image->resizeXY( $img_w, NV_MAX_HEIGHT );
// }
// else
// {
// $image->resizeXY( NV_MAX_WIDTH, $img_h );
// }
// $image->cropFromLeft( 0, 0, $img_w, $img_h );
// $image->save( NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder, $name );
// $image_info = $image->create_Image_info;
$homeimg = str_replace(NV_UPLOADS_REAL_DIR . '/' . $module . '/', '', $hinhanh);
$name = $basename;
$i = 1;
while (file_exists(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/thumb/' . $name)) {
$name = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
$i++;
}
if ($image_info1['width'] / $image_info1['height'] < $thumb_w / $thumb_h) {
$image->resizeXY($thumb_w, NV_MAX_HEIGHT);
} else {
$image->resizeXY(NV_MAX_WIDTH, $thumb_h);
}
$image->cropFromCenter($thumb_w, $thumb_h);
$image->save(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/thumb', $name);
$image_info = $image->create_Image_info;
$thumb_name = str_replace(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/', '', $image_info['src']);
$name = $basename;
$i = 1;
while (file_exists(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/block/' . $name)) {
$name = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
$i++;
}
if ($image_info1['width'] / $image_info1['height'] < $block_w / $block_h) {
$image->resizeXY($block_w, NV_MAX_HEIGHT);
} else {
$image->resizeXY(NV_MAX_WIDTH, $block_h);
}
$image->cropFromCenter($block_w, $block_h);
$image->save(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/block', $name);
if ($image_info) {
$image_info = $image->create_Image_info;
} else {
$image_info['src'] = "";
}
$block_name = str_replace(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/', '', $image_info['src']);
$image->close();
if (!empty($thumb_name) and !empty($block_name)) {
$homeimgthumb = $thumb_name . "|" . $block_name;
}
} else {
$homeimg = "";
$homeimgthumb = "";
}
$arr_img = array($homeimg, $homeimgthumb);
return $arr_img;
}
示例6: isset
function nv_news_block_news($block_config, $mod_data)
{
global $module_array_cat, $module_info, $db, $module_config, $global_config;
$module = 'news';
$blockwidth = $module_config[$module]['blockwidth'];
$show_no_image = $module_config[$module]['show_no_image'];
$numrow = isset($block_config['numrow']) ? $block_config['numrow'] : 20;
$cache_file = NV_LANG_DATA . '__block_news_' . $numrow . '_' . NV_CACHE_PREFIX . '.cache';
if (($cache = nv_get_cache($module, $cache_file)) != false) {
$array_block_news = unserialize($cache);
} else {
$array_block_news = array();
$db->sqlreset()->select('id, catid, publtime, exptime, title, alias, homeimgthumb, homeimgfile, hometext')->from(NV_PREFIXLANG . '_' . $mod_data . '_rows')->where('status= 1')->order('publtime DESC')->limit($numrow);
$result = $db->query($db->sql());
while (list($id, $catid, $publtime, $exptime, $title, $alias, $homeimgthumb, $homeimgfile, $hometext) = $result->fetch(3)) {
$link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module . '&' . NV_OP_VARIABLE . '=' . $module_array_cat[$catid]['alias'] . '/' . $alias . '-' . $id . $global_config['rewrite_exturl'];
$array_block_news[] = array('id' => $id, 'title' => $title, 'link' => $link, 'homeimgfile' => $homeimgfile, 'width' => $blockwidth, 'hometext' => $hometext);
}
$cache = serialize($array_block_news);
nv_set_cache($module, $cache_file, $cache);
}
if (file_exists(NV_ROOTDIR . '/themes/' . $module_info['template'] . '/blocks/block_news.tpl')) {
$block_theme = $module_info['template'];
} else {
$block_theme = 'default';
}
$xtpl = new XTemplate('block_news.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/blocks/');
$i = 1;
foreach ($array_block_news as $array_news) {
$array_news['hometext'] = nv_clean60($array_news['hometext'], 20);
$image = NV_UPLOADS_REAL_DIR . '/' . $module . '/' . $array_news['homeimgfile'];
if ($array_news['homeimgfile'] != '' and file_exists($image)) {
if ($i == 1) {
$width = 370;
$height = 150;
} else {
$width = 170;
$height = 115;
}
$array_news['imgurl'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $array_news['homeimgfile'];
$imginfo = nv_is_image($image);
$basename = basename($image);
if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
$basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $row['id'] . '_\\1_' . $width . '-' . $height . '\\2', $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$array_news['imgurl'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
require_once NV_ROOTDIR . '/includes/class/image.class.php';
$_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$_image->cropFromCenter($width, $height);
$_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$array_news['imgurl'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
} elseif (nv_is_url($array_news['homeimgfile'])) {
$array_news['imgurl'] = $array_news['homeimgfile'];
} elseif (!empty($module_config[$module_name]['show_no_image'])) {
$array_news['imgurl'] = NV_BASE_SITEURL . $module_config[$module_name]['show_no_image'];
} else {
$array_news['imgurl'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no-image.png';
}
$xtpl->assign('blocknews', $array_news);
if ($i == 1) {
$xtpl->parse('main.news_main');
} else {
$array_news['title0'] = nv_clean60($array_news['title'], 40);
$xtpl->assign('blocknews', $array_news);
$xtpl->assign('FL', $i % 2 != 0 ? 'right' : 'left');
$xtpl->parse('main.newsloop');
}
$i++;
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例7: image
$row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
require_once NV_ROOTDIR . '/includes/class/image.class.php';
$image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$thumb_width = $width;
$thumb_height = $height;
$maxwh = max($thumb_width, $thumb_height);
if ($image->fileinfo['width'] > $image->fileinfo['height']) {
$width = 0;
$height = $maxwh;
} else {
$width = $maxwh;
$height = 0;
}
$image->resizeXY($width, $height);
$image->cropFromCenter($thumb_width, $thumb_height);
$image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
} elseif (nv_is_url($row['homeimgfile'])) {
$row['imgsource'] = $row['homeimgfile'];
} elseif (!empty($module_config[$module_name]['show_no_image'])) {
$row['imgsource'] = NV_BASE_SITEURL . $module_config[$module]['show_no_image'];
} else {
$row['imgsource'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no_image.gif';
}
$array_data[$row['id']] = $row;
}
示例8: nv_get_viewImage
function nv_get_viewImage($fileName)
{
global $array_thumb_config;
if (preg_match('/^' . nv_preg_quote(NV_UPLOADS_DIR) . '\\/(([a-z0-9\\-\\_\\/]+\\/)*([a-z0-9\\-\\_\\.]+)(\\.(gif|jpg|jpeg|png)))$/i', $fileName, $m)) {
$viewFile = NV_FILES_DIR . '/' . $m[1];
if (file_exists(NV_ROOTDIR . '/' . $viewFile)) {
$size = @getimagesize(NV_ROOTDIR . '/' . $viewFile);
return array($viewFile, $size[0], $size[1]);
} else {
$m[2] = rtrim($m[2], '/');
if (isset($array_thumb_config[NV_UPLOADS_DIR . '/' . $m[2]])) {
$thumb_config = $array_thumb_config[NV_UPLOADS_DIR . '/' . $m[2]];
} else {
$thumb_config = $array_thumb_config[''];
$_arr_path = explode('/', NV_UPLOADS_DIR . '/' . $m[2]);
while (sizeof($_arr_path) > 1) {
array_pop($_arr_path);
$_path = implode('/', $_arr_path);
if (isset($array_thumb_config[$_path])) {
$thumb_config = $array_thumb_config[$_path];
break;
}
}
}
$viewDir = NV_FILES_DIR;
if (!empty($m[2])) {
if (!is_dir(NV_ROOTDIR . '/' . $m[2])) {
$e = explode('/', $m[2]);
$cp = NV_FILES_DIR;
foreach ($e as $p) {
if (is_dir(NV_ROOTDIR . '/' . $cp . '/' . $p)) {
$viewDir .= '/' . $p;
} else {
$mk = nv_mkdir(NV_ROOTDIR . '/' . $cp, $p);
if ($mk[0] > 0) {
$viewDir .= '/' . $p;
}
}
$cp .= '/' . $p;
}
}
}
$image = new image(NV_ROOTDIR . '/' . $fileName, NV_MAX_WIDTH, NV_MAX_HEIGHT);
if ($thumb_config['thumb_type'] == 4) {
$thumb_width = $thumb_config['thumb_width'];
$thumb_height = $thumb_config['thumb_height'];
$maxwh = max($thumb_width, $thumb_height);
if ($image->fileinfo['width'] > $image->fileinfo['height']) {
$thumb_config['thumb_width'] = 0;
$thumb_config['thumb_height'] = $maxwh;
} else {
$thumb_config['thumb_width'] = $maxwh;
$thumb_config['thumb_height'] = 0;
}
}
$image->resizeXY($thumb_config['thumb_width'], $thumb_config['thumb_height']);
if ($thumb_config['thumb_type'] == 4) {
$image->cropFromCenter($thumb_width, $thumb_height);
}
$image->save(NV_ROOTDIR . '/' . $viewDir, $m[3] . $m[4], $thumb_config['thumb_quality']);
$create_Image_info = $image->create_Image_info;
$error = $image->error;
$image->close();
if (empty($error)) {
return array($viewDir . '/' . basename($create_Image_info['src']), $create_Image_info['width'], $create_Image_info['height']);
}
}
} else {
$size = @getimagesize(NV_ROOTDIR . '/' . $fileName);
return array($viewFile, $size[0], $size[1]);
}
return false;
}
示例9: viewsubcat_main
function viewsubcat_main($viewcat, $array_cat)
{
global $module_name, $module_file, $global_array_cat, $lang_module, $module_config, $module_info, $global_config;
$xtpl = new XTemplate($viewcat . '.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('TEMPLATE', $global_config['module_theme']);
// Hien thi cac chu de con
foreach ($array_cat as $key => $array_row_i) {
if (isset($array_cat[$key]['content'])) {
$array_row_i['rss'] = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $module_info['alias']['rss'] . "/" . $array_row_i['alias'];
$xtpl->assign('CAT', $array_row_i);
$catid = intval($array_row_i['catid']);
if ($array_row_i['subcatid'] != '') {
$exl = 0;
$arrsubcat_s = explode(',', $array_row_i['subcatid']);
foreach ($arrsubcat_s as $subcatid_i) {
if ($global_array_cat[$subcatid_i]['inhome'] == 1) {
$xtpl->clear_autoreset();
if ($exl < 3) {
$xtpl->assign('SUBCAT', $global_array_cat[$subcatid_i]);
$xtpl->parse('main.listcat.subcatloop');
$xtpl->set_autoreset();
} else {
$more = array('title' => $lang_module['more'], 'link' => $global_array_cat[$catid]['link']);
$xtpl->assign('MORE', $more);
$xtpl->parse('main.listcat.subcatmore');
$xtpl->set_autoreset();
break;
}
++$exl;
}
}
}
$a = 0;
$xtpl->assign('IMGWIDTH', $module_config[$module_name]['homewidth']);
foreach ($array_cat[$key]['content'] as $array_row_i) {
$newday = $array_row_i['publtime'] + 86400 * $array_row_i['newday'];
$array_row_i['publtime'] = nv_date('d/m/Y h:i:s A', $array_row_i['publtime']);
$array_row_i['hometext'] = nv_clean60($array_row_i['hometext'], 90);
$array_row_i['title0'] = nv_clean60($array_row_i['title'], 40);
++$a;
if ($a == 1) {
$image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $array_row_i['homeimgfile'];
if ($array_row_i['homeimgfile'] != '' and file_exists($image)) {
$width = 370;
$height = 200;
$array_row_i['imghome'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $array_row_i['homeimgfile'];
$imginfo = nv_is_image($image);
$basename = basename($image);
if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
$basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $array_row_i['id'] . '_\\1_' . $width . '-' . $height . '\\2', $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$array_row_i['imghome'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
} else {
require_once NV_ROOTDIR . '/includes/class/image.class.php';
$_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$_image->cropFromCenter($width, $height);
$_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
$array_row_i['imghome'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
}
}
}
}
if ($newday >= NV_CURRENTTIME) {
$xtpl->parse('main.listcat.newday');
}
$xtpl->assign('CONTENT', $array_row_i);
if ($array_row_i['imghome'] != "") {
$xtpl->assign('HOMEIMG', $array_row_i['imghome']);
$xtpl->assign('HOMEIMGALT', !empty($array_row_i['homeimgalt']) ? $array_row_i['homeimgalt'] : $array_row_i['title']);
$xtpl->parse('main.listcat.image');
}
if (defined('NV_IS_MODADMIN')) {
$xtpl->assign('ADMINLINK', nv_link_edit_page($array_row_i['id']) . " " . nv_link_delete_page($array_row_i['id']));
$xtpl->parse('main.listcat.adminlink');
}
} else {
if ($newday >= NV_CURRENTTIME) {
$xtpl->assign('CLASS', 'icon_new_small');
} else {
$xtpl->assign('CLASS', 'icon_list');
}
$array_row_i['title0'] = nv_clean60($array_row_i['title'], 35);
$array_row_i['hometext'] = nv_clean60($array_row_i['hometext'], 90);
$xtpl->assign('OTHER', $array_row_i);
$xtpl->parse('main.listcat.related.loop');
}
if ($a > 1) {
$xtpl->assign('WCT', 'col-md-8 ');
} else {
$xtpl->assign('WCT', '');
}
$xtpl->set_autoreset();
}
if ($a > 1) {
$xtpl->parse('main.listcat.related');
}
$xtpl->parse('main.listcat');
}
//.........这里部分代码省略.........