templates.php
2.72 KB
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
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* JHtml helper class.
*
* @since 1.6
*/
class JHtmlTemplates
{
/**
* Display the thumb for the template.
*
* @param string $template The name of the template.
* @param integer $clientId The application client ID the template applies to
*
* @return string The html string
*
* @since 1.6
*/
public static function thumb($template, $clientId = 0)
{
$client = JApplicationHelper::getClientInfo($clientId);
$basePath = $client->path . '/templates/' . $template;
$thumb = $basePath . '/template_thumbnail.png';
$preview = $basePath . '/template_preview.png';
$html = '';
if (file_exists($thumb))
{
JHtml::_('bootstrap.tooltip');
$clientPath = ($clientId == 0) ? '' : 'administrator/';
$thumb = $clientPath . 'templates/' . $template . '/template_thumbnail.png';
$html = JHtml::_('image', $thumb, JText::_('COM_TEMPLATES_PREVIEW'));
if (file_exists($preview))
{
$html = '<button type="button" data-target="#' . $template . '-Modal" class="thumbnail pull-left hasTooltip" data-toggle="modal"'
. ' title="' . JHtml::_('tooltipText', 'COM_TEMPLATES_CLICK_TO_ENLARGE') . '">' . $html . '</button>';
}
}
return $html;
}
/**
* Renders the html for the modal linked to thumb.
*
* @param string $template The name of the template.
* @param integer $clientId The application client ID the template applies to
*
* @return string The html string
*
* @since 3.4
*/
public static function thumbModal($template, $clientId = 0)
{
$client = JApplicationHelper::getClientInfo($clientId);
$basePath = $client->path . '/templates/' . $template;
$baseUrl = ($clientId == 0) ? JUri::root(true) : JUri::root(true) . '/administrator';
$thumb = $basePath . '/template_thumbnail.png';
$preview = $basePath . '/template_preview.png';
$html = '';
if (file_exists($thumb))
{
if (file_exists($preview))
{
$preview = $baseUrl . '/templates/' . $template . '/template_preview.png';
$footer = '<button type="button" class="btn" data-dismiss="modal">'
. JText::_('JTOOLBAR_CLOSE') . '</button>';
$html .= JHtml::_(
'bootstrap.renderModal',
$template . '-Modal',
array(
'title' => JText::_('COM_TEMPLATES_BUTTON_PREVIEW'),
'height' => '500px',
'width' => '800px',
'footer' => $footer,
),
$body = '<div><img src="' . $preview . '" style="max-width:100%" alt="' . $template . '"></div>'
);
}
}
return $html;
}
}