2024-08-06 18:06:00 +05:45

51 lines
1.3 KiB
PHP

<?php
namespace Opencart\Catalog\Controller\Extension\Opencart\Module;
/**
* Class Banner
*
* @package
*/
class Banner extends \Opencart\System\Engine\Controller {
/**
* @param array $setting
*
* @return string
*/
public function index(array $setting): string {
static $module = 0;
$this->load->model('design/banner');
$this->load->model('tool/image');
$data['banners'] = [];
$results = $this->model_design_banner->getBanner($setting['banner_id']);
foreach ($results as $result) {
if (is_file(DIR_IMAGE . html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'))) {
$data['banners'][] = [
'title' => $result['title'],
'link' => $result['link'],
'image' => $this->model_tool_image->resize(html_entity_decode($result['image'], ENT_QUOTES, 'UTF-8'), $setting['width'], $setting['height'])
];
}
}
if ($data['banners']) {
$data['module'] = $module++;
$data['effect'] = $setting['effect'];
$data['controls'] = $setting['controls'];
$data['indicators'] = $setting['indicators'];
$data['items'] = $setting['items'];
$data['interval'] = $setting['interval'];
$data['width'] = $setting['width'];
$data['height'] = $setting['height'];
return $this->load->view('extension/opencart/module/banner', $data);
} else {
return '';
}
}
}