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']);
124 function bodyFooter($params) {
128 function footer($params) {
130 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
131 <div class="align-right">
132 <a href="http://fusionforge.org/">
133 <img src="'. util_make_url ('/images/pow-fusionforge.png') .'" alt="Powered By FusionForge" />
137 global $sys_show_source;
138 if ($sys_show_source) {
140 print util_make_link ('/source.php?file=' . $SCRIPT_NAME, _('Show source'), array ("class" => "showsource"));
149 function headerCSS() {
151 <link href="http://yui.yahooapis.com/2.6.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css" rel="stylesheet" />
152 <link href="http://yui.yahooapis.com/2.6.0/build/base/base-min.css" type="text/css" rel="stylesheet" />
153 <link rel="stylesheet" type="text/css" href="'. util_make_url ('/themes/css/fusionforge.css') .'" />
154 <link rel="stylesheet" type="text/css" href="'. THEME_DIR .'/css/theme.css" />
155 <link rel="stylesheet" type="text/css" href="'. THEME_DIR .'/css/theme-pages.css" />
158 plugin_hook ('cssfile',$this);
161 function getRootIndex() {
162 return $this->rootindex;
166 * boxTop() - Top HTML box
168 * @param string Box title
169 * @param bool Whether to echo or return the results
170 * @param string The box background color
172 function boxTop($title, $id = '') {
174 <div id="' . $this->toSlug($id) . '" class="box-surround">
175 <div id="'. $this->toSlug($id) . '-title" class="box-title">
176 <div class="box-title-left">
177 <div class="box-title-right">
178 <h3 class="box-title-content" id="'. $this->toSlug($id) .'-title-content">'. $title .'</h3>
182 <div id="'. $this->toSlug($id) .'-content" class="box-content">
188 * boxMiddle() - Middle HTML box
190 * @param string Box title
191 * @param string The box background color
193 function boxMiddle($title, $id = '') {
195 </div> <!-- class="box-content" -->
196 <h3 id="title-'. $this->toSlug($id).'" class="box-middle">'.$title.'</h3>
197 <div class="box-content">
203 * boxBottom() - Bottom HTML box
206 function boxBottom() {
209 </div> <!-- class="box-surround" -->
215 * boxGetAltRowStyle() - Get an alternating row style for tables
217 * @param int Row number
219 function boxGetAltRowStyle($i) {
221 return 'class="bgcolor-white"';
223 return 'class="bgcolor-grey"';
228 * listTableTop() - Takes an array of titles and builds the first row of a new table.
230 * @param array The array of titles
231 * @param array The array of title links
232 * @param boolean Whether to highlight or not the entry
234 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
235 $return = '<table class="width-100p100 listTable';
236 if ($selected == true) {
237 $return .= ' selected';
242 $count=count($title_arr);
244 for ($i=0; $i<$count; $i++) {
246 <th scope="col"><a class="sortbutton" href="'.util_make_url ($links_arr[$i]).'"><strong>'.$title_arr[$i].'</strong></a></th>';
249 for ($i=0; $i<$count; $i++) {
251 <th scope="col"><strong>'.$title_arr[$i].'</strong></th>';
254 return $return.'</tr>';
257 function listTableBottom() {
263 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='WHITE',$total_width='100%') {
264 $count=count($TABS_DIRS);
265 $width=intval((100/$count));
269 <table class="tabGenerator width-100p100" summary="" ';
271 if ($total_width != '100%') {
272 $return .= 'style="width:' . $total_width . ';"';
277 $folder = $this->imgroot.($nested ? 'bottomtab-new/' : 'toptab-new/');
279 for ($i=0; $i<$count; $i++) {
280 if ($selected == $i) {
281 $left_img = $folder.'selected-left.gif';
282 $middle_img = $folder.'selected-middle.gif';
283 $right_img = $folder.'selected-right.gif';
284 $separ_img = $folder.'selected-separator.gif';
285 $css_class = $nested ? 'bottomTabSelected' : 'topTabSelected';
287 $left_img = $folder.'left.gif';
288 $middle_img = $folder.'middle.gif';
289 $right_img = $folder.'right.gif';
290 $separ_img = $folder.'separator.gif';
291 $css_class = $nested ? 'bottomTab' : 'topTab';
294 $clear_img = $this->imgroot.'clear.png';
299 $return .= '<td class="tg-left">' . "\n";
301 if ($selected == $i) {
302 $return .= ' class="selected"';
308 $return .= ' class="nested"';
310 $return .= '>' . "\n";
312 $return .= '</div>' . "\n";
313 $return .= '</td>' . "\n";
316 $return .= '<td class="tg-middle" style="width:'.$width.'%;">' . "\n";
318 if ($selected == $i) {
319 $return .= ' class="selected"';
324 $return .= ' class="nested"';
326 $return .= '>' . "\n";
327 $return .= '<a href="'.$TABS_DIRS[$i].'">'.$TABS_TITLES[$i].'</a>' . "\n";
329 $return .= '</div>' . "\n";
330 $return .= '</td>' . "\n";
333 // if the next tab is not selected, close this tab
334 if ($selected != $i+1) {
335 $return .= '<td class="tg-right">' . "\n";
337 if ($selected == $i) {
338 $return .= ' class="selected"';
343 $return .= ' class="nested"';
345 $return .= '>' . "\n";
347 $return .= '</div>' . "\n";
348 $return .= '</td>' . "\n";
359 function searchBox() {
360 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
362 if(get_magic_quotes_gpc()) {
363 $defaultWords = stripslashes($words);
365 $defaultWords = $words;
368 // if there is no search currently, set the default
369 if ( ! isset($type_of_search) ) {
374 <form id="searchBox" action="'.util_make_url ('/search/').'" method="get">
377 SEARCH__PARAMETER_GROUP_ID => $group_id,
378 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
379 SEARCH__PARAMETER_FORUM_ID => $forum_id,
380 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
383 $searchManager =& getSearchManager();
384 $searchManager->setParametersValues($parameters);
385 $searchEngines =& $searchManager->getAvailableSearchEngines();
388 <label for="searchBox-words">
389 <select name="type_of_search">';
390 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
391 $searchEngine =& $searchEngines[$i];
392 echo '<option class="ff" value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
394 echo '</select></label>';
396 $parameters = $searchManager->getParameters();
397 foreach($parameters AS $name => $value) {
398 print '<input class="ff" type="hidden" value="'.$value.'" name="'.$name.'" />';
400 print '<input type="text" size="12" id="searchBox-words" name="words" value="'.$defaultWords.'" />';
401 print '<input type="submit" name="Search" value="'._('Search').'" />';
403 if (isset($group_id) && $group_id) {
404 print util_make_link ('/search/advanced_search.php?group_id='.$group_id, _('Advanced search'), array('class'=>'userlink'));
411 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
412 // display the searchmask
414 <form class="ff" name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
415 <input class="ff" type="hidden" name="search" value="1"/>
416 <input class="ff" type="hidden" name="group_id" value="'.$group_id.'"/>
417 <div align="center"><br />
420 <td class="ff" colspan ="2">
421 <input class="ff" type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
422 <input class="ff" type="submit" name="submitbutton" value="'._('Search').'" />
426 <td class="ff" valign="top">
427 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
430 <input class="ff" type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
433 </table><br /></div>'
434 .$this->createUnderSections($sectionsArray).'
438 //create javascript methods for select none/all
440 <script type="text/javascript">
441 <!-- method for disable/enable checkboxes
442 function setCheckBoxes(parent, checked) {
445 for (var i = 0; i < document.advancedsearch.elements.length; i++)
446 if (document.advancedsearch.elements[i].type == "checkbox")
447 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
448 document.advancedsearch.elements[i].checked = checked;
456 function createUnderSections($sectionsArray) {
457 global $group_subsection_names;
459 foreach ($sectionsArray as $section) {
460 if(is_array($section)) {
461 $countLines += (3 + count ($section));
463 //2 lines one for section name and one for checkbox
467 $breakLimit = round($countLines/3);
468 $break = $breakLimit;
471 <table width="99%" border="0" cellspacing="0" cellpadding="1" style="background-color:'. $this->COLOR_LTBACK2.'">
474 <table width="100%" cellspacing="0" border="0" style="background-color:'. $this->COLOR_LTBACK1.'">
475 <tr class="ff" style="font-weight: bold;background-color:'. $this->COLOR_LTBACK2 .'">
476 <td class="ff" colspan="2">'._('Search in').'</td>
477 <td class="ff" style="text-align:right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
479 <tr class="ff" height="20">
480 <td class="ff" colspan="3"> </td>
482 <tr class="ff" align="center" valign="top">
484 foreach($sectionsArray as $key => $section) {
485 $oldcountlines = $countLines;
486 if (is_array($section)) {
487 $countLines += (3 + count ($section));
492 if ($countLines >= $break) {
493 //if the next block is so large that shifting it to the next column hits the breakpoint better
494 //the second part of statement (behind &&) proofs, that no 4th column is added
495 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
496 $return .= '</td><td class="ff">';
497 $break += $breakLimit;
501 $return .= '<table style="width:90%; background-color:'. $this->COLOR_LTBACK2.'">
504 <table style="width:100%;">
505 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK2 .'; font-weight: bold">
507 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
509 <td class="ff" style="text-align:right">'
510 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
513 <tr class="ff" style="background-color:'. $this->COLOR_LTBACK1.'">
514 <td class="ff" colspan="2">';
516 if (!is_array($section)) {
517 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key).'"';
518 if (isset($GLOBALS[urlencode($key)]))
519 $return .= ' checked="checked" ';
520 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
523 foreach($section as $underkey => $undersection) {
524 $return .= ' <input class="ff" type="checkbox" name="'.urlencode($key.$underkey).'"';
525 if (isset($GLOBALS[urlencode($key.$underkey)]))
526 $return .= ' checked ';
527 $return .= '></input>'.$undersection.'<br />';
533 </table></td></tr></table><br />';
535 if ($countLines >= $break) {
536 if (($countLines - $break) < ($break - $countLines)) {
537 $return .= '</td><td class="ff" width="33%">';
538 $break += $breakLimit;
543 return $return.' </td>
545 </table></td></tr></table>';
549 * beginSubMenu() - Opening a submenu.
551 * @return string Html to start a submenu.
553 function beginSubMenu () {
560 * endSubMenu() - Closing a submenu.
562 * @return string Html to end a submenu.
564 function endSubMenu () {
565 $return = '</strong></p>';
570 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
572 * @param array The array of titles.
573 * @param array The array of title links.
574 * @return string Html to build a submenu.
576 function printSubMenu ($title_arr,$links_arr) {
577 $count=count($title_arr);
582 for ($i=0; $i<$count; $i++) {
583 $return .= util_make_link ($links_arr[$i], $title_arr[$i]) . ' | ';
585 $return .= util_make_link ($links_arr[$i], $title_arr[$i]);
590 * subMenu() - Takes two array of titles and links and build a menu.
592 * @param array The array of titles.
593 * @param array The array of title links.
594 * @return string Html to build a submenu.
596 function subMenu ($title_arr,$links_arr) {
597 $return = $this->beginSubMenu () ;
598 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
599 $return .= $this->endSubMenu () ;
604 * multiTableRow() - create a mutlilevel row in a table
606 * @param string the row attributes
607 * @param array the array of cell data, each element is an array,
608 * the first item being the text,
609 * the subsequent items are attributes (dont include
610 * the bgcolor for the title here, that will be
611 * handled by $istitle
612 * @param boolean is this row part of the title ?
615 function multiTableRow($row_attr, $cell_data, $istitle) {
617 <tr class="ff" '.$row_attr;
619 $return .=' align="center" bgcolor="'. $this->COLOR_HTMLBOX_TITLE .'"';
622 for ( $c = 0; $c < count($cell_data); $c++ ) {
623 $return .='<td class="ff" ';
624 for ( $a=1; $a < count($cell_data[$c]); $a++) {
625 $return .= $cell_data[$c][$a].' ';
629 $return .='<font color="'.$this->FONTCOLOR_HTMLBOX_TITLE.'"><strong>';
631 $return .= $cell_data[$c][0];
633 $return .='</strong></font>';
645 * feedback() - returns the htmlized feedback string when an action is performed.
647 * @param string feedback string
648 * @return string htmlized feedback
650 function feedback($feedback) {
655 <h3 style="color:red">'.strip_tags($feedback, '<br>').'</h3>';
660 * getThemeIdFromName()
662 * @param string the dirname of the theme
663 * @return integer the theme id
665 function getThemeIdFromName($dirname) {
666 $res=db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
668 return db_result($res,0,'theme_id');
674 // c-file-style: "bsd"