5 * Copyright 2010 (c) FusionForge Team
6 * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
7 * Copyright 2011, Franck Villaume - Capgemini
8 * http://fusionforge.org
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published
14 * by the Free Software Foundation; either version 2 of the License,
15 * or (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with FusionForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28 require_once $gfwww.'include/Layout.class.php';
30 define('TOP_TAB_HEIGHT', 30);
31 define('BOTTOM_TAB_HEIGHT', 22);
33 class Theme extends Layout {
34 var $header_displayed = false;
37 // Ensure our stylesheets are loaded before the default one (reset first).
38 $this->addStylesheet('/scripts/yui/reset-fonts-grids/reset-fonts-grids.css');
39 $this->addStylesheet('/scripts/yui/base/base-min.css');
40 $this->addStylesheet('/themes/css/fusionforge.css');
41 $this->addStylesheet('/themes/gforge/css/theme.css');
42 $this->addStylesheet('/themes/gforge/css/theme-pages.css');
46 $this->doctype = 'strict';
47 $this->themeurl = util_make_url('themes/gforge/');
48 $this->imgbaseurl = $this->themeurl . 'images/';
49 $this->imgroot = $this->imgbaseurl;
53 function bodyHeader($params) {
56 // Don't display the headers twice (when errors for example).
57 if ($this->header_displayed)
59 $this->header_displayed=true;
61 // The root location for images
62 if (!isset($params['h1'])) {
63 $params['h1'] = $params['title'];
66 if (!$params['title']) {
67 $params['title'] = forge_get_config('forge_name');
69 $params['title'] = $params['title'] . " - forge_get_config('forge_name') ";
73 <table id="header" class="width-100p100">
75 <td id="header-col1">';
76 echo util_make_link ('/', html_image('header/top-logo.png',192,54,array('alt'=>'FusionForge Home')));
78 <td id="header-col2">';
84 $items = $this->navigation->getUserLinks();
85 for ($j = 0; $j < count($items['titles']); $j++) {
86 $links[] = util_make_link($items['urls'][$j], $items['titles'][$j],
87 array('class'=>'userlink'), true);
89 echo implode(' | ', $links);
90 plugin_hook ('headermenu', $params);
100 echo $this->outerTabs($params);
101 echo '<!-- inner tabs -->' . "\n";
102 if (isset($params['group']) && $params['group']) {
103 echo $this->projectTabs($params['toptab'],$params['group']);
105 echo '<div id="maindiv">
107 // echo '<div class="printheader">'. forge_get_config('forge_name') . ' ' . util_make_url('/') .'</div>';
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']);
120 echo '<h1>'.$params['h1'].'</h1>';
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() . '
149 * boxTop() - Top HTML box
151 * @param string Box title
152 * @param bool Whether to echo or return the results
153 * @param string The box background color
155 function boxTop($title, $id = '') {
157 <div id="' . $this->toSlug($id) . '" class="box-surround">
158 <div id="'. $this->toSlug($id) . '-title" class="box-title">
159 <div class="box-title-left">
160 <div class="box-title-right">
161 <h3 class="box-title-content" id="'. $this->toSlug($id) .'-title-content">'. $title .'</h3>
162 </div> <!-- class="box-title-right" -->
163 </div> <!-- class="box-title-left" -->
164 </div> <!-- class="box-title" -->
165 <div id="'. $this->toSlug($id) .'-content" class="box-content">
171 * boxMiddle() - Middle HTML box
173 * @param string Box title
174 * @param string The box background color
176 function boxMiddle($title, $id = '') {
178 </div> <!-- class="box-content" -->
179 <h3 id="title-'. $this->toSlug($id).'" class="box-middle">'.$title.'</h3>
180 <div class="box-content">
186 * boxBottom() - Bottom HTML box
189 function boxBottom() {
191 </div> <!-- class="box-content" -->
192 </div> <!-- class="box-surround" -->
198 * boxGetAltRowStyle() - Get an alternating row style for tables
200 * @param int Row number
202 function boxGetAltRowStyle($i) {
204 return 'class="bgcolor-white"';
206 return 'class="bgcolor-grey"';
210 function tabGenerator($TABS_DIRS, $TABS_TITLES, $nested=false,
211 $selected=false, $sel_tab_bgcolor='WHITE',
212 $total_width='100%') {
213 $count=count($TABS_DIRS);
219 <table class="tabGenerator width-100p100" summary="" ';
221 if ($total_width != '100%') {
222 $return .= 'style="width:' . $total_width . ';"';
227 /* $folder = $this->imgurl.($nested ? 'bottomtab-new/' : 'toptab-new/');*/
229 $accumulated_width = 0;
230 for ($i=0; $i<$count; $i++) {
231 $tabwidth = intval(ceil(($i+1)*100/$count)) - $accumulated_width ;
232 $accumulated_width += $tabwidth ;
234 if ($selected == $i) {
235 $left_img = $folder.'selected-left.gif';
236 $middle_img = $folder.'selected-middle.gif';
237 $right_img = $folder.'selected-right.gif';
238 $separ_img = $folder.'selected-separator.gif';
239 $css_class = $nested ? 'bottomTabSelected' : 'topTabSelected';
241 $left_img = $folder.'left.gif';
242 $middle_img = $folder.'middle.gif';
243 $right_img = $folder.'right.gif';
244 $separ_img = $folder.'separator.gif';
245 $css_class = $nested ? 'bottomTab' : 'topTab';
248 $clear_img = $this->imgurl.'clear.png';
253 $return .= '<td class="tg-left">' . "\n";
255 if ($selected == $i) {
256 $return .= ' class="selected"';
262 $return .= ' class="nested"';
264 $return .= '>' . "\n";
266 $return .= '</div>' . "\n";
267 $return .= '</td>' . "\n";
270 $return .= '<td class="tg-middle" style="width:'.$tabwidth.'%;">' . "\n";
272 if ($selected == $i) {
273 $return .= ' class="selected"';
278 $return .= ' class="nested"';
280 $return .= '>' . "\n";
281 $return .= '<a href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>' . "\n";
283 $return .= '</div>' . "\n";
284 $return .= '</td>' . "\n";
287 // if the next tab is not selected, close this tab
288 if ($selected != $i+1) {
289 $return .= '<td class="tg-right">' . "\n";
291 if ($selected == $i) {
292 $return .= ' class="selected"';
297 $return .= ' class="nested"';
299 $return .= '>' . "\n";
301 $return .= '</div>' . "\n";
302 $return .= '</td>' . "\n";
315 * beginSubMenu() - Opening a submenu.
317 * @return string Html to start a submenu.
319 function beginSubMenu () {
326 * endSubMenu() - Closing a submenu.
328 * @return string Html to end a submenu.
330 function endSubMenu() {
331 $return = '</strong></p>';
336 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
338 * @param array The array of titles.
339 * @param array The array of title links.
340 * @param array The array of the html attributes.
341 * @return string Html to build a submenu.
343 function printSubMenu($title_arr, $links_arr, $attr_arr) {
344 $count = count($title_arr);
348 for ($i = 0; $i < $count; $i++) {
349 $return .= util_make_link($links_arr[$i], $title_arr[$i], $attr_arr[$i]) . ' | ';
351 $return .= util_make_link($links_arr[$i], $title_arr[$i], $attr_arr[$i]);
356 * subMenu() - Takes two array of titles and links and build a menu.
358 * @param array The array of titles.
359 * @param array The array of title links.
360 * @param array The array of the html attributes.
361 * @return string Html to build a submenu.
363 function subMenu($title_arr, $links_arr, $attr_arr = false) {
364 $return = $this->beginSubMenu();
365 $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr) ;
366 $return .= $this->endSubMenu();
371 * multiTableRow() - create a mutlilevel row in a table
373 * @param string the row attributes
374 * @param array the array of cell data, each element is an array,
375 * the first item being the text,
376 * the subsequent items are attributes (dont include
377 * the bgcolor for the title here, that will be
378 * handled by $istitle
379 * @param boolean is this row part of the title ?
382 function multiTableRow($row_attr, $cell_data, $istitle) {
384 <tr class="ff" '.$row_attr;
386 $return .=' align="center"';
389 for ( $c = 0; $c < count($cell_data); $c++ ) {
390 $return .='<td class="ff" ';
391 for ( $a=1; $a < count($cell_data[$c]); $a++) {
392 $return .= $cell_data[$c][$a].' ';
396 $return .='<strong>';
398 $return .= $cell_data[$c][0];
400 $return .='</strong>';
412 * getThemeIdFromName()
414 * @param string the dirname of the theme
415 * @return integer the theme id
417 function getThemeIdFromName($dirname) {
418 $res=db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
420 return db_result($res,0,'theme_id');
426 // c-file-style: "bsd"