Загрузка данных
<?php
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
// Создаем сокращения для параметров
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user = JFactory::getUser();
$info = $params->get('info_block_position', 0);
JLoader::register('fieldattach', 'components/com_fieldsattach/helpers/fieldattach.php');
JLoader::register('imagemaker', 'templates/probel/html/imagemaker.php');
JLoader::register('geturbisfield', 'templates/probel/html/getfielder.php');
$aparttit = '';
$aparttit = geturbisfield::fieldvalue($this->item->id, 5, false);
$topordown = fieldattach::getValue($this->item->id, 9, false);
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
if($this->item->catid == 60) $doc->addStyleSheet($this->baseurl.'/templates/probel/css/stylewtb.css');
// --- НАЧАЛО БЛОКА ГЕНЕРАЦИИ OG И TWITTER ТЕГОВ ---
// 1. Формируем заголовок страницы
$settit = '';
if(!isset($doc->_metaTags['name']['browser_title'])){
$doc->setTitle($this->item->title . ' | ' . $app->get('sitename'));
$settit = $this->item->category_title . ': ' . $this->item->title;
} else {
$settit = $doc->_metaTags['name']['browser_title'];
}
// 2. Формируем ЧИСТОЕ описание
$globalDesc = $app->get('MetaDesc');
$cleanText = strip_tags($this->item->text);
$cleanText = str_replace(array("\r", "\n", "\t"), ' ', $cleanText);
$cleanText = trim(preg_replace('/\s+/', ' ', $cleanText));
$tempDesc = mb_substr($cleanText, 0, 155);
$finalDesc = mb_substr($tempDesc, 0, mb_strrpos($tempDesc, ' ')) . '... Подробности на ' . $app->get('sitename');
// Устанавливаем описание (если пустое или равно глобальному)
if ($doc->getDescription() == '' || $doc->getDescription() == $globalDesc) {
$doc->setDescription($finalDesc);
}
// 3. Логика получения картинки для превью
$mainimage = imagemaker::makeimage($this->item->id, 950, 550, 'realimage', $this->item->title);
$raw_photo_path = !empty($mainimage) ? $mainimage : '';
if (empty($raw_photo_path) && isset($images->image_fulltext) && !empty($images->image_fulltext)) {
$raw_photo_path = $images->image_fulltext;
}
if (empty($raw_photo_path) && isset($images->image_intro) && !empty($images->image_intro)) {
$raw_photo_path = $images->image_intro;
}
if (!empty($raw_photo_path)) {
$clean_path = ltrim($raw_photo_path, '/');
if (strpos($clean_path, 'http') === 0) {
$final_discover_image = $clean_path;
} else {
$final_discover_image = JURI::base() . $clean_path;
}
} else {
$final_discover_image = JURI::base() . 'templates/probel/images/logo.png';
}
// 4. Добавляем мета-теги (теперь они точно попадут в <head>)
$doc->addCustomTag('<meta property="og:type" content="article" />');
$doc->addCustomTag('<meta property="og:url" content="'.JURI::current().'" />');
$doc->addCustomTag('<meta property="og:title" content="'.$settit.'" />');
$doc->addCustomTag('<meta property="og:image" content="'.$final_discover_image.'" />');
$doc->addCustomTag('<meta property="og:description" content="'.$doc->getDescription().'" />');
$doc->addCustomTag('<meta property="og:site_name" content="'.$app->get('sitename').'" />');
$doc->addCustomTag('<meta name="twitter:card" content="summary_large_image" />');
$doc->addCustomTag('<meta name="twitter:title" content="'.$settit.'" />');
$doc->addCustomTag('<meta name="twitter:description" content="'.$doc->getDescription().'" />');
$doc->addCustomTag('<meta name="twitter:image" content="'.$final_discover_image.'" />');
// --- КОНЕЦ БЛОКА ГЕНЕРАЦИИ OG И TWITTER ТЕГОВ ---
// Генерация серверной микроразметки NewsArticle для Google Discover
$schema_data = [
"@context" => "https://schema.org",
"@type" => "NewsArticle",
"mainEntityOfPage" => [
"@type" => "WebPage",
"@id" => JURI::current()
],
"headline" => $settit,
"image" => [
$final_discover_image
],
"datePublished" => date('c', strtotime($this->item->created)),
"dateModified" => !empty($this->item->modified) && $this->item->modified != $this->item->created ? date('c', strtotime($this->item->modified)) : date('c', strtotime($this->item->created)),
"author" => [
"@type" => "Person",
"name" => !empty($this->item->author) ? $this->item->author : "Редакция ProBelarus"
],
"publisher" => [
"@type" => "Organization",
"name" => $app->get('sitename'),
"logo" => [
"@type" => "ImageObject",
"url" => JURI::base() . "templates/probel/images/logo.png"
]
],
"description" => $doc->getDescription()
];
$doc->addCustomTag('<script type="application/ld+json">' . json_encode($schema_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . '</script>');
?>
<?php
// ============================================================
// === ГЕНЕРАЦИЯ OG, TWITTER И SCHEMA.ORG ТЕГОВ ==============
// ============================================================
// 1. Получаем чистый заголовок
$pageTitle = htmlspecialchars($this->item->title, ENT_QUOTES, 'UTF-8');
// 2. Получаем или генерируем ОПИСАНИЕ
$globalDesc = $app->get('MetaDesc');
$currentDesc = $doc->getDescription();
if (empty($currentDesc) || $currentDesc === $globalDesc) {
$cleanText = strip_tags($this->item->text);
$cleanText = str_replace(array("\r", "\n", "\t"), ' ', $cleanText);
$cleanText = trim(preg_replace('/\s+/', ' ', $cleanText));
$tempDesc = mb_substr($cleanText, 0, 155);
$finalDesc = mb_substr($tempDesc, 0, mb_strrpos($tempDesc, ' ')) . '...';
$finalDesc = $finalDesc . ' Подробности на ' . $app->get('sitename');
} else {
$finalDesc = $currentDesc;
}
$doc->setDescription($finalDesc);
// 3. Получаем ссылку на ОРИГИНАЛЬНУЮ картинку
$imageUrl = '';
$images = json_decode($this->item->images);
if (isset($images->image_fulltext) && !empty($images->image_fulltext)) {
$imageUrl = $images->image_fulltext;
} elseif (isset($images->image_intro) && !empty($images->image_intro)) {
$imageUrl = $images->image_intro;
} else {
$generatedImage = imagemaker::makeimage($this->item->id, 950, 550, 'realimage', $this->item->title);
if (!empty($generatedImage)) {
$imageUrl = $generatedImage;
}
}
$finalImageUrl = '';
if (!empty($imageUrl)) {
if (strpos($imageUrl, 'http') === 0) {
$finalImageUrl = $imageUrl;
} else {
$cleanPath = ltrim($imageUrl, '/');
$finalImageUrl = JURI::base() . $cleanPath;
}
} else {
$finalImageUrl = JURI::base() . 'templates/probel/images/logo.png';
}
// 4. УДАЛЯЕМ ВСЕ СТАРЫЕ МЕТА-ТЕГИ
$doc->_metaTags['property'] = array_filter(
$doc->_metaTags['property'],
function($key) {
return strpos($key, 'og:') !== 0;
},
ARRAY_FILTER_USE_KEY
);
$doc->_metaTags['name'] = array_filter(
$doc->_metaTags['name'],
function($key) {
return strpos($key, 'twitter:') !== 0;
},
ARRAY_FILTER_USE_KEY
);
// 5. Добавляем НОВЫЕ теги
$doc->setMetaData('og:type', 'article', 'property');
$doc->setMetaData('og:url', JURI::current(), 'property');
$doc->setMetaData('og:title', $pageTitle, 'property');
$doc->setMetaData('og:description', htmlspecialchars($finalDesc, ENT_QUOTES, 'UTF-8'), 'property');
$doc->setMetaData('og:image', $finalImageUrl, 'property');
$doc->setMetaData('og:image:width', '1200', 'property');
$doc->setMetaData('og:image:height', '630', 'property');
$doc->setMetaData('og:site_name', $app->get('sitename'), 'property');
$doc->setMetaData('twitter:card', 'summary_large_image', 'name');
$doc->setMetaData('twitter:title', $pageTitle, 'name');
$doc->setMetaData('twitter:description', htmlspecialchars($finalDesc, ENT_QUOTES, 'UTF-8'), 'name');
$doc->setMetaData('twitter:image', $finalImageUrl, 'name');
// 6. Удаляем старую Schema.org разметку
foreach ($doc->_custom as $key => $customTag) {
if (strpos($customTag, 'application/ld+json') !== false && strpos($customTag, '"NewsArticle"') !== false) {
unset($doc->_custom[$key]);
}
}
// 7. Добавляем НОВУЮ Schema.org разметку
$schema_data = [
"@context" => "https://schema.org",
"@type" => "NewsArticle",
"mainEntityOfPage" => [
"@type" => "WebPage",
"@id" => JURI::current()
],
"headline" => $pageTitle,
"image" => [$finalImageUrl],
"datePublished" => date('c', strtotime($this->item->created)),
"dateModified" => (!empty($this->item->modified) && $this->item->modified != $this->item->created)
? date('c', strtotime($this->item->modified))
: date('c', strtotime($this->item->created)),
"author" => [
"@type" => "Person",
"name" => !empty($this->item->author) ? $this->item->author : "Редакция ProBelarus"
],
"publisher" => [
"@type" => "Organization",
"name" => $app->get('sitename'),
"logo" => [
"@type" => "ImageObject",
"url" => JURI::base() . "templates/probel/images/logo.png"
]
],
"description" => htmlspecialchars($finalDesc, ENT_QUOTES, 'UTF-8')
];
$doc->addCustomTag('<script type="application/ld+json">' . json_encode($schema_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . '</script>');
// ============================================================
// === КОНЕЦ БЛОКА ГЕНЕРАЦИИ МЕТА-ТЕГОВ ======================
// ============================================================
?>
<section id="single-item" class="item-page products-area <?php echo $this->pageclass_sfx?>">
<?php if ($params->get('show_title')) : ?>
<div class="row">
<div class="col-sm-12">
<div class="section-title">
<h1 class="<?php echo $this->pageclass_sfx?>"><?php echo str_ireplace('|', '<br />', $this->item->title); ?></h1>
<?php if($params->get('show_publish_date')){
echo '<small>'.date('d/m/Y', strtotime($this->item->created)).' | <span class="fa fa-eye"></span> '.$this->item->hits.' просмотров</small>';
}
?>
</div>
</div>
</div>
<?php endif; ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<div class="row">
<div class="col-md-12 itemgallery <?php echo $this->pageclass_sfx?>">
<?php
$mainimage = imagemaker::makeimage($this->item->id, 950, 550, 'realimage', $this->item->title);
$dopfoto = imagemaker::makeimage($this->item->id, 950, 620, 'gallery', $this->item->title);
$bigimage = imagemaker::makeimage($this->item->id, 600, 350, 2, $this->item->title);
if(!empty($mainimage) && $topordown != '4' && $topordown != '1' && $topordown != '3'){ ?>
<div id="singleimage" class="singleblogimage">
<a class="popup-image" href="<?php echo $mainimage;?>">
<img src="<?php echo $mainimage;?>" /></a>
</div>
<?php }
if($topordown == '1' ){
if(!empty($dopfoto)){ ?>
<div class="itemgallery <?php echo $this->pageclass_sfx?>">
<?php echo $dopfoto;?>
<div class="clear"><br/></div>
</div>
<?php }
}
?>
<div class="datanews">
<?php
/*
$this->item->text = str_ireplace('2024 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2025 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2026 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2027 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2024 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2025 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2026 г', date('Y').' г',$this->item->text);
$this->item->text = str_ireplace('2027 г', date('Y').' г',$this->item->text);
*/
echo $this->item->text; ?>
</div>
<?php if (isset ($this->item->toc)) : ?>
<?php echo $this->item->toc; ?>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?>
</div>
<?php
if($topordown != '4' && $topordown != '1' ){
if(!empty($dopfoto)){ ?>
<div class="col-md-12 itemgallery <?php echo $this->pageclass_sfx?>">
<?php echo $dopfoto;?>
</div>
<?php }
}
?>
<?php $map = fieldattach::getFieldValue($this->item->id, 5, false);
if(!empty($map)) { ?>
<div class="col-md-12 <?php echo $this->pageclass_sfx?>">
<div class="itemmap">
<?php echo $map; ?>
</div>
</div>
<?php } ?>
<?php if($this->item->catid != '4'){ ?>
<div class="col-md-12">
<hr>
<p class="greycolor">Поделись с друзьями!</p>
<script src="https://yastatic.net/es5-shims/0.0.2/es5-shims.min.js"></script>
<script src="https://yastatic.net/share2/share.js"></script>
<div class="ya-share2" data-size="m" data-services="collections,vkontakte,facebook,odnoklassniki,twitter,linkedin,viber,whatsapp,telegram"></div>
<p class="greycolor hidden-xs"><br/>Обнаружили ошибку? Выделите текст и нажмите Ctrl + Enter<br/></p>
</div>
<?php } ?>
<?php
// читайте также ///////////////////////////////////
$infra = fieldattach::getValue($this->item->id, 118, false);
if(empty($infra)) {
$db = JFactory::getDBO();
$query = '';
$ctid= $this->item->catid;
if($ctid == '375' || $ctid == '290') {
$query = 'SELECT * FROM #__content WHERE state = 1 AND catid = '.$this->item->catid.' ORDER BY created DESC LIMIT 11';
$db->setQuery( $query );
$result = $db->loadObjectList();
}
elseif($ctid == '346' || $ctid == '348' || $ctid == '362' || $ctid == '363' || $ctid == '364' || $ctid == '365' || $ctid == '366' || $ctid == '368') {
$query = 'SELECT * FROM #__content WHERE state = 1 AND catid = '.$this->item->catid.' ORDER BY RAND() LIMIT 11';
$db->setQuery( $query );
$result = $db->loadObjectList();
}
if(!empty($result)){
// Кнопка "Следующая статья" (pagination) удалена отсюда, чтобы не мешать вовлечению
echo '<div class="clear"></div>';
?>
<div class="col-md-12 products-area lookmore-area">
<h3><span>Вам также понравится:</span></h3>
<div class="katslide-list">
<?php
foreach ($result as $item) {
$itemimage = '';
$itemimage = imagemaker::makeimage($item->id, 460, 345, 3, $item->title);
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid));
if(!empty($itemimage) && $item->id != $this->item->id){
?>
<div class="slidereadmore">
<a href="<?php echo $item->link;?>" style="text-decoration: none; color: inherit; display: block;">
<div class="insideitem equalhi">
<div class="katitemimage">
<?php echo $itemimage;?>
</div>
<div class="katitemtext">
<div class="itemtitle itemtitlebidder">
<?php echo $item->title;?>
</div>
</div>
</div>
</a>
</div>
<?php
}
}
?>
</div>
</div>
<?php
echo '</div>';
/////////////////////////////////////////
}
} elseif(!empty($infra)) {
// Кнопка "Следующая статья" удалена и из альтернативного вывода
?>
<div class="clear"></div>
<div class="subregionz">
<?php echo '<div class="col-md-12"><h3>Вам также понравится:</h3></div>';
$relatedarr = array();
$relatedarr = explode(',', $infra);
$relatedarr = array_reverse($relatedarr);
$num = 0;
echo '<div class="col-md-12">';
foreach ($relatedarr as $ids){
$num++;
$article = JTable::getInstance("content");
$article->load($ids);
$infraitem = $article;
$infralink = JRoute::_(ContentHelperRoute::getArticleRoute($infraitem->id, $infraitem->catid));
echo '<div class="tag-item col-md-12 col-sm-12 col-xs-12">';
echo '<a href="'.$infralink.'">'.$infraitem->title.'</a></div>';
}
?>
</div>
</div>
<?php }
// читайте также ///////////////////////////////////
?>
<?php
// МИГРАЦИЯ БАННЕРА ТУРОВ НА САМЫЙ НИЗ СТРАНИЦЫ
if($this->item->catid != '4'){
JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_banners/models', 'BannersModel');
JLoader::register('BannerHelper', JPATH_ROOT . '/components/com_banners/helpers/banner.php');
$model = JModelLegacy::getInstance('Banners', 'BannersModel', array('ignore_request' => true));
$model->setState('filter.client_id', 0);
$model->setState('filter.category_id', 385);
$model->setState('list.limit', 1);
$model->setState('list.start', 0);
$model->setState('filter.ordering', 'random');
$banners = $model->getItems();
if ($banners){
$model->impress();
if(isset($banners[0]) && !empty($banners[0])){
$this->banner = $banners[0];
$this->setLayout('banners');
echo '<div class="col-md-12">'.$this->loadTemplate().'</div>';
}
}
}
?>
<?php if($this->item->catid != '4'){ ?>
<div class="col-md-12">
<?php
jimport('joomla.application.module.helper');
$modules = JModuleHelper::getModules('reklamny-blok-niz');
foreach ($modules as $module) {
echo JModuleHelper::renderModule($module);
}
?>
</div>
<?php } ?>
</div>
</section>
<div class="clear"><br/></div>
<?php
$userId = JFactory::getUser()->get('id');
if(!$user->get('guest')){ ?>
<style>
.hidewhenlogin{
display: none !important;
}
</style>
<?php } ?>
<?php
if($this->item->id == 8151){
if($userId && !$user->get('guest')){
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$customFields = FieldsHelper::getFields('com_users.user', $user, true);
?>
<div class="modal fade" id="callprava" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Заказать платный пакет</h4>
</div>
<div class="modal-body">
<div class="formholder metalform">
<form method="post" action="#" class="webforms" enctype="multipart/form-data">
<div class="formholder">
<h4 class="pockettitle"></h4>
<p><?php echo $user->name;?></p>
<hr style="border-color: #ccc;">
<?php /*
<div xmlns="http://www.w3.org/1999/xhtml" class="line">
<div class="name">Наименование организации, УНП:</div>
<input type="text" name="data-tovar" placeholder="" class="input"></input></div>
*/ ?>
<input type="hidden" name="data-tovar" value="Запрос платного пакета от <?php echo $user->name.' ('.$user->email.')';?>">
<div xmlns="http://www.w3.org/1999/xhtml" class="line required">
<div class="name">Контактное лицо:</div>
<input type="text" name="data-imya" value="<?php echo $customFields[1]->value;?>" placeholder="" class="input"></input></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="line required">
<div class="name">Контактный телефон:</div>
<input type="text" name="data-telefon" placeholder="" value="<?php echo $customFields[2]->value;?>" class="input telbox"></input></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="line required">
<div class="name">Электронная почта:</div>
<input type="text" name="data-mail" placeholder="" value="<?php echo $user->email;?>" class="input"></input></div>
<br/>
<br/>
<input type="hidden" name="data-comment" class="data-comment" value="">
<input type="hidden" name="data-stranica" class="data-stranica" value="">
<input type="hidden" name="data-tema" class="data-tema" value="Купить платный пакет">
<div class="submit"><button type="submit" class="button subbutton btn btn-primary">ОТПРАВИТЬ</button></div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php } else echo '<style>.hidewhenlogout{display: none !important;}</style>';
}
?>
<style>.hidewhenlogout{display: none !important;}</style>