3 require_once $gfwww.'include/Layout.class.php';
5 define('THEME_DIR', util_make_url ('/themes/gforge'));
7 define('TOP_TAB_HEIGHT', 30);
8 define('BOTTOM_TAB_HEIGHT', 22);
10 class Theme extends Layout {
16 $this->imgroot = THEME_DIR.'/images/';
17 $this->jsroot = THEME_DIR.'/js/';
21 * Layout() - Constructor
24 // Constructor for parent class...
25 if ( file_exists($GLOBALS['sys_custom_path'] . '/index_std.php') ) {
26 $this->rootindex = $GLOBALS['sys_custom_path'] . '/index_std.php';
28 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
34 * header() - "steel theme" top of page
36 * @param array Header parameters array
38 function header($params) {
39 if (!isset($params['title'])) {
40 $params['title'] = $GLOBALS['sys_name'];
42 $params['title'] = $GLOBALS['sys_name'] . ': ' . $params['title'];
45 print '<?xml version="1.0" encoding="utf-8"?>';
47 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
48 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . _('en') . '" lang="' . _('en') . '">
50 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
51 <title>'. $params['title'] . '</title>
52 <link rel="icon" type="image/png" href="'. util_make_url('/images/icon.png') .'" />
53 <link rel="shortcut icon" type="image/png" href="'. util_make_url('/images/icon.png') .'" />';
55 echo $this->headerLink();
58 <script type="text/javascript" src="'. $this->jsroot .'gforge.js"></script>
59 <script type="text/javascript">';
60 plugin_hook ("javascript",false);
70 $this->bodyHeader($params);
73 function bodyHeader($params) {
77 <table id="header" class="width-100p100">
80 <h1>'. util_make_link ('/', html_image('header/top-logo.png',192,54,array('alt'=>'FusionForge Home'))) .'</h1>
82 <td id="header-col2">';
83 echo $this->searchBox();
88 if (session_loggedin()) {
89 $u =& user_get_object(user_getid());
90 echo util_make_link ('/account/logout.php', sprintf("%s (%s)", _('Log Out'), $u->getRealName()), array('class'=>'userlink'));
92 echo util_make_link ('/account/', _('My Account'), array('class'=>'userlink'));
94 $url = '/account/login.php';
95 if(getStringFromServer('REQUEST_METHOD') != 'POST') {
96 $url .= '?return_to=';
97 $url .= urlencode(getStringFromServer('REQUEST_URI'));
100 echo util_make_link ($url, _('Log In'),array('class'=>'userlink'));
102 if (!$GLOBALS['sys_user_reg_restricted']) {
103 echo util_make_link ('/account/register.php', _('New Account'),array('class'=>'userlink'));
107 plugin_hook ('headermenu', $params);
109 echo $this->quickNav();
117 echo $this->outerTabs($params);
118 echo '<!-- inner tabs -->';
119 if (isset($params['group']) && $params['group']) {
120 echo $this->projectTabs($params['toptab'],$params['group']);
122 echo '<div id="maindiv">
126 function bodyFooter($params) {
131 function footer($params) {
133 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
134 <div class="align-right">
135 <a href="http://fusionforge.org/">
136 <img src="'. util_make_url ('/images/pow-fusionforge.png') .'" alt="Powered By FusionForge" />
140 global $sys_show_source;
141 if ($sys_show_source) {
143 print util_make_link ('/source.php?file=' . $SCRIPT_NAME, _('Show source'), array ("class" => "showsource"));
152 function headerCSS() {
154 <link href="http://yui.yahooapis.com/2.6.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css" rel="stylesheet" />
155 <link href="http://yui.yahooapis.com/2.6.0/build/base/base-min.css" type="text/css" rel="stylesheet" />
156 <link rel="stylesheet" type="text/css" href="'. util_make_url ('/themes/css/fusionforge.css') .'" />
157 <link rel="stylesheet" type="text/css" href="'. THEME_DIR .'/css/theme.css" />
158 <link rel="stylesheet" type="text/css" href="'. THEME_DIR .'/css/theme-pages.css" />
161 plugin_hook ('cssfile',$this);
164 function getRootIndex() {
165 return $this->rootindex;
169 * boxTop() - Top HTML box
171 * @param string Box title
172 * @param bool Whether to echo or return the results
173 * @param string The box background color
175 function boxTop($title, $id = '') {
177 <div id="' . $this->toSlug($id) . '" class="box-surround">
178 <div id="'. $this->toSlug($id) . '-title" class="box-title">
179 <div class="box-title-left">
180 <div class="box-title-right">
181 <h3 class="box-title-content" id="'. $this->toSlug($id) .'-title-content">'. $title .'</h3>
185 <div id="'. $this->toSlug($id) .'-content" class="box-content">
191 * boxMiddle() - Middle HTML box
193 * @param string Box title
194 * @param string The box background color
196 function boxMiddle($title, $id = '') {
198 </div> <!-- class="box-content" -->
199 <h3 id="title-'. $this->toSlug($id).'" class="box-middle">'.$title.'</h3>
200 <div class="box-content">
206 * boxBottom() - Bottom HTML box
209 function boxBottom() {
212 </div> <!-- class="box-surround" -->
218 * boxGetAltRowStyle() - Get an alternating row style for tables
220 * @param int Row number
222 function boxGetAltRowStyle($i) {
224 return 'class="bgcolor-white"';
226 return 'class="bgcolor-grey"';
231 * listTableTop() - Takes an array of titles and builds the first row of a new table.
233 * @param array The array of titles
234 * @param array The array of title links
235 * @param boolean Whether to highlight or not the entry
237 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
238 $return = '<table class="width-100p100 listTable';
239 if ($selected == true) {
240 $return .= ' selected';
245 $count=count($title_arr);
247 for ($i=0; $i<$count; $i++) {
249 <th scope="col"><a class="sortbutton" href="'.util_make_url ($links_arr[$i]).'"><strong>'.$title_arr[$i].'</strong></a></th>';
252 for ($i=0; $i<$count; $i++) {
254 <th scope="col"><strong>'.$title_arr[$i].'</strong></th>';
257 return $return.'</tr>';
260 function listTableBottom() {
266 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='WHITE',$total_width='100%') {
267 $count=count($TABS_DIRS);
268 $width=intval((100/$count));
272 <table class="tabGenerator width-100p100" summary="" ';
274 if ($total_width != '100%') {
275 $return .= 'style="width:' . $total_width . ';"';
280 $folder = $this->imgroot.($nested ? 'bottomtab-new/' : 'toptab-new/');
282 for ($i=0; $i<$count; $i++) {
283 if ($selected == $i) {
284 $left_img = $folder.'selected-left.gif';
285 $middle_img = $folder.'selected-middle.gif';
286 $right_img = $folder.'selected-right.gif';
287 $separ_img = $folder.'selected-separator.gif';
288 $css_class = $nested ? 'bottomTabSelected' : 'topTabSelected';
290 $left_img = $folder.'left.gif';
291 $middle_img = $folder.'middle.gif';
292 $right_img = $folder.'right.gif';
293 $separ_img = $folder.'separator.gif';
294 $css_class = $nested ? 'bottomTab' : 'topTab';
297 $clear_img = $this->imgroot.'clear.png';
302 $return .= '<td class="tg-left">' . "\n";
304 if ($selected == $i) {
305 $return .= ' class="selected"';
311 $return .= ' class="nested"';
313 $return .= '>' . "\n";
315 $return .= '</div>' . "\n";
316 $return .= '</td>' . "\n";
319 $return .= '<td class="tg-middle" style="width:'.$width.'%;">' . "\n";
321 if ($selected == $i) {
322 $return .= ' class="selected"';
327 $return .= ' class="nested"';
329 $return .= '>' . "\n";
330 $return .= '<a href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>' . "\n";
332 $return .= '</div>' . "\n";
333 $return .= '</td>' . "\n";
336 // if the next tab is not selected, close this tab
337 if ($selected != $i+1) {
338 $return .= '<td class="tg-right">' . "\n";
340 if ($selected == $i) {
341 $return .= ' class="selected"';
346 $return .= ' class="nested"';
348 $return .= '>' . "\n";
350 $return .= '</div>' . "\n";
351 $return .= '</td>' . "\n";
362 function searchBox() {
363 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
365 if(get_magic_quotes_gpc()) {
366 $defaultWords = stripslashes($words);
368 $defaultWords = $words;
371 // if there is no search currently, set the default
372 if ( ! isset($type_of_search) ) {
377 <form id="searchBox" action="'.util_make_url ('/search/').'" method="get">
380 SEARCH__PARAMETER_GROUP_ID => $group_id,
381 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
382 SEARCH__PARAMETER_FORUM_ID => $forum_id,
383 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
386 $searchManager =& getSearchManager();
387 $searchManager->setParametersValues($parameters);
388 $searchEngines =& $searchManager->getAvailableSearchEngines();
391 <label for="searchBox-words">
392 <select name="type_of_search">';
393 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
394 $searchEngine =& $searchEngines[$i];
395 echo '<option class="ff" value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
397 echo '</select></label>';
399 $parameters = $searchManager->getParameters();
400 foreach($parameters AS $name => $value) {
401 print '<input class="ff" type="hidden" value="'.$value.'" name="'.$name.'" />';
403 print '<input type="text" size="12" id="searchBox-words" name="words" value="'.$defaultWords.'" />';
404 print '<input type="submit" name="Search" value="'._('Search').'" />';
406 if (isset($group_id) && $group_id) {
407 print util_make_link ('/search/advanced_search.php?group_id='.$group_id, _('Advanced search'), array('class'=>'userlink'));
414 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
415 // display the searchmask
417 <form class="ff" name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
418 <input class="ff" type="hidden" name="search" value="1"/>
419 <input class="ff" type="hidden" name="group_id" value="'.$group_id.'"/>
420 <div align="center"><br />
423 <td class="ff" colspan ="2">
424 <input class="ff" type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
425 <input class="ff" type="submit" name="submitbutton" value="'._('Search').'" />
429 <td class="ff" valign="top">
430 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
433 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
436 </table><br /></div>'
437 .$this->createUnderSections($sectionsArray).'
441 //create javascript methods for select none/all
443 <script type="text/javascript">
444 <!-- method for disable/enable checkboxes
445 function setCheckBoxes(parent, checked) {
448 for (var i = 0; i < document.advancedsearch.elements.length; i++)
449 if (document.advancedsearch.elements[i].type == "checkbox")
450 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
451 document.advancedsearch.elements[i].checked = checked;
459 function createUnderSections($sectionsArray) {
460 global $group_subsection_names;
462 foreach ($sectionsArray as $section) {
463 if(is_array($section)) {
464 $countLines += (3 + count ($section));
466 //2 lines one for section name and one for checkbox
470 $breakLimit = round($countLines/3);
471 $break = $breakLimit;
474 <table width="99%" border="0" cellspacing="0" cellpadding="1" style="background-color:'. $this->COLOR_LTBACK2.'">
477 <table width="100%" cellspacing="0" border="0" style="background-color:'. $this->COLOR_LTBACK1.'">
478 <tr class="ff" style="font-weight: bold;background-color:'. $this->COLOR_LTBACK2 .'">
479 <td class="ff" colspan="2">'._('Search in').'</td>
480 <td class="ff" style="text-align:right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
482 <tr class="ff" height="20">
483 <td class="ff" colspan="3"> </td>
485 <tr class="ff" align="center" valign="top">
487 foreach($sectionsArray as $key => $section) {
488 $oldcountlines = $countLines;
489 if (is_array($section)) {
490 $countLines += (3 + count ($section));
495 if ($countLines >= $break) {
496 //if the next block is so large that shifting it to the next column hits the breakpoint better
497 //the second part of statement (behind &&) proofs, that no 4th column is added
498 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
499 $return .= '</td><td class="ff">';
500 $break += $breakLimit;
504 $return .= '<table style="width:90%; background-color:'. $this->COLOR_LTBACK2.'">
507 <table style="width:100%;">
508 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK2 .'; font-weight: bold">
510 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
512 <td class="ff" style="text-align:right">'
513 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
516 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK1.'">
517 <td class="ff" colspan="2">';
519 if (!is_array($section)) {
520 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key).'"';
521 if (isset($GLOBALS[urlencode($key)]))
522 $return .= ' checked="checked" ';
523 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
526 foreach($section as $underkey => $undersection) {
527 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key.$underkey).'"';
528 if (isset($GLOBALS[urlencode($key.$underkey)]))
529 $return .= ' checked ';
530 $return .= '></input>'.$undersection.'<br />';
536 </table></td></tr></table><br />';
538 if ($countLines >= $break) {
539 if (($countLines - $break) < ($break - $countLines)) {
540 $return .= '</td><td class="ff" width="33%">';
541 $break += $breakLimit;
546 return $return.' </td>
548 </table></td></tr></table>';
552 * beginSubMenu() - Opening a submenu.
554 * @return string Html to start a submenu.
556 function beginSubMenu () {
563 * endSubMenu() - Closing a submenu.
565 * @return string Html to end a submenu.
567 function endSubMenu () {
568 $return = '</strong></p>';
573 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
575 * @param array The array of titles.
576 * @param array The array of title links.
577 * @return string Html to build a submenu.
579 function printSubMenu ($title_arr,$links_arr) {
580 $count=count($title_arr);
585 for ($i=0; $i<$count; $i++) {
586 $return .= util_make_link ($links_arr[$i], $title_arr[$i]) . ' | ';
588 $return .= util_make_link ($links_arr[$i], $title_arr[$i]);
593 * subMenu() - Takes two array of titles and links and build a menu.
595 * @param array The array of titles.
596 * @param array The array of title links.
597 * @return string Html to build a submenu.
599 function subMenu ($title_arr,$links_arr) {
600 $return = $this->beginSubMenu () ;
601 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
602 $return .= $this->endSubMenu () ;
607 * multiTableRow() - create a mutlilevel row in a table
609 * @param string the row attributes
610 * @param array the array of cell data, each element is an array,
611 * the first item being the text,
612 * the subsequent items are attributes (dont include
613 * the bgcolor for the title here, that will be
614 * handled by $istitle
615 * @param boolean is this row part of the title ?
618 function multiTableRow($row_attr, $cell_data, $istitle) {
620 <tr class="ff" '.$row_attr;
622 $return .=' align="center" bgcolor="'. $this->COLOR_HTMLBOX_TITLE .'"';
625 for ( $c = 0; $c < count($cell_data); $c++ ) {
626 $return .='<td class="ff" ';
627 for ( $a=1; $a < count($cell_data[$c]); $a++) {
628 $return .= $cell_data[$c][$a].' ';
632 $return .='<font color="'.$this->FONTCOLOR_HTMLBOX_TITLE.'"><strong>';
634 $return .= $cell_data[$c][0];
636 $return .='</strong></font>';
648 * feedback() - returns the htmlized feedback string when an action is performed.
650 * @param string feedback string
651 * @return string htmlized feedback
653 function feedback($feedback) {
658 <h3 style="color:red">'.strip_tags($feedback, '<br>').'</h3>';
663 * getThemeIdFromName()
665 * @param string the dirname of the theme
666 * @return integer the theme id
668 function getThemeIdFromName($dirname) {
669 $res=db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
671 return db_result($res,0,'theme_id');
677 // c-file-style: "bsd"