5 * Copyright 2010 (c) FusionForge Team
6 * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
7 * Copyright 2011, Franck Villaume - Capgemini
8 * Copyright 2011-2012, Franck Villaume - TrivialDev
9 * http://fusionforge.org
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once $gfwww.'include/Layout.class.php';
29 define('TOP_TAB_HEIGHT', 30);
30 define('BOTTOM_TAB_HEIGHT', 22);
32 class Theme extends Layout {
33 var $header_displayed = false;
36 // Ensure our stylesheets are loaded before the default one (reset first).
37 $this->addStylesheet('/scripts/yui/reset-fonts-grids/reset-fonts-grids.css');
38 $this->addStylesheet('/scripts/yui/base/base-min.css');
39 $this->addStylesheet('/themes/css/fusionforge.css');
40 $this->addStylesheet('/themes/gforge/css/theme.css');
41 $this->addStylesheet('/themes/gforge/css/theme-pages.css');
45 //$this->doctype = 'strict';
46 $this->themeurl = util_make_url('themes/gforge/');
47 $this->imgbaseurl = $this->themeurl . 'images/';
48 $this->imgroot = $this->imgbaseurl;
51 function bodyHeader($params) {
54 // Don't display the headers twice (when errors for example).
55 if ($this->header_displayed)
57 $this->header_displayed=true;
59 // The root location for images
60 if (!isset($params['h1']) && isset($params['title'])) {
61 $params['h1'] = util_ifsetor($params['title'], "!! title not set !!");
64 if (!util_ifsetor($params['title'])) {
65 $params['title'] = forge_get_config('forge_name');
67 $params['title'] = $params['title'] . " – " . forge_get_config('forge_name');
71 <table id="header" class="width-100p100">
73 <td id="header-col1">';
74 echo util_make_link ('/', html_image('header/top-logo.png',192,54,array('alt'=>'FusionForge Home')));
76 <td id="header-col2">';
82 $items = $this->navigation->getUserLinks();
83 for ($j = 0; $j < count($items['titles']); $j++) {
84 $links[] = util_make_link($items['urls'][$j], $items['titles'][$j],
85 array('class'=>'userlink'), true);
87 echo implode(' | ', $links);
88 plugin_hook('headermenu', $params);
98 echo $this->outerTabs($params);
99 echo '<!-- inner tabs -->' . "\n";
100 if (isset($params['group']) && $params['group']) {
101 echo $this->projectTabs($params['toptab'],$params['group']);
103 echo '<div id="maindiv">
105 // echo '<div class="printheader">'. forge_get_config('forge_name') . ' ' . util_make_url('/') .'</div>';
107 plugin_hook('message', array());
109 if(isset($GLOBALS['error_msg']) && $GLOBALS['error_msg']) {
110 echo $this->error_msg($GLOBALS['error_msg']);
112 if(isset($GLOBALS['warning_msg']) && $GLOBALS['warning_msg']) {
113 echo $this->warning_msg($GLOBALS['warning_msg']);
115 if(isset($GLOBALS['feedback']) && $GLOBALS['feedback']) {
116 echo $this->feedback($GLOBALS['feedback']);
119 if (isset($params['h1'])) {
120 echo '<h1>'.$params['h1'].'</h1>';
121 } elseif (isset($params['title'])) {
122 echo '<h1 class="hide">'.$params['title'].'</h1>';
124 if (isset($params['submenu']))
125 echo $params['submenu'];
128 function bodyFooter($params) {
129 echo '</div><!-- id="maindiv" -->' . "\n";
132 function footer($params) {
133 $this->bodyFooter($params);
135 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
136 <div class="align-right">
137 ' . $this->navigation->getPoweredBy() . '
139 ' . $this->navigation->getShowSource() . '
142 plugin_hook('webanalytics_url', array());
151 * boxTop() - Top HTML box
153 * @param string Box title
154 * @param bool Whether to echo or return the results
155 * @param string The box background color
157 function boxTop($title, $id = '') {
159 $id = $this->toSlug($id);
160 $idid = ' id="' . $id . '"';
161 $idtitle = ' id="' . $id . '-title"';
162 $idtcont = ' id="' . $id . '-title-content"';
163 $idcont = ' id="' . $id . '-content"';
172 <div' . $idid . ' class="box-surround">
173 <div' . $idtitle . ' class="box-title">
174 <div class="box-title-left">
175 <div class="box-title-right">
176 <h3 class="box-title-content"' . $idtcont . '>'. $title .'</h3>
177 </div> <!-- class="box-title-right" -->
178 </div> <!-- class="box-title-left" -->
179 </div> <!-- class="box-title" -->
180 <div' . $idcont . ' class="box-content">
186 * boxMiddle() - Middle HTML box
188 * @param string Box title
189 * @param string The box background color
191 function boxMiddle($title, $id = '') {
193 $id = $this->toSlug($id);
194 $idtitle = ' id="' . $id . '-title"';
200 </div> <!-- class="box-content" -->
201 <h3' . $idtitle . ' class="box-middle">'.$title.'</h3>
202 <div class="box-content">
208 * boxBottom() - Bottom HTML box
211 function boxBottom() {
213 </div> <!-- class="box-content" -->
214 </div> <!-- class="box-surround" -->
220 * boxGetAltRowStyle() - Get an alternating row style for tables
222 * @param int Row number
224 function boxGetAltRowStyle($i) {
226 return 'class="bgcolor-white"';
228 return 'class="bgcolor-grey"';
232 function tabGenerator($TABS_DIRS, $TABS_TITLES, $TABS_TOOLTIPS, $nested=false,
233 $selected=false, $sel_tab_bgcolor='WHITE',
234 $total_width='100%') {
235 $count=count($TABS_DIRS);
240 global $use_tooltips ;
244 <table class="tabGenerator width-100p100" summary="" ';
246 if ($total_width != '100%') {
247 $return .= 'style="width:' . $total_width . ';"';
252 /* $folder = $this->imgurl.($nested ? 'bottomtab-new/' : 'toptab-new/');*/
254 $accumulated_width = 0;
255 for ($i=0; $i<$count; $i++) {
256 $tabwidth = intval(ceil(($i+1)*100/$count)) - $accumulated_width ;
257 $accumulated_width += $tabwidth ;
259 if ($selected == $i) {
260 $left_img = $folder.'selected-left.gif';
261 $middle_img = $folder.'selected-middle.gif';
262 $right_img = $folder.'selected-right.gif';
263 $separ_img = $folder.'selected-separator.gif';
264 $css_class = $nested ? 'bottomTabSelected' : 'topTabSelected';
266 $left_img = $folder.'left.gif';
267 $middle_img = $folder.'middle.gif';
268 $right_img = $folder.'right.gif';
269 $separ_img = $folder.'separator.gif';
270 $css_class = $nested ? 'bottomTab' : 'topTab';
273 $clear_img = $this->imgurl.'clear.png';
278 $return .= '<td class="tg-left">' . "\n";
280 if ($selected == $i) {
281 $return .= ' class="selected"';
287 $return .= ' class="nested"';
289 $return .= '>' . "\n";
291 $return .= '</div>' . "\n";
292 $return .= '</td>' . "\n";
295 $return .= '<td class="tg-middle" style="width:'.$tabwidth.'%;">' . "\n";
297 if ($selected == $i) {
298 $return .= ' class="selected"';
303 $return .= ' class="nested"';
305 $return .= '>' . "\n";
308 $return .= ' title="'.$TABS_TOOLTIPS[$i].'"';
310 $return .= ' href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>' . "\n";
312 $return .= '</div>' . "\n";
313 $return .= '</td>' . "\n";
316 // if the next tab is not selected, close this tab
317 if ($selected != $i+1) {
318 $return .= '<td class="tg-right">' . "\n";
320 if ($selected == $i) {
321 $return .= ' class="selected"';
326 $return .= ' class="nested"';
328 $return .= '>' . "\n";
330 $return .= '</div>' . "\n";
331 $return .= '</td>' . "\n";
343 * beginSubMenu() - Opening a submenu.
345 * @return string Html to start a submenu.
347 function beginSubMenu() {
354 * endSubMenu() - Closing a submenu.
356 * @return string Html to end a submenu.
358 function endSubMenu() {
359 $return = '</strong></p>';
364 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
366 * @param array The array of titles.
367 * @param array The array of title links.
368 * @param array The array of the html attributes.
369 * @return string Html to build a submenu.
371 function printSubMenu($title_arr, $links_arr, $attr_arr) {
372 $count = count($title_arr);
376 for ($i = 0; $i < $count; $i++) {
377 $return .= util_make_link($links_arr[$i], $title_arr[$i], $attr_arr[$i]) . $this->subMenuSeparator();
379 $return .= util_make_link($links_arr[$i], $title_arr[$i], $attr_arr[$i]);
384 * subMenuSeparator() - returns the separator used between submenus
386 * @return string Html to build a submenu separator.
388 function subMenuSeparator() {
393 * subMenu() - Takes two array of titles and links and build a menu.
395 * @param array The array of titles.
396 * @param array The array of title links.
397 * @param array The array of the html attributes.
398 * @return string Html to build a submenu.
400 function subMenu($title_arr, $links_arr, $attr_arr = false) {
401 $return = $this->beginSubMenu();
402 $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr);
403 $return .= $this->endSubMenu();
408 * multiTableRow() - create a mutlilevel row in a table
410 * @param string the row attributes
411 * @param array the array of cell data, each element is an array,
412 * the first item being the text,
413 * the subsequent items are attributes (dont include
414 * the bgcolor for the title here, that will be
415 * handled by $istitle
416 * @param boolean is this row part of the title ?
419 function multiTableRow($row_attr, $cell_data, $istitle) {
421 <tr class="ff" '.$row_attr;
423 $return .=' align="center"';
426 for ( $c = 0; $c < count($cell_data); $c++ ) {
427 $return .='<td class="ff" ';
428 for ( $a=1; $a < count($cell_data[$c]); $a++) {
429 $return .= $cell_data[$c][$a].' ';
433 $return .='<strong>';
435 $return .= $cell_data[$c][0];
437 $return .='</strong>';
449 * getThemeIdFromName()
451 * @param string the dirname of the theme
452 * @return integer the theme id
454 function getThemeIdFromName($dirname) {
455 $res=db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
457 return db_result($res,0,'theme_id');
463 // c-file-style: "bsd"