view.html.php
8.07 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
// namespace components\com_jmap\views\sitemap;
/**
* @package JMAP::SITEMAP::components::com_jmap
* @subpackage views
* @subpackage sitemap
* @author Joomla! Extensions Store
* @copyright (C) 2015 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
/**
* Main view class
*
* @package JMAP::SITEMAP::components::com_jmap
* @subpackage views
* @subpackage sitemap
* @since 1.0
*/
class JMapViewSitemap extends JMapView {
/**
* Display the sitemap
* @access public
* @return void
*/
public function display($tpl = null) {
$app = JFactory::getApplication ();
$menu = $app->getMenu ();
$document = $this->document;
$this->menuname = $menu->getActive ();
$this->cparams = $this->getModel ()->getState ( 'cparams' );
if (isset ( $this->menuname )) {
$this->menuname = $this->menuname->title;
}
// Call by cache handler get no params, so recover from model state
if(!$tpl) {
$tpl = $this->getModel ()->getState ( 'documentformat' );
}
// Accordion della sitemap
if($this->getModel ()->getState ( 'cparams' )->get('includejquery', 1)) {
JHtml::_('jquery.framework');
}
// If there is a pingiframe request ensure that the gojs template is not executed, eventually fallback to the default template
if($app->input->getInt('pingiframe', null) && $this->cparams->get('sitemap_html_template', '') == 'gojs') {
$this->cparams->set('sitemap_html_template', '');
}
// Check if enabled the draggable mindmap sitemap
$draggableSitemap = $this->cparams->get('draggable_sitemap', 0);
$mindMapSitemap = $this->cparams->get('sitemap_html_template', '') == 'mindmap';
$goJsSitemap = $this->goJsSitemap = $this->cparams->get('sitemap_html_template', '') == 'gojs' ? 1 : 0;
if($draggableSitemap && $mindMapSitemap) {
$this->loadJQueryUI($document);
}
// Add the original component script
$this->scriptsLoading = $this->cparams->get('loadasyncscripts', 0) ? true : false;
if($this->cparams->get('treeview_scripts', 1)) {
$document->addScript ( JUri::root(true) . '/components/com_jmap/js/jquery.treeview.js', 'text/javascript', $this->scriptsLoading );
}
// Manage sitemap layout
if(!$this->cparams->get('show_icons', 1)) {
$document->addStyleDeclaration('span.folder{cursor:pointer}');
} else {
// Check if a template override is requested
if(!$this->cparams->get('template_override', 0)) {
$document->addStyleSheet ( JUri::root(true) . '/components/com_jmap/js/jquery.treeview.css' );
if($sitemapTemplate = $this->cparams->get('sitemap_html_template', null)) {
$document->addStyleSheet ( JUri::root(true) . '/components/com_jmap/js/jquery.treeview-' . $sitemapTemplate . '.css' );
}
} else {
JHtml::stylesheet('com_jmap/js/jquery.treeview.css', array(), true, false, false, false);
if($sitemapTemplate = $this->cparams->get('sitemap_html_template', null)) {
JHtml::stylesheet('com_jmap/js/jquery.treeview-' . $sitemapTemplate . '.css', array(), true, false, false, false);
}
}
}
// Indentation margin side
$this->marginSide = 'margin-left:';
// Detect if the language is RTL and if so load overrides
$this->isRTL = JFactory::getLanguage()->isRTL();
if($this->isRTL && !$mindMapSitemap && !$goJsSitemap) {
if($this->cparams->get('show_icons', 1)) {
// Check if a template override is requested
if(!$this->cparams->get('template_override', 0)) {
$document->addStyleSheet ( JUri::root(true) . '/components/com_jmap/js/rtl/jquery.treeview.css' );
if($sitemapTemplate = $this->cparams->get('sitemap_html_template', null)) {
$document->addStyleSheet ( JUri::root(true) . '/components/com_jmap/js/rtl/jquery.treeview-' . $sitemapTemplate . '.css' );
}
} else {
JHtml::stylesheet('com_jmap/js/rtl/jquery.treeview.css', array(), true, false, false, false);
if($sitemapTemplate = $this->cparams->get('sitemap_html_template', null)) {
JHtml::stylesheet('com_jmap/js/rtl/jquery.treeview-' . $sitemapTemplate . '.css', array(), true, false, false, false);
}
}
}
// Indentation margin side for RTL
$this->marginSide = 'margin-right:';
}
$this->mergeAliasMenu = $this->cparams->get('merge_alias_menu', 0);
// Inject JS domain vars
if($this->cparams->get('treeview_scripts', 1)) {
$document->addScriptDeclaration("
var jmapExpandAllTree = " . $this->getModel ()->getState ( 'cparams' )->get('show_expanded', 0) . ";
var jmapExpandLocation = '" . $this->getModel ()->getState ( 'cparams' )->get('expand_location', 'location') . "';
var jmapAnimated = " . $this->getModel ()->getState ( 'cparams' )->get('animated', 1) . ";
var jmapAnimateSpeed = " . $this->getModel ()->getState ( 'cparams' )->get('animate_speed', 200) . ";
var jmapDraggableSitemap = " . $draggableSitemap . ";
var jmapGojsSitemap = " . $goJsSitemap . ";
var jmapisRTLLanguage = " . (int)$this->isRTL . ";
var jmapHideEmptyCats = " . $this->getModel ()->getState ( 'cparams' )->get('hide_empty_cats', 0) . ";
var jmapLinkableCatsSources = {};
var jmapMergeMenuTree = {};
var jmapMergeAliasMenu = " . $this->mergeAliasMenu . ";
var jmapExpandFirstLevel = " . $this->getModel ()->getState ( 'cparams' )->get('expand_first_level', 0) . ";
var jmapGojsAutoHeightCanvas = " . $this->getModel ()->getState ( 'cparams' )->get('auto_height_canvas', 1) . ";
var jmapGojsAutoScaleCanvas = " . $this->getModel ()->getState ( 'cparams' )->get('auto_scale_canvas', 0) . ";
var jmapGojsRootColor = '" . $this->getModel ()->getState ( 'cparams' )->get('root_color', '#9df2e9') . "';
var jmapGojsChildColor = '" . $this->getModel ()->getState ( 'cparams' )->get('child_color', '#e0c8be') . "';
var jmapGojsNodeColorText = '" . $this->getModel ()->getState ( 'cparams' )->get('node_color_text', '#333') . "';
var jmapGojsTreeOrientation = '" . $this->getModel ()->getState ( 'cparams' )->get('tree_orientation', 'horizontal') . "';
jQuery(function($){
$('ul.jmap_filetree li a:empty').parent('li').css('display', 'none');
});
");
}
$this->data = $this->get ( 'SitemapData' );
$this->application = $app;
$this->document = $document;
$uriInstance = JUri::getInstance();
if($this->cparams->get('append_livesite', true)) {
$customHttpPort = trim($this->cparams->get('custom_http_port', ''));
$getPort = $customHttpPort ? ':' . $customHttpPort : '';
$customDomain = trim($this->cparams->get('custom_sitemap_domain', ''));
$getDomain = $customDomain ? rtrim($customDomain, '/') : rtrim($uriInstance->getScheme() . '://' . $uriInstance->getHost(), '/');
$this->liveSite = rtrim($getDomain . $getPort, '/');
} else {
$this->liveSite = null;
}
// Add meta info
$this->_prepareDocument();
parent::display ( $tpl );
}
/**
* Prepares the document
*/
protected function _prepareDocument() {
$app = JFactory::getApplication();
$document = JFactory::getDocument();
$menus = $app->getMenu();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
$this->params = new JRegistry;
if(!is_null($menu)) {
$this->params->loadString($menu->params);
}
$title = $this->params->get('page_title', $this->cparams->get ( 'defaulttitle', 'Sitemap' ));
// Joomla 3.2+ support
if(method_exists($app, 'get')) {
if ($app->get('sitename_pagetitles', 0) == 1) {
$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
}
elseif ($app->get('sitename_pagetitles', 0) == 2) {
$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
}
}
$document->setTitle($title);
if ($this->params->get('menu-meta_description')) {
$document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords')) {
$document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots')) {
$document->setMetadata('robots', $this->params->get('robots'));
}
}
}