-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathview.html.php
More file actions
134 lines (115 loc) · 3.62 KB
/
view.html.php
File metadata and controls
134 lines (115 loc) · 3.62 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
<?php
/**
* @package Com_Tjnotification
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die;
JLoader::import('preferences', JPATH_SITE . '/components/com_tjnotifications/models');
/**
* new notification View
*
* @since 0.0.1
*/
class TjnotificationsViewNotification extends JViewLegacy
{
/**
* View form
*
* @var form
*/
protected $form = null;
/**
* Display the Hello World view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
// Get the Data
$form = $this->get('Form');
$item = $this->get('Item');
// Get data from the model
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->state = $this->get('State');
$this->component = $this->state->get('filter.component');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Assign the Data
$this->form = $form;
$this->item = $item;
$this->tags = json_decode($this->item->replacement_tags);
$this->addToolBar();
$extension = JFactory::getApplication()->input->get('extension', '', 'word');
if ($extension)
{
$this->_setToolBar();
}
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolBar()
{
JToolBarHelper::title(JText::_('COM_TJNOTIFICATIONS'));
JToolBarHelper::apply('notification.editSave', 'JTOOLBAR_APPLY');
JToolBarHelper::save('notification.saveClose', 'JTOOLBAR_SAVE');
JToolBarHelper::custom('notification.saveNew', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
// Add preview toolbar
JToolbarHelper::modal('templatePreview', 'icon-eye', 'COM_TJNOTIFICATIONS_TEMPLATE_PREVIEW');
JToolBarHelper::cancel('notification.cancel', 'JTOOLBAR_CANCEL');
}
/**
* Function to set tool bar.
*
* @return void
*
* @since 1.8
*/
public function _setToolBar()
{
$component = $this->state->get('filter.component');
$section = $this->state->get('filter.section');
// Avoid nonsense situation.
if ($component == 'com_notifications')
{
return;
}
// Need to load the menu language file as mod_menu hasn't been loaded yet.
$lang = JFactory::getLanguage();
$lang->load($component, JPATH_BASE, null, false, true)
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, null, false, true);
// If a component notification title string is present, let's use it.
if ($lang->hasKey($component_title_key = strtoupper($component . ($section ? "_$section" : '')) . '_NOTIFICATIONS_TEMPLATES'))
{
$title = JText::_($component_title_key);
}
elseif ($lang->hasKey($component_section_key = strtoupper($component . ($section ? "_$section" : ''))))
// Else if the component section string exits, let's use it
{
$title = JText::sprintf('COM_TJNOTIFICATIONS_NOTIFICATION_TITLE', $this->escape(JText::_($component_section_key)));
}
else
// Else use the base title
{
$title = JText::_('COM_TJNOTIFICATIONS_NOTIFICATION_BASE_TITLE');
}
// Prepare the toolbar.
JToolbarHelper::title($title, 'folder notifications ' . substr($component, 4) . ($section ? "-$section" : '') . '-notification templates');
}
}