forked from NinjaForge/Ninjaboard
/
html.php
165 lines (143 loc) · 6.41 KB
/
html.php
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
<?php defined( 'KOOWA' ) or die( 'Restricted access' );
/**
* @category Ninjaboard
* @copyright Copyright (C) 2007 - 2011 NinjaForge. All rights reserved.
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link http://ninjaforge.com
*/
class ComNinjaboardViewHtml extends ComNinjaViewDefault
{
/**
* Constructor
*
* @param object An optional KConfig object with configuration options
*/
public function __construct(KConfig $config)
{
parent::__construct($config);
$model = KFactory::get($this->getModel());
if(KInflector::isPlural($this->getName()) && $model->getTotal() < 1) $this->_createToolbar()->reset()->append(KFactory::get('admin::com.ninja.toolbar.button.new'));
}
public function display()
{
//Load the js message box plugin
KFactory::get('admin::com.ninja.helper.default')->js('/Roar.js');
KFactory::get('admin::com.ninja.helper.default')->css('/Roar.css');
// Display the toolbar
$toolbar = $this->_createToolbar();
$path = KFactory::get($this->getModel())->getIdentifier()->path;
if(KInflector::isPlural(KFactory::get($this->getModel())->getIdentifier()->name) && $this->getName() != 'dashboard')
{
$this->_mixinMenubar();
}
if ($this->getName() == 'dashboard')
{
$toolbar->reset();
$this->_document->setBuffer(false, 'modules', 'submenu');
}
else
{
$toolbar->append('spacer');
}
$toolbar->append(KFactory::get('admin::com.ninja.toolbar.button.about'));
//@TODO finish this
//$this->lang();
return '<div class="nf template-'.JFactory::getApplication()->getTemplate().'">'.
parent::display().
'</div>';
//Add tooltips?
//if(KInflector::isPlural($this->getName()) && (KFactory::get($this->getModel())->getTotal() > 1)) KTemplate::loadHelper('admin::com.ninja.helper.behavior.tooltip', 'th.hasHint', array('showOnce' => true, 'showOnLoad' => true, 'fixed' => true));
}
/**
* MooTools.lang localization for Form.Validator.js and Date.js
*
* Will likely be moved to Napi once stable
*
* @author Stian Didriksen <stian@ninjaforge.com>
* @return void
*/
protected function lang()
{
$lang = KFactory::get('lib.joomla.language')->getTag();
$translate = create_function('$text', 'return ucfirst(JText::_($text));');
$months = json_encode(array_map($translate, array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')));
$days = json_encode(array_map($translate, array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')));
$dateParts = explode('-', str_replace(array('%Y','%M','%D'), array('year', 'month', 'date'), JText::_('%Y-%M-%D')));
$dateOrder = json_encode($dateParts);
$shortDate = JText::_('DATE_FORMAT_LC4');
$translate = create_function('$text', 'return JText::_($text);');
$parts = array_map($translate, array(
'lessThanMinuteAgo' => 'less than a minute ago',
'minuteAgo' => 'about a minute ago',
'minutesAgo' => '{delta} minutes ago',
'hourAgo' => 'about an hour ago',
'hoursAgo' => 'about {delta} hours ago',
'dayAgo' => '1 day ago',
'daysAgo' => '{delta} days ago',
'weekAgo' => '1 week ago',
'weeksAgo' => '{delta} weeks ago',
'monthAgo' => '1 month ago',
'monthsAgo' => '{delta} months ago',
'yearAgo' => '1 year ago',
'yearsAgo' => '{delta} years ago',
'lessThanMinuteUntil' => 'less than a minute from now',
'minuteUntil' => 'about a minute from now',
'minutesUntil' => '{delta} minutes from now',
'hourUntil' => 'about an hour from now',
'hoursUntil' => 'about {delta} hours from now',
'dayUntil' => '1 day from now',
'daysUntil' => '{delta} days from now',
'weekUntil' => '1 week from now',
'weeksUntil' => '{delta} weeks from now',
'monthUntil' => '1 month from now',
'monthsUntil' => '{delta} months from now',
'yearUntil' => '1 year from now',
'yearsUntil' => '{delta} years from now'
));
echo KHelperArray::toString($parts, ':', ',"');
die('<pre>'.var_export($parts, true).'</pre>');
$this->_document->addScriptDeclaration("
MooTools.lang.set('$lang', 'Date', {
months: $months,
days: $days,
//culture's date order: MM/DD/YYYY
dateOrder: $dateOrder,
shortDate: '$shortDate',
$parts
});
MooTools.lang.set('$lang', 'Form.Validator', {
required:'This field is required.',
minLength:'Please enter at least {minLength} characters (you entered {length} characters).',
maxLength:'Please enter no more than {maxLength} characters (you entered {length} characters).',
integer:'Please enter an integer in this field. Numbers with decimals (e.g. 1.25) are not permitted.',
numeric:'Please enter only numeric values in this field (i.e. \"1\" or \"1.1\" or \"-1\" or \"-1.1\").',
digits:'Please use numbers and punctuation only in this field (for example, a phone number with dashes or dots is permitted).',
alpha:'Please use letters only (a-z) with in this field. No spaces or other characters are allowed.',
alphanum:'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.',
dateSuchAs:'Please enter a valid date such as {date}',
dateInFormatMDY:'Please enter a valid date such as MM/DD/YYYY (i.e. \"12/31/1999\")',
email:'Please enter a valid email address. For example \"fred@domain.com\".',
url:'Please enter a valid URL such as http://www.google.com.',
currencyDollar:'Please enter a valid $ amount. For example $100.00 .',
oneRequired:'Please enter something for at least one of these inputs.',
errorPrefix: 'Error: ',
warningPrefix: 'Warning: ',
//Form.Validator.Extras
noSpace: 'There can be no spaces in this input.',
reqChkByNode: 'No items are selected.',
requiredChk: 'This field is required.',
reqChkByName: 'Please select a {label}.',
match: 'This field needs to match the {matchName} field',
startDate: 'the start date',
endDate: 'the end date',
currendDate: 'the current date',
afterDate: 'The date should be the same or after {label}.',
beforeDate: 'The date should be the same or before {label}.',
startMonth: 'Please select a start month',
sameMonth: 'These two dates must be in the same month - you must change one or the other.',
creditcard: 'The credit card number entered is invalid. Please check the number and try again. {length} digits entered.'
});
MooTools.lang.setLanguage('$lang');
");
}
}