optimize declined payment event condition, RT#81305
[freeside.git] / min_selfservice / elements / menu.php
1 <?
2
3 require_once('session.php');
4
5 $skin_info = $freeside->skin_info( array(
6   'session_id' => $_COOKIE['session_id'],
7 ) );
8
9 extract($skin_info);
10
11 ?>
12 <style type="text/css">
13 #menu_ul ul li {
14   display: inline;
15   width: 100%;
16
17 </style>
18
19 <ul id="menu_ul">
20
21 <?
22
23   $menu_array = array(
24     'payment.php Payments', 
25     'payment_cc.php Credit Card Payment',
26     'payment_ach.php Electronic check payment',
27     'payment_paypal.php PayPal payment',
28     'payment_webpay.php Webpay payment',
29   );
30   $submenu = array(); 
31
32   foreach ($menu_array AS $menu_item) {
33     if ( preg_match('/^\s*$/', $menu_item) ) {
34       print_menu($submenu, $current_menu, $menu_disable);
35       $submenu = array();
36     } else {
37       $submenu[] = $menu_item;
38     }
39   }
40   print_menu($submenu, $current_menu, $menu_disable);
41
42   function print_menu($submenu_array, $current_menu, $menu_disable) {
43     if ( count($submenu_array) == 0 ) { return; }
44
45     $links = array();
46     $labels = array();
47     foreach ($submenu_array AS $submenu_item) {
48       $pieces = preg_split('/\s+/', $submenu_item, 2, PREG_SPLIT_NO_EMPTY);
49       $links[] = $pieces[0];
50       $labels[] = $pieces[1];
51     }
52
53     print_link($links[0], $labels[0], $current_menu, $links);
54
55     if ( count($links) > 1 ) {
56       if ( in_array( $current_menu, $links ) ) {
57         echo '<img src="images/dropdown_arrow_white.gif">';
58       } else {
59         echo '<img src="images/dropdown_arrow_white.gif" style="display:none;">';
60         echo '<img src="images/dropdown_arrow_grey.gif">';
61       }
62     }
63
64     array_shift($links);
65     array_shift($labels);
66
67     echo '</a>';
68
69     if ( count($links) > 0 ) {
70       echo '<ul>';
71       foreach ($links AS $link) {
72         $label = array_shift($labels);
73         if ( in_array($label, $menu_disable) == 0) {
74           print_link($link, $label, $current_menu, array($link) );
75           echo '</a></li>';
76         }
77       }
78       echo '</ul>';
79     }
80
81     echo '</li>';
82
83   }
84
85   function print_link($link, $label, $current_menu, $search_array) {
86       echo '<li><a href="'. $link. '"';
87       if ( in_array( $current_menu, $search_array ) ) {
88         echo ' class="current_menu"';
89       }
90       echo '>'. _($label);
91   }
92
93 ?>
94
95 </ul>
96
97 <div style="clear:both;"></div>
98 <table cellpadding="0" cellspacing="0" border="0" style="min-width:666px">
99 <tr>
100 <td class="page">