]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/tabs.php
Release 6.5.16
[Github/sugarcrm.git] / include / tabs.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38  
39
40
41
42
43 class SugarWidgetTabs extends SugarWidget
44 {
45  var $tabs;
46  var $current_key;
47
48  function SugarWidgetTabs(&$tabs,$current_key,$jscallback)
49  {
50    $this->tabs = $tabs;
51    $this->current_key = $current_key;
52    $this->jscallback = $jscallback;
53  }
54
55  function display()
56  {
57         ob_start();
58 ?>
59 <script>
60 var keys = [ <?php 
61 $tabs_count = count($this->tabs);
62 for($i=0; $i < $tabs_count;$i++) 
63 {
64  $tab = $this->tabs[$i];
65  echo "\"".$tab['key']."\""; 
66  if ($tabs_count > ($i + 1))
67  {
68    echo ",";
69  }
70 }
71 ?>]; 
72 tabPreviousKey = '';
73
74 function selectTabCSS(key)
75 {
76
77
78   for( var i=0; i<keys.length;i++)
79   {
80    var liclass = '';
81    var linkclass = '';
82
83  if ( key == keys[i])
84  {
85    var liclass = 'active';
86    var linkclass = 'current';
87  }
88         document.getElementById('tab_li_'+keys[i]).className = liclass;
89
90         document.getElementById('tab_link_'+keys[i]).className = linkclass;
91   }
92     <?php echo $this->jscallback;?>(key, tabPreviousKey);
93     tabPreviousKey = key;
94 }
95 </script>
96
97 <ul id="searchTabs" class="tablist">
98 <?php 
99         foreach ($this->tabs as $tab)
100         {
101                 $TITLE = $tab['title'];
102                 $LI_ID = "";
103                 $A_ID = "";
104
105           if ( ! empty($tab['hidden']) && $tab['hidden'] == true)
106                 {
107                           $LI_ID = "style=\"display: none\"";
108                           $A_ID = "style=\"display: none\"";
109
110                 } else if ( $this->current_key == $tab['key'])
111                 {
112                           $LI_ID = "class=\"active\"";
113                           $A_ID = "class=\"current\"";
114                 }
115
116                 $LINK = "<li $LI_ID id=\"tab_li_".$tab['link']."\"><a $A_ID id=\"tab_link_".$tab['link']."\" href=\"javascript:selectTabCSS('{$tab['link']}');\">$TITLE</a></li>";
117
118 ?>
119 <?php echo $LINK; ?>    
120 <?php
121         }
122 ?>
123 </ul>
124 <?php 
125         $ob_contents = ob_get_contents();
126         ob_end_clean();
127         return $ob_contents;
128         }
129 }
130 ?>