AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/amisdesseniors-fr/brest/components/com_djcatalog2/views/items/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/brest/components/com_djcatalog2/views/items/view.html.php
<?php
/**
 * @package DJ-Catalog2
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 *
 */

defined ('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Router\Route;

jimport('joomla.application.component.view');
jimport('joomla.html.pagination');

class DJCatalog2ViewItems extends HtmlView {

	public function __construct($config = array())
	{
		parent::__construct($config);
		$this->_addPath('template', JPATH_ROOT.'/components/com_djcatalog2'.  '/themes/default/views/items');
		$theme = DJCatalog2ThemeHelper::getThemeName();
		if ($theme && $theme != 'default') {
			$this->_addPath('template', JPATH_ROOT.'/components/com_djcatalog2'.  '/themes/'.$theme.'/views/items');
		}
	}

	function display($tpl = null) {
		$app = Factory::getApplication();
		$jinput = $app->input;
		$view = $jinput->get('view');
		$document= Factory::getDocument();
		$model = $this->getModel();
		$user	= Factory::getUser();
		$groups	= $user->getAuthorisedViewLevels();

		$menus		= $app->getMenu('site');
		$menu  = $menus->getActive();

		$mOption = (empty($menu->query['option'])) ? null : $menu->query['option'];
		$mCatid = (empty($menu->query['cid'])) ? null : (int)$menu->query['cid'];
		$mProdid   = (empty($menu->query['pid'])) ? null : (int)$menu->query['pid'];

		$filter_catid		= $jinput->getInt('cid', null);
		if ($filter_catid === null && $mOption == 'com_djcatalog2' && $mCatid) {
			$filter_catid = $mCatid;
			$jinput->set('cid', $filter_catid);
		}

		$filter_producerid	= $jinput->get( 'pid',null,'string' );
		if ($filter_producerid === null && $mOption == 'com_djcatalog2' && $mProdid) {
			$filter_producerid = $mProdid;
			$jinput->set('pid', (int)$filter_producerid);
		}

		$params = Djcatalog2Helper::getParams();

		$filter_order		= $jinput->get( 'order',$params->get('items_default_order','i.ordering'),'cmd' );
		$filter_order_Dir	= $jinput->get( 'dir',	$params->get('items_default_order_dir','asc'), 'word' );
		$search				= urldecode($jinput->get( 'search','','string' ));
		$search				= \Joomla\String\StringHelper::strtolower( $search );

		$mapsearch			= urldecode($jinput->get( 'mapsearch','','string' ));
		$mapsearch			= \Joomla\String\StringHelper::strtolower( $mapsearch );

		$limitstart	= $jinput->get('limitstart', 0, 'int');
		$limit_items_show = $params->get('limit_items_show',10);
		//$jinput->set('limit', $limit_items_show);

		$lists = array();

		if (\Joomla\String\StringHelper::strlen($search) > 0 && (\Joomla\String\StringHelper::strlen($search)) < 1 || \Joomla\String\StringHelper::strlen($search) > 40) {
			Factory::getApplication()->enqueueMessage(Text::_( 'COM_DJCATALOG2_SEARCH_RESTRICTION'), 'notice');
		}
		if ($filter_order_Dir == '' || $filter_order_Dir == 'desc') {
			$lists['order_Dir'] = 'asc';
		} else {
			$lists['order_Dir'] = 'desc';
		}
		$lists['order'] = $filter_order;

		$layout = $jinput->get('layout', 'default', 'string');
		$dispatcher	= Joomla\CMS\Factory::getApplication()->getDispatcher();
		$categories = Djc2Categories::getInstance(array('state'=>'1', 'access'=>$groups));

		// current category
		$category = $categories->get((int) $jinput->getInt('cid',0));
		$subcategories = null;
		if (!empty($category)) {
			$subcategories = $category->getChildren();
			//$subcategories = $model->getSubCategories($category);
		}
		/* If Cateogory not published set 404 */
		if (($category && $category->id > 0 && $category->published == 0) || empty($category)) {
			throw new Exception(Text::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
		}

		if (!in_array($category->access, $groups))
		{
			throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'), 403);
		}

		//Tags filter
		$tag = $jinput->get('tag');
		if(isset($tag) && (int)$tag > 0){
			$model->setState('filter.tags', (int)$tag);
		}

		$list = $model->getItems();

		$total = count($list);//$model->getTotal();
		$pagination = $model->getPagination();
		$pagination->setAdditionalUrlParam('cid',$category->catslug);

		// Set additional params saved in url
		foreach ($_GET as $key => $value) {
			// Skip the 'start' parameter
			if ($key !== 'start') {
				// Add the key and value to the pagination additional URL parameters
				$pagination->setAdditionalUrlParam($key, $value);
			}
		}

		// search filter
		$lists['search'] = $search;

		if ($params->get('images_only')) {
			$lists['pic_only'] = $jinput->getInt('pic_only', 1);
		} else {
			$lists['pic_only'] = $jinput->getInt('pic_only', 0);
		}

		// locations filter
		$lists['mapsearch']= $mapsearch;

		// category filter
		$category_options = $categories->getOptionList('- '.Text::_('COM_DJCATALOG2_SELECT_CATEGORY').' -');
		if ($filter_catid > 0 && (int)$params->get('category_filter_type', '0') > 0) {
			$category_path = $category->getPath();
			if (count($category_path) > 0) {
				$parent_category = null;
				$parent_id = 0;
				if ($params->get('category_filter_type', '1') == '1' || count($category_path) == 1) {
					//$parent_category = $categories->get((int)end($category_path));
					$parent_id = ($mCatid == 0 && count($category_path) == 1) ? 0 : (int)end($category_path);
				} else if ($params->get('category_filter_type', '1') == '2') {
					$parent_id = ($mCatid == 0) ? $mCatid : (((int)end($category_path) == $category->id) ? $category->id : $category->parent_id);
				} else {
					$parent_id = ((int)$mCatid > 0) ? 0 : (int)$category_path[1];
				}

				$parent_category = $categories->get($parent_id);

				if ($parent_category) {
					$childrenList = array($parent_category->id);
					$parent_category->makeChildrenList($childrenList);
					foreach ($category_options as $key => $option) {
						if (!in_array($option->value, $childrenList)) {
							unset($category_options[$key]);
						}
						if ($option->value == $parent_category->id) {
							$category_options[$key]->text = ($parent_category->id == $filter_catid || (int)$option->value == 0) ?  '- '.Text::_('COM_DJCATALOG2_SELECT_CATEGORY').' -' : '- '.Text::_('COM_DJCATALOG2_SELECT_CATEGORY_LEVEL_UP').' -';
						}
					}
				}
			}
		}

		$lists['categories'] = Joomla\CMS\HTML\HTMLHelper::_('select.genericlist', $category_options, 'cid', 'class="input form-control" ', 'value', 'text', $filter_catid);

		// producer filter
		$producers_first_option = new stdClass();
		$producers_first_option->id = '0';
		$producers_first_option->text = '- '.Text::_('COM_DJCATALOG2_SELECT_PRODUCER').' -';
		$producers_first_option->disable = false;
		$prodList = $model->getProducers();
		$producers = count($prodList) ? array_merge(array($producers_first_option),$prodList) : array($producers_first_option);
		$lists['producers'] = Joomla\CMS\HTML\HTMLHelper::_('select.genericlist', $producers, 'pid', 'class="input form-control" ', 'id', 'text', (int)$filter_producerid);

		$lists['index'] = $model->getIndexCount();

		if ((int)$params->get('show_country_state_filter') > 0) {

			$selectedCountries = $params->get('country_state_filter_country', array());

			$filter_countryid = $jinput->getInt('cntid', 0);
			$countries_first_option = new stdClass();
			$countries_first_option->id = '0';
			$countries_first_option->country_name = '- '.Text::_('COM_DJCATALOG2_SELECT_COUNTRY').' -';
			$countries_first_option->disable = false;
			$cntList = $model->getCountries($selectedCountries);
			$countries = count($cntList) ? array_merge(array($countries_first_option),$cntList) : array($countries_first_option);
			$lists['countries'] = Joomla\CMS\HTML\HTMLHelper::_('select.genericlist', $countries, 'cntid', 'class="input form-control" ', 'id', 'country_name', (int)$filter_countryid);


			$filter_stateid = $jinput->getInt('stid', 0);
			$states_first_option = new stdClass();
			$states_first_option->id = '0';
			$states_first_option->country_id = 0;
			$states_first_option->name = '- '.Text::_('COM_DJCATALOG2_SELECT_STATE').' -';
			$states_first_option->disable = false;
			$stateCountries = array();

			if ($filter_countryid > 0){
				$stateCountries[] = $filter_countryid;
			} else {
				$stateCountries = $selectedCountries;
			}

			if (!empty($stateCountries)) {
				$stateList = $model->getStates($stateCountries);
				$states = count($stateList) ? array_merge(array($states_first_option),$stateList) : array($states_first_option);
				if ((int)$params->get('show_country_state_filter') == 2 && count($stateCountries) > 1) {
					$groupedStates = array();
					$groupOpts = array('format.depth' => 0, 'group.items' => 'items', 'group.label' => 'name', 'group.label.toHtml' => true, 'id' => 'stid', 'list.select' => $filter_stateid, 'list.attr'   => 'class="input form-control"');
					foreach($states as $state) {
						if (!isset($groupedStates[$state->country_id])) {
							$groupedStates[$state->country_id] = new stdClass();
							if ($state->country_id) {
								$groupedStates[$state->country_id]->id = $state->country_id;
								$groupedStates[$state->country_id]->name = $state->country_name;
							}
							$groupedStates[$state->country_id]->items = array();
						}
						$groupedStates[$state->country_id]->items[] = HTMLHelperSelect::option($state->id, $state->name);
					}
					$lists['states'] = Joomla\CMS\HTML\HTMLHelper::_('select.groupedlist', $groupedStates, 'stid', $groupOpts);
				} else {
					$lists['states'] = Joomla\CMS\HTML\HTMLHelper::_('select.genericlist', $states, 'stid', 'class="input form-control" ', 'id', 'name', (int)$filter_stateid);
				}
			} else {
				$lists['states'] = null;
			}
		}
		/* plugins */
		PluginHelper::importPlugin('djcatalog2');
		PluginHelper::importPlugin('content');

		if ($category && $category->id > 0) {
			$results = Joomla\CMS\Factory::getApplication()->triggerEvent('onPrepareItemDescription', array (& $category, & $params, $limitstart));
		}

		if (count($list)) {
			PluginHelper::importPlugin('djcatalog2');

			foreach ($list as $k=>$v) {
				$list[$k]->event = new stdClass();

				$resultsAfterTitle = Joomla\CMS\Factory::getApplication()->triggerEvent('onAfterDJCatalog2DisplayTitle', array (&$list[$k], &$this->params, 0, 'items.'.$params->get('list_layout','items')));
				$list[$k]->event->afterDJCatalog2DisplayTitle = trim(implode("\n", $resultsAfterTitle));

				$resultsBeforeContent = Joomla\CMS\Factory::getApplication()->triggerEvent('onBeforeDJCatalog2DisplayContent', array (&$list[$k], &$this->params, 0, 'items.'.$params->get('list_layout','items')));
				$list[$k]->event->beforeDJCatalog2DisplayContent = trim(implode("\n", $resultsBeforeContent));

				$resultsAfterContent = Joomla\CMS\Factory::getApplication()->triggerEvent('onAfterDJCatalog2DisplayContent', array (&$list[$k], &$this->params, 0, 'items.'.$params->get('list_layout','items')));
				$list[$k]->event->afterDJCatalog2DisplayContent = trim(implode("\n", $resultsAfterContent));

				$orgDescription = $list[$k]->description;
				$list[$k]->description = $list[$k]->intro_desc;
				Joomla\CMS\Factory::getApplication()->triggerEvent('onPrepareItemDescription', array (&$list[$k], &$this->params, 0, 'items.'. $params->get('list_layout','items') ));
				$list[$k]->intro_desc = $list[$k]->description;
				$list[$k]->description = $orgDescription;
			}
		}

		$this->document = $document;
		$this->item = $category;
		$this->categories = $categories;
		$this->subcategories = $subcategories;
		$this->lists = $lists;
		$this->items = $list;
		$this->lists = $lists;
		$this->total = $total;
		$this->pagination = $pagination;
		$this->params = $params;
		$this->model = $model;
		$this->attributes = $model->getAttributes();
		$this->column_attributes = $model->getFieldGroups();
		$this->sortables = $model->getSortables();
		$this->_prepareDocument();


		parent::display($tpl);
	}

	protected function _prepareDocument() {
		$app		= Factory::getApplication();
		$menus		= $app->getMenu();
		$pathway	= $app->getPathway();
		$title		= null;
		$heading 	= null;

		$menu = $menus->getActive();

		$id = (int) @$menu->query['cid'];
		$pid	= $app->input->get( 'pid',null,'string' );
		$limitstart = $app->input->get('limitstart', 0, 'int');

		if ($menu) {
			$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
		}
		$title = $this->params->get('page_title', '');

		if (!empty($this->item->metatitle)) {
			$title = $this->item->metatitle;
		}

		$headingOverride = $this->params->get('category_heading_override', 0);

		if ($this->item->id > 0) {
			$heading = $this->item->heading ? trim((string)$this->item->heading): trim((string)$this->item->name);
			if ($headingOverride == '1') {
				$this->params->set('page_heading', $heading);
			}
		}

		if ($headingOverride == '1') {
			$this->params->set('show_page_heading', 1);
		}
		else if ($headingOverride == '-1') {
			$this->params->set('show_page_heading', 0);
		}

		$metakeys = null;
		$metadesc = null;

		if ($menu && ($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] != 'items' || $id != $this->item->id)) {

			if (!empty($this->item->metatitle)) {
				$title = $this->item->metatitle;
			}
			else if ($this->item->name && $this->item->id > 0) {
				$title = $this->item->name;
			}

			$path = array();
			if ($this->item->id == 0) {
				//$path = array(array('title' => $title, 'link' => ''));
			} else {
				$path = array(array('title' => $this->item->name, 'link' => ''));
			}

			$category = $this->categories->get($this->item->parent_id);
			if ($category) {
				while (($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] == 'item' || $id != $category->id) && $category->id > 0)
				{
					$path[] = array('title' => $category->name, 'link' => DJCatalogHelperRoute::getCategoryRoute($category->catslug));
					$category = $this->categories->get($category->parent_id);
				}
			}

			$path = array_reverse($path);

			foreach ($path as $item)
			{
				$pathway->addItem($item['title'], $item['link']);
			}
		} else if (!empty($menu)) {
			if ($this->params->get('menu-meta_description')) {
				$metadesc = $this->params->get('menu-meta_description');
			}
			if ($this->params->get('menu-meta_keywords')) {
				$metakeys = $this->params->get('menu-meta_keywords');
			}
		}

		if (empty($title)) {
			$title = $app->getCfg('sitename');
		}
		elseif ($app->getCfg('sitename_pagetitles', 0)) {
			if ($app->getCfg('sitename_pagetitles', 0) == '2') {
				$title = Text::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
			} else {
				$title = Text::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
			}
		}

		if ($this->pagination->total > 0 && $this->pagination->total > $this->pagination->limit) {
			$pages_total = ceil($this->pagination->total / $this->pagination->limit);
			$page_no = ceil(($this->pagination->limitstart + 1) / $this->pagination->limit);

			$previous_page = ($page_no > 1) ? (($page_no - 2) * $this->pagination->limit) : false;
			$next_page = ($page_no < $pages_total) ? ($page_no * $this->pagination->limit) : false;

			if ($previous_page !== false) {
				$this->document->addHeadLink(Route::_('&limitstart='.(int)$previous_page), 'prev', 'rel');
			}
			if ($next_page !== false) {
				$this->document->addHeadLink(Route::_('&limitstart='.(int)$next_page), 'next', 'rel');
			}

			if ($this->pagination->limitstart > 0) {
				if ($page_no > 0) {
					$title .= ' ['.$page_no.'/'.$pages_total.']';
				}
			}

		}

		$this->document->setTitle($title);

		$uri = Uri::getInstance();
		$vars = $uri->getQuery(true);
		unset($vars['order']);
		unset($vars['dir']);
		unset($vars['l']);

		$baseUrl = DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid);

		if (!empty($vars)){
			$baseUrl .= '&'.$uri->buildQuery($vars);
		}

		$app->setHeader('X-App-DJCatalog-URI', urlencode(Route::_($baseUrl, false)));
		$app->setHeader('X-App-DJCatalog-URL', urlencode(Route::_($baseUrl, false, (Uri::getInstance()->isSSL() ? 1 : -1))));

		$canonical = Route::_($baseUrl, true, (Uri::getInstance()->isSSL() ? 1 : -1));

		$menu = $app->getMenu('site')->getActive();
		// We do not add different Canonical URL when the current menu applies any filtering criteria 
		if (!empty($menu) && !empty($menu->query) && $menu->query['view'] == 'items' && $menu->query['option'] == 'com_djcatalog2') {
			if (!empty($menu->query['filter'])) {
				$canonical = Uri::current();
			}
		}

		$this->document->addHeadLink($canonical, 'canonical');

		if (!empty($this->item->metadesc))
		{
			$this->document->setDescription($this->item->metadesc);
		}
		elseif (!empty($metadesc))
		{
			$this->document->setDescription($metadesc);
		}

		if (!empty($this->item->metakey))
		{
			$this->document->setMetadata('keywords', $this->item->metakey);
		}
		elseif (!empty($metakeys))
		{
			$this->document->setMetadata('keywords', $metakeys);
		}

		if ($app->input->get('filtering', false)) {
			$this->document->setMetadata('robots', 'noindex, follow');
		} else if ($this->params->get('robots'))
		{
			$this->document->setMetadata('robots', $this->params->get('robots'));
		}

		// Preparing data for Social Networks

		$description = null;
		if ($this->item->id > 0 && !empty($this->item->metadesc)) {
			$description = $this->item->metadesc;
		} else if ($metadesc) {
			$description = $metadesc;
		} else if ($this->item->id > 0) {
			$description = $this->item->description;
		}
		if($description !== null)
		$description = Joomla\CMS\HTML\HTMLHelper::_('string.truncate', $description, 300, true, false);
		$item_images = DJCatalog2ImageHelper::getImages('category',$this->item->id);
		$url = Route::_(DJCatalogHelperRoute::getCategoryRoute($this->item->catslug), true, (Uri::getInstance()->isSSL() ? 1 : -1));
		//$url = Uri::base(false).substr($url, strlen(Uri::base(true)) + 1);
		$image_size = null;
		$image_url = null;

		if (isset($item_images[0])) {
			$image_path = DJCatalog2ImageHelper::getImagePath($item_images[0]->fullpath, 'fullscreen');
			$image_size = @getimagesize($image_path);
			$image_url = Uri::root(false).DJCATIMGPATH .'/'.$item_images[0]->path.'/'.$item_images[0]->name.'_f.'.$item_images[0]->ext;
		}

		// Facebook OG
		$this->document->addCustomTag('<meta property="og:title" content="'.trim((string)$title).'" />');
		if ($description) {
			$this->document->addCustomTag('<meta property="og:description" content="'.$description.'" />');
		}
		$this->document->addCustomTag('<meta property="og:url" content="'.$url.'" />');

		//if (isset($item_images[0])) {
		if ($image_url) {
			$this->document->addCustomTag('<meta property="og:image" content="'.$image_url.'" />');

			if (is_array($image_size) && count($image_size) > 1) {
				$this->document->addCustomTag('<meta property="og:image:width" content="'.$image_size[0].'" />');
				$this->document->addCustomTag('<meta property="og:image:height" content="'.$image_size[1].'" />');
			}
		}

		// Twitter Cards
		$this->document->addCustomTag('<meta property="twitter:card" content="summary" />');
		$this->document->addCustomTag('<meta property="twitter:title" content="'.trim((string)$title).'" />');
		if ($description) {
			$this->document->addCustomTag('<meta property="twitter:description" content="'.$description.'" />');
		}
		//if (isset($item_images[0])) {
		if ($image_url) {
			$this->document->addCustomTag('<meta property="twitter:image:src" content="'.$image_url.'" />');

			if (is_array($image_size) && count($image_size) > 1) {
				$this->document->addCustomTag('<meta property="twitter:image:width" content="'.$image_size[0].'" />');
				$this->document->addCustomTag('<meta property="twitter:image:height" content="'.$image_size[1].'" />');
			}
		}

		if ($this->params->get('rss_enabled', '1') == '1') {
			$this->feedlink =  Route::_(DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid).'&format=feed&type=rss&limitstart=0');
			//$link = '&format=feed&limitstart=';
			$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
			$this->document->addHeadLink(Route::_( DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid) . '&format=feed&type=rss'), 'alternate', 'rel', $attribs);
			$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
			$this->document->addHeadLink(Route::_( DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid) . '&format=feed&type=atom'), 'alternate', 'rel', $attribs);
		}
	}

}





Anon7 - 2022
AnonSec Team