Skip to content

Commit 2d08164

Browse files
committed
Updates
* Simple devices CSS minor fix * Linked Object performance improvement * Control Panel template re-organizig * Performance monitor minor update
1 parent 5e2885a commit 2d08164

10 files changed

+901
-907
lines changed

admin.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,23 @@
7272

7373
$result = str_replace("nf.php", "admin.php", $result);
7474

75+
startMeasure('postProcessGeneral');
7576
require(ROOT.'lib/utils/postprocess_general.inc.php');
77+
endMeasure('postProcessGeneral');
78+
79+
startMeasure('postProcessSubscriptions');
7680
require(ROOT.'lib/utils/postprocess_subscriptions.inc.php');
7781
//require(ROOT.'lib/utils/postprocess_result.inc.php');
78-
82+
endMeasure('postProcessSubscriptions');
83+
endMeasure('part2');
7984

8085
startMeasure('accelerationProcess');
8186
if ((!defined('DISABLE_PANEL_ACCELERATION') || DISABLE_PANEL_ACCELERATION!=1)) {
8287
$result = preg_replace('/href="(\/admin\.php.+?)">/is','href="\1" onclick="return partLoad(this.href);">',$result);
8388
}
8489
endMeasure('accelerationProcess');
8590

86-
endMeasure('part2');
91+
8792

8893

