1
|
|
|
<?php |
2
|
|
|
global $AR; |
3
|
|
|
|
4
|
|
|
require_once($AR->dir->install."/lib/ar/html.php"); |
5
|
|
|
|
6
|
|
|
class pinp_yui { |
7
|
|
|
static public function _getSection( $section ) { |
8
|
|
|
return yui::getSection( $section ); |
9
|
|
|
} |
10
|
|
|
} |
11
|
|
|
|
12
|
|
|
class yui { |
13
|
|
|
|
14
|
|
|
static public function getSectionContent($settings) { |
15
|
|
|
$result = ''; |
16
|
|
|
|
17
|
|
|
if(is_array($settings)) { |
18
|
|
|
foreach ($settings as $item) { |
19
|
|
|
$result .= '<a class="sidebar_task'; |
20
|
|
|
if ($item['class']) { |
21
|
|
|
$result .= ' ' . $item['class']; |
22
|
|
|
} |
23
|
|
|
$result .= '"'; |
24
|
|
|
|
25
|
|
|
if ($item['href']) { |
26
|
|
|
$result .= ' href="' . $item['href'] . '"'; |
27
|
|
|
} |
28
|
|
|
if ($item['onclick']) { |
29
|
|
|
$result .= ' onclick="' . $item['onclick'] . '"'; |
30
|
|
|
} |
31
|
|
|
if ($item['target']) { |
32
|
|
|
$result .= ' target="' . $item['target'] . '"'; |
33
|
|
|
} else { |
34
|
|
|
// FIXME: This should not be used in strict doctype, but we don't want it in our |
35
|
|
|
// window either. |
36
|
|
|
|
37
|
|
|
// $result .= ' target="_blank"'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$result .= '>'; |
41
|
|
|
|
42
|
|
|
if ($item['icon']) { |
43
|
|
|
$result .= '<img class="task_icon" src="' . $item['icon'] . '" alt="' . $item['iconalt'] . '" title="' . $item['iconalt'] . '"> '; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$itemlabel = $item['nlslabel']; |
47
|
|
|
$maxlabellength = 25; |
48
|
|
|
if (mb_strlen($itemlabel, "utf-8") > $maxlabellength) { |
49
|
|
|
$origName = $itemlabel; |
50
|
|
|
$itemlabel = "<span title=\"$origName\">" . mb_substr($itemlabel, 0, $maxlabellength-3, "utf-8")."..."."</span>"; |
51
|
|
|
} |
52
|
|
|
$result .= $itemlabel; |
53
|
|
|
$result .= "</a>"; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
return $result; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
static public function getSection($section) { |
|
|
|
|
61
|
|
|
$invisibleSections= $_COOKIE['invisibleSections']; |
62
|
|
|
|
63
|
|
|
$maxheadlength = 18; |
64
|
|
|
if ($section['icon']) { |
65
|
|
|
$maxheadlength = 14; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$sectionDisplayName = $section['label']; |
69
|
|
|
$sectionName = $section['id']; |
70
|
|
|
$icon = $section['icon']; |
71
|
|
|
|
72
|
|
|
if (mb_strlen($sectionDisplayName, "utf-8") > $maxheadlength) { |
73
|
|
|
$origName = htmlspecialchars($sectionDisplayName); |
74
|
|
|
$sectionDisplayName = "<span title=\"$origName\">".htmlspecialchars(mb_substr($sectionDisplayName, 0, $maxheadlength-3, "utf-8")."...")."</span>"; |
75
|
|
|
} else { |
76
|
|
|
$sectionDisplayName = htmlspecialchars($sectionDisplayName); |
77
|
|
|
} |
78
|
|
|
$icontag = ""; |
79
|
|
|
if ($icon) { |
80
|
|
|
$icontag .= '<img src="' . $icon . '" class="icon" alt="' . $section['iconalt'] . '" title="' . $section['iconalt'] . '">'; |
81
|
|
|
if( $section['overlay_icon'] ) { |
82
|
|
|
$icontag .= '<img src="' . $section['overlay_icon'] . '" class="overlay_icon" alt="' . $section['overlay_iconalt'] . '" title="' . $section['overlay_iconalt'] . '">'; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
if (strstr(strtolower($invisibleSections), $sectionName . ";")) { |
87
|
|
|
$section_class = " collapsed"; |
88
|
|
|
} else { |
89
|
|
|
$section_class = " expanded"; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$sectionhead_class = ""; |
93
|
|
|
if ($icon) { |
94
|
|
|
$sectionhead_class .= " iconsection"; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
if( $section['inline_icon'] ) { |
98
|
|
|
$sectionhead_class .= " iconinlinesection"; |
99
|
|
|
$icontag .= '<img src="' . $section['inline_icon'] . '" class="inline_icon" alt="' . $section['inline_iconalt'] . '" title="' . $section['inline_iconalt'] . '">'; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
$togglehref = "javascript:muze.ariadne.explore.sidebar.section.toggle('" . $sectionName . "');"; |
103
|
|
|
|
104
|
|
|
$result = ''; |
105
|
|
|
|
106
|
|
|
$result .= '<div class="section' . $section_class . '">'; |
107
|
|
|
$result .= $icontag; |
108
|
|
|
|
109
|
|
|
$result .= '<div class="sectionhead yuimenubar' . $sectionhead_class . '">'; |
110
|
|
|
$result .= '<a href="' . $togglehref . '">' . $sectionDisplayName . '</a>'; |
111
|
|
|
$result .= '<a class="toggle" href="' . $togglehref . '"> </a>'; |
112
|
|
|
$result .= '</div>'; |
113
|
|
|
|
114
|
|
|
$result .= '<div class="sectionbody" id="' . $sectionName . '_body">'; |
115
|
|
|
|
116
|
|
|
$result .= '<div class="section_content">'; |
117
|
|
|
|
118
|
|
|
if ($section['details']) { |
119
|
|
|
$result .= '<div class="details">'; |
120
|
|
|
$result .= $section['details']; |
121
|
|
|
$result .= '</div>'; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
$result .= self::getSectionContent($section['tasks']); |
125
|
|
|
$result .= '</div>'; |
126
|
|
|
|
127
|
|
|
$result .= '</div>'; |
128
|
|
|
$result .= '</div>'; |
129
|
|
|
return $result; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
|
134
|
|
|
/* explore.sidebar.info.php */ |
135
|
|
|
static public function section_table($info) { |
136
|
|
|
global $ARnls; |
137
|
|
|
$result = ''; |
138
|
|
|
if (is_array($info)) { |
139
|
|
|
$rows = ar_html::nodes(); |
140
|
|
|
foreach( $info as $key => $value ) { |
141
|
|
|
$rows[] = ar_html::tag("tr", ar_html::tag("td", $ARnls[$key].":"), ar_html::tag("td", array("class" => "data"), $value) ); |
142
|
|
|
} |
143
|
|
|
$result = ar_html::tag("table", array("class" => "infotable"), $rows); |
144
|
|
|
} |
145
|
|
|
return $result; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
static public function labelspan($label, $maxlabellength=16) { |
149
|
|
|
// Reduce length of a label if they are too long. |
150
|
|
|
if (mb_strlen($label, "utf-8") > $maxlabellength) { |
151
|
|
|
$label = ar_html::tag("span", array("title" => $label),htmlspecialchars(mb_substr($label, 0, $maxlabellength-3,"utf-8")."...")); |
152
|
|
|
} else { |
153
|
|
|
$label = htmlspecialchars($label); |
154
|
|
|
} |
155
|
|
|
return $label; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
/* dialog.templates.list.php */ |
160
|
|
|
static public function layout_sortfunc($a, $b) { |
161
|
|
|
if ($a == $b) { |
162
|
|
|
return 0; |
163
|
|
|
} |
164
|
|
|
return ($a < $b) ? -1 : 1; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/* explore.php */ |
168
|
|
|
static public function yui_menuitems($menuitems, $menuname, $menuid='') { |
169
|
|
|
$result = ''; |
170
|
|
|
if (is_array($menuitems)) { |
171
|
|
|
$nodes = ar_html::nodes(); |
172
|
|
|
|
173
|
|
|
foreach ($menuitems as $item) { |
174
|
|
|
if (!$item['href']) { |
175
|
|
|
$item['href'] = "#"; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
$link = array( |
179
|
|
|
"class" => $menuname. 'itemlabel', |
180
|
|
|
"href" => $item["href"], |
181
|
|
|
); |
182
|
|
|
|
183
|
|
|
if( $item["onclick"] ) { |
184
|
|
|
$link["onclick"] = $item["onclick"]; |
185
|
|
|
} |
186
|
|
|
if( $item["icon"] ) { |
187
|
|
|
$icon = ar_html::tag("img", array("src" => $item["icon"], "alt" => $item["iconalt"], "title" => $item["iconalt"])); |
188
|
|
|
} else { |
189
|
|
|
$icon = false; |
190
|
|
|
} |
191
|
|
|
if( $item["label"] ) { |
192
|
|
|
$content = ar_html::tag("span", array("class" => "menulabel"), $item['label']); |
193
|
|
|
} else { |
194
|
|
|
$content = false; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
$a = ar_html::tag("a", $link, $icon, $content); |
198
|
|
|
|
199
|
|
|
if( is_array($item['submenu']) ) { |
200
|
|
|
$submenu = self::yui_menuitems($item['submenu'], "yuimenu"); |
201
|
|
|
} else { |
202
|
|
|
$submenu = false; |
203
|
|
|
} |
204
|
|
|
$nodes[] = ar_html::tag("li", array("id" => $item['id'], "class" => $menuname."item"), $a, $submenu); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
$div = array( "class" => $menuname ); |
208
|
|
|
if( $menuid ) { |
209
|
|
|
$div["id"] = $menuid; |
210
|
|
|
} |
211
|
|
|
$result = ar_html::tag("div", $div, |
212
|
|
|
ar_html::tag("div", array("class"=>"bd"), |
213
|
|
|
ar_html::tag("ul", array("class" => "first-of-type"), $nodes) |
214
|
|
|
) |
215
|
|
|
); |
216
|
|
|
|
217
|
|
|
} |
218
|
|
|
return $result; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
|
222
|
|
|
|
223
|
|
|
/* Explore.browse.php */ |
224
|
|
|
static private function getTableClass($count, $total) { |
225
|
|
|
$class = array(); |
226
|
|
|
if ($count == 0) { |
227
|
|
|
$class[] = "yui-dt-first"; |
228
|
|
|
} |
229
|
|
|
if ($count == ($total-1)) { |
230
|
|
|
$class[] = "yui-dt-last"; |
231
|
|
|
} |
232
|
|
|
return $class; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
static public function showTable($divId, $tableId, $columnDefs, $data) { |
236
|
|
|
|
237
|
|
|
if (!is_array($columnDefs)) { |
238
|
|
|
return; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
$colnum = count($columnDefs); |
242
|
|
|
|
243
|
|
|
$headcols = ar_html::nodes(); |
244
|
|
|
|
245
|
|
|
for ($num = 0; $num < $colnum; $num++) { |
246
|
|
|
|
247
|
|
|
$class = self::getTableClass($num, $colnum); |
248
|
|
|
$class[] = 'yui-dt-col'.$columnDefs[$num]['key']; |
249
|
|
|
$class[] = 'yui-dt-sortable'; |
250
|
|
|
$headcols[] = ar_html::tag('th', array('class' => $class ), |
251
|
|
|
ar_html::tag('div', array('class' => 'yui-dt-header'), |
252
|
|
|
ar_html::tag('span', array('class' => 'yui-dt-label'), |
253
|
|
|
ar_html::tag('a', array('class' => 'yui-dt-sortable'), htmlspecialchars($columnDefs[$num]['label']) ) |
254
|
|
|
) |
255
|
|
|
) |
256
|
|
|
); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
$head = ar_html::tag('thead', ar_html::tag('tr', array('class' => array('yui-dt-first', 'yui-dt-last')), $headcols) ); |
260
|
|
|
|
261
|
|
|
if (is_array($data)) { |
262
|
|
|
$oddeven = 'even'; |
263
|
|
|
|
264
|
|
|
$rownums = count($data); |
265
|
|
|
|
266
|
|
|
$bodyrows = ar_html::nodes(); |
267
|
|
|
|
268
|
|
|
for ($rownum = 0; $rownum < $rownums; $rownum++) { |
269
|
|
|
$rowclass = self::getTableClass($rownum, $rownums); |
270
|
|
|
$rowclass[] = 'explore_item'; |
271
|
|
|
$rowclass[] = $oddeven; |
272
|
|
|
|
273
|
|
|
$bodycols = ar_html::nodes(); |
274
|
|
|
|
275
|
|
View Code Duplication |
if ($data[$rownum]['name']) { |
276
|
|
|
$data[$rownum]['name'] = self::labelspan($data[$rownum]['name'], 24); |
277
|
|
|
} |
278
|
|
View Code Duplication |
if ($data[$rownum]['filename']) { |
279
|
|
|
$data[$rownum]['filename'] = self::labelspan($data[$rownum]['filename'], 24); |
280
|
|
|
} |
281
|
|
|
for ($num = 0; $num < $colnum; $num++) { |
282
|
|
|
$colclass = self::getTableClass($num, $colnum); |
283
|
|
|
$colclass[] = 'yui-dt-col-'.$columnDefs[$num]['key']; |
284
|
|
|
$bodycols[] = ar_html::tag('td', array('class' => $colclass), $data[$rownum][$columnDefs[$num]['key']] ); |
285
|
|
|
} |
286
|
|
|
$bodyrows[] = ar_html::tag('tr', array('class' => $rowclass, 'path' => $data[$rownum]['path']), $bodycols); |
287
|
|
|
$oddeven = ($oddeven == 'even' ? 'odd' : 'even'); |
288
|
|
|
} |
289
|
|
|
} |
290
|
|
|
$body = ar_html::tag('tbody', array('class' => 'yui-dt-body'), $bodyrows); |
|
|
|
|
291
|
|
|
|
292
|
|
|
$table = ar_html::tag('table', array('id' => $tableId), $head, $body); |
293
|
|
|
|
294
|
|
|
echo ar_html::tag('div', array('id' => $divId, 'class' => 'yui-dt-'), $table)."\n"; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
static public function showTableJs($divId, $tableId, $columnDefs) { |
298
|
|
|
$jsColDefs = ''; |
299
|
|
|
$jsFields = ''; |
300
|
|
|
foreach ($columnDefs as $colDef) { |
301
|
|
|
$jsColDefs .= "\t\t\t".'{key:"' . $colDef['key'] . '"'; |
302
|
|
|
if ($colDef['label']) { |
303
|
|
|
$jsColDefs .= ',label:"' . $colDef['label'] . '"'; |
304
|
|
|
} |
305
|
|
|
if ($colDef['sortable']) { |
306
|
|
|
$jsColDefs .= ',sortable:true'; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
if ($colDef['formatter']) { |
310
|
|
|
$jsColDefs .= ',formatter:"' . $colDef['formatter'] . '"'; |
311
|
|
|
} |
312
|
|
|
if ($colDef['formatterfunc']) { |
313
|
|
|
$jsColDefs .= ',formatter:' . $colDef['formatterfunc']; |
314
|
|
|
} |
315
|
|
|
$jsColDefs .= "},\n"; |
316
|
|
|
|
317
|
|
|
$jsFields .= "\t\t\t\t".'{key:"' . $colDef['key'] . '"'; |
318
|
|
|
if ($colDef['parser']) { |
319
|
|
|
$jsFields .= ',parser:"' . $colDef['parser'] . '"'; |
320
|
|
|
} |
321
|
|
|
if ($colDef['parserfunc']) { |
322
|
|
|
$jsFields .= ',parser:' . $colDef['parserfunc']; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
$jsFields .= '},'."\n"; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
// Strip last comma and \n; |
329
|
|
|
$jsColDefs = substr($jsColDefs, 0, strlen($jsColDefs)-2); |
330
|
|
|
$jsFields = substr($jsFields, 0, strlen($jsFields)-2); |
331
|
|
|
echo ' muze.ariadne.explore.viewpane.myColumnDefs = [' . "\n"; |
332
|
|
|
echo $jsColDefs."\n"; |
333
|
|
|
echo ' ];' . "\n"; |
334
|
|
|
echo ' muze.ariadne.explore.viewpane.load_handler = function() {' . "\n"; |
335
|
|
|
echo ' muze.ariadne.explore.viewpane.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("' . $tableId . '"));' . "\n"; |
336
|
|
|
echo ' muze.ariadne.explore.viewpane.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;' . "\n"; |
337
|
|
|
echo ' muze.ariadne.explore.viewpane.myDataSource.responseSchema = {' . "\n"; |
338
|
|
|
echo ' fields: [' . "\n"; |
339
|
|
|
echo $jsFields."\n"; |
340
|
|
|
echo ' ]' . "\n"; |
341
|
|
|
echo ' };' . "\n"; |
342
|
|
|
echo ' muze.ariadne.explore.viewpane.dataTable = new YAHOO.widget.DataTable("' . $divId . '", muze.ariadne.explore.viewpane.myColumnDefs, muze.ariadne.explore.viewpane.myDataSource,{});' . "\n"; |
343
|
|
|
echo ' muze.ariadne.explore.viewpane.dataTable.subscribe("rowClickEvent", muze.ariadne.explore.viewpane.rowClick);' . "\n"; |
344
|
|
|
echo ' muze.ariadne.explore.viewpane.dataTable.subscribe("rowDblclickEvent", muze.ariadne.explore.viewpane.rowDoubleClick);' . "\n"; |
345
|
|
|
echo ' muze.ariadne.explore.viewpane.dataTable.subscribe("rowMouseoverEvent", muze.ariadne.explore.viewpane.onEventHighlightRow);' . "\n"; |
346
|
|
|
echo ' muze.ariadne.explore.viewpane.dataTable.subscribe("rowMouseoutEvent", muze.ariadne.explore.viewpane.onEventUnhighlightRow);' . "\n"; |
347
|
|
|
echo ' muze.ariadne.explore.viewpane.dataTable.subscribe("columnSortEvent", muze.ariadne.explore.viewpane.onEventSortColumn);' . "\n"; |
348
|
|
|
echo ' muze.ariadne.explore.viewpane.hideRows();' . "\n"; |
349
|
|
|
echo ' };' . "\n"; |
350
|
|
|
echo ' muze.event.attach(document.body, "viewpaneLoaded", muze.ariadne.explore.viewpane.hideRows)' . "\n"; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
static public function colDefs($fields) { |
354
|
|
|
global $ARnls; |
355
|
|
|
|
356
|
|
|
// Create a default set of column definitions given a set of field keys. |
357
|
|
|
// This uses the keyname for the index, and ARnls key as the label. |
358
|
|
|
// All columns are defined as sortable; |
359
|
|
|
if (is_array($fields)) { |
360
|
|
|
$columnDefs = array(); |
361
|
|
|
foreach ($fields as $key) { |
362
|
|
|
if (!$ARnls[$key]) { |
363
|
|
|
$ARnls[$key] = $key; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
$colDef = array( |
367
|
|
|
'key' => $key, |
368
|
|
|
'label' => $ARnls[$key], |
369
|
|
|
'sortable' => true |
370
|
|
|
); |
371
|
|
|
|
372
|
|
|
array_push($columnDefs, $colDef); |
373
|
|
|
} |
374
|
|
|
} |
375
|
|
|
return $columnDefs; |
|
|
|
|
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
static public function getSvnIcon($status) { |
379
|
|
|
global $AR; |
380
|
|
|
global $ARnls; |
381
|
|
|
|
382
|
|
|
if ($status == 'insubversion') { |
383
|
|
|
$iconsrc = $AR->dir->images . 'svn/InSubVersionIcon.png'; |
384
|
|
|
$alt = $ARnls['ariadne:svn:insubversion']; |
385
|
|
|
} elseif ($status == 'modified') { |
386
|
|
|
$iconsrc = $AR->dir->images . 'svn/ModifiedIcon.png'; |
387
|
|
|
$alt = $ARnls['ariadne:svn:modified']; |
388
|
|
|
} |
389
|
|
|
if ($iconsrc) { |
390
|
|
|
return ar_html::tag('img', array('class' => 'explore_svnicon', 'src' => $iconsrc, 'alt' => $alt, 'title' => $alt )); |
|
|
|
|
391
|
|
|
} else { |
392
|
|
|
return null; |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
static public function getTypeIcon($item, $viewtype='list') { |
397
|
|
|
|
398
|
|
|
|
399
|
|
|
$type = $item["type"]; |
400
|
|
|
|
401
|
|
|
$iconsize = 'small'; |
402
|
|
|
if ($viewtype == 'icons') { |
403
|
|
|
$iconsize = 'large'; |
404
|
|
|
} elseif($viewtype == 'list') { |
405
|
|
|
$iconsize = 'medium'; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
$result = ar_html::nodes(); |
409
|
|
|
if( $type == "pshortcut" ) { |
410
|
|
|
$result[] = ar_html::tag('img', array('title' => $item['vtype'], 'alt' => $item['vtype'], 'class' => 'explore_icon', 'src' => $item['icons'][$iconsize]) ); |
411
|
|
|
$result[] = ar_html::tag('img', array('title' => $item['type'], 'alt' => $item['type'], 'class' => 'explore_icon_shortcut_'.$viewtype, 'src' => $item['overlay_icons'][$iconsize]) ); |
412
|
|
|
} else { |
413
|
|
|
$result[] = ar_html::tag('img', array('title' => $item['type'], 'alt' => $item['type'], 'class' => 'explore_icon', 'src' => $item['icons'][$iconsize]) ); |
414
|
|
|
} |
415
|
|
|
return $result; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
static public function showList($data, $viewtype='list') { |
419
|
|
|
global $ARnls; |
420
|
|
|
|
421
|
|
|
if (is_array($data['objects']) && count($data['objects']) && $data['total'] > 0) { |
422
|
|
|
$nodes = ar_html::nodes(); |
423
|
|
|
switch ($viewtype) { |
424
|
|
|
case "details" : |
425
|
|
|
$maxlen = 32; |
426
|
|
|
break; |
427
|
|
|
case "icons" : |
428
|
|
|
$maxlen = 14; |
429
|
|
|
break; |
430
|
|
|
default : |
431
|
|
|
$maxlen = 11; |
432
|
|
|
break; |
433
|
|
|
} |
434
|
|
|
foreach ($data['objects'] as $node) { |
435
|
|
|
$content = self::getTypeIcon($node, $viewtype); |
436
|
|
|
if( is_array($node['svn']) ) { |
437
|
|
|
$content[] = self::getSvnIcon($node['svn']['status']); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
$item_class = "explore_item"; |
441
|
|
|
if ($node['priority'] < 0) { |
442
|
|
|
$item_class .= " hidden"; |
443
|
|
|
} |
444
|
|
|
$content[]= ar_html::tag('span', array('class' => 'explore_name'), self::labelspan($node['name'], $maxlen )); |
445
|
|
|
$nodes[] = ar_html::tag( 'li', array('class' => $item_class, 'data-path' => $node['path']), |
446
|
|
|
ar_html::tag( 'a', array('class' => 'explore_link', 'href' => $node['local_url'].'explore.html', 'onDblClick' => "top.muze.ariadne.explore.view('" . htmlspecialchars($node['path']) . "'); return false;", 'title' => $node['name']), $content) ); |
447
|
|
|
} |
448
|
|
|
$result = ar_html::tag('ul', array('class' => array('explore_list', $viewtype) ), $nodes); |
449
|
|
|
} else { |
450
|
|
|
|
451
|
|
|
if ($data['total'] > 1000) { |
452
|
|
|
$content = htmlspecialchars($ARnls['ariadne:too_many_objects_found'] . " (" . $data['total'] . ")"); |
453
|
|
|
$selectoptions = array( |
454
|
|
|
"sanity-off" => $ARnls['ariadne:select:showall'] |
455
|
|
|
); |
456
|
|
|
|
457
|
|
|
foreach ($selectoptions as $key => $value) { |
458
|
|
|
$content .= '<br><a href="#" onclick="muze.ariadne.explore.viewpane.setfilter(\'' . htmlspecialchars($key) . '\'); return false;">' . htmlspecialchars($value) . '</a>'; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
$result = ar_html::tag('div', array('class'=>'noobjects'), $content); |
462
|
|
|
} else { |
463
|
|
|
$result = ar_html::tag('div', array('class'=>'noobjects'), htmlspecialchars($ARnls['ariadne:no_objects_found']) ); |
464
|
|
|
} |
465
|
|
|
} |
466
|
|
|
echo $result."\n"; |
467
|
|
|
} |
468
|
|
|
|
469
|
|
View Code Duplication |
private function getPagingPrev($current_page) { |
470
|
|
|
global $AR; |
471
|
|
|
return array( |
472
|
|
|
"class" => "prev", |
473
|
|
|
"image" => $AR->dir->www . "images/icons/small/prev.png", |
474
|
|
|
"label" => $ARnls['ariadne:prev'], |
|
|
|
|
475
|
|
|
"onclick" => "muze.ariadne.explore.viewpane.view(muze.ariadne.explore.viewpane.path, " . ($current_page - 1) . "); return false; " |
476
|
|
|
); |
477
|
|
|
|
478
|
|
|
} |
479
|
|
|
|
480
|
|
View Code Duplication |
private function getPagingNext($current_page) { |
481
|
|
|
global $AR; |
482
|
|
|
return array( |
483
|
|
|
"class" => "next", |
484
|
|
|
"image" => $AR->dir->www . "images/icons/small/next.png", |
485
|
|
|
"label" => $ARnls['ariadne:next'], |
|
|
|
|
486
|
|
|
"onclick" => "muze.ariadne.explore.viewpane.view(muze.ariadne.explore.viewpane.path, " . ($current_page + 1) . "); return false;" |
487
|
|
|
); |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
private static function getPagingEntry($number, $current_page, $class = false) { |
491
|
|
|
$entry = array( |
492
|
|
|
"label" => $number, |
493
|
|
|
"onclick" => "muze.ariadne.explore.viewpane.view(muze.ariadne.explore.viewpane.path, $number); return false;" |
494
|
|
|
); |
495
|
|
|
$entryclass = ""; |
496
|
|
|
if ($current_page == $number) { |
497
|
|
|
$entryclass .= "current "; |
498
|
|
|
} |
499
|
|
|
if ($class) { |
500
|
|
|
$entryclass .= $class; |
501
|
|
|
} |
502
|
|
|
if ($entryclass) { |
503
|
|
|
$entry['class'] = $entryclass; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
return $entry; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
private static function getPagingStart($current_page, $total_pages) { |
510
|
|
|
if ($current_page > 4) { |
511
|
|
|
$start = $current_page - 2; |
512
|
|
|
if ($start > ($total_pages - 6)) { |
513
|
|
|
$start = $total_pages - 4; |
514
|
|
|
} |
515
|
|
|
} else { |
516
|
|
|
$start = 2; |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
if ($start < 2) { |
520
|
|
|
$start = 2; |
521
|
|
|
} |
522
|
|
|
return $start; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
private static function getPagingEnd($current_page, $total_pages) { |
526
|
|
|
$start = self::getPagingStart($current_page, $total_pages); |
527
|
|
|
if ($current_page > 4) { |
528
|
|
|
$end = $start + 4; |
529
|
|
|
} else { |
530
|
|
|
$end = $start + 3; |
531
|
|
|
} |
532
|
|
|
if ($end > $total_pages - 1) { |
533
|
|
|
$end = $total_pages - 1; |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
return $end; |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
|
540
|
|
|
private static function getPagingEntries($total, $items_per_page, $current_page) { |
541
|
|
|
global $AR; |
542
|
|
|
if (!($total > $items_per_page)) { |
543
|
|
|
return array(); |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
$total_pages = (int) ($total/$items_per_page); |
547
|
|
|
if ($total % $items_per_page > 0) { |
548
|
|
|
$total_pages++; |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
$pagingentries = array(); |
552
|
|
|
|
553
|
|
|
if ($current_page > 1) { |
554
|
|
|
$pagingentries[] = self::getPagingPrev($current_page); |
555
|
|
|
} |
556
|
|
|
$pagingentries[] = self::getPagingEntry(1, $current_page, "first"); |
557
|
|
|
|
558
|
|
|
$start = self::getPagingStart($current_page, $total_pages); |
559
|
|
|
$end = self::getPagingEnd($current_page, $total_pages); |
560
|
|
|
|
561
|
|
|
if ($start > 2) { |
562
|
|
|
$pagingentries[] = array( |
563
|
|
|
"label" => '...', |
564
|
|
|
"class" => "ellipsis" |
565
|
|
|
); |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
for ($i=$start; $i <= $end; $i++) { |
569
|
|
|
if ($total_pages >= $i) { |
570
|
|
|
$pagingentries[] = self::getPagingEntry($i, $current_page); |
571
|
|
|
} |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
if ($end < ($total_pages - 1)) { |
575
|
|
|
$pagingentries[] = array( |
576
|
|
|
"label" => '...', |
577
|
|
|
"class" => "ellipsis" |
578
|
|
|
); |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
$pagingentries[] = self::getPagingEntry($total_pages, $current_page, "last"); |
582
|
|
|
|
583
|
|
|
if ($current_page < $total_pages) { |
584
|
|
|
$pagingentries[] = self::getPagingNext($current_page); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
return $pagingentries; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
private static function getPagingLink($href) { |
591
|
|
|
if ($href) { |
592
|
|
|
return ' href="' . $href . '"'; |
593
|
|
|
} |
594
|
|
|
return ' href="#"'; |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
private static function getPagingImage($image, $label) { |
598
|
|
|
if (!$image) { |
599
|
|
|
return htmlspecialchars($label); |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
$result = '<img src="'. $image . '"'; |
603
|
|
|
if ($label) { |
604
|
|
|
$result .= ' alt="' . htmlspecialchars($label) . '"'; |
605
|
|
|
$result .= ' title="' . htmlspecialchars($label) . '"'; |
606
|
|
|
} |
607
|
|
|
$result .= '>'; |
608
|
|
|
return $result; |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
static public function showPaging($total, $items_per_page, $current_page, $pagingclass="") { |
612
|
|
|
$pagingentries = self::getPagingEntries($total, $items_per_page, $current_page); |
613
|
|
|
|
614
|
|
|
if (!sizeof($pagingentries)) { |
615
|
|
|
return; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
$result = "<ul class='paging"; |
619
|
|
|
if ($pagingclass) { |
620
|
|
|
$result .= " $pagingclass"; |
621
|
|
|
} |
622
|
|
|
$result .= "'>"; |
623
|
|
|
foreach ($pagingentries as $entry) { |
624
|
|
|
$result .= "<li"; |
625
|
|
|
if ($entry['class']) { |
626
|
|
|
$result .= ' class="' . $entry['class'] . '"'; |
627
|
|
|
} |
628
|
|
|
$result .= ">"; |
629
|
|
|
$result .= "<a"; |
630
|
|
|
|
631
|
|
|
if ($entry['onclick']) { |
632
|
|
|
$result .= ' onclick="' . $entry['onclick'] . '"'; |
633
|
|
|
} |
634
|
|
|
$result .= self::getPagingLink($entry['href']); |
635
|
|
|
|
636
|
|
|
$result .= ">"; |
637
|
|
|
|
638
|
|
|
$result .= self::getPagingImage($entry['image'], $entry['label']); |
639
|
|
|
|
640
|
|
|
$result .= "</a>"; |
641
|
|
|
$result .= "</li>"; |
642
|
|
|
} |
643
|
|
|
$result .= "</ul>"; |
644
|
|
|
echo $result; |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
|
648
|
|
|
/* dialog.add.list.php */ |
649
|
|
|
static public function getTypes($arObject, $showall) { |
650
|
|
|
$result = Array(); |
651
|
|
|
if (!$showall) { |
652
|
|
|
$typetree = $arObject->call('typetree.ini'); |
653
|
|
|
$thistypetree = $typetree[$arObject->type]; |
654
|
|
|
|
655
|
|
|
if (is_array($thistypetree)) { |
656
|
|
|
foreach( $thistypetree as $type => $name ) { |
657
|
|
|
$result[$type] = $name; |
658
|
|
|
} |
659
|
|
|
} |
660
|
|
|
} else { |
661
|
|
|
$systemtypes = $arObject->ls("/system/ariadne/types/", "system.get.phtml"); |
662
|
|
|
foreach ($systemtypes as $object) { |
663
|
|
|
$type=$object->data->value; |
664
|
|
|
$name=$object->nlsdata->name; |
665
|
|
|
|
666
|
|
|
$result[$type] = $name; |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
$arObject->call('typetree.ini'); |
670
|
|
|
$arTypeNames = $arObject->getvar('arTypeNames'); |
671
|
|
|
if (is_array($arTypeNames)) { |
672
|
|
|
$result = array_merge($result, $arTypeNames); |
673
|
|
|
} |
674
|
|
|
} |
675
|
|
|
asort($result); |
676
|
|
|
return $result; |
677
|
|
|
} |
678
|
|
|
|
679
|
|
|
static public function checkType($arObject, $type, $name, $currentpath, $arReturnTemplate) { |
680
|
|
|
if (!$arObject->CheckSilent("add", $type)) { |
681
|
|
|
$class .= "greyed"; |
|
|
|
|
682
|
|
|
} |
683
|
|
|
$dotPos=strpos($type, '.'); |
684
|
|
|
if (false!==$dotPos) { |
685
|
|
|
$realtype=substr($type, 0, $dotPos); |
686
|
|
|
} else { |
687
|
|
|
$realtype=$type; |
688
|
|
|
} |
689
|
|
|
|
690
|
|
|
$icon = $arObject->call("system.get.icon.php", array("type" => $type)); |
691
|
|
|
|
692
|
|
|
$itemurl = $currentpath . $arReturnTemplate . "?arNewType=" . RawUrlEncode($type) . "&" . ldGetServerVar("QUERY_STRING"); |
693
|
|
|
$result = array( |
694
|
|
|
"type" => $type, |
695
|
|
|
"class" => $class, |
696
|
|
|
"icon" => $icon, |
697
|
|
|
"realtype" => $realtype, |
698
|
|
|
"href" => $itemurl, |
699
|
|
|
"name" => $name |
700
|
|
|
); |
701
|
|
|
return $result; |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
function getItems($arObject, $typeslist, $currentpath, $arReturnTemplate) { |
705
|
|
|
$result = array(); |
706
|
|
|
foreach( $typeslist as $type => $name ) { |
707
|
|
|
$result[] = self::checkType($arObject, $type, $name, $currentpath, $arReturnTemplate); |
708
|
|
|
} |
709
|
|
|
return $result; |
710
|
|
|
} |
711
|
|
|
} |
712
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: