HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/retile.ru/public_html/catalog/controller/extension/module/uni_news_related.php
<?php
class ControllerExtensionModuleUniNewsRelated extends Controller {
	public function index($product_id = 0) {
		$this->load->language('extension/module/uni_othertext');
		$this->load->language('extension/module/uni_news');
		
		$this->load->model('extension/module/uni_news');
		$this->load->model('tool/image');
		
		$settings = $this->config->get('uni_news');
		
		$data['news'] = [];
		
		if(isset($settings['image_width'])) {
			$thumb_width = $settings['image_width'];
			$thumb_height = $settings['image_height'];
			$numchars = $settings['chars'];
		} else {
			$thumb_width = 320;
			$thumb_height = 240;
			$numchars = 140; 
		}
			
		$numchars = 140;
		
		$data['img_width'] = $thumb_width;
		$data['img_height'] = $thumb_height;
		
		$product_id = isset($this->request->get['product_id']) ? (int)$this->request->get['product_id'] : (int)$product_id;
		
		$results = $this->model_extension_module_uni_news->getNewsStoryforRelatedProduct($product_id);
		
		if($results) {
			$this->document->addStyle('catalog/view/theme/unishop2/stylesheet/news.css');

			foreach ($results as $result) {
				if ($result['image']) {
					$image = $this->model_tool_image->resize($result['image'], $thumb_width, $thumb_height);
				} else {
					$image = $this->model_tool_image->resize('placeholder.png', $thumb_width, $thumb_height);
				}

				$description = utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $numchars) . '..';
				
				$news_category = $this->model_extension_module_uni_news->getCategory($result['category_id']);

				$data['news'][] = [
					'name'        	=> $result['name'],
					'image'			=> $image,
					'description'	=> $description,
					'href'         	=> $this->url->link('information/uni_news_story', 'news_id=' . $result['news_id']),
					'viewed'   		=> $result['viewed'],
					'posted'   		=> date($this->language->get('date_format_short'), strtotime($result['date_added'])),
					'category_name' => isset($news_category['name']) ? $news_category['name'] : '',
					'category_href' => isset($news_category['category_id']) ? $this->url->link('information/uni_news', 'news_path='.$news_category['category_id']) : '',
				];
			}
		}

		return $this->load->view('extension/module/uni_news_related', $data);
	}
}
?>