8994
if (isset($_GET['part_load'])) {
@@ -169,4 +174,4 @@
169174
endMeasure('TOTAL');
170175

171176
// print performance report
172-
performanceReport();
177+
performanceReport($_GET['debug']);

css/devices.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
.device-widget.mini {
1616
padding:5px;
17-
min-width:150px; //
17+
min-width:150px;
1818
max-width:150px;
1919
width:150px;
2020
border:none;
@@ -28,8 +28,8 @@
2828

2929
.device-widget.mini.sensor {
3030
min-width:75px;
31-
max-width:75px;
32-
width:75px;
31+
/* max-width:75px;
32+
width:75px; */
3333
}
3434

3535
.device-widget.mini.openable {

lib/perfmonitor.class.php

+24-15
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function getmicrotime()
3232
* @param mixed $mpoint Monitoring block name
3333
* @return void
3434
*/
35-
function StartMeasure($mpoint)
35+
function startMeasure($mpoint)
3636
{
3737
global $perf_data;
3838

@@ -43,11 +43,13 @@ function StartMeasure($mpoint)
4343
$perf_data[$mpoint]['START'] = getmicrotime();
4444
}
4545

46-
if ((isset($perf_data[$mpoint]['MEMORY_START']) && !$perf_data[$mpoint]['MEMORY_START'])
47-
|| !isset($perf_data[$mpoint]['MEMORY_START'])
48-
&& function_exists('memory_get_usage')
49-
) {
50-
$perf_data[$mpoint]['MEMORY_START'] = memory_get_usage();
46+
if (defined('TRACK_MEMORY_USAGE')) {
47+
if ((isset($perf_data[$mpoint]['MEMORY_START']) && !$perf_data[$mpoint]['MEMORY_START'])
48+
|| !isset($perf_data[$mpoint]['MEMORY_START'])
49+
&& function_exists('memory_get_usage')
50+
) {
51+
$perf_data[$mpoint]['MEMORY_START'] = memory_get_usage();
52+
}
5153
}
5254
}
5355

@@ -57,7 +59,7 @@ function StartMeasure($mpoint)
5759
* @param mixed $save_to_db Save to DB (Default 0) Currently not used
5860
* @return void
5961
*/
60-
function EndMeasure($mpoint)
62+
function endMeasure($mpoint)
6163
{
6264
global $perf_data;
6365

@@ -67,8 +69,10 @@ function EndMeasure($mpoint)
6769

6870
$perf_data[$mpoint]['END'] = getmicrotime();
6971

70-
if (!isset($perf_data[$mpoint]['MEMORY_END']) && function_exists('memory_get_usage')) {
71-
$perf_data[$mpoint]['MEMORY_END'] = memory_get_usage();
72+
if (defined('TRACK_MEMORY_USAGE')) {
73+
if (!isset($perf_data[$mpoint]['MEMORY_END']) && function_exists('memory_get_usage')) {
74+
$perf_data[$mpoint]['MEMORY_END'] = memory_get_usage();
75+
}
7276
}
7377

7478
if (!isset($perf_data[$mpoint]['TIME'])) {
@@ -109,12 +113,14 @@ function EndMeasure($mpoint)
109113
* @param mixed $hidden n/a (default 1)
110114
* @return void
111115
*/
112-
function PerformanceReport($hidden = 0)
116+
function PerformanceReport($visible = 0)
113117
{
114118
global $perf_data;
115119

116-
if (!$hidden) {
120+
if (!$visible) {
117121
echo "<!-- BEGIN PERFORMANCE REPORT\n";
122+
} else {
123+
echo "<div style='position:absolute;top:60px;left:710px;width:800px;height:300px;'><pre>";
118124
}
119125

120126
foreach ($perf_data as $k => $v) {
@@ -130,11 +136,11 @@ function PerformanceReport($hidden = 0)
130136

131137
$rs = "$k (" . $v['NUM'] . "): " . round($v['TIME'], 4) . " " . round($v['PROC'], 2) . "%";
132138

133-
if ($v['MEMORY_START']) {
139+
if (isset($v['MEMORY_START'])) {
134140
$rs .= ' M (s): ' . $v['MEMORY_START'] . 'b';
135141
}
136142

137-
if ($v['MEMORY_END']) {
143+
if (isset($v['MEMORY_END'])) {
138144
$rs .= ' M (e): ' . $v['MEMORY_END'] . 'b';
139145
}
140146

@@ -145,9 +151,12 @@ function PerformanceReport($hidden = 0)
145151
$tmp[] = $rs;
146152
}
147153

148-
if (!$hidden) {
149-
echo implode("\n", $tmp);
154+
echo implode("\n", $tmp);
155+
156+
if (!$visible) {
150157
echo "\n END PERFORMANCE REPORT -->";
158+
} else {
159+
echo "</pre></div>";
151160
}
152161
return $tmp;
153162
}

lib/utils/postprocess_general.inc.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
$result = preg_replace('/<!--\s+(\w)/','<!--$1',$result);
4-
$result = preg_replace('/([\w\]])\s+-->/','$1-->',$result);
3+
//$result = preg_replace('/<!--\s+(\w)/','<!--$1',$result);
4+
//$result = preg_replace('/([\w\]])\s+-->/','$1-->',$result);

modules/linkedobject/linkedobject.class.php

+36-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,38 @@ function run()
236236
}
237237

238238
if ($this->object_field) {
239-
$objects = SQLSelect("SELECT objects.*, classes.TITLE AS CLASS_NAME FROM objects JOIN classes WHERE CLASS_ID=classes.ID ORDER BY CLASS_ID, TITLE");
239+
$objects = SQLSelect("SELECT objects.CLASS_ID, objects.TITLE, objects.DESCRIPTION, classes.TITLE AS CLASS_NAME FROM objects JOIN classes WHERE CLASS_ID=classes.ID ORDER BY CLASS_ID, TITLE");
240240

241+
$objects[]=array('ID'=>'scripts','TITLE'=>'AllScripts','DESCRIPTION'=>LANG_SCRIPTS);
242+
243+
$total = count($objects);
244+
$old_class_id=0;
245+
246+
$list_result='';
247+
248+
if ($total) {
249+
$objects[0]['FIRST']=1;
250+
$objects[$total-1]['LAST']=1;
251+
for($i=0;$i<$total;$i++) {
252+
if ($objects[$i]['CLASS_ID']!=$old_class_id) {
253+
$objects[$i]['NEW_GROUP']=1;
254+
$old_class_id=$objects[$i]['CLASS_ID'];
255+
if ($i>0) {
256+
$list_result.='</optgroup>';
257+
}
258+
$list_result.='<optgroup label="'.$objects[$i]['CLASS_NAME'].'">';
259+
}
260+
$list_result.='<option value="'.$objects[$i]['TITLE'].'">'.$objects[$i]['TITLE'];
261+
if ($objects[$i]['DESCRIPTION']!='') {
262+
$list_result.=' - '.$objects[$i]['DESCRIPTION'];
263+
}
264+
$list_result.='</option>';
265+
}
266+
$list_result.='</optgroup>';
267+
}
268+
$out['OBJECTS_LIST_RESULT']=$list_result;
269+
270+
/*
241271
foreach($objects as $key => $object) {
242272
if($object['CLASS_ID'] != $objects[$key-1]['CLASS_ID']) {
243273
$objects[$key]['NEW_GROUP_START'] = 1;
@@ -250,11 +280,15 @@ function run()
250280
$objects[$key]['NEW_GROUP_END'] = 0;
251281
}
252282
}
283+
*/
253284

254-
$objects[]=array('ID'=>'scripts','TITLE'=>'AllScripts','DESCRIPTION'=>LANG_SCRIPTS);
285+
255286
//echo '<pre>';
256287
//var_dump($objects);
257288
//die();
289+
290+
291+
258292
$out['OBJECTS'] = $objects;
259293
$out['OBJECT_FIELD'] = $this->object_field;
260294
}

templates/linkedobject/linkedobject.html

+1-15
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@
99
<select name="[#OBJECT_FIELD#]" id='linked_object_copy<#UNIQ#>' style="width:<#WIDTH#>" onChange="linked_object_chaged<#UNIQ#>();">
1010
<option value="">
1111
<option value="[add]">[ <#LANG_ADD#> ]
12-
[#begin OBJECTS#]
13-
[#if NEW_GROUP_START == 1 AND NEW_GROUP_END == 0#]
14-
<optgroup label="[#CLASS_NAME#]">
15-
[#endif#]
16-
[#if NEW_GROUP_START == 1 AND NEW_GROUP_END == 1#]
17-
<optgroup label="[#CLASS_NAME#]">
18-
[#endif#]
19-
<option value="[#TITLE#]">[#TITLE#][#if DESCRIPTION!=""#] - [#DESCRIPTION#][#endif#]</option>
20-
[#if NEW_GROUP_START == 0 AND NEW_GROUP_END == 1#]
21-
</optgroup>
22-
[#endif#]
23-
[#if NEW_GROUP_START == 1 AND NEW_GROUP_END == 1#]
24-
</optgroup>
25-
[#endif#]
26-
[#end OBJECTS#]
12+
[#OBJECTS_LIST_RESULT#]
2713
</select>
2814
<a href="#" id="linked_object_link<#UNIQ#>" target="_blank" style='display:none'><i class="glyphicon glyphicon-export"></i></a>
2915
</nobr>

0 commit comments

Comments
 (0)