3 require_once $gfwww.'include/Layout.class.php';
5 define('THEME_DIR', util_make_uri ('/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_uri('/images/icon.png') .'" />
53 <link rel="shortcut icon" type="image/png" href="'. util_make_uri('/images/icon.png') .'" />';
55 echo $this->headerLink();
58 <script type="text/javascript" src="'. util_make_uri('/js/common.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_uri ('/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_uri ('/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);
271 // The width for each tab is given in percent. Note
272 // that an integer value is used as Opera doesn't seem
273 // to interpret fractional percentage values:
274 // http://www.christianmontoya.com/2007/06/26/fluid-widths-and-point-nine-nine-percent/
275 $width=intval((100/$count));
276 $rest_width=100-$count*$width;
280 <table class="tabGenerator width-100p100" summary="" ';
282 if ($total_width != '100%') {
283 $return .= 'style="width:' . $total_width . ';"';
288 $folder = $this->imgroot.($nested ? 'bottomtab-new/' : 'toptab-new/');
290 for ($i=0; $i<$count; $i++) {
291 if ($selected == $i) {
292 $left_img = $folder.'selected-left.gif';
293 $middle_img = $folder.'selected-middle.gif';
294 $right_img = $folder.'selected-right.gif';
295 $separ_img = $folder.'selected-separator.gif';
296 $css_class = $nested ? 'bottomTabSelected' : 'topTabSelected';
298 $left_img = $folder.'left.gif';
299 $middle_img = $folder.'middle.gif';
300 $right_img = $folder.'right.gif';
301 $separ_img = $folder.'separator.gif';
302 $css_class = $nested ? 'bottomTab' : 'topTab';
305 $clear_img = $this->imgroot.'clear.png';
310 $return .= '<td class="tg-left">' . "\n";
312 if ($selected == $i) {
313 $return .= ' class="selected"';
319 $return .= ' class="nested"';
321 $return .= '>' . "\n";
323 $return .= '</div>' . "\n";
324 $return .= '</td>' . "\n";
327 $return .= '<td class="tg-middle" style="width:'.$width.'%;">' . "\n";
329 if ($selected == $i) {
330 $return .= ' class="selected"';
335 $return .= ' class="nested"';
337 $return .= '>' . "\n";
338 $return .= '<a href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>' . "\n";
340 $return .= '</div>' . "\n";
341 $return .= '</td>' . "\n";
344 // if the next tab is not selected, close this tab
345 if ($selected != $i+1) {
346 $return .= '<td class="tg-right">' . "\n";
348 if ($selected == $i) {
349 $return .= ' class="selected"';
354 $return .= ' class="nested"';
356 $return .= '>' . "\n";
358 $return .= '</div>' . "\n";
359 $return .= '</td>' . "\n";
363 // create a partial tab if there is any rest-width
364 if ($rest_width > 0) {
366 $return .= '<td class="tg-left">' . "\n";
367 $return .= '<div><div' . ($nested ? ' class="nested"' : '') . ">\n";
368 $return .= '</div></div>' . "\n";
369 $return .= '</td>' . "\n";
371 $return .= '<td class="tg-middle" style="width:'.$rest_width.'%;">' . "\n";
372 $return .= '<div><div' . ($nested ? ' class="nested"' : '') . ">\n";
373 $return .= '</div></div>' . "\n";
374 $return .= '</td>' . "\n";
384 function searchBox() {
385 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
387 if(get_magic_quotes_gpc()) {
388 $defaultWords = stripslashes($words);
390 $defaultWords = $words;
393 // if there is no search currently, set the default
394 if ( ! isset($type_of_search) ) {
399 <form id="searchBox" action="'.util_make_url ('/search/').'" method="get">
402 SEARCH__PARAMETER_GROUP_ID => $group_id,
403 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
404 SEARCH__PARAMETER_FORUM_ID => $forum_id,
405 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
408 $searchManager =& getSearchManager();
409 $searchManager->setParametersValues($parameters);
410 $searchEngines =& $searchManager->getAvailableSearchEngines();
413 <label for="searchBox-words">
414 <select name="type_of_search">';
415 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
416 $searchEngine =& $searchEngines[$i];
417 echo '<option class="ff" value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
419 echo '</select></label>';
421 $parameters = $searchManager->getParameters();
422 foreach($parameters AS $name => $value) {
423 print '<input class="ff" type="hidden" value="'.$value.'" name="'.$name.'" />';
425 print '<input type="text" size="12" id="searchBox-words" name="words" value="'.$defaultWords.'" />';
426 print '<input type="submit" name="Search" value="'._('Search').'" />';
428 if (isset($group_id) && $group_id) {
429 print util_make_link ('/search/advanced_search.php?group_id='.$group_id, _('Advanced search'), array('class'=>'userlink'));
436 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
437 // display the searchmask
439 <form class="ff" name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
440 <input class="ff" type="hidden" name="search" value="1"/>
441 <input class="ff" type="hidden" name="group_id" value="'.$group_id.'"/>
442 <div align="center"><br />
445 <td class="ff" colspan ="2">
446 <input class="ff" type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
447 <input class="ff" type="submit" name="submitbutton" value="'._('Search').'" />
451 <td class="ff" valign="top">
452 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
455 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
458 </table><br /></div>'
459 .$this->createUnderSections($sectionsArray).'
463 //create javascript methods for select none/all
465 <script type="text/javascript">
466 <!-- method for disable/enable checkboxes
467 function setCheckBoxes(parent, checked) {
470 for (var i = 0; i < document.advancedsearch.elements.length; i++)
471 if (document.advancedsearch.elements[i].type == "checkbox")
472 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
473 document.advancedsearch.elements[i].checked = checked;
481 function createUnderSections($sectionsArray) {
482 global $group_subsection_names;
484 foreach ($sectionsArray as $section) {
485 if(is_array($section)) {
486 $countLines += (3 + count ($section));
488 //2 lines one for section name and one for checkbox
492 $breakLimit = round($countLines/3);
493 $break = $breakLimit;
496 <table width="99%" border="0" cellspacing="0" cellpadding="1" style="background-color:'. $this->COLOR_LTBACK2.'">
499 <table width="100%" cellspacing="0" border="0" style="background-color:'. $this->COLOR_LTBACK1.'">
500 <tr class="ff" style="font-weight: bold;background-color:'. $this->COLOR_LTBACK2 .'">
501 <td class="ff" colspan="2">'._('Search in').'</td>
502 <td class="ff" style="text-align:right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
504 <tr class="ff" height="20">
505 <td class="ff" colspan="3"> </td>
507 <tr class="ff" align="center" valign="top">
509 foreach($sectionsArray as $key => $section) {
510 $oldcountlines = $countLines;
511 if (is_array($section)) {
512 $countLines += (3 + count ($section));
517 if ($countLines >= $break) {
518 //if the next block is so large that shifting it to the next column hits the breakpoint better
519 //the second part of statement (behind &&) proofs, that no 4th column is added
520 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
521 $return .= '</td><td class="ff">';
522 $break += $breakLimit;
526 $return .= '<table style="width:90%; background-color:'. $this->COLOR_LTBACK2.'">
529 <table style="width:100%;">
530 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK2 .'; font-weight: bold">
532 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
534 <td class="ff" style="text-align:right">'
535 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
538 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK1.'">
539 <td class="ff" colspan="2">';
541 if (!is_array($section)) {
542 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key).'"';
543 if (isset($GLOBALS[urlencode($key)]))
544 $return .= ' checked="checked" ';
545 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
548 foreach($section as $underkey => $undersection) {
549 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key.$underkey).'"';
550 if (isset($GLOBALS[urlencode($key.$underkey)]))
551 $return .= ' checked ';
552 $return .= '></input>'.$undersection.'<br />';
558 </table></td></tr></table><br />';
560 if ($countLines >= $break) {
561 if (($countLines - $break) < ($break - $countLines)) {
562 $return .= '</td><td class="ff" width="33%">';
563 $break += $breakLimit;
568 return $return.' </td>
570 </table></td></tr></table>';
574 * beginSubMenu() - Opening a submenu.
576 * @return string Html to start a submenu.
578 function beginSubMenu () {
585 * endSubMenu() - Closing a submenu.
587 * @return string Html to end a submenu.
589 function endSubMenu () {
590 $return = '</strong></p>';
595 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
597 * @param array The array of titles.
598 * @param array The array of title links.
599 * @return string Html to build a submenu.
601 function printSubMenu ($title_arr,$links_arr) {
602 $count=count($title_arr);
607 for ($i=0; $i<$count; $i++) {
608 $return .= util_make_link ($links_arr[$i], $title_arr[$i]) . ' | ';
610 $return .= util_make_link ($links_arr[$i], $title_arr[$i]);
615 * subMenu() - Takes two array of titles and links and build a menu.
617 * @param array The array of titles.
618 * @param array The array of title links.
619 * @return string Html to build a submenu.
621 function subMenu ($title_arr,$links_arr) {
622 $return = $this->beginSubMenu () ;
623 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
624 $return .= $this->endSubMenu () ;
629 * multiTableRow() - create a mutlilevel row in a table
631 * @param string the row attributes
632 * @param array the array of cell data, each element is an array,
633 * the first item being the text,
634 * the subsequent items are attributes (dont include
635 * the bgcolor for the title here, that will be
636 * handled by $istitle
637 * @param boolean is this row part of the title ?
640 function multiTableRow($row_attr, $cell_data, $istitle) {
642 <tr class="ff" '.$row_attr;
644 $return .=' align="center" bgcolor="'. $this->COLOR_HTMLBOX_TITLE .'"';
647 for ( $c = 0; $c < count($cell_data); $c++ ) {
648 $return .='<td class="ff" ';
649 for ( $a=1; $a < count($cell_data[$c]); $a++) {
650 $return .= $cell_data[$c][$a].' ';
654 $return .='<font color="'.$this->FONTCOLOR_HTMLBOX_TITLE.'"><strong>';
656 $return .= $cell_data[$c][0];
658 $return .='</strong></font>';
670 * feedback() - returns the htmlized feedback string when an action is performed.
672 * @param string feedback string
673 * @return string htmlized feedback
675 function feedback($feedback) {
680 <h3 style="color:red">'.strip_tags($feedback, '<br>').'</h3>';
685 * getThemeIdFromName()
687 * @param string the dirname of the theme
688 * @return integer the theme id
690 function getThemeIdFromName($dirname) {
691 $res=db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
693 return db_result($res,0,'theme_id');
699 // c-file-style: "bsd"