| 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/components/com_djcatalog2/views/producer/ |
Upload File : |
<?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\Router\Route;
use Joomla\CMS\Uri\Uri;
jimport('joomla.application.component.view');
jimport('joomla.html.pagination');
class DJCatalog2ViewProducer extends HtmlView {
public function __construct($config = array())
{
parent::__construct($config);
$this->_addPath('template', JPATH_ROOT.'/components/com_djcatalog2'. '/themes/default/views/producer');
$theme = DJCatalog2ThemeHelper::getThemeName();
if ($theme && $theme != 'default') {
$this->_addPath('template', JPATH_ROOT.'/components/com_djcatalog2'. '/themes/'.$theme.'/views/producer');
}
}
function display($tpl = null) {
$app = Factory::getApplication();
$document= Factory::getDocument();
$model = $this->getModel();
$params = Djcatalog2Helper::getParams();
$menus = $app->getMenu('site');
$menu = $menus->getActive();
$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$categories = Djc2Categories::getInstance(array('state'=>'1'));
$item = $model->getItem();
/* If Item not published set 404 */
if ($item->id == 0 || !$item->published)
{
throw new Exception(Text::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
}
/* plugins */
PluginHelper::importPlugin('djcatalog2');
$results = Joomla\CMS\Factory::getApplication()->triggerEvent('onPrepareItemDescription', array (& $item, & $params, 0));
$this->categories = $categories;
$this->item = $item;
$this->params = $params;
$this->attributes = $model->getAttributes();
$this->_prepareDocument();
parent::display($tpl);
}
protected function _prepareDocument() {
$app = Factory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
$heading = null;
$menu = $menus->getActive();
$cid = (int) @$menu->query['cid'];
$pid = (int) @$menu->query['pid'];
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;
}
$metakeys = null;
$metadesc = null;
if ($menu && ($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] != 'producer' || $pid != $this->item->id)) {
if ($this->item->metatitle) {
$title = $this->item->metatitle;
}
else if ($this->item->name) {
$title = $this->item->name;
}
$path = array(array('title' => $this->item->name, 'link' => ''));
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
$this->params->set('page_heading', $this->item->name);
} 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);
}
}
$this->document->setTitle($title);
foreach($this->document->_links as $key => $headlink) {
if ($headlink['relation'] == 'canonical' ) {
unset($this->document->_links[$key]);
}
}
$canonical = Route::_(DJCatalogHelperRoute::getProducerRoute($this->item->slug, $this->item->catslug), true, (Uri::getInstance()->isSSL() ? 1 : -1));
//$canonical = Uri::base(false).substr(Route::_($canonical), strlen(Uri::base(true)) + 1);
$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 ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
// Preparing data for Social Networks
$description = null;
if ($this->item->metadesc) {
$description = $this->item->metadesc;
} else if ($metadesc) {
$description = $metadesc;
} else {
$description = $this->item->description;
}
$description = Joomla\CMS\HTML\HTMLHelper::_('string.truncate', $description, 300, true, false);
$item_images = DJCatalog2ImageHelper::getImages('producer',$this->item->id);
$url = Route::_(DJCatalogHelperRoute::getProducerRoute($this->item->id.':'.$this->item->alias), 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).'" />');
$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).'" />');
$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].'" />');
}
}
}
}
?>