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/common/menu.php
<?php
class ControllerCommonMenu extends Controller {
	public function index() {

				$uniset = $this->config->get('config_unishop2');
				
				$this->load->model('tool/image');
				
				$new_data = $this->load->controller('extension/module/uni_new_data', ['type' => 'menu']);
				
				$data = isset($data) ? array_merge($data, $new_data) : $new_data;
				
				$third_level_limit = isset($uniset['menu']['third_level']['limit']) ? $uniset['menu']['third_level']['limit'] : 0;
			
		$this->load->language('common/menu');

		// Menu
		$this->load->model('catalog/category');

		$this->load->model('catalog/product');

		
			if(isset($uniset['menu']['caching']['status'])){
				$cache_name = 'category.unishop.menu.'.(int)$this->config->get('config_language_id').'.'.(int)$this->config->get('config_store_id');
				$data['categories'] = $this->cache->get($cache_name) ? $this->cache->get($cache_name) : [];
			} else {
				$data['categories'] = [];
			}
			
			if(!$data['categories']) {
			

		$categories = $this->model_catalog_category->getCategories(0);
		$current_url = rtrim($this->request->server['HTTPS'] ? HTTPS_SERVER : HTTP_SERVER, '/') 
               . '/' 
               . ltrim($this->request->server['REQUEST_URI'], '/');


		foreach ($categories as $category) {
			if ($category['top']) {

				$show_child_image = in_array($category['category_id'], $uniset['menu']['second_level']['image']) ? true : false;
			
				// Level 2
				$children_data = array();

				$children = $this->model_catalog_category->getCategories($category['category_id']);

				foreach ($children as $child) {
					$filter_data = array(
						'filter_category_id'  => $child['category_id'],
						'filter_sub_category' => true
					);

						
				$children2 = $this->model_catalog_category->getCategories($child['category_id']);
					
				$children_data2 = [];
				$child_count = 0;
				$more = '';
				$show_more = $third_level_limit && $third_level_limit < count($children2) ? true : false;
				
				$children_data2_url = rtrim($this->url->link('product/category', 'path='.$category['category_id'].'_'.$child['category_id'].'_'.$child2['category_id'], true));

				foreach ($children2 as $child2) {
					if(isset($uniset['menu_links_show']) ? $child2['top'] : 1) {
						$children_data2[] = [
							'name'  		=> $child2['name'],
							'category_id'	=> $child2['category_id'],
							'href'  		=> ($current_url != $children_data2_url) ? $children_data2_url : 'javascript:;' ,
							'sort_order'	=> $child2['sort_order']
						];
							
						$child_count++;
					}
						
					if($show_more && $third_level_limit == $child_count) {
						$more = count($children2);
						break;
					}
				}
				
				if(isset($data['landinglinks'][$child['category_id']])) {
					$children_data2 = array_merge($children_data2, $data['landinglinks'][$child['category_id']]);
					
					array_multisort(array_column($children_data2, 'sort_order'), SORT_ASC, $children_data2);
				}
					
				if(isset($uniset['menu_links_show']) ? $child['top'] : 1) {
					$children_data_url = rtrim($this->url->link('product/category', 'path='.$category['category_id'].'_'.$child['category_id'], true));

					$children_data[] = [
						'name'       	=> $child['name'],
						'category_id'	=> $child['category_id'],
						'image'			=> $show_child_image && $children_data2 && $child['image'] ? $this->model_tool_image->resize($child['image'], 100, 100) : '',
						'children'   	=> $children_data2,
						'href'        	=> ($current_url != $children_data_url) ? $children_data_url : 'javascript:;' ,
						'sort_order'	=> $child['sort_order'],
						'more'			=> $more
					];
				}
			}
			
			if (isset($data['landinglinks'][$category['category_id']])) {
				$children_data = array_merge($children_data, $data['landinglinks'][$category['category_id']]);
					
				array_multisort(array_column($children_data, 'sort_order'), SORT_ASC, $children_data);
			}
			
			// Level 1
				$category_url = rtrim($this->url->link('product/category', 'path=' . $category['category_id']));
				
				$data['categories'][] = array(
					'name'     => $category['name'],
					'icon'		=> isset($data['icons'][$category['category_id']]) ? $data['icons'][$category['category_id']] : [],
					'banner'	=> isset($data['banners'][$category['category_id']]) && $category['column'] > 1 ? $data['banners'][$category['category_id']] : [],
					'sort_order'=> $category['sort_order'],
					'children' => $children_data,
					'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => ($current_url != $category_url) ? $category_url : 'javascript:;'
				);
			}
		}


			if($data['additional_link']) {
				$data['categories'] = array_merge($data['categories'], $data['additional_link']);
				
				if(count($data['categories']) > 1) {
					array_multisort(array_column($data['categories'], 'sort_order'), SORT_ASC, $data['categories']);
				}
			}
			
				if(isset($uniset['menu']['caching']['status'])){
					$this->cache->set($cache_name, $data['categories']);
				}
			}
			
		return $this->load->view('common/menu', $data);
	}
}