File size: 7,895 Bytes
e07769f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Content\Site\Helper\RouteHelper;

HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers');
HTMLHelper::_('behavior.caption');

$app = Factory::getApplication();

// Create shortcuts to some properties.
$params  = $this->item->params;
$images  = json_decode($this->item->images);
$urls    = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user    = Factory::getUser();
$info    = $params->get('info_block_position', 0);
$attribs = json_decode($this->item->attribs);
?>

<div class="item-page<?php echo $this->pageclass_sfx; ?>" itemscope itemtype="https://schema.org/Article">
    <meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*' ? Factory::getApplication()->get('language') : $this->item->language); ?>">

    <?php if ($this->params->get('show_page_heading')) : ?>
    <div class="page-header">
        <h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
    </div>
    <?php endif; ?>

    <?php if (!empty($this->item->pagination) && !$this->item->paginationposition && $this->item->paginationrelative) {
        echo $this->item->pagination;
    } ?>

    <?php if ($params->get('show_title')) : ?>
    <div class="page-header">
        <h2 itemprop="headline">
            <?php echo $this->escape($this->item->title); ?>
        </h2>
        <?php if ($this->item->state == 0) : ?>
            <span class="label label-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
        <?php endif; ?>
        <?php if (strtotime($this->item->publish_up) > strtotime(Factory::getDate())) : ?>
            <span class="label label-warning"><?php echo Text::_('JNOTPUBLISHEDYET'); ?></span>
        <?php endif; ?>
        <?php echo $this->item->event->afterDisplayTitle; ?>
    </div>
    <?php endif; ?>

    <?php if ($canEdit) : ?>
        <div class="mb-4 flex gap-2">
            <?php echo HTMLHelper::_('icon.edit', $this->item, $params); ?>
            <?php echo HTMLHelper::_('icon.print_popup', $this->item, $params); ?>
            <?php echo HTMLHelper::_('icon.email', $this->item, $params); ?>
        </div>
    <?php endif; ?>

    <?php // Content is generated by content plugin event "onContentAfterTitle" ?>
    <?php echo $this->item->event->afterDisplayTitle; ?>

    <?php if ($params->get('show_tags') && !empty($this->item->tags->itemTags)) : ?>
        <?php $this->item->tagLayout = new FileLayout('joomla.content.tags'); ?>
        <?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
    <?php endif; ?>

    <?php // Content is generated by content plugin event "onContentBeforeDisplay" ?>
    <?php echo $this->item->event->beforeDisplayContent; ?>

    <?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '0')) || ($params->get('urls_position') == '0' && empty($urls->urls_position))) || (empty($urls->urls_position) && (!$params->get('urls_position')))) : ?>
    <?php echo $this->loadTemplate('links'); ?>
    <?php endif; ?>

    <?php if ($params->get('access-view')) : ?>
        <?php
        if (!empty($this->item->pagination) && !$this->item->paginationposition && $this->item->paginationrelative) {
            echo $this->item->pagination;
        }
        ?>

        <?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
        <?php $imgfloat = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
        <figure class="mb-6 overflow-hidden rounded-2xl">
            <img<?php if ($images->image_fulltext_caption) : ?> class="w-full h-auto object-cover"<?php endif; ?> src="<?php echo htmlspecialchars($images->image_fulltext, ENT_COMPAT, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8'); ?>" itemprop="image"/>
            <?php if ($images->image_fulltext_caption) : ?>
                <figcaption class="text-sm text-gray-500 mt-2 text-center bg-orange-50 p-2 rounded-b-2xl">
                    <?php echo htmlspecialchars($images->image_fulltext_caption, ENT_COMPAT, 'UTF-8'); ?>
                </figcaption>
            <?php endif; ?>
        </figure>
        <?php endif; ?>

        <div itemprop="articleBody" class="prose prose-orange max-w-none">
            <?php echo $this->item->text; ?>
        </div>

        <?php if ($info == 1 || $info == 2) : ?>
            <?php if ($useDefList) : ?>
                <div class="bg-orange-50 rounded-xl p-4 mt-6 text-sm text-gray-600">
                    <?php // Note: Not exists edit and edit-state in Joomla 4 ?>
                    <?php echo LayoutHelper::render('joomla.content.info_block', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>
                </div>
            <?php endif; ?>
        <?php endif; ?>

        <?php if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative) : ?>
            <?php echo $this->item->pagination; ?>
        <?php endif; ?>

        <?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '1')) || ($params->get('urls_position') == '1'))) : ?>
            <?php echo $this->loadTemplate('links'); ?>
        <?php endif; ?>

        <?php // Optional teaser intro text for guests ?>
    <?php elseif ($params->get('show_noauth') == true && $user->get('guest')) : ?>
        <?php echo LayoutHelper::render('joomla.content.intro_image', $this->item); ?>
        <?php echo HTMLHelper::_('content.prepare', $this->item->introtext); ?>
        <?php // Optional link to let them register to see the whole article. ?>
        <?php if ($params->get('show_readmore') && $this->item->fulltext != null) : ?>
            <?php $menu = Factory::getApplication()->getMenu(); ?>
            <?php $active = $menu->getActive(); ?>
            <?php $itemId = $active->id; ?>
            <?php $link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); ?>
            <?php $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); ?>
            
            <p class="readmore">
                <a href="<?php echo $link; ?>" class="btn btn-secondary">
                    <?php $attribs = json_decode($this->item->attribs); ?>
                    <?php if ($attribs->alternative_readmore == null) : ?>
                        <?php echo Text::_('COM_CONTENT_REGISTER_TO_READ_MORE'); ?>
                    <?php elseif ($readmore = $attribs->alternative_readmore) : ?>
                        <?php echo $readmore; ?>
                        <?php if ($params->get('show_readmore_title', 0) != 0) : ?>
                            <?php echo HTMLHelper::_('string.truncate', $this->item->title, $params->get('readmore_limit')); ?>
                        <?php endif; ?>
                    <?php elseif ($params->get('show_readmore_title', 0) == 0) : ?>
                        <?php echo Text::sprintf('COM_CONTENT_READ_MORE_TITLE'); ?>
                    <?php else : ?>
                        <?php echo Text::_('COM_CONTENT_READ_MORE'); ?>
                        <?php echo HTMLHelper::_('string.truncate', $this->item->title, $params->get('readmore_limit')); ?>
                    <?php endif; ?>
                </a>
            </p>
        <?php endif; ?>
    <?php endif; ?>

    <?php // Content is generated by content plugin event "onContentAfterDisplay" ?>
    <?php echo $this->item->event->afterDisplayContent; ?>
</div>