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);
273 <table class="tabGenerator width-100p100" summary="" ';
275 if ($total_width != '100%') {
276 $return .= 'style="width:' . $total_width . ';"';
281 $folder = $this->imgroot.($nested ? 'bottomtab-new/' : 'toptab-new/');
283 $accumulated_width = 0;
284 for ($i=0; $i<$count; $i++) {
285 $tabwidth = intval(ceil(($i+1)*100/$count)) - $accumulated_width ;
286 $accumulated_width += $tabwidth ;
288 if ($selected == $i) {
289 $left_img = $folder.'selected-left.gif';
290 $middle_img = $folder.'selected-middle.gif';
291 $right_img = $folder.'selected-right.gif';
292 $separ_img = $folder.'selected-separator.gif';
293 $css_class = $nested ? 'bottomTabSelected' : 'topTabSelected';
295 $left_img = $folder.'left.gif';
296 $middle_img = $folder.'middle.gif';
297 $right_img = $folder.'right.gif';
298 $separ_img = $folder.'separator.gif';
299 $css_class = $nested ? 'bottomTab' : 'topTab';
302 $clear_img = $this->imgroot.'clear.png';
307 $return .= '<td class="tg-left">' . "\n";
309 if ($selected == $i) {
310 $return .= ' class="selected"';
316 $return .= ' class="nested"';
318 $return .= '>' . "\n";
320 $return .= '</div>' . "\n";
321 $return .= '</td>' . "\n";
324 $return .= '<td class="tg-middle" style="width:'.$tabwidth.'%;">' . "\n";
326 if ($selected == $i) {
327 $return .= ' class="selected"';
332 $return .= ' class="nested"';
334 $return .= '>' . "\n";
335 $return .= '<a href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>' . "\n";
337 $return .= '</div>' . "\n";
338 $return .= '</td>' . "\n";
341 // if the next tab is not selected, close this tab
342 if ($selected != $i+1) {
343 $return .= '<td class="tg-right">' . "\n";
345 if ($selected == $i) {
346 $return .= ' class="selected"';
351 $return .= ' class="nested"';
353 $return .= '>' . "\n";
355 $return .= '</div>' . "\n";
356 $return .= '</td>' . "\n";
367 function searchBox() {
368 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
370 if(get_magic_quotes_gpc()) {
371 $defaultWords = stripslashes($words);
373 $defaultWords = $words;
376 // if there is no search currently, set the default
377 if ( ! isset($type_of_search) ) {
382 <form id="searchBox" action="'.util_make_url ('/search/').'" method="get">
385 SEARCH__PARAMETER_GROUP_ID => $group_id,
386 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
387 SEARCH__PARAMETER_FORUM_ID => $forum_id,
388 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
391 $searchManager =& getSearchManager();
392 $searchManager->setParametersValues($parameters);
393 $searchEngines =& $searchManager->getAvailableSearchEngines();
396 <label for="searchBox-words">
397 <select name="type_of_search">';
398 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
399 $searchEngine =& $searchEngines[$i];
400 echo '<option class="ff" value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
402 echo '</select></label>';
404 $parameters = $searchManager->getParameters();
405 foreach($parameters AS $name => $value) {
406 print '<input class="ff" type="hidden" value="'.$value.'" name="'.$name.'" />';
408 print '<input type="text" size="12" id="searchBox-words" name="words" value="'.$defaultWords.'" />';
409 print '<input type="submit" name="Search" value="'._('Search').'" />';
411 if (isset($group_id) && $group_id) {
412 print util_make_link ('/search/advanced_search.php?group_id='.$group_id, _('Advanced search'), array('class'=>'userlink'));
419 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
420 // display the searchmask
422 <form class="ff" name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
423 <input class="ff" type="hidden" name="search" value="1"/>
424 <input class="ff" type="hidden" name="group_id" value="'.$group_id.'"/>
425 <div align="center"><br />
428 <td class="ff" colspan ="2">
429 <input class="ff" type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
430 <input class="ff" type="submit" name="submitbutton" value="'._('Search').'" />
434 <td class="ff" valign="top">
435 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
438 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
441 </table><br /></div>'
442 .$this->createUnderSections($sectionsArray).'
446 //create javascript methods for select none/all
448 <script type="text/javascript">
449 <!-- method for disable/enable checkboxes
450 function setCheckBoxes(parent, checked) {
453 for (var i = 0; i < document.advancedsearch.elements.length; i++)
454 if (document.advancedsearch.elements[i].type == "checkbox")
455 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
456 document.advancedsearch.elements[i].checked = checked;
464 function createUnderSections($sectionsArray) {
465 global $group_subsection_names;
467 foreach ($sectionsArray as $section) {
468 if(is_array($section)) {
469 $countLines += (3 + count ($section));
471 //2 lines one for section name and one for checkbox
475 $breakLimit = round($countLines/3);
476 $break = $breakLimit;
479 <table width="99%" border="0" cellspacing="0" cellpadding="1" style="background-color:'. $this->COLOR_LTBACK2.'">
482 <table width="100%" cellspacing="0" border="0" style="background-color:'. $this->COLOR_LTBACK1.'">
483 <tr class="ff" style="font-weight: bold;background-color:'. $this->COLOR_LTBACK2 .'">
484 <td class="ff" colspan="2">'._('Search in').'</td>
485 <td class="ff" style="text-align:right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
487 <tr class="ff" height="20">
488 <td class="ff" colspan="3"> </td>
490 <tr class="ff" align="center" valign="top">
492 foreach($sectionsArray as $key => $section) {
493 $oldcountlines = $countLines;
494 if (is_array($section)) {
495 $countLines += (3 + count ($section));
500 if ($countLines >= $break) {
501 //if the next block is so large that shifting it to the next column hits the breakpoint better
502 //the second part of statement (behind &&) proofs, that no 4th column is added
503 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
504 $return .= '</td><td class="ff">';
505 $break += $breakLimit;
509 $return .= '<table style="width:90%; background-color:'. $this->COLOR_LTBACK2.'">
512 <table style="width:100%;">
513 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK2 .'; font-weight: bold">
515 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
517 <td class="ff" style="text-align:right">'
518 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
521 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK1.'">
522 <td class="ff" colspan="2">';
524 if (!is_array($section)) {
525 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key).'"';
526 if (isset($GLOBALS[urlencode($key)]))
527 $return .= ' checked="checked" ';
528 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
531 foreach($section as $underkey => $undersection) {
532 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key.$underkey).'"';
533 if (isset($GLOBALS[urlencode($key.$underkey)]))
534 $return .= ' checked ';
535 $return .= '></input>'.$undersection.'<br />';
541 </table></td></tr></table><br />';
543 if ($countLines >= $break) {
544 if (($countLines - $break) < ($break - $countLines)) {
545 $return .= '</td><td class="ff" width="33%">';
546 $break += $breakLimit;
551 return $return.' </td>
553 </table></td></tr></table>';
557 * beginSubMenu() - Opening a submenu.
559 * @return string Html to start a submenu.
561 function beginSubMenu () {
568 * endSubMenu() - Closing a submenu.
570 * @return string Html to end a submenu.
572 function endSubMenu () {
573 $return = '</strong></p>';
578 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
580 * @param array The array of titles.
581 * @param array The array of title links.
582 * @return string Html to build a submenu.
584 function printSubMenu ($title_arr,$links_arr) {
585 $count=count($title_arr);
590 for ($i=0; $i<$count; $i++) {
591 $return .= util_make_link ($links_arr[$i], $title_arr[$i]) . ' | ';
593 $return .= util_make_link ($links_arr[$i], $title_arr[$i]);
598 * subMenu() - Takes two array of titles and links and build a menu.
600 * @param array The array of titles.
601 * @param array The array of title links.
602 * @return string Html to build a submenu.
604 function subMenu ($title_arr,$links_arr) {
605 $return = $this->beginSubMenu () ;
606 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
607 $return .= $this->endSubMenu () ;
612 * multiTableRow() - create a mutlilevel row in a table
614 * @param string the row attributes
615 * @param array the array of cell data, each element is an array,
616 * the first item being the text,
617 * the subsequent items are attributes (dont include
618 * the bgcolor for the title here, that will be
619 * handled by $istitle
620 * @param boolean is this row part of the title ?
623 function multiTableRow($row_attr, $cell_data, $istitle) {
625 <tr class="ff" '.$row_attr;
627 $return .=' align="center" bgcolor="'. $this->COLOR_HTMLBOX_TITLE .'"';
630 for ( $c = 0; $c < count($cell_data); $c++ ) {
631 $return .='<td class="ff" ';
632 for ( $a=1; $a < count($cell_data[$c]); $a++) {
633 $return .= $cell_data[$c][$a].' ';
637 $return .='<font color="'.$this->FONTCOLOR_HTMLBOX_TITLE.'"><strong>';
639 $return .= $cell_data[$c][0];
641 $return .='</strong></font>';
653 * feedback() - returns the htmlized feedback string when an action is performed.
655 * @param string feedback string
656 * @return string htmlized feedback
658 function feedback($feedback) {
663 <h3 style="color:red">'.strip_tags($feedback, '<br>').'</h3>';
668 * getThemeIdFromName()
670 * @param string the dirname of the theme
671 * @return integer the theme id
673 function getThemeIdFromName($dirname) {
674 $res=db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
676 return db_result($res,0,'theme_id');
682 // c-file-style: "bsd"