@@ -24,7 +24,7 @@ |
||
24 | 24 | function privatemsg_views_handlers() { |
25 | 25 | return array( |
26 | 26 | 'info' => array( |
27 | - 'path' => drupal_get_path('module', 'privatemsg') . '/views', |
|
27 | + 'path' => drupal_get_path('module', 'privatemsg').'/views', |
|
28 | 28 | ), |
29 | 29 | 'handlers' => array( |
30 | 30 | // field handlers |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function hook_privatemsg_message_view_alter(&$var) { |
344 | 344 | // add a link to each message |
345 | - $vars['message_links'][] = array('title' => t('My link'), 'href' => '/path/to/my/action/'. $vars['message']['mid']); |
|
345 | + $vars['message_links'][] = array('title' => t('My link'), 'href' => '/path/to/my/action/'.$vars['message']['mid']); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | } |
407 | 407 | |
408 | 408 | $args = array_merge(array($author->uid), array_keys($recipients)); |
409 | - $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args); |
|
409 | + $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('.db_placeholders($recipients).') GROUP BY recipient', $args); |
|
410 | 410 | while ($row = db_fetch_array($result)) { |
411 | 411 | $recipient = $recipients[$row['recipient']]; |
412 | 412 | // If there's a rule disallowing blocking of this message, send it anyway. |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | should be displayed automatically in the action form', |
459 | 459 | 'callback' => 'privatemsg_thread_change_status', // Function callback that will be executed. |
460 | 460 | 'callback arguments' => array('status' => PRIVATEMSG_READ), // Additional arguments to above function |
461 | - 'undo callback' => 'privatemsg_thread_change_status', // Provide a function which can "undo" the operation. Optional. |
|
461 | + 'undo callback' => 'privatemsg_thread_change_status', // Provide a function which can "undo" the operation. Optional. |
|
462 | 462 | 'undo callback arguments' => array('status' => PRIVATEMSG_UNREAD), // Additional arguments to above function. |
463 | 463 | ), |
464 | 464 | ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ), |
39 | 39 | ); |
40 | 40 | $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter')); |
41 | - $result = pager_query($query['query'] . tablesort_sql($header), 100); |
|
41 | + $result = pager_query($query['query'].tablesort_sql($header), 100); |
|
42 | 42 | |
43 | 43 | $rows = array(); |
44 | 44 | while ($tag = db_fetch_array($result)) { |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $row['tag'] = check_plain($tag['tag']); |
47 | 47 | $row['count'] = $tag['count']; |
48 | 48 | $row['public'] = $tag['public'] ? t('Yes') : '-'; |
49 | - $row['operations'] = l(t('edit'), 'admin/settings/messages/tags/edit/' . $tag['tag_id']); |
|
50 | - $row['operations'] .= ' ' . l(t('delete'), 'admin/settings/messages/tags/delete/' . $tag['tag_id']); |
|
49 | + $row['operations'] = l(t('edit'), 'admin/settings/messages/tags/edit/'.$tag['tag_id']); |
|
50 | + $row['operations'] .= ' '.l(t('delete'), 'admin/settings/messages/tags/delete/'.$tag['tag_id']); |
|
51 | 51 | |
52 | 52 | $rows[] = $row; |
53 | 53 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $rows[] = array(array('data' => t('No tags available.'), 'colspan' => count($header))); |
58 | 58 | } |
59 | 59 | |
60 | - return theme('table', $header, $rows) . theme('pager'); |
|
60 | + return theme('table', $header, $rows).theme('pager'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | function privatemsg_filter_dropdown(&$form_state, $account) { |
315 | 315 | |
316 | - drupal_add_css(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg_filter.css'); |
|
316 | + drupal_add_css(drupal_get_path('module', 'privatemsg_filter').'/privatemsg_filter.css'); |
|
317 | 317 | |
318 | 318 | $form['filter'] = array( |
319 | 319 | '#type' => 'fieldset', |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | if (isset($filter['author'])) { |
378 | 378 | $string = ''; |
379 | 379 | foreach ($filter['author'] as $author) { |
380 | - $string .= $author->name . ', '; |
|
380 | + $string .= $author->name.', '; |
|
381 | 381 | } |
382 | 382 | $form['filter']['author']['#default_value'] = $string; |
383 | 383 | } |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $query['tags'][] = $tag; |
442 | 442 | } |
443 | 443 | } |
444 | - $sql = 'SELECT pmt.tag FROM {pm_tags} pmt WHERE pmt.tag_id IN ('. implode(', ', $filter['tags']) .')'; |
|
444 | + $sql = 'SELECT pmt.tag FROM {pm_tags} pmt WHERE pmt.tag_id IN ('.implode(', ', $filter['tags']).')'; |
|
445 | 445 | $result = db_query($sql); |
446 | 446 | while ($row = db_fetch_object($result)) { |
447 | 447 | $query['tags'][] = $row->tag; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | ); |
536 | 536 | |
537 | 537 | // JS for hiding the submit buttons. |
538 | - drupal_add_js(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg-filter-list.js'); |
|
538 | + drupal_add_js(drupal_get_path('module', 'privatemsg_filter').'/privatemsg-filter-list.js'); |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $tags = array(); |
565 | 565 | |
566 | 566 | foreach ($thread['tags'] as $tag_id => $tag) { |
567 | - $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13) . '...' : $tag, 'messages', array( |
|
567 | + $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13).'...' : $tag, 'messages', array( |
|
568 | 568 | 'attributes' => array('title' => $tag), |
569 | 569 | 'query' => array('tags' => $tag) |
570 | 570 | )); |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | |
612 | 612 | // Check if its a filtered view. |
613 | 613 | if ($argument == 'sent') { |
614 | - $fragments['where'][] = "pm.author = %d"; |
|
615 | - $fragments['query_args']['where'][] = $account->uid; |
|
614 | + $fragments['where'][] = "pm.author = %d"; |
|
615 | + $fragments['query_args']['where'][] = $account->uid; |
|
616 | 616 | } |
617 | 617 | if ($argument == 'inbox') { |
618 | - $fragments['having'][] = '((SELECT pmf.author FROM {pm_message} pmf WHERE pmf.mid = pmi.thread_id) = %d AND COUNT(pmi.thread_id) > 1) OR (SELECT COUNT(*) FROM {pm_message} pmf INNER JOIN {pm_index} pmif ON (pmf.mid = pmif.mid) WHERE pmif.thread_id = pmi.thread_id AND pmf.author <> %d) > 0'; |
|
618 | + $fragments['having'][] = '((SELECT pmf.author FROM {pm_message} pmf WHERE pmf.mid = pmi.thread_id) = %d AND COUNT(pmi.thread_id) > 1) OR (SELECT COUNT(*) FROM {pm_message} pmf INNER JOIN {pm_index} pmif ON (pmf.mid = pmif.mid) WHERE pmif.thread_id = pmi.thread_id AND pmf.author <> %d) > 0'; |
|
619 | 619 | $fragments['query_args']['having'][] = $account->uid; |
620 | 620 | $fragments['query_args']['having'][] = $account->uid; |
621 | 621 | } |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | foreach ($filter['tags'] as $tag) { |
628 | 628 | $fragments['inner_join'][] = "INNER JOIN {pm_tags_index} pmti$count ON (pmti$count.thread_id = pmi.thread_id AND pmti$count.uid = pmi.uid)"; |
629 | 629 | $fragments['where'][] = "pmti$count.tag_id = %d"; |
630 | - $fragments['query_args']['where'][] = $tag; |
|
630 | + $fragments['query_args']['where'][] = $tag; |
|
631 | 631 | $count++; |
632 | 632 | } |
633 | 633 | } |
@@ -636,20 +636,20 @@ discard block |
||
636 | 636 | foreach ($filter['author'] as $author) { |
637 | 637 | $fragments['inner_join'][] = "INNER JOIN {pm_index} pmi$count ON (pmi$count.mid = pm.mid)"; |
638 | 638 | $fragments['where'][] = "pmi$count.uid = %d"; |
639 | - $fragments['query_args']['where'][] = $author->uid; |
|
639 | + $fragments['query_args']['where'][] = $author->uid; |
|
640 | 640 | $count++; |
641 | 641 | } |
642 | 642 | } |
643 | 643 | |
644 | 644 | if (isset($filter['search']) && !empty($filter['search'])) { |
645 | 645 | if (variable_get('privatemsg_filter_searchbody', FALSE)) { |
646 | - $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
|
647 | - $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
|
648 | - $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
|
646 | + $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
|
647 | + $fragments['query_args']['where'][] = '%%'.$filter['search'].'%%'; |
|
648 | + $fragments['query_args']['where'][] = '%%'.$filter['search'].'%%'; |
|
649 | 649 | } |
650 | 650 | else { |
651 | - $fragments['where'][] = "pm.subject LIKE '%s'"; |
|
652 | - $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
|
651 | + $fragments['where'][] = "pm.subject LIKE '%s'"; |
|
652 | + $fragments['query_args']['where'][] = '%%'.$filter['search'].'%%'; |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | $count = db_result(db_query($query['count'])); |
679 | 679 | $tags = ''; |
680 | 680 | while ($tag = db_fetch_array($results)) { |
681 | - $tags .= $tag['tag'] . ', '; |
|
681 | + $tags .= $tag['tag'].', '; |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | $form['tags'] = array( |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | if (!empty($fragment)) { |
756 | 756 | $query = _privatemsg_assemble_query(array('tags_autocomplete', 'privatemsg_filter'), $fragment, $tags); |
757 | 757 | $result = db_query_range($query['query'], $fragment, 0, 10); |
758 | - $prefix = count($tags) ? implode(", ", $tags) .", " : ''; |
|
758 | + $prefix = count($tags) ? implode(", ", $tags).", " : ''; |
|
759 | 759 | // 3: Build proper suggestions and print. |
760 | 760 | while ($tag = db_fetch_object($result)) { |
761 | - $matches[$prefix . $tag->tag .", "] = $tag->tag; |
|
761 | + $matches[$prefix.$tag->tag.", "] = $tag->tag; |
|
762 | 762 | } |
763 | 763 | } |
764 | 764 | // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | if (!empty($threads)) { |
818 | 818 | // If the tag list needs to be for specific threads. |
819 | 819 | $fragments['select'][] = 'ti.thread_id'; |
820 | - $fragments['inner_join'][] = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id'; |
|
821 | - $fragments['where'][] = 'ti.thread_id IN (' . db_placeholders($threads) . ')'; |
|
820 | + $fragments['inner_join'][] = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id'; |
|
821 | + $fragments['where'][] = 'ti.thread_id IN ('.db_placeholders($threads).')'; |
|
822 | 822 | $fragments['query_args']['where'] += $threads; |
823 | 823 | } |
824 | 824 | else { |
@@ -875,14 +875,14 @@ discard block |
||
875 | 875 | $fragments['select'][] = 'pmt.tag'; |
876 | 876 | $fragments['where'][] = "pmt.tag LIKE '%s'"; |
877 | 877 | // Escape % to get through the placeholder replacement. |
878 | - $fragments['query_args']['where'][] = $search .'%%'; |
|
878 | + $fragments['query_args']['where'][] = $search.'%%'; |
|
879 | 879 | if (!empty($tags)) { |
880 | 880 | // Exclude tags. |
881 | - $fragments['where'][] = "pmt.tag NOT IN (". db_placeholders($tags, 'text') .")"; |
|
881 | + $fragments['where'][] = "pmt.tag NOT IN (".db_placeholders($tags, 'text').")"; |
|
882 | 882 | $fragments['query_args']['where'] += $tags; |
883 | 883 | } |
884 | 884 | // LEFT JOIN to be able to load public, unused tags. |
885 | - $fragments['inner_join'][] = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d'; |
|
885 | + $fragments['inner_join'][] = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d'; |
|
886 | 886 | $fragments['query_args']['join'][] = $user->uid; |
887 | 887 | // Autocomplete should only display Tags used by that user or public tags. |
888 | 888 | // This is done to avoid information disclosure as part of tag names. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $is_new = theme_mark(MARK_NEW); |
96 | 96 | $options['fragment'] = 'new'; |
97 | 97 | } |
98 | - $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new; |
|
98 | + $field['data'] = l($thread['subject'], 'messages/view/'.$thread['thread_id'], $options).$is_new; |
|
99 | 99 | $field['class'] = 'privatemsg-list-subject'; |
100 | 100 | return $field; |
101 | 101 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $options = array(); |
112 | 112 | if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) { |
113 | 113 | $options['fragment'] = 'new'; |
114 | - $field['data'] .= '<br />' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/' . $thread['thread_id'], $options); |
|
114 | + $field['data'] .= '<br />'.l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/'.$thread['thread_id'], $options); |
|
115 | 115 | } |
116 | 116 | $field['class'] = 'privatemsg-list-count'; |
117 | 117 | return $field; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | function theme_privatemsg_list($form) { |
240 | 240 | $has_posts = !empty($form['#data']); |
241 | 241 | |
242 | - drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css'); |
|
242 | + drupal_add_css(drupal_get_path('module', 'privatemsg').'/styles/privatemsg-list.css'); |
|
243 | 243 | |
244 | 244 | // Load the table columns. |
245 | 245 | $columns = array_merge(array('subject', 'last_updated'), array_filter(variable_get('privatemsg_display_fields', array('participants')))); |
@@ -33,7 +33,7 @@ |
||
33 | 33 | 'boinc_solr_comments_nodetypes' => variable_get('boinc_solr_comments_nodetypes', ''), |
34 | 34 | ); |
35 | 35 | if (empty($default['boinc_solr_comments_nodetypes'])) { |
36 | - $default['boinc_solr_comments_nodetypes'] = array('forum','team_forum','news','page','story'); |
|
36 | + $default['boinc_solr_comments_nodetypes'] = array('forum', 'team_forum', 'news', 'page', 'story'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Define the form |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | var $MOD43; |
25 | 25 | |
26 | 26 | /* Class creator */ |
27 | - function pBarcode39($BasePath="",$EnableMOD43=FALSE) |
|
27 | + function pBarcode39($BasePath = "", $EnableMOD43 = FALSE) |
|
28 | 28 | { |
29 | - $this->MOD43 = $EnableMOD43; |
|
29 | + $this->MOD43 = $EnableMOD43; |
|
30 | 30 | $this->Codes = ""; |
31 | 31 | $this->Reverse = ""; |
32 | 32 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | |
37 | 37 | while (!feof($FileHandle)) |
38 | 38 | { |
39 | - $Buffer = fgets($FileHandle,4096); |
|
40 | - $Buffer = str_replace(chr(10),"",$Buffer); |
|
41 | - $Buffer = str_replace(chr(13),"",$Buffer); |
|
42 | - $Values = preg_split("/;/",$Buffer); |
|
39 | + $Buffer = fgets($FileHandle, 4096); |
|
40 | + $Buffer = str_replace(chr(10), "", $Buffer); |
|
41 | + $Buffer = str_replace(chr(13), "", $Buffer); |
|
42 | + $Values = preg_split("/;/", $Buffer); |
|
43 | 43 | |
44 | 44 | $this->Codes[$Values[0]] = $Values[1]; |
45 | 45 | } |
@@ -47,32 +47,32 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /* Return the projected size of a barcode */ |
50 | - function getSize($TextString,$Format="") |
|
50 | + function getSize($TextString, $Format = "") |
|
51 | 51 | { |
52 | - $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
53 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
54 | - $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
52 | + $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
53 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
54 | + $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
55 | 55 | $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
56 | 56 | $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12; |
57 | - $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
57 | + $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
58 | 58 | |
59 | 59 | $TextString = $this->encode39($TextString); |
60 | 60 | $BarcodeLength = strlen($this->Result); |
61 | 61 | |
62 | - if ( $DrawArea ) { $WOffset = 20; } else { $WOffset = 0; } |
|
63 | - if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; } |
|
62 | + if ($DrawArea) { $WOffset = 20; } else { $WOffset = 0; } |
|
63 | + if ($ShowLegend) { $HOffset = $FontSize + $LegendOffset + $WOffset; } else { $HOffset = 0; } |
|
64 | 64 | |
65 | - $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
66 | - $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
65 | + $X1 = cos($Angle*PI/180)*($WOffset + $BarcodeLength); |
|
66 | + $Y1 = sin($Angle*PI/180)*($WOffset + $BarcodeLength); |
|
67 | 67 | |
68 | - $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
69 | - $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
68 | + $X2 = $X1 + cos(($Angle + 90)*PI/180)*($HOffset + $Height); |
|
69 | + $Y2 = $Y1 + sin(($Angle + 90)*PI/180)*($HOffset + $Height); |
|
70 | 70 | |
71 | 71 | |
72 | - $AreaWidth = max(abs($X1),abs($X2)); |
|
73 | - $AreaHeight = max(abs($Y1),abs($Y2)); |
|
72 | + $AreaWidth = max(abs($X1), abs($X2)); |
|
73 | + $AreaHeight = max(abs($Y1), abs($Y2)); |
|
74 | 74 | |
75 | - return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight)); |
|
75 | + return(array("Width"=>$AreaWidth, "Height"=>$AreaHeight)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /* Create the encoded string */ |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | { |
81 | 81 | $this->Result = "100101101101"."0"; |
82 | 82 | $TextString = ""; |
83 | - for($i=1;$i<=strlen($Value);$i++) |
|
83 | + for ($i = 1; $i <= strlen($Value); $i++) |
|
84 | 84 | { |
85 | - $CharCode = ord($this->mid($Value,$i,1)); |
|
86 | - if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; } |
|
85 | + $CharCode = ord($this->mid($Value, $i, 1)); |
|
86 | + if ($CharCode >= 97 && $CharCode <= 122) { $CharCode = $CharCode - 32; } |
|
87 | 87 | |
88 | - if ( isset($this->Codes[chr($CharCode)]) ) |
|
88 | + if (isset($this->Codes[chr($CharCode)])) |
|
89 | 89 | { |
90 | 90 | $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0"; |
91 | 91 | $TextString = $TextString.chr($CharCode); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if ( $this->MOD43 ) |
|
95 | + if ($this->MOD43) |
|
96 | 96 | { |
97 | 97 | $Checksum = $this->checksum($TextString); |
98 | 98 | $this->Result = $this->Result.$this->Codes[$Checksum]."0"; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | /* Create the encoded string */ |
108 | - function draw($Object,$Value,$X,$Y,$Format="") |
|
108 | + function draw($Object, $Value, $X, $Y, $Format = "") |
|
109 | 109 | { |
110 | 110 | $this->pChartObject = $Object; |
111 | 111 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
114 | 114 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
115 | 115 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
116 | - $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
116 | + $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
117 | 117 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
118 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
119 | - $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
120 | - $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
118 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
119 | + $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
120 | + $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
121 | 121 | $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 255; |
122 | 122 | $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 255; |
123 | 123 | $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 255; |
@@ -125,76 +125,76 @@ discard block |
||
125 | 125 | $AreaBorderG = isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG; |
126 | 126 | $AreaBorderB = isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB; |
127 | 127 | |
128 | - $TextString = $this->encode39($Value); |
|
128 | + $TextString = $this->encode39($Value); |
|
129 | 129 | |
130 | - if ( $DrawArea ) |
|
130 | + if ($DrawArea) |
|
131 | 131 | { |
132 | - $X1 = $X + cos(($Angle-135) * PI / 180) * 10; |
|
133 | - $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10; |
|
132 | + $X1 = $X + cos(($Angle - 135)*PI/180)*10; |
|
133 | + $Y1 = $Y + sin(($Angle - 135)*PI/180)*10; |
|
134 | 134 | |
135 | - $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20); |
|
136 | - $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20); |
|
135 | + $X2 = $X1 + cos($Angle*PI/180)*(strlen($this->Result) + 20); |
|
136 | + $Y2 = $Y1 + sin($Angle*PI/180)*(strlen($this->Result) + 20); |
|
137 | 137 | |
138 | - if ( $ShowLegend ) |
|
138 | + if ($ShowLegend) |
|
139 | 139 | { |
140 | - $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
141 | - $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
140 | + $X3 = $X2 + cos(($Angle + 90)*PI/180)*($Height + $LegendOffset + $this->pChartObject->FontSize + 10); |
|
141 | + $Y3 = $Y2 + sin(($Angle + 90)*PI/180)*($Height + $LegendOffset + $this->pChartObject->FontSize + 10); |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20); |
|
146 | - $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20); |
|
145 | + $X3 = $X2 + cos(($Angle + 90)*PI/180)*($Height + 20); |
|
146 | + $Y3 = $Y2 + sin(($Angle + 90)*PI/180)*($Height + 20); |
|
147 | 147 | } |
148 | 148 | |
149 | - $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
150 | - $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
149 | + $X4 = $X3 + cos(($Angle + 180)*PI/180)*(strlen($this->Result) + 20); |
|
150 | + $Y4 = $Y3 + sin(($Angle + 180)*PI/180)*(strlen($this->Result) + 20); |
|
151 | 151 | |
152 | - $Polygon = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4); |
|
153 | - $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB); |
|
154 | - $this->pChartObject->drawPolygon($Polygon,$Settings); |
|
152 | + $Polygon = array($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4); |
|
153 | + $Settings = array("R"=>$AreaR, "G"=>$AreaG, "B"=>$AreaB, "BorderR"=>$AreaBorderR, "BorderG"=>$AreaBorderG, "BorderB"=>$AreaBorderB); |
|
154 | + $this->pChartObject->drawPolygon($Polygon, $Settings); |
|
155 | 155 | } |
156 | 156 | |
157 | - for($i=1;$i<=strlen($this->Result);$i++) |
|
157 | + for ($i = 1; $i <= strlen($this->Result); $i++) |
|
158 | 158 | { |
159 | - if ( $this->mid($this->Result,$i,1) == 1 ) |
|
159 | + if ($this->mid($this->Result, $i, 1) == 1) |
|
160 | 160 | { |
161 | - $X1 = $X + cos($Angle * PI / 180) * $i; |
|
162 | - $Y1 = $Y + sin($Angle * PI / 180) * $i; |
|
163 | - $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height; |
|
164 | - $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height; |
|
161 | + $X1 = $X + cos($Angle*PI/180)*$i; |
|
162 | + $Y1 = $Y + sin($Angle*PI/180)*$i; |
|
163 | + $X2 = $X1 + cos(($Angle + 90)*PI/180)*$Height; |
|
164 | + $Y2 = $Y1 + sin(($Angle + 90)*PI/180)*$Height; |
|
165 | 165 | |
166 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
167 | - $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings); |
|
166 | + $Settings = array("R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha); |
|
167 | + $this->pChartObject->drawLine($X1, $Y1, $X2, $Y2, $Settings); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - if ( $ShowLegend ) |
|
171 | + if ($ShowLegend) |
|
172 | 172 | { |
173 | - $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2); |
|
174 | - $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2); |
|
173 | + $X1 = $X + cos($Angle*PI/180)*(strlen($this->Result)/2); |
|
174 | + $Y1 = $Y + sin($Angle*PI/180)*(strlen($this->Result)/2); |
|
175 | 175 | |
176 | - $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
177 | - $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
176 | + $LegendX = $X1 + cos(($Angle + 90)*PI/180)*($Height + $LegendOffset); |
|
177 | + $LegendY = $Y1 + sin(($Angle + 90)*PI/180)*($Height + $LegendOffset); |
|
178 | 178 | |
179 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE); |
|
180 | - $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings); |
|
179 | + $Settings = array("R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha, "Angle"=>-$Angle, "Align"=>TEXT_ALIGN_TOPMIDDLE); |
|
180 | + $this->pChartObject->drawText($LegendX, $LegendY, $TextString, $Settings); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - function checksum( $string ) |
|
184 | + function checksum($string) |
|
185 | 185 | { |
186 | 186 | $checksum = 0; |
187 | - $length = strlen( $string ); |
|
187 | + $length = strlen($string); |
|
188 | 188 | $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'; |
189 | 189 | |
190 | - for( $i=0; $i < $length; ++$i ) |
|
191 | - $checksum += strpos( $charset, $string[$i] ); |
|
190 | + for ($i = 0; $i < $length; ++$i) |
|
191 | + $checksum += strpos($charset, $string[$i]); |
|
192 | 192 | |
193 | - return substr( $charset, ($checksum % 43), 1 ); |
|
193 | + return substr($charset, ($checksum%43), 1); |
|
194 | 194 | } |
195 | 195 | |
196 | - function left($value,$NbChar) { return substr($value,0,$NbChar); } |
|
197 | - function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); } |
|
198 | - function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); } |
|
196 | + function left($value, $NbChar) { return substr($value, 0, $NbChar); } |
|
197 | + function right($value, $NbChar) { return substr($value, strlen($value) - $NbChar, $NbChar); } |
|
198 | + function mid($value, $Depart, $NbChar) { return substr($value, $Depart - 1, $NbChar); } |
|
199 | 199 | } |
200 | 200 | ?> |
201 | 201 | \ No newline at end of file |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("INDICATOR_CAPTION_DEFAULT" , 700001); |
|
17 | - define("INDICATOR_CAPTION_EXTENDED" , 700002); |
|
16 | + define("INDICATOR_CAPTION_DEFAULT", 700001); |
|
17 | + define("INDICATOR_CAPTION_EXTENDED", 700002); |
|
18 | 18 | |
19 | - define("INDICATOR_CAPTION_INSIDE" , 700011); |
|
20 | - define("INDICATOR_CAPTION_BOTTOM" , 700012); |
|
19 | + define("INDICATOR_CAPTION_INSIDE", 700011); |
|
20 | + define("INDICATOR_CAPTION_BOTTOM", 700012); |
|
21 | 21 | |
22 | - define("INDICATOR_VALUE_BUBBLE" , 700021); |
|
23 | - define("INDICATOR_VALUE_LABEL" , 700022); |
|
22 | + define("INDICATOR_VALUE_BUBBLE", 700021); |
|
23 | + define("INDICATOR_VALUE_LABEL", 700022); |
|
24 | 24 | |
25 | 25 | /* pIndicator class definition */ |
26 | 26 | class pIndicator |
@@ -34,24 +34,24 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | /* Draw an indicator */ |
37 | - function draw($X,$Y,$Width,$Height,$Format="") |
|
37 | + function draw($X, $Y, $Width, $Height, $Format = "") |
|
38 | 38 | { |
39 | - $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
|
40 | - $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
39 | + $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
|
40 | + $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
41 | 41 | $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
42 | - $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
|
42 | + $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
|
43 | 43 | $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE; |
44 | 44 | $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE; |
45 | - $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
|
46 | - $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
|
45 | + $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
|
46 | + $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
|
47 | 47 | $CaptionLayout = isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED; |
48 | - $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
|
49 | - $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
48 | + $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
|
49 | + $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
50 | 50 | $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255; |
51 | 51 | $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255; |
52 | 52 | $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255; |
53 | - $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
|
54 | - $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
53 | + $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
|
54 | + $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
55 | 55 | $SubCaptionR = isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50; |
56 | 56 | $SubCaptionG = isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50; |
57 | 57 | $SubCaptionB = isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50; |
@@ -60,109 +60,109 @@ discard block |
||
60 | 60 | $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize; |
61 | 61 | $CaptionFontName = isset($Format["CaptionFontName"]) ? $Format["CaptionFontName"] : $this->pChartObject->FontName; |
62 | 62 | $CaptionFontSize = isset($Format["CaptionFontSize"]) ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize; |
63 | - $Unit = isset($Format["Unit"]) ? $Format["Unit"] : ""; |
|
63 | + $Unit = isset($Format["Unit"]) ? $Format["Unit"] : ""; |
|
64 | 64 | |
65 | 65 | /* Convert the Values to display to an array if needed */ |
66 | - if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
|
66 | + if (!is_array($Values)) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
|
67 | 67 | |
68 | 68 | /* No section, let's die */ |
69 | - if ( $IndicatorSections == NULL ) { return(0); } |
|
69 | + if ($IndicatorSections == NULL) { return(0); } |
|
70 | 70 | |
71 | 71 | /* Determine indicator visual configuration */ |
72 | 72 | $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
73 | 73 | foreach ($IndicatorSections as $Key => $Settings) |
74 | 74 | { |
75 | - if ( $Settings["End"] > $OverallMax ) { $OverallMax = $Settings["End"]; } |
|
76 | - if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; } |
|
75 | + if ($Settings["End"] > $OverallMax) { $OverallMax = $Settings["End"]; } |
|
76 | + if ($Settings["Start"] < $OverallMin) { $OverallMin = $Settings["Start"]; } |
|
77 | 77 | } |
78 | - $RealWidth = $Width - (count($IndicatorSections)-1)*$SectionsMargin; |
|
79 | - $XScale = $RealWidth / ($OverallMax-$OverallMin); |
|
78 | + $RealWidth = $Width - (count($IndicatorSections) - 1)*$SectionsMargin; |
|
79 | + $XScale = $RealWidth/($OverallMax - $OverallMin); |
|
80 | 80 | |
81 | 81 | $X1 = $X; $ValuesPos = ""; |
82 | 82 | foreach ($IndicatorSections as $Key => $Settings) |
83 | 83 | { |
84 | - $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]); |
|
84 | + $Color = array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"]); |
|
85 | 85 | $Caption = $Settings["Caption"]; |
86 | 86 | $SubCaption = $Settings["Start"]." - ".$Settings["End"]; |
87 | 87 | |
88 | - $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; |
|
88 | + $X2 = $X1 + ($Settings["End"] - $Settings["Start"])*$XScale; |
|
89 | 89 | |
90 | - if ( $Key == 0 && $DrawLeftHead ) |
|
90 | + if ($Key == 0 && $DrawLeftHead) |
|
91 | 91 | { |
92 | - $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2); |
|
93 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
94 | - $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
95 | - $this->pChartObject->drawLine($X1-2,$Y+$Height,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
92 | + $Poly = ""; $Poly[] = $X1 - 1; $Poly[] = $Y; $Poly[] = $X1 - 1; $Poly[] = $Y + $Height; $Poly[] = $X1 - 1 - $HeadSize; $Poly[] = $Y + ($Height/2); |
|
93 | + $this->pChartObject->drawPolygon($Poly, $Color); |
|
94 | + $this->pChartObject->drawLine($X1 - 2, $Y, $X1 - 2 - $HeadSize, $Y + ($Height/2), $Color); |
|
95 | + $this->pChartObject->drawLine($X1 - 2, $Y + $Height, $X1 - 2 - $HeadSize, $Y + ($Height/2), $Color); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /* Determine the position of the breaks */ |
99 | 99 | $Break = ""; |
100 | - foreach($Values as $iKey => $Value) |
|
100 | + foreach ($Values as $iKey => $Value) |
|
101 | 101 | { |
102 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
102 | + if ($Value >= $Settings["Start"] && $Value <= $Settings["End"]) |
|
103 | 103 | { |
104 | - $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale; |
|
104 | + $XBreak = $X1 + ($Value - $Settings["Start"])*$XScale; |
|
105 | 105 | $ValuesPos[$Value] = $XBreak; |
106 | 106 | $Break[] = floor($XBreak); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
110 | + if ($ValueDisplay == INDICATOR_VALUE_LABEL) |
|
111 | 111 | { |
112 | - if ( $Break == "" ) |
|
113 | - $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
|
112 | + if ($Break == "") |
|
113 | + $this->pChartObject->drawFilledRectangle($X1, $Y, $X2, $Y + $Height, $Color); |
|
114 | 114 | else |
115 | 115 | { |
116 | 116 | sort($Break); |
117 | 117 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
118 | - foreach($Break as $iKey => $Value) |
|
118 | + foreach ($Break as $iKey => $Value) |
|
119 | 119 | { |
120 | - if ( $Value-5 >= $X1 ) |
|
121 | - { $Poly[] = $Value-5; $Poly[] = $Y; } |
|
122 | - elseif ($X1 - ($Value-5) > 0 ) |
|
120 | + if ($Value - 5 >= $X1) |
|
121 | + { $Poly[] = $Value - 5; $Poly[] = $Y; } |
|
122 | + elseif ($X1 - ($Value - 5) > 0) |
|
123 | 123 | { |
124 | - $Offset = $X1 - ($Value-5); |
|
124 | + $Offset = $X1 - ($Value - 5); |
|
125 | 125 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset; |
126 | 126 | } |
127 | 127 | |
128 | - $Poly[] = $Value; $Poly[] = $Y+5; |
|
128 | + $Poly[] = $Value; $Poly[] = $Y + 5; |
|
129 | 129 | |
130 | - if ( $Value+5 <= $X2 ) |
|
131 | - { $Poly[] = $Value+5; $Poly[] = $Y; } |
|
132 | - elseif (($Value+5) > $X2 ) |
|
130 | + if ($Value + 5 <= $X2) |
|
131 | + { $Poly[] = $Value + 5; $Poly[] = $Y; } |
|
132 | + elseif (($Value + 5) > $X2) |
|
133 | 133 | { |
134 | - $Offset = ($Value+5) - $X2; |
|
134 | + $Offset = ($Value + 5) - $X2; |
|
135 | 135 | $Poly[] = $X2; $Poly[] = $Y + $Offset; |
136 | 136 | $LastPointWritten = TRUE; |
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
140 | - if ( !$LastPointWritten ) { $Poly[] = $X2; $Poly[] = $Y; } |
|
141 | - $Poly[] = $X2; $Poly[] = $Y+$Height; |
|
142 | - $Poly[] = $X1; $Poly[] = $Y+$Height; |
|
140 | + if (!$LastPointWritten) { $Poly[] = $X2; $Poly[] = $Y; } |
|
141 | + $Poly[] = $X2; $Poly[] = $Y + $Height; |
|
142 | + $Poly[] = $X1; $Poly[] = $Y + $Height; |
|
143 | 143 | |
144 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
144 | + $this->pChartObject->drawPolygon($Poly, $Color); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | else |
148 | - $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
|
148 | + $this->pChartObject->drawFilledRectangle($X1, $Y, $X2, $Y + $Height, $Color); |
|
149 | 149 | |
150 | - if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) |
|
150 | + if ($Key == count($IndicatorSections) - 1 && $DrawRightHead) |
|
151 | 151 | { |
152 | - $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2); |
|
153 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
154 | - $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
155 | - $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
152 | + $Poly = ""; $Poly[] = $X2 + 1; $Poly[] = $Y; $Poly[] = $X2 + 1; $Poly[] = $Y + $Height; $Poly[] = $X2 + 1 + $HeadSize; $Poly[] = $Y + ($Height/2); |
|
153 | + $this->pChartObject->drawPolygon($Poly, $Color); |
|
154 | + $this->pChartObject->drawLine($X2 + 1, $Y, $X2 + 1 + $HeadSize, $Y + ($Height/2), $Color); |
|
155 | + $this->pChartObject->drawLine($X2 + 1, $Y + $Height, $X2 + 1 + $HeadSize, $Y + ($Height/2), $Color); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) |
|
158 | + if ($CaptionPosition == INDICATOR_CAPTION_INSIDE) |
|
159 | 159 | { |
160 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
160 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y + $Height + $TextPadding, $CaptionFontName, $CaptionFontSize, 0, $Caption); |
|
161 | 161 | $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding; |
162 | 162 | |
163 | - if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
163 | + if ($CaptionLayout == INDICATOR_CAPTION_EXTENDED) |
|
164 | 164 | { |
165 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption); |
|
165 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y + $Height + $TextPadding, $CaptionFontName, $CaptionFontSize, 0, $SubCaption); |
|
166 | 166 | $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2; |
167 | 167 | } |
168 | 168 | |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | else |
172 | 172 | { $YOffset = 0; $XOffset = 0; } |
173 | 173 | |
174 | - if ( $CaptionColorFactor == NULL ) |
|
175 | - { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } |
|
174 | + if ($CaptionColorFactor == NULL) |
|
175 | + { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$CaptionR, "G"=>$CaptionG, "B"=>$CaptionB, "Alpha"=>$CaptionAlpha); } |
|
176 | 176 | else |
177 | - { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); } |
|
177 | + { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$Settings["R"] + $CaptionColorFactor, "G"=>$Settings["G"] + $CaptionColorFactor, "B"=>$Settings["B"] + $CaptionColorFactor); } |
|
178 | 178 | |
179 | - if ( $SubCaptionColorFactor == NULL ) |
|
180 | - $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$SubCaptionR,"G"=>$SubCaptionG,"B"=>$SubCaptionB,"Alpha"=>$SubCaptionAlpha); |
|
179 | + if ($SubCaptionColorFactor == NULL) |
|
180 | + $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$SubCaptionR, "G"=>$SubCaptionG, "B"=>$SubCaptionB, "Alpha"=>$SubCaptionAlpha); |
|
181 | 181 | else |
182 | - $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$SubCaptionColorFactor,"G"=>$Settings["G"]+$SubCaptionColorFactor,"B"=>$Settings["B"]+$SubCaptionColorFactor); |
|
182 | + $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$Settings["R"] + $SubCaptionColorFactor, "G"=>$Settings["G"] + $SubCaptionColorFactor, "B"=>$Settings["B"] + $SubCaptionColorFactor); |
|
183 | 183 | |
184 | 184 | $RestoreShadow = $this->pChartObject->Shadow; |
185 | 185 | $this->pChartObject->Shadow = FALSE; |
186 | 186 | |
187 | - if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
|
188 | - $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor); |
|
189 | - elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
187 | + if ($CaptionLayout == INDICATOR_CAPTION_DEFAULT) |
|
188 | + $this->pChartObject->drawText($X1, $Y + $Height + $TextPadding, $Caption, $CaptionColor); |
|
189 | + elseif ($CaptionLayout == INDICATOR_CAPTION_EXTENDED) |
|
190 | 190 | { |
191 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
191 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y + $Height + $TextPadding, $CaptionFontName, $CaptionFontSize, 0, $Caption); |
|
192 | 192 | $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"]; |
193 | 193 | |
194 | - $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$TextPadding,$Caption,$CaptionColor); |
|
195 | - $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$CaptionHeight+$TextPadding*2,$SubCaption,$SubCaptionColor); |
|
194 | + $this->pChartObject->drawText($X1 + $XOffset, $Y + $Height - $YOffset + $TextPadding, $Caption, $CaptionColor); |
|
195 | + $this->pChartObject->drawText($X1 + $XOffset, $Y + $Height - $YOffset + $CaptionHeight + $TextPadding*2, $SubCaption, $SubCaptionColor); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $this->pChartObject->Shadow = $RestoreShadow; |
@@ -203,32 +203,32 @@ discard block |
||
203 | 203 | $RestoreShadow = $this->pChartObject->Shadow; |
204 | 204 | $this->pChartObject->Shadow = FALSE; |
205 | 205 | |
206 | - foreach($Values as $Key => $Value) |
|
206 | + foreach ($Values as $Key => $Value) |
|
207 | 207 | { |
208 | - if ( $Value >= $OverallMin && $Value <= $OverallMax ) |
|
208 | + if ($Value >= $OverallMin && $Value <= $OverallMax) |
|
209 | 209 | { |
210 | 210 | foreach ($IndicatorSections as $Key => $Settings) |
211 | 211 | { |
212 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
212 | + if ($Value >= $Settings["Start"] && $Value <= $Settings["End"]) |
|
213 | 213 | { |
214 | 214 | $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale; |
215 | 215 | |
216 | - if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) |
|
216 | + if ($ValueDisplay == INDICATOR_VALUE_BUBBLE) |
|
217 | 217 | { |
218 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit); |
|
218 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y, $ValueFontName, $ValueFontSize, 0, $Value.$Unit); |
|
219 | 219 | $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2); |
220 | 220 | |
221 | - $this->pChartObject->drawFilledCircle($X1,$Y,$Radius+4,array("R"=>$Settings["R"]+20,"G"=>$Settings["G"]+20,"B"=>$Settings["B"]+20)); |
|
222 | - $this->pChartObject->drawFilledCircle($X1,$Y,$Radius,array("R"=>255,"G"=>255,"B"=>255)); |
|
221 | + $this->pChartObject->drawFilledCircle($X1, $Y, $Radius + 4, array("R"=>$Settings["R"] + 20, "G"=>$Settings["G"] + 20, "B"=>$Settings["B"] + 20)); |
|
222 | + $this->pChartObject->drawFilledCircle($X1, $Y, $Radius, array("R"=>255, "G"=>255, "B"=>255)); |
|
223 | 223 | |
224 | - $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize); |
|
225 | - $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings); |
|
224 | + $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE, "FontName"=>$ValueFontName, "FontSize"=>$ValueFontSize); |
|
225 | + $this->pChartObject->drawText($X1 - 1, $Y - 1, $Value.$Unit, $TextSettings); |
|
226 | 226 | } |
227 | - elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
227 | + elseif ($ValueDisplay == INDICATOR_VALUE_LABEL) |
|
228 | 228 | { |
229 | 229 | $Caption = ""; |
230 | - $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit); |
|
231 | - $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption); |
|
230 | + $Caption[] = array("Format"=>array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"], "Alpha"=>100), "Caption"=>$Value.$Unit); |
|
231 | + $this->pChartObject->drawLabelBox(floor($X1), floor($Y) + 2, "Value - ".$Settings["Caption"], $Caption); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | $X1 = $X2 + $SectionsMargin; |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("NODE_TYPE_FREE" , 690001); |
|
17 | - define("NODE_TYPE_CENTRAL" , 690002); |
|
16 | + define("NODE_TYPE_FREE", 690001); |
|
17 | + define("NODE_TYPE_CENTRAL", 690002); |
|
18 | 18 | |
19 | - define("NODE_SHAPE_CIRCLE" , 690011); |
|
20 | - define("NODE_SHAPE_TRIANGLE" , 690012); |
|
21 | - define("NODE_SHAPE_SQUARE" , 690013); |
|
19 | + define("NODE_SHAPE_CIRCLE", 690011); |
|
20 | + define("NODE_SHAPE_TRIANGLE", 690012); |
|
21 | + define("NODE_SHAPE_SQUARE", 690013); |
|
22 | 22 | |
23 | - define("ALGORITHM_RANDOM" , 690021); |
|
24 | - define("ALGORITHM_WEIGHTED" , 690022); |
|
25 | - define("ALGORITHM_CIRCULAR" , 690023); |
|
26 | - define("ALGORITHM_CENTRAL" , 690024); |
|
23 | + define("ALGORITHM_RANDOM", 690021); |
|
24 | + define("ALGORITHM_WEIGHTED", 690022); |
|
25 | + define("ALGORITHM_CIRCULAR", 690023); |
|
26 | + define("ALGORITHM_CENTRAL", 690024); |
|
27 | 27 | |
28 | - define("LABEL_CLASSIC" , 690031); |
|
29 | - define("LABEL_LIGHT" , 690032); |
|
28 | + define("LABEL_CLASSIC", 690031); |
|
29 | + define("LABEL_LIGHT", 690032); |
|
30 | 30 | |
31 | 31 | /* pSpring class definition */ |
32 | 32 | class pSpring |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->Default["R"] = 255; |
54 | 54 | $this->Default["G"] = 255; |
55 | 55 | $this->Default["B"] = 255; |
56 | - $this->Default["Alpha"] = 100; |
|
56 | + $this->Default["Alpha"] = 100; |
|
57 | 57 | $this->Default["BorderR"] = 0; |
58 | 58 | $this->Default["BorderG"] = 0; |
59 | 59 | $this->Default["BorderB"] = 0; |
@@ -62,52 +62,52 @@ discard block |
||
62 | 62 | $this->Default["BackgroundR"] = 255; |
63 | 63 | $this->Default["BackgroundG"] = 255; |
64 | 64 | $this->Default["BackgroundB"] = 255; |
65 | - $this->Default["BackgroundAlpha"] = 0; |
|
65 | + $this->Default["BackgroundAlpha"] = 0; |
|
66 | 66 | $this->Default["Force"] = 1; |
67 | 67 | $this->Default["NodeType"] = NODE_TYPE_FREE; |
68 | - $this->Default["Size"] = 5; |
|
68 | + $this->Default["Size"] = 5; |
|
69 | 69 | $this->Default["Shape"] = NODE_SHAPE_CIRCLE; |
70 | 70 | $this->Default["FreeZone"] = 40; |
71 | 71 | $this->Default["LinkR"] = 0; |
72 | 72 | $this->Default["LinkG"] = 0; |
73 | 73 | $this->Default["LinkB"] = 0; |
74 | - $this->Default["LinkAlpha"] = 0; |
|
74 | + $this->Default["LinkAlpha"] = 0; |
|
75 | 75 | |
76 | - $this->Labels["Type"] = LABEL_CLASSIC; |
|
76 | + $this->Labels["Type"] = LABEL_CLASSIC; |
|
77 | 77 | $this->Labels["R"] = 0; |
78 | 78 | $this->Labels["G"] = 0; |
79 | 79 | $this->Labels["B"] = 0; |
80 | - $this->Labels["Alpha"] = 100; |
|
80 | + $this->Labels["Alpha"] = 100; |
|
81 | 81 | |
82 | - $this->AutoComputeFreeZone = FALSE; |
|
82 | + $this->AutoComputeFreeZone = FALSE; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /* Set default links options */ |
86 | - function setLinkDefaults($Settings="") |
|
86 | + function setLinkDefaults($Settings = "") |
|
87 | 87 | { |
88 | - if ( isset($Settings["R"]) ) { $this->Default["LinkR"] = $Settings["R"]; } |
|
89 | - if ( isset($Settings["G"]) ) { $this->Default["LinkG"] = $Settings["G"]; } |
|
90 | - if ( isset($Settings["B"]) ) { $this->Default["LinkB"] = $Settings["B"]; } |
|
91 | - if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; } |
|
88 | + if (isset($Settings["R"])) { $this->Default["LinkR"] = $Settings["R"]; } |
|
89 | + if (isset($Settings["G"])) { $this->Default["LinkG"] = $Settings["G"]; } |
|
90 | + if (isset($Settings["B"])) { $this->Default["LinkB"] = $Settings["B"]; } |
|
91 | + if (isset($Settings["Alpha"])) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; } |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /* Set default links options */ |
95 | - function setLabelsSettings($Settings="") |
|
95 | + function setLabelsSettings($Settings = "") |
|
96 | 96 | { |
97 | - if ( isset($Settings["Type"]) ) { $this->Labels["Type"] = $Settings["Type"]; } |
|
98 | - if ( isset($Settings["R"]) ) { $this->Labels["R"] = $Settings["R"]; } |
|
99 | - if ( isset($Settings["G"]) ) { $this->Labels["G"] = $Settings["G"]; } |
|
100 | - if ( isset($Settings["B"]) ) { $this->Labels["B"] = $Settings["B"]; } |
|
101 | - if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; } |
|
97 | + if (isset($Settings["Type"])) { $this->Labels["Type"] = $Settings["Type"]; } |
|
98 | + if (isset($Settings["R"])) { $this->Labels["R"] = $Settings["R"]; } |
|
99 | + if (isset($Settings["G"])) { $this->Labels["G"] = $Settings["G"]; } |
|
100 | + if (isset($Settings["B"])) { $this->Labels["B"] = $Settings["B"]; } |
|
101 | + if (isset($Settings["Alpha"])) { $this->Labels["Alpha"] = $Settings["Alpha"]; } |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /* Auto compute the FreeZone size based on the number of connections */ |
105 | 105 | function autoFreeZone() |
106 | 106 | { |
107 | 107 | /* Check connections reciprocity */ |
108 | - foreach($this->Data as $Key => $Settings) |
|
108 | + foreach ($this->Data as $Key => $Settings) |
|
109 | 109 | { |
110 | - if ( isset($Settings["Connections"]) ) |
|
110 | + if (isset($Settings["Connections"])) |
|
111 | 111 | { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; } |
112 | 112 | else |
113 | 113 | { $this->Data[$Key]["FreeZone"] = 20; } |
@@ -116,60 +116,60 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | /* Set link properties */ |
119 | - function linkProperties($FromNode,$ToNode,$Settings) |
|
119 | + function linkProperties($FromNode, $ToNode, $Settings) |
|
120 | 120 | { |
121 | - if ( !isset($this->Data[$FromNode]) ) { return(0); } |
|
122 | - if ( !isset($this->Data[$ToNode]) ) { return(0); } |
|
121 | + if (!isset($this->Data[$FromNode])) { return(0); } |
|
122 | + if (!isset($this->Data[$ToNode])) { return(0); } |
|
123 | 123 | |
124 | 124 | $R = isset($Settings["R"]) ? $Settings["R"] : 0; |
125 | 125 | $G = isset($Settings["G"]) ? $Settings["G"] : 0; |
126 | 126 | $B = isset($Settings["B"]) ? $Settings["B"] : 0; |
127 | 127 | $Alpha = isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100; |
128 | - $Name = isset($Settings["Name"]) ? $Settings["Name"] : NULL; |
|
128 | + $Name = isset($Settings["Name"]) ? $Settings["Name"] : NULL; |
|
129 | 129 | $Ticks = isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL; |
130 | 130 | |
131 | - $this->Links[$FromNode][$ToNode]["R"] = $R; $this->Links[$ToNode][$FromNode]["R"] = $R; |
|
132 | - $this->Links[$FromNode][$ToNode]["G"] = $G; $this->Links[$ToNode][$FromNode]["G"] = $G; |
|
133 | - $this->Links[$FromNode][$ToNode]["B"] = $B; $this->Links[$ToNode][$FromNode]["B"] = $B; |
|
131 | + $this->Links[$FromNode][$ToNode]["R"] = $R; $this->Links[$ToNode][$FromNode]["R"] = $R; |
|
132 | + $this->Links[$FromNode][$ToNode]["G"] = $G; $this->Links[$ToNode][$FromNode]["G"] = $G; |
|
133 | + $this->Links[$FromNode][$ToNode]["B"] = $B; $this->Links[$ToNode][$FromNode]["B"] = $B; |
|
134 | 134 | $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha; |
135 | - $this->Links[$FromNode][$ToNode]["Name"] = $Name; $this->Links[$ToNode][$FromNode]["Name"] = $Name; |
|
135 | + $this->Links[$FromNode][$ToNode]["Name"] = $Name; $this->Links[$ToNode][$FromNode]["Name"] = $Name; |
|
136 | 136 | $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks; |
137 | 137 | } |
138 | 138 | |
139 | - function setNodeDefaults($Settings="") |
|
139 | + function setNodeDefaults($Settings = "") |
|
140 | 140 | { |
141 | - if ( isset($Settings["R"]) ) { $this->Default["R"] = $Settings["R"]; } |
|
142 | - if ( isset($Settings["G"]) ) { $this->Default["G"] = $Settings["G"]; } |
|
143 | - if ( isset($Settings["B"]) ) { $this->Default["B"] = $Settings["B"]; } |
|
144 | - if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"] = $Settings["Alpha"]; } |
|
145 | - if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"] = $Settings["BorderR"]; } |
|
146 | - if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"] = $Settings["BorderG"]; } |
|
147 | - if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"] = $Settings["BorderB"]; } |
|
148 | - if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"] = $Settings["BorderAlpha"]; } |
|
149 | - if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"] = $Settings["Surrounding"]; } |
|
150 | - if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"] = $Settings["BackgroundR"]; } |
|
151 | - if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"] = $Settings["BackgroundG"]; } |
|
152 | - if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"] = $Settings["BackgroundB"]; } |
|
153 | - if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"] = $Settings["BackgroundAlpha"]; } |
|
154 | - if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"] = $Settings["NodeType"]; } |
|
155 | - if ( isset($Settings["Size"]) ) { $this->Default["Size"] = $Settings["Size"]; } |
|
156 | - if ( isset($Settings["Shape"]) ) { $this->Default["Shape"] = $Settings["Shape"]; } |
|
157 | - if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"] = $Settings["FreeZone"]; } |
|
141 | + if (isset($Settings["R"])) { $this->Default["R"] = $Settings["R"]; } |
|
142 | + if (isset($Settings["G"])) { $this->Default["G"] = $Settings["G"]; } |
|
143 | + if (isset($Settings["B"])) { $this->Default["B"] = $Settings["B"]; } |
|
144 | + if (isset($Settings["Alpha"])) { $this->Default["Alpha"] = $Settings["Alpha"]; } |
|
145 | + if (isset($Settings["BorderR"])) { $this->Default["BorderR"] = $Settings["BorderR"]; } |
|
146 | + if (isset($Settings["BorderG"])) { $this->Default["BorderG"] = $Settings["BorderG"]; } |
|
147 | + if (isset($Settings["BorderB"])) { $this->Default["BorderB"] = $Settings["BorderB"]; } |
|
148 | + if (isset($Settings["BorderAlpha"])) { $this->Default["BorderAlpha"] = $Settings["BorderAlpha"]; } |
|
149 | + if (isset($Settings["Surrounding"])) { $this->Default["Surrounding"] = $Settings["Surrounding"]; } |
|
150 | + if (isset($Settings["BackgroundR"])) { $this->Default["BackgroundR"] = $Settings["BackgroundR"]; } |
|
151 | + if (isset($Settings["BackgroundG"])) { $this->Default["BackgroundG"] = $Settings["BackgroundG"]; } |
|
152 | + if (isset($Settings["BackgroundB"])) { $this->Default["BackgroundB"] = $Settings["BackgroundB"]; } |
|
153 | + if (isset($Settings["BackgroundAlpha"])) { $this->Default["BackgroundAlpha"] = $Settings["BackgroundAlpha"]; } |
|
154 | + if (isset($Settings["NodeType"])) { $this->Default["NodeType"] = $Settings["NodeType"]; } |
|
155 | + if (isset($Settings["Size"])) { $this->Default["Size"] = $Settings["Size"]; } |
|
156 | + if (isset($Settings["Shape"])) { $this->Default["Shape"] = $Settings["Shape"]; } |
|
157 | + if (isset($Settings["FreeZone"])) { $this->Default["FreeZone"] = $Settings["FreeZone"]; } |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /* Add a node */ |
161 | - function addNode($NodeID,$Settings="") |
|
161 | + function addNode($NodeID, $Settings = "") |
|
162 | 162 | { |
163 | 163 | /* if the node already exists, ignore */ |
164 | 164 | if (isset($this->Data[$NodeID])) { return(0); } |
165 | 165 | |
166 | - $Name = isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID; |
|
167 | - $Connections = isset($Settings["Connections"]) ? $Settings["Connections"] : NULL; |
|
166 | + $Name = isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID; |
|
167 | + $Connections = isset($Settings["Connections"]) ? $Settings["Connections"] : NULL; |
|
168 | 168 | |
169 | 169 | $R = isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"]; |
170 | 170 | $G = isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"]; |
171 | 171 | $B = isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"]; |
172 | - $Alpha = isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"]; |
|
172 | + $Alpha = isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"]; |
|
173 | 173 | $BorderR = isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"]; |
174 | 174 | $BorderG = isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"]; |
175 | 175 | $BorderB = isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"]; |
@@ -178,29 +178,29 @@ discard block |
||
178 | 178 | $BackgroundR = isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"]; |
179 | 179 | $BackgroundG = isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"]; |
180 | 180 | $BackgroundB = isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"]; |
181 | - $BackgroundAlpha = isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"]; |
|
182 | - $Force = isset($Settings["Force"]) ? $Settings["Force"] : $this->Default["Force"]; |
|
181 | + $BackgroundAlpha = isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"]; |
|
182 | + $Force = isset($Settings["Force"]) ? $Settings["Force"] : $this->Default["Force"]; |
|
183 | 183 | $NodeType = isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"]; |
184 | - $Size = isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"]; |
|
184 | + $Size = isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"]; |
|
185 | 185 | $Shape = isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"]; |
186 | 186 | $FreeZone = isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"]; |
187 | 187 | |
188 | - if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; } |
|
188 | + if ($Surrounding != NULL) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; } |
|
189 | 189 | |
190 | 190 | $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha; |
191 | 191 | $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha; |
192 | - $this->Data[$NodeID]["BackgroundR"] = $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha; |
|
192 | + $this->Data[$NodeID]["BackgroundR"] = $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha; |
|
193 | 193 | $this->Data[$NodeID]["Name"] = $Name; |
194 | 194 | $this->Data[$NodeID]["Force"] = $Force; |
195 | 195 | $this->Data[$NodeID]["Type"] = $NodeType; |
196 | 196 | $this->Data[$NodeID]["Size"] = $Size; |
197 | 197 | $this->Data[$NodeID]["Shape"] = $Shape; |
198 | - $this->Data[$NodeID]["FreeZone"] = $FreeZone; |
|
199 | - if ( $Connections != NULL ) |
|
198 | + $this->Data[$NodeID]["FreeZone"] = $FreeZone; |
|
199 | + if ($Connections != NULL) |
|
200 | 200 | { |
201 | - if ( is_array($Connections ) ) |
|
201 | + if (is_array($Connections)) |
|
202 | 202 | { |
203 | - foreach($Connections as $Key => $Value) |
|
203 | + foreach ($Connections as $Key => $Value) |
|
204 | 204 | $this->Data[$NodeID]["Connections"][] = $Value; |
205 | 205 | } |
206 | 206 | else |
@@ -209,37 +209,37 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | /* Set color attribute for a list of nodes */ |
212 | - function setNodesColor($Nodes,$Settings="") |
|
212 | + function setNodesColor($Nodes, $Settings = "") |
|
213 | 213 | { |
214 | - if ( is_array($Nodes) ) |
|
214 | + if (is_array($Nodes)) |
|
215 | 215 | { |
216 | 216 | foreach ($Nodes as $Key => $NodeID) |
217 | 217 | { |
218 | - if (isset($this->Data[$NodeID]) ) |
|
218 | + if (isset($this->Data[$NodeID])) |
|
219 | 219 | { |
220 | - if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; } |
|
221 | - if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; } |
|
222 | - if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; } |
|
223 | - if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; } |
|
224 | - if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; } |
|
225 | - if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; } |
|
226 | - if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; } |
|
227 | - if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; } |
|
228 | - if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; } |
|
220 | + if (isset($Settings["R"])) { $this->Data[$NodeID]["R"] = $Settings["R"]; } |
|
221 | + if (isset($Settings["G"])) { $this->Data[$NodeID]["G"] = $Settings["G"]; } |
|
222 | + if (isset($Settings["B"])) { $this->Data[$NodeID]["B"] = $Settings["B"]; } |
|
223 | + if (isset($Settings["Alpha"])) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; } |
|
224 | + if (isset($Settings["BorderR"])) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; } |
|
225 | + if (isset($Settings["BorderG"])) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; } |
|
226 | + if (isset($Settings["BorderB"])) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; } |
|
227 | + if (isset($Settings["BorderAlpha"])) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; } |
|
228 | + if (isset($Settings["Surrounding"])) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; } |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | 232 | else |
233 | 233 | { |
234 | - if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; } |
|
235 | - if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; } |
|
236 | - if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; } |
|
237 | - if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; } |
|
238 | - if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; } |
|
239 | - if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; } |
|
240 | - if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; } |
|
241 | - if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; } |
|
242 | - if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; } |
|
234 | + if (isset($Settings["R"])) { $this->Data[$Nodes]["R"] = $Settings["R"]; } |
|
235 | + if (isset($Settings["G"])) { $this->Data[$Nodes]["G"] = $Settings["G"]; } |
|
236 | + if (isset($Settings["B"])) { $this->Data[$Nodes]["B"] = $Settings["B"]; } |
|
237 | + if (isset($Settings["Alpha"])) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; } |
|
238 | + if (isset($Settings["BorderR"])) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; } |
|
239 | + if (isset($Settings["BorderG"])) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; } |
|
240 | + if (isset($Settings["BorderB"])) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; } |
|
241 | + if (isset($Settings["BorderAlpha"])) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; } |
|
242 | + if (isset($Settings["Surrounding"])) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; } |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
@@ -250,22 +250,22 @@ discard block |
||
250 | 250 | /* Check if a connection exists and create it if required */ |
251 | 251 | function checkConnection($SourceID, $TargetID) |
252 | 252 | { |
253 | - if ( isset($this->Data[$SourceID]["Connections"]) ) |
|
253 | + if (isset($this->Data[$SourceID]["Connections"])) |
|
254 | 254 | { |
255 | 255 | foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID) |
256 | - { if ( $TargetID == $ConnectionID ) { return(TRUE); } } |
|
256 | + { if ($TargetID == $ConnectionID) { return(TRUE); } } |
|
257 | 257 | } |
258 | 258 | $this->Data[$SourceID]["Connections"][] = $TargetID; |
259 | 259 | } |
260 | 260 | /* Get the median linked nodes position */ |
261 | - function getMedianOffset($Key,$X,$Y) |
|
261 | + function getMedianOffset($Key, $X, $Y) |
|
262 | 262 | { |
263 | 263 | $Cpt = 1; |
264 | - if ( isset($this->Data[$Key]["Connections"]) ) |
|
264 | + if (isset($this->Data[$Key]["Connections"])) |
|
265 | 265 | { |
266 | - foreach($this->Data[$Key]["Connections"] as $ID => $NodeID) |
|
266 | + foreach ($this->Data[$Key]["Connections"] as $ID => $NodeID) |
|
267 | 267 | { |
268 | - if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) ) |
|
268 | + if (isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"])) |
|
269 | 269 | { |
270 | 270 | $X = $X + $this->Data[$NodeID]["X"]; |
271 | 271 | $Y = $Y + $this->Data[$NodeID]["Y"]; |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
276 | - return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt)); |
|
276 | + return(array("X"=>$X/$Cpt, "Y"=>$Y/$Cpt)); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /* Return the ID of the attached partner with the biggest weight */ |
280 | 280 | function getBiggestPartner($Key) |
281 | 281 | { |
282 | - if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); } |
|
282 | + if (!isset($this->Data[$Key]["Connections"])) { return(""); } |
|
283 | 283 | |
284 | 284 | $MaxWeight = 0; $Result = ""; |
285 | - foreach($this->Data[$Key]["Connections"] as $Key => $PeerID) |
|
285 | + foreach ($this->Data[$Key]["Connections"] as $Key => $PeerID) |
|
286 | 286 | { |
287 | - if ( $this->Data[$PeerID]["Weight"] > $MaxWeight ) |
|
287 | + if ($this->Data[$PeerID]["Weight"] > $MaxWeight) |
|
288 | 288 | { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; } |
289 | 289 | } |
290 | 290 | return($Result); |
@@ -293,94 +293,94 @@ discard block |
||
293 | 293 | /* Do the initial node positions computing pass */ |
294 | 294 | function firstPass($Algorithm) |
295 | 295 | { |
296 | - $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1; |
|
297 | - $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1; |
|
296 | + $CenterX = ($this->X2 - $this->X1)/2 + $this->X1; |
|
297 | + $CenterY = ($this->Y2 - $this->Y1)/2 + $this->Y1; |
|
298 | 298 | |
299 | 299 | /* Check connections reciprocity */ |
300 | - foreach($this->Data as $Key => $Settings) |
|
300 | + foreach ($this->Data as $Key => $Settings) |
|
301 | 301 | { |
302 | - if ( isset($Settings["Connections"]) ) |
|
302 | + if (isset($Settings["Connections"])) |
|
303 | 303 | { |
304 | - foreach($Settings["Connections"] as $ID => $ConnectionID) |
|
305 | - $this->checkConnection($ConnectionID,$Key); |
|
304 | + foreach ($Settings["Connections"] as $ID => $ConnectionID) |
|
305 | + $this->checkConnection($ConnectionID, $Key); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); } |
|
309 | + if ($this->AutoComputeFreeZone) { $this->autoFreeZone(); } |
|
310 | 310 | |
311 | 311 | /* Get the max number of connections */ |
312 | 312 | $MaxConnections = 0; |
313 | - foreach($this->Data as $Key => $Settings) |
|
314 | - { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } } |
|
313 | + foreach ($this->Data as $Key => $Settings) |
|
314 | + { if (isset($Settings["Connections"])) { if ($MaxConnections < count($Settings["Connections"])) { $MaxConnections = count($Settings["Connections"]); } } } |
|
315 | 315 | |
316 | - if ( $Algorithm == ALGORITHM_WEIGHTED ) |
|
316 | + if ($Algorithm == ALGORITHM_WEIGHTED) |
|
317 | 317 | { |
318 | - foreach($this->Data as $Key => $Settings) |
|
318 | + foreach ($this->Data as $Key => $Settings) |
|
319 | 319 | { |
320 | - if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
321 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
320 | + if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
321 | + if ($Settings["Type"] == NODE_TYPE_FREE) |
|
322 | 322 | { |
323 | - if ( isset($Settings["Connections"]) ) |
|
323 | + if (isset($Settings["Connections"])) |
|
324 | 324 | { $Connections = count($Settings["Connections"]); } |
325 | 325 | else |
326 | 326 | { $Connections = 0; } |
327 | 327 | |
328 | 328 | $Ring = $MaxConnections - $Connections; |
329 | - $Angle = rand(0,360); |
|
329 | + $Angle = rand(0, 360); |
|
330 | 330 | |
331 | - $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX; |
|
332 | - $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY; |
|
331 | + $this->Data[$Key]["X"] = cos(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterX; |
|
332 | + $this->Data[$Key]["Y"] = sin(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterY; |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | } |
336 | - elseif ( $Algorithm == ALGORITHM_CENTRAL ) |
|
336 | + elseif ($Algorithm == ALGORITHM_CENTRAL) |
|
337 | 337 | { |
338 | 338 | /* Put a weight on each nodes */ |
339 | - foreach($this->Data as $Key => $Settings) |
|
339 | + foreach ($this->Data as $Key => $Settings) |
|
340 | 340 | { |
341 | - if ( isset($Settings["Connections"]) ) |
|
341 | + if (isset($Settings["Connections"])) |
|
342 | 342 | $this->Data[$Key]["Weight"] = count($Settings["Connections"]); |
343 | 343 | else |
344 | 344 | $this->Data[$Key]["Weight"] = 0; |
345 | 345 | } |
346 | 346 | |
347 | 347 | $MaxConnections = $MaxConnections + 1; |
348 | - for($i=$MaxConnections;$i>=0;$i--) |
|
348 | + for ($i = $MaxConnections; $i >= 0; $i--) |
|
349 | 349 | { |
350 | - foreach($this->Data as $Key => $Settings) |
|
350 | + foreach ($this->Data as $Key => $Settings) |
|
351 | 351 | { |
352 | - if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
353 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
352 | + if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
353 | + if ($Settings["Type"] == NODE_TYPE_FREE) |
|
354 | 354 | { |
355 | - if ( isset($Settings["Connections"]) ) |
|
355 | + if (isset($Settings["Connections"])) |
|
356 | 356 | { $Connections = count($Settings["Connections"]); } |
357 | 357 | else |
358 | 358 | { $Connections = 0; } |
359 | 359 | |
360 | - if ( $Connections == $i ) |
|
360 | + if ($Connections == $i) |
|
361 | 361 | { |
362 | 362 | $BiggestPartner = $this->getBiggestPartner($Key); |
363 | - if ( $BiggestPartner != "" ) |
|
363 | + if ($BiggestPartner != "") |
|
364 | 364 | { |
365 | 365 | $Ring = $this->Data[$BiggestPartner]["FreeZone"]; |
366 | 366 | $Weight = $this->Data[$BiggestPartner]["Weight"]; |
367 | - $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"]; |
|
367 | + $AngleDivision = 360/$this->Data[$BiggestPartner]["Weight"]; |
|
368 | 368 | $Done = FALSE; $Tries = 0; |
369 | 369 | while (!$Done && $Tries <= $Weight*2) |
370 | 370 | { |
371 | 371 | $Tries++; |
372 | - $Angle = floor(rand(0,$Weight)*$AngleDivision); |
|
373 | - if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) ) |
|
372 | + $Angle = floor(rand(0, $Weight)*$AngleDivision); |
|
373 | + if (!isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"])) |
|
374 | 374 | { |
375 | 375 | $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; |
376 | 376 | $Done = TRUE; |
377 | 377 | } |
378 | 378 | } |
379 | - if ( !$Done ) |
|
380 | - { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; } |
|
379 | + if (!$Done) |
|
380 | + { $Angle = rand(0, 360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; } |
|
381 | 381 | |
382 | - $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"]; |
|
383 | - $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"]; |
|
382 | + $X = cos(deg2rad($Angle))*($Ring) + $this->Data[$BiggestPartner]["X"]; |
|
383 | + $Y = sin(deg2rad($Angle))*($Ring) + $this->Data[$BiggestPartner]["Y"]; |
|
384 | 384 | |
385 | 385 | $this->Data[$Key]["X"] = $X; |
386 | 386 | $this->Data[$Key]["Y"] = $Y; |
@@ -390,30 +390,30 @@ discard block |
||
390 | 390 | } |
391 | 391 | } |
392 | 392 | } |
393 | - elseif ( $Algorithm == ALGORITHM_CIRCULAR ) |
|
393 | + elseif ($Algorithm == ALGORITHM_CIRCULAR) |
|
394 | 394 | { |
395 | 395 | $MaxConnections = $MaxConnections + 1; |
396 | - for($i=$MaxConnections;$i>=0;$i--) |
|
396 | + for ($i = $MaxConnections; $i >= 0; $i--) |
|
397 | 397 | { |
398 | - foreach($this->Data as $Key => $Settings) |
|
398 | + foreach ($this->Data as $Key => $Settings) |
|
399 | 399 | { |
400 | - if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
401 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
400 | + if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
401 | + if ($Settings["Type"] == NODE_TYPE_FREE) |
|
402 | 402 | { |
403 | - if ( isset($Settings["Connections"]) ) |
|
403 | + if (isset($Settings["Connections"])) |
|
404 | 404 | { $Connections = count($Settings["Connections"]); } |
405 | 405 | else |
406 | 406 | { $Connections = 0; } |
407 | 407 | |
408 | - if ( $Connections == $i ) |
|
408 | + if ($Connections == $i) |
|
409 | 409 | { |
410 | 410 | $Ring = $MaxConnections - $Connections; |
411 | - $Angle = rand(0,360); |
|
411 | + $Angle = rand(0, 360); |
|
412 | 412 | |
413 | - $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX; |
|
414 | - $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY; |
|
413 | + $X = cos(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterX; |
|
414 | + $Y = sin(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterY; |
|
415 | 415 | |
416 | - $MedianOffset = $this->getMedianOffset($Key,$X,$Y); |
|
416 | + $MedianOffset = $this->getMedianOffset($Key, $X, $Y); |
|
417 | 417 | |
418 | 418 | $this->Data[$Key]["X"] = $MedianOffset["X"]; |
419 | 419 | $this->Data[$Key]["Y"] = $MedianOffset["Y"]; |
@@ -422,16 +422,16 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | } |
425 | - elseif ( $Algorithm == ALGORITHM_RANDOM ) |
|
425 | + elseif ($Algorithm == ALGORITHM_RANDOM) |
|
426 | 426 | { |
427 | - foreach($this->Data as $Key => $Settings) |
|
427 | + foreach ($this->Data as $Key => $Settings) |
|
428 | 428 | { |
429 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
429 | + if ($Settings["Type"] == NODE_TYPE_FREE) |
|
430 | 430 | { |
431 | - $this->Data[$Key]["X"] = $CenterX + rand(-20,20); |
|
432 | - $this->Data[$Key]["Y"] = $CenterY + rand(-20,20); |
|
431 | + $this->Data[$Key]["X"] = $CenterX + rand(-20, 20); |
|
432 | + $this->Data[$Key]["Y"] = $CenterY + rand(-20, 20); |
|
433 | 433 | } |
434 | - if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
434 | + if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | } |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | function doPass() |
441 | 441 | { |
442 | 442 | /* Compute vectors */ |
443 | - foreach($this->Data as $Key => $Settings) |
|
443 | + foreach ($this->Data as $Key => $Settings) |
|
444 | 444 | { |
445 | - if ( $Settings["Type"] != NODE_TYPE_CENTRAL ) |
|
445 | + if ($Settings["Type"] != NODE_TYPE_CENTRAL) |
|
446 | 446 | { |
447 | 447 | unset($this->Data[$Key]["Vectors"]); |
448 | 448 | |
@@ -450,48 +450,48 @@ discard block |
||
450 | 450 | $Y1 = $Settings["Y"]; |
451 | 451 | |
452 | 452 | /* Repulsion vectors */ |
453 | - foreach($this->Data as $Key2 => $Settings2) |
|
453 | + foreach ($this->Data as $Key2 => $Settings2) |
|
454 | 454 | { |
455 | - if ( $Key != $Key2 ) |
|
455 | + if ($Key != $Key2) |
|
456 | 456 | { |
457 | 457 | $X2 = $this->Data[$Key2]["X"]; |
458 | 458 | $Y2 = $this->Data[$Key2]["Y"]; |
459 | 459 | $FreeZone = $this->Data[$Key2]["FreeZone"]; |
460 | 460 | |
461 | - $Distance = $this->getDistance($X1,$Y1,$X2,$Y2); |
|
462 | - $Angle = $this->getAngle($X1,$Y1,$X2,$Y2) + 180; |
|
461 | + $Distance = $this->getDistance($X1, $Y1, $X2, $Y2); |
|
462 | + $Angle = $this->getAngle($X1, $Y1, $X2, $Y2) + 180; |
|
463 | 463 | |
464 | 464 | /* Nodes too close, repulsion occurs */ |
465 | - if ( $Distance < $FreeZone ) |
|
465 | + if ($Distance < $FreeZone) |
|
466 | 466 | { |
467 | - $Force = log(pow(2,$FreeZone-$Distance)); |
|
468 | - if ( $Force > 1 ) |
|
469 | - { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); } |
|
467 | + $Force = log(pow(2, $FreeZone - $Distance)); |
|
468 | + if ($Force > 1) |
|
469 | + { $this->Data[$Key]["Vectors"][] = array("Type"=>"R", "Angle"=>$Angle%360, "Force"=>$Force); } |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
474 | 474 | /* Attraction vectors */ |
475 | - if ( isset($Settings["Connections"]) ) |
|
475 | + if (isset($Settings["Connections"])) |
|
476 | 476 | { |
477 | - foreach($Settings["Connections"] as $ID => $NodeID) |
|
477 | + foreach ($Settings["Connections"] as $ID => $NodeID) |
|
478 | 478 | { |
479 | - if ( isset($this->Data[$NodeID]) ) |
|
479 | + if (isset($this->Data[$NodeID])) |
|
480 | 480 | { |
481 | 481 | $X2 = $this->Data[$NodeID]["X"]; |
482 | 482 | $Y2 = $this->Data[$NodeID]["Y"]; |
483 | 483 | $FreeZone = $this->Data[$Key2]["FreeZone"]; |
484 | 484 | |
485 | - $Distance = $this->getDistance($X1,$Y1,$X2,$Y2); |
|
486 | - $Angle = $this->getAngle($X1,$Y1,$X2,$Y2); |
|
485 | + $Distance = $this->getDistance($X1, $Y1, $X2, $Y2); |
|
486 | + $Angle = $this->getAngle($X1, $Y1, $X2, $Y2); |
|
487 | 487 | |
488 | - if ( $Distance > $FreeZone ) |
|
489 | - $Force = log(($Distance-$FreeZone)+1); |
|
488 | + if ($Distance > $FreeZone) |
|
489 | + $Force = log(($Distance - $FreeZone) + 1); |
|
490 | 490 | else |
491 | - { $Force = log(($FreeZone-$Distance)+1); ($Angle = $Angle + 180); } |
|
491 | + { $Force = log(($FreeZone - $Distance) + 1); ($Angle = $Angle + 180); } |
|
492 | 492 | |
493 | - if ( $Force > 1 ) |
|
494 | - $this->Data[$Key]["Vectors"][] = array("Type"=>"A","Angle"=>$Angle % 360,"Force"=>$Force); |
|
493 | + if ($Force > 1) |
|
494 | + $this->Data[$Key]["Vectors"][] = array("Type"=>"A", "Angle"=>$Angle%360, "Force"=>$Force); |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
@@ -499,22 +499,22 @@ discard block |
||
499 | 499 | } |
500 | 500 | |
501 | 501 | /* Move the nodes accoding to the vectors */ |
502 | - foreach($this->Data as $Key => $Settings) |
|
502 | + foreach ($this->Data as $Key => $Settings) |
|
503 | 503 | { |
504 | 504 | $X = $Settings["X"]; |
505 | 505 | $Y = $Settings["Y"]; |
506 | 506 | |
507 | - if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) |
|
507 | + if (isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL) |
|
508 | 508 | { |
509 | - foreach($Settings["Vectors"] as $ID => $Vector) |
|
509 | + foreach ($Settings["Vectors"] as $ID => $Vector) |
|
510 | 510 | { |
511 | 511 | $Type = $Vector["Type"]; |
512 | 512 | $Force = $Vector["Force"]; |
513 | 513 | $Angle = $Vector["Angle"]; |
514 | 514 | $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR; |
515 | 515 | |
516 | - $X = cos(deg2rad($Angle)) * $Force * $Factor + $X; |
|
517 | - $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y; |
|
516 | + $X = cos(deg2rad($Angle))*$Force*$Factor + $X; |
|
517 | + $Y = sin(deg2rad($Angle))*$Force*$Factor + $Y; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -526,15 +526,15 @@ discard block |
||
526 | 526 | function lastPass() |
527 | 527 | { |
528 | 528 | /* Put everything inside the graph area */ |
529 | - foreach($this->Data as $Key => $Settings) |
|
529 | + foreach ($this->Data as $Key => $Settings) |
|
530 | 530 | { |
531 | 531 | $X = $Settings["X"]; |
532 | 532 | $Y = $Settings["Y"]; |
533 | 533 | |
534 | - if ( $X < $this->X1 ) { $X = $this->X1; } |
|
535 | - if ( $X > $this->X2 ) { $X = $this->X2; } |
|
536 | - if ( $Y < $this->Y1 ) { $Y = $this->Y1; } |
|
537 | - if ( $Y > $this->Y2 ) { $Y = $this->Y2; } |
|
534 | + if ($X < $this->X1) { $X = $this->X1; } |
|
535 | + if ($X > $this->X2) { $X = $this->X2; } |
|
536 | + if ($Y < $this->Y1) { $Y = $this->Y1; } |
|
537 | + if ($Y > $this->Y2) { $Y = $this->Y2; } |
|
538 | 538 | |
539 | 539 | $this->Data[$Key]["X"] = $X; |
540 | 540 | $this->Data[$Key]["Y"] = $Y; |
@@ -542,21 +542,21 @@ discard block |
||
542 | 542 | |
543 | 543 | /* Dump all links */ |
544 | 544 | $Links = ""; |
545 | - foreach($this->Data as $Key => $Settings) |
|
545 | + foreach ($this->Data as $Key => $Settings) |
|
546 | 546 | { |
547 | 547 | $X1 = $Settings["X"]; |
548 | 548 | $Y1 = $Settings["Y"]; |
549 | 549 | |
550 | - if ( isset($Settings["Connections"]) ) |
|
550 | + if (isset($Settings["Connections"])) |
|
551 | 551 | { |
552 | 552 | foreach ($Settings["Connections"] as $ID => $NodeID) |
553 | 553 | { |
554 | - if ( isset($this->Data[$NodeID]) ) |
|
554 | + if (isset($this->Data[$NodeID])) |
|
555 | 555 | { |
556 | 556 | $X2 = $this->Data[$NodeID]["X"]; |
557 | 557 | $Y2 = $this->Data[$NodeID]["Y"]; |
558 | 558 | |
559 | - $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]); |
|
559 | + $Links[] = array("X1"=>$X1, "Y1"=>$Y1, "X2"=>$X2, "Y2"=>$Y2, "Source"=>$Settings["Name"], "Destination"=>$this->Data[$NodeID]["Name"]); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | } |
@@ -564,29 +564,29 @@ discard block |
||
564 | 564 | |
565 | 565 | /* Check collisions */ |
566 | 566 | $Conflicts = 0; |
567 | - foreach($this->Data as $Key => $Settings) |
|
567 | + foreach ($this->Data as $Key => $Settings) |
|
568 | 568 | { |
569 | 569 | $X1 = $Settings["X"]; |
570 | 570 | $Y1 = $Settings["Y"]; |
571 | 571 | |
572 | - if ( isset($Settings["Connections"]) ) |
|
572 | + if (isset($Settings["Connections"])) |
|
573 | 573 | { |
574 | 574 | foreach ($Settings["Connections"] as $ID => $NodeID) |
575 | 575 | { |
576 | - if ( isset($this->Data[$NodeID]) ) |
|
576 | + if (isset($this->Data[$NodeID])) |
|
577 | 577 | { |
578 | 578 | $X2 = $this->Data[$NodeID]["X"]; |
579 | 579 | $Y2 = $this->Data[$NodeID]["Y"]; |
580 | 580 | |
581 | - foreach($Links as $IDLinks => $Link) |
|
581 | + foreach ($Links as $IDLinks => $Link) |
|
582 | 582 | { |
583 | 583 | $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"]; |
584 | 584 | |
585 | - if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) ) |
|
585 | + if (!($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4)) |
|
586 | 586 | { |
587 | - if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) ) |
|
587 | + if ($this->intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4)) |
|
588 | 588 | { |
589 | - if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] ) |
|
589 | + if ($Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"]) |
|
590 | 590 | { $Conflicts++; } |
591 | 591 | } |
592 | 592 | } |
@@ -602,31 +602,31 @@ discard block |
||
602 | 602 | function center() |
603 | 603 | { |
604 | 604 | /* Determine the real center */ |
605 | - $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1; |
|
606 | - $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1; |
|
605 | + $TargetCenterX = ($this->X2 - $this->X1)/2 + $this->X1; |
|
606 | + $TargetCenterY = ($this->Y2 - $this->Y1)/2 + $this->Y1; |
|
607 | 607 | |
608 | 608 | /* Get current boundaries */ |
609 | 609 | $XMin = $this->X2; $XMax = $this->X1; |
610 | 610 | $YMin = $this->Y2; $YMax = $this->Y1; |
611 | - foreach($this->Data as $Key => $Settings) |
|
611 | + foreach ($this->Data as $Key => $Settings) |
|
612 | 612 | { |
613 | 613 | $X = $Settings["X"]; |
614 | 614 | $Y = $Settings["Y"]; |
615 | 615 | |
616 | - if ( $X < $XMin) { $XMin = $X; } |
|
617 | - if ( $X > $XMax) { $XMax = $X; } |
|
618 | - if ( $Y < $YMin) { $YMin = $Y; } |
|
619 | - if ( $Y > $YMax) { $YMax = $Y; } |
|
616 | + if ($X < $XMin) { $XMin = $X; } |
|
617 | + if ($X > $XMax) { $XMax = $X; } |
|
618 | + if ($Y < $YMin) { $YMin = $Y; } |
|
619 | + if ($Y > $YMax) { $YMax = $Y; } |
|
620 | 620 | } |
621 | - $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin; |
|
622 | - $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin; |
|
621 | + $CurrentCenterX = ($XMax - $XMin)/2 + $XMin; |
|
622 | + $CurrentCenterY = ($YMax - $YMin)/2 + $YMin; |
|
623 | 623 | |
624 | 624 | /* Compute the offset to apply */ |
625 | 625 | $XOffset = $TargetCenterX - $CurrentCenterX; |
626 | 626 | $YOffset = $TargetCenterY - $CurrentCenterY; |
627 | 627 | |
628 | 628 | /* Correct the points position */ |
629 | - foreach($this->Data as $Key => $Settings) |
|
629 | + foreach ($this->Data as $Key => $Settings) |
|
630 | 630 | { |
631 | 631 | $this->Data[$Key]["X"] = $Settings["X"] + $XOffset; |
632 | 632 | $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset; |
@@ -634,20 +634,20 @@ discard block |
||
634 | 634 | } |
635 | 635 | |
636 | 636 | /* Create the encoded string */ |
637 | - function drawSpring($Object,$Settings="") |
|
637 | + function drawSpring($Object, $Settings = "") |
|
638 | 638 | { |
639 | 639 | $this->pChartObject = $Object; |
640 | 640 | |
641 | - $Pass = isset($Settings["Pass"]) ? $Settings["Pass"] : 50; |
|
642 | - $Retries = isset($Settings["Retry"]) ? $Settings["Retry"] : 10; |
|
641 | + $Pass = isset($Settings["Pass"]) ? $Settings["Pass"] : 50; |
|
642 | + $Retries = isset($Settings["Retry"]) ? $Settings["Retry"] : 10; |
|
643 | 643 | $this->MagneticForceA = isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5; |
644 | 644 | $this->MagneticForceR = isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2; |
645 | - $this->RingSize = isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40; |
|
645 | + $this->RingSize = isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40; |
|
646 | 646 | $DrawVectors = isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE; |
647 | - $DrawQuietZone = isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE; |
|
647 | + $DrawQuietZone = isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE; |
|
648 | 648 | $CenterGraph = isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE; |
649 | 649 | $TextPadding = isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4; |
650 | - $Algorithm = isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED; |
|
650 | + $Algorithm = isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED; |
|
651 | 651 | |
652 | 652 | $FontSize = $Object->FontSize; |
653 | 653 | $this->X1 = $Object->GraphAreaX1; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | $this->Y2 = $Object->GraphAreaY2; |
657 | 657 | |
658 | 658 | $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1; |
659 | - while ($Conflicts != 0 && $Jobs < $Retries ) |
|
659 | + while ($Conflicts != 0 && $Jobs < $Retries) |
|
660 | 660 | { |
661 | 661 | $Jobs++; |
662 | 662 | |
@@ -664,70 +664,70 @@ discard block |
||
664 | 664 | $this->firstPass($Algorithm); |
665 | 665 | |
666 | 666 | /* Apply the vectors */ |
667 | - if ( $Pass > 0 ) |
|
667 | + if ($Pass > 0) |
|
668 | 668 | { |
669 | - for ($i=0; $i<=$Pass; $i++) { $this->doPass(); } |
|
669 | + for ($i = 0; $i <= $Pass; $i++) { $this->doPass(); } |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | $Conflicts = $this->lastPass(); |
673 | - if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] ) |
|
673 | + if ($this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"]) |
|
674 | 674 | { $this->History["MinimumConflicts"] = $Conflicts; $this->History["Result"] = $this->Data; } |
675 | 675 | } |
676 | 676 | |
677 | 677 | $Conflicts = $this->History["MinimumConflicts"]; |
678 | 678 | $this->Data = $this->History["Result"]; |
679 | 679 | |
680 | - if ( $CenterGraph ) { $this->center(); } |
|
680 | + if ($CenterGraph) { $this->center(); } |
|
681 | 681 | |
682 | 682 | /* Draw the connections */ |
683 | 683 | $Drawn = ""; |
684 | - foreach($this->Data as $Key => $Settings) |
|
684 | + foreach ($this->Data as $Key => $Settings) |
|
685 | 685 | { |
686 | 686 | $X = $Settings["X"]; |
687 | 687 | $Y = $Settings["Y"]; |
688 | 688 | |
689 | - if ( isset($Settings["Connections"]) ) |
|
689 | + if (isset($Settings["Connections"])) |
|
690 | 690 | { |
691 | 691 | foreach ($Settings["Connections"] as $ID => $NodeID) |
692 | 692 | { |
693 | - if ( !isset($Drawn[$Key]) ) { $Drawn[$Key] = ""; } |
|
694 | - if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; } |
|
693 | + if (!isset($Drawn[$Key])) { $Drawn[$Key] = ""; } |
|
694 | + if (!isset($Drawn[$NodeID])) { $Drawn[$NodeID] = ""; } |
|
695 | 695 | |
696 | - if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) ) |
|
696 | + if (isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key])) |
|
697 | 697 | { |
698 | - $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]); |
|
698 | + $Color = array("R"=>$this->Default["LinkR"], "G"=>$this->Default["LinkG"], "B"=>$this->Default["LinkB"], "Alpha"=>$this->Default["Alpha"]); |
|
699 | 699 | |
700 | - if ( $this->Links != "" ) |
|
700 | + if ($this->Links != "") |
|
701 | 701 | { |
702 | - if ( isset($this->Links[$Key][$NodeID]["R"]) ) |
|
703 | - { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); } |
|
702 | + if (isset($this->Links[$Key][$NodeID]["R"])) |
|
703 | + { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"], "G"=>$this->Links[$Key][$NodeID]["G"], "B"=>$this->Links[$Key][$NodeID]["B"], "Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); } |
|
704 | 704 | |
705 | - if ( isset($this->Links[$Key][$NodeID]["Ticks"]) ) |
|
705 | + if (isset($this->Links[$Key][$NodeID]["Ticks"])) |
|
706 | 706 | { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; } |
707 | 707 | } |
708 | 708 | |
709 | 709 | $X2 = $this->Data[$NodeID]["X"]; |
710 | 710 | $Y2 = $this->Data[$NodeID]["Y"]; |
711 | - $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color); |
|
711 | + $this->pChartObject->drawLine($X, $Y, $X2, $Y2, $Color); |
|
712 | 712 | $Drawn[$Key][$NodeID] = TRUE; |
713 | 713 | |
714 | - if ( isset($this->Links) && $this->Links != "" ) |
|
714 | + if (isset($this->Links) && $this->Links != "") |
|
715 | 715 | { |
716 | - if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) ) |
|
716 | + if (isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"])) |
|
717 | 717 | { |
718 | 718 | $Name = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"]; |
719 | 719 | $TxtX = ($X2 - $X)/2 + $X; |
720 | 720 | $TxtY = ($Y2 - $Y)/2 + $Y; |
721 | 721 | |
722 | - if ( $X <= $X2 ) |
|
723 | - $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360; |
|
722 | + if ($X <= $X2) |
|
723 | + $Angle = (360 - $this->getAngle($X, $Y, $X2, $Y2))%360; |
|
724 | 724 | else |
725 | - $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360; |
|
725 | + $Angle = (360 - $this->getAngle($X2, $Y2, $X, $Y))%360; |
|
726 | 726 | |
727 | 727 | $Settings = $Color; |
728 | 728 | $Settings["Angle"] = $Angle; |
729 | 729 | $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; |
730 | - $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings); |
|
730 | + $this->pChartObject->drawText($TxtX, $TxtY, $Name, $Settings); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | } |
@@ -736,59 +736,59 @@ discard block |
||
736 | 736 | } |
737 | 737 | |
738 | 738 | /* Draw the quiet zones */ |
739 | - if ( $DrawQuietZone ) |
|
739 | + if ($DrawQuietZone) |
|
740 | 740 | { |
741 | - foreach($this->Data as $Key => $Settings) |
|
741 | + foreach ($this->Data as $Key => $Settings) |
|
742 | 742 | { |
743 | 743 | $X = $Settings["X"]; |
744 | 744 | $Y = $Settings["Y"]; |
745 | 745 | $FreeZone = $Settings["FreeZone"]; |
746 | 746 | |
747 | - $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2)); |
|
747 | + $this->pChartObject->drawFilledCircle($X, $Y, $FreeZone, array("R"=>0, "G"=>0, "B"=>0, "Alpha"=>2)); |
|
748 | 748 | } |
749 | 749 | } |
750 | 750 | |
751 | 751 | |
752 | 752 | /* Draw the nodes */ |
753 | - foreach($this->Data as $Key => $Settings) |
|
753 | + foreach ($this->Data as $Key => $Settings) |
|
754 | 754 | { |
755 | 755 | $X = $Settings["X"]; |
756 | 756 | $Y = $Settings["Y"]; |
757 | - $Name = $Settings["Name"]; |
|
757 | + $Name = $Settings["Name"]; |
|
758 | 758 | $FreeZone = $Settings["FreeZone"]; |
759 | 759 | $Shape = $Settings["Shape"]; |
760 | 760 | $Size = $Settings["Size"]; |
761 | 761 | |
762 | - $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]); |
|
762 | + $Color = array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"], "Alpha"=>$Settings["Alpha"], "BorderR"=>$Settings["BorderR"], "BorderG"=>$Settings["BorderG"], "BorderB"=>$Settings["BorderB"], "BorderApha"=>$Settings["BorderAlpha"]); |
|
763 | 763 | |
764 | - if ( $Shape == NODE_SHAPE_CIRCLE ) |
|
764 | + if ($Shape == NODE_SHAPE_CIRCLE) |
|
765 | 765 | { |
766 | - $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color); |
|
766 | + $this->pChartObject->drawFilledCircle($X, $Y, $Size, $Color); |
|
767 | 767 | } |
768 | - elseif ( $Shape == NODE_SHAPE_TRIANGLE ) |
|
768 | + elseif ($Shape == NODE_SHAPE_TRIANGLE) |
|
769 | 769 | { |
770 | 770 | $Points = ""; |
771 | - $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y; |
|
772 | - $Points[] = cos(deg2rad(45)) * $Size + $X; $Points[] = sin(deg2rad(45)) * $Size + $Y; |
|
773 | - $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y; |
|
774 | - $this->pChartObject->drawPolygon($Points,$Color); |
|
771 | + $Points[] = cos(deg2rad(270))*$Size + $X; $Points[] = sin(deg2rad(270))*$Size + $Y; |
|
772 | + $Points[] = cos(deg2rad(45))*$Size + $X; $Points[] = sin(deg2rad(45))*$Size + $Y; |
|
773 | + $Points[] = cos(deg2rad(135))*$Size + $X; $Points[] = sin(deg2rad(135))*$Size + $Y; |
|
774 | + $this->pChartObject->drawPolygon($Points, $Color); |
|
775 | 775 | } |
776 | - elseif ( $Shape == NODE_SHAPE_SQUARE ) |
|
776 | + elseif ($Shape == NODE_SHAPE_SQUARE) |
|
777 | 777 | { |
778 | - $Offset = $Size/2; $Size = $Size / 2; |
|
779 | - $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color); |
|
778 | + $Offset = $Size/2; $Size = $Size/2; |
|
779 | + $this->pChartObject->drawFilledRectangle($X - $Offset, $Y - $Offset, $X + $Offset, $Y + $Offset, $Color); |
|
780 | 780 | } |
781 | 781 | |
782 | - if ( $Name != "" ) |
|
782 | + if ($Name != "") |
|
783 | 783 | { |
784 | - $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]); |
|
784 | + $LabelOptions = array("R"=>$this->Labels["R"], "G"=>$this->Labels["G"], "B"=>$this->Labels["B"], "Alpha"=>$this->Labels["Alpha"]); |
|
785 | 785 | |
786 | - if ( $this->Labels["Type"] == LABEL_LIGHT ) |
|
786 | + if ($this->Labels["Type"] == LABEL_LIGHT) |
|
787 | 787 | { |
788 | 788 | $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT; |
789 | - $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions); |
|
789 | + $this->pChartObject->drawText($X, $Y, $Name, $LabelOptions); |
|
790 | 790 | } |
791 | - elseif ( $this->Labels["Type"] == LABEL_CLASSIC ) |
|
791 | + elseif ($this->Labels["Type"] == LABEL_CLASSIC) |
|
792 | 792 | { |
793 | 793 | $LabelOptions["Align"] = TEXT_ALIGN_TOPMIDDLE; |
794 | 794 | $LabelOptions["DrawBox"] = TRUE; |
@@ -798,67 +798,67 @@ discard block |
||
798 | 798 | $LabelOptions["BoxRounded"] = TRUE; |
799 | 799 | $LabelOptions["NoShadow"] = TRUE; |
800 | 800 | |
801 | - $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions); |
|
801 | + $this->pChartObject->drawText($X, $Y + $Size + $TextPadding, $Name, $LabelOptions); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
806 | 806 | /* Draw the vectors */ |
807 | - if ( $DrawVectors ) |
|
807 | + if ($DrawVectors) |
|
808 | 808 | { |
809 | - foreach($this->Data as $Key => $Settings) |
|
809 | + foreach ($this->Data as $Key => $Settings) |
|
810 | 810 | { |
811 | 811 | $X1 = $Settings["X"]; |
812 | 812 | $Y1 = $Settings["Y"]; |
813 | 813 | |
814 | - if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) |
|
814 | + if (isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL) |
|
815 | 815 | { |
816 | - foreach($Settings["Vectors"] as $ID => $Vector) |
|
816 | + foreach ($Settings["Vectors"] as $ID => $Vector) |
|
817 | 817 | { |
818 | 818 | $Type = $Vector["Type"]; |
819 | 819 | $Force = $Vector["Force"]; |
820 | 820 | $Angle = $Vector["Angle"]; |
821 | 821 | $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR; |
822 | - $Color = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0); |
|
822 | + $Color = $Type == "A" ? array("FillR"=>255, "FillG"=>0, "FillB"=>0) : array("FillR"=>0, "FillG"=>255, "FillB"=>0); |
|
823 | 823 | |
824 | - $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1; |
|
825 | - $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1; |
|
824 | + $X2 = cos(deg2rad($Angle))*$Force*$Factor + $X1; |
|
825 | + $Y2 = sin(deg2rad($Angle))*$Force*$Factor + $Y1; |
|
826 | 826 | |
827 | - $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color); |
|
827 | + $this->pChartObject->drawArrow($X1, $Y1, $X2, $Y2, $Color); |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | - return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts)); |
|
833 | + return(array("Pass"=>$Jobs, "Conflicts"=>$Conflicts)); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /* Return the distance between two points */ |
837 | - function getDistance($X1,$Y1,$X2,$Y2) |
|
838 | - { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); } |
|
837 | + function getDistance($X1, $Y1, $X2, $Y2) |
|
838 | + { return (sqrt(($X2 - $X1)*($X2 - $X1) + ($Y2 - $Y1)*($Y2 - $Y1))); } |
|
839 | 839 | |
840 | 840 | /* Return the angle made by a line and the X axis */ |
841 | - function getAngle($X1,$Y1,$X2,$Y2) |
|
841 | + function getAngle($X1, $Y1, $X2, $Y2) |
|
842 | 842 | { |
843 | - $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent)); |
|
844 | - if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); } |
|
843 | + $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1; $Angle = rad2deg(atan2($Opposite, $Adjacent)); |
|
844 | + if ($Angle > 0) { return($Angle); } else { return(360 - abs($Angle)); } |
|
845 | 845 | } |
846 | 846 | |
847 | - function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) |
|
847 | + function intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4) |
|
848 | 848 | { |
849 | - $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4)); |
|
850 | - $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2)); |
|
849 | + $A = (($X3*$Y4 - $X4*$Y3)*($X1 - $X2) - ($X1*$Y2 - $X2*$Y1)*($X3 - $X4)); |
|
850 | + $B = (($Y1 - $Y2)*($X3 - $X4) - ($Y3 - $Y4)*($X1 - $X2)); |
|
851 | 851 | |
852 | - if ( $B == 0 ) { return(FALSE); } |
|
853 | - $Xi = $A / $B; |
|
852 | + if ($B == 0) { return(FALSE); } |
|
853 | + $Xi = $A/$B; |
|
854 | 854 | |
855 | 855 | $C = ($X1 - $X2); |
856 | - if ( $C == 0 ) { return(FALSE); } |
|
857 | - $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C); |
|
856 | + if ($C == 0) { return(FALSE); } |
|
857 | + $Yi = $Xi*(($Y1 - $Y2)/$C) + (($X1*$Y2 - $X2*$Y1)/$C); |
|
858 | 858 | |
859 | - if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4)) |
|
859 | + if ($Xi >= min($X1, $X2) && $Xi >= min($X3, $X4) && $Xi <= max($X1, $X2) && $Xi <= max($X3, $X4)) |
|
860 | 860 | { |
861 | - if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4)) |
|
861 | + if ($Yi >= min($Y1, $Y2) && $Yi >= min($Y3, $Y4) && $Yi <= max($Y1, $Y2) && $Yi <= max($Y3, $Y4)) |
|
862 | 862 | { return(TRUE); } |
863 | 863 | } |
864 | 864 |