5 * Extends the basic Error class to add HTML functions
6 * for displaying all site dependent HTML, while allowing
7 * extendibility/overriding by themes via the Theme class.
9 * Make sure browser.php is included _before_ you create an instance
12 * Geoffrey Herteg, August 29, 2000
16 require_once $gfcommon.'include/constants.php';
17 require_once $gfcommon.'include/Navigation.class.php';
19 class Layout extends Error {
22 * Which doctype to use. Can be configured in the
23 * constructor. If set to 'strict', headerHTMLDeclaration will
24 * create a doctype definition that uses the strict doctype,
25 * otherwise it will use the transitional doctype.
26 * @var string $doctype
28 var $doctype = 'transitional';
31 * Which cssfiles to use. Can be configured in the
34 * @var array $cssurls is a list of urls that should point to
35 * the used stylesheets.
40 * The default main page content
41 * @var string $rootindex
43 var $rootindex = 'index_std.php';
46 * The base directory of the theme in the servers file system
47 * @var string $themedir
52 * The base url of the theme
53 * @var string $themeurl
58 * The base directory of the css files in the servers file system
64 * The base url of the css files
65 * @var string $cssbaseurl
70 * The base directory of the image files in the servers file system
76 * The base url of the image files
77 * @var string $imgbaseurl
82 * The base directory of the js files in the servers file system
88 * The base url of the js files
89 * @var string $jsbaseurl
94 * kept for backwards compatibility
97 * The base directory of the theme
98 * @var string $themeroot
99 * @todo: remove in 5.0
100 * @deprecated deprecated since 4.9
105 * The base directory of the theme
106 * @var string $themeroot
107 * @todo: remove in 5.0
108 * @deprecated deprecated since 4.9
113 * The navigation object that provides the basic links. Should
120 * Layout() - Constructor
123 // parent constructor
126 $this->navigation = new Navigation();
128 // determine rootindex
129 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
130 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
132 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
135 // determine theme{dir,url}
136 $this->themedir = forge_get_config('themes_root') . forge_get_config('default_theme') . '/';
137 if (!file_exists ($this->themedir)) {
138 html_error_top(_("Can't find theme directory!"));
141 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
143 // determine {css,img,js}{url,dir}
144 if (file_exists ($this->themedir . 'css/')) {
145 $this->cssdir = $this->themedir . 'css/';
146 $this->cssbaseurl = $this->themeurl . 'css/';
148 $this->cssdir = $this->themedir;
149 $this->cssbaseurl = $this->themeurl;
152 if (file_exists ($this->themedir . 'images/')) {
153 $this->imgdir = $this->themedir . 'images/';
154 $this->imgbaseurl = $this->themeurl . 'images/';
156 $this->imgdir = $this->themedir;
157 $this->imgbaseurl = $this->themeurl;
160 if (file_exists ($this->themedir . 'js/')) {
161 $this->jsdir = $this->themedir . 'js/';
162 $this->jsbaseurl = $this->themeurl . 'js/';
164 $this->jsdir = $this->themedir;
165 $this->jsbaseurl = $this->themeurl;
168 // determine CSS stylesheets
169 $this->cssurls[] = util_make_url ('/themes/css/fusionforge.css');
171 /* check if a personalized css stylesheet exist, if yes include only
172 this stylesheet. New stylesheets should use the <themename>.css file.
174 $theme_cssfile = forge_get_config('default_theme') . '.css';
175 if (file_exists($this->cssdir . $theme_cssfile)) {
176 $this->cssurls[] = $this->cssbaseurl . $theme_cssfile;
178 /* if this is not the case, then include the compatibility stylesheet
179 that contains all removed styles from the code and check if a
180 custom stylesheet exists.
181 Used for compatibility with existing stylesheets
183 $this->cssurls[] = util_make_url('/themes/css/gforge-compat.css');
184 if (file_exists($this->cssdir . 'theme.css')) {
185 $this->cssurls[] = $this->cssbaseurl . 'theme.css';
189 // for backward compatibility
190 $this->themeroot = $this->themedir;
191 $this->imgroot = $this->imgbaseurl;
195 * header() - generates the complete header of page by calling
196 * headerStart() and bodyHeader().
198 function header($params) {
199 $this->headerStart($params); ?>
202 $this->bodyHeader($params);
207 * headerStart() - generates the header code for all themes up to the
209 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
210 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
211 * headerJS() to adapt your theme.
213 * @param array Header parameters array
215 function headerStart($params) {
216 $this->headerHTMLDeclaration();
219 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
221 $this->headerTitle($params);
222 $this->headerFavIcon();
224 $this->headerSearch();
233 * headerLink() - creates the link headers of the page (FavIcon, RSS and Search)
234 * @deprecated deprecated since 4.9, use the individual header-functions
235 * @todo remove in 5.0
237 function headerLink() {
238 $this->headerFavIcon();
240 $this->headerSearch();
244 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
245 * XML declaration, the doctype definition, and the opening <html>.
248 function headerHTMLDeclaration() {
249 print '<?xml version="1.0" encoding="utf-8"?>';
250 if ($this->doctype=='strict') {
251 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
253 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
255 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
256 . _('en') . '" lang="' . _('en') . '">';
260 * headerTitle() - creates the <title> header
262 * @param array Header parameters array
264 function headerTitle($params) {
265 echo $this->navigation->getTitle($params);
270 * headerFavIcon() - creates the favicon <link> headers
273 function headerFavIcon() {
274 echo $this->navigation->getFavIcon();
278 * headerRSS() - creates the RSS <link> headers
281 function headerRSS() {
282 echo $this->navigation->getRSS();
286 * headerSearch() - creates the search <link> header
289 function headerSearch() {
290 echo '<link rel="search" title="'
291 . forge_get_config ('forge_name').'" href="'
292 . util_make_url ('/export/search_plugin.php')
293 . '" type="application/opensearchdescription+xml"/>';
297 * Create the CSS headers for all cssfiles in $cssfiles and
298 * calls the plugin cssfile hook.
300 function headerCSS() {
301 // include the common css
302 foreach ($this->cssurls as $cssurl) {
303 echo '<link rel="stylesheet" type="text/css" href="' . $cssurl . '" />';
306 plugin_hook ('cssfile',$this);
310 * headerJS() - creates the JS headers and calls the plugin javascript hook
311 * @todo generalize this
313 function headerJS() {
315 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
316 <script type="text/javascript">';
317 plugin_hook ("javascript",false);
322 function bodyHeader($params){
325 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
327 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
328 <td><?php $this->searchBox(); ?></td>
329 <td align="right"><?php
330 $items = $this->navigation->getUserLinks();
331 for ($j = 0; $j < count($items['titles']); $j++) {
332 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
335 $params['template'] = ' {menu}';
336 plugin_hook ('headermenu', $params);
341 <td> </td>
346 <table border="0" width="100%" cellspacing="0" cellpadding="0">
352 <?php echo $this->outerTabs($params); ?>
359 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
360 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
361 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
362 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
363 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
368 <!-- Outer body row -->
370 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
371 <td valign="top" width="99%" class="toptab" colspan="3">
373 <!-- Inner Tabs / Shell -->
375 <table border="0" width="100%" cellspacing="0" cellpadding="0">
379 if (isset($params['group']) && $params['group']) {
387 echo $this->projectTabs($params['toptab'],$params['group']);
397 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
398 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
399 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
403 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
404 <td valign="top" width="99%" class="projecttab">
410 function footer($params) {
414 <!-- end main body row -->
418 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
421 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
422 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
423 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
427 <!-- end inner body row -->
430 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
433 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
434 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
435 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
439 $this->footerEnd($params);
442 function footerEnd($params) { ?>
444 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
446 <?php echo $this->navigation->getPoweredBy(); ?>
449 <?php echo $this->navigation->getShowSource(); ?>
458 function getRootIndex() {
459 return $this->rootindex;
463 * boxTop() - Top HTML box
465 * @param string Box title
466 * @param bool Whether to echo or return the results
467 * @param string The box background color
469 function boxTop($title) {
471 <!-- Box Top Start -->
473 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
474 <tr class="align-center">
475 <td valign="top" align="right" width="10" style="background:url('.$this->imgbaseurl.'box-topleft.png)"><img src="'.$this->imgbaseurl.'clear.png" width="10" height="20" alt="" /></td>
476 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
477 <td valign="top" width="10" style="background:url('.$this->imgbaseurl.'box-topright.png)"><img src="'.$this->imgbaseurl.'clear.png" width="10" height="20" alt="" /></td>
481 <table cellspacing="2" cellpadding="2" width="100%" border="0">
485 <!-- Box Top End -->';
489 * boxMiddle() - Middle HTML box
491 * @param string Box title
492 * @param string The box background color
494 function boxMiddle($title) {
496 <!-- Box Middle Start -->
499 <tr class="align-center">
500 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
504 <!-- Box Middle End -->';
508 * boxBottom() - Bottom HTML box
510 * @param bool Whether to echo or return the results
512 function boxBottom() {
514 <!-- Box Bottom Start -->
521 <!-- Box Bottom End -->';
525 * boxGetAltRowStyle() - Get an alternating row style for tables
527 * @param int Row number
529 function boxGetAltRowStyle($i) {
531 return ' class="altRowStyleEven"';
533 return ' class="altRowStyleOdd"';
538 * listTableTop() - Takes an array of titles and builds the first row of a new table.
540 * @param array The array of titles
541 * @param array The array of title links
543 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
545 <table cellspacing="0" cellpadding="0" width="100%" border="0">
546 <tr class="align-center">
547 <!-- <td valign="top" align="right" width="10" style="background:url('.$this->imgbaseurl.'box-grad.png)"><img src="'.$this->imgbaseurl.'box-topleft.png" width="10" height="75" alt="" /></td> -->
548 <td style="background:url('.$this->imgbaseurl.'box-grad.png)">
549 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
550 <tr class="tableheading">';
551 $count=count($title_arr);
553 for ($i=0; $i<$count; $i++) {
554 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
557 for ($i=0; $i<$count; $i++) {
559 <td>'.$title_arr[$i].'</td>';
562 return $return.'</tr>';
565 function listTableBottom() {
566 return '</table></td>
567 <!-- <td valign="top" align="right" width="10" style="background:url('.$this->imgbaseurl.'box-grad.png)"><img src="'.$this->imgbaseurl.'box-topright.png" width="10" height="75" alt="" /></td> -->
571 function outerTabs($params) {
572 $menu =& $this->navigation->getSiteMenu();
574 echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
579 * Prints out the quicknav menu, contained here in case we
580 * want to allow it to be overridden.
582 function quickNav() {
583 if (!session_loggedin()) {
586 // get all projects that the user belongs to
587 $res = db_query_params ('SELECT group_id FROM groups JOIN user_group USING (group_id) WHERE user_group.user_id=$1 AND groups.status=$2 ORDER BY group_name',
591 if (!$res || db_numrows($res) < 1) {
595 <form id="quicknavform" name="quicknavform" action=""><div>
596 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
597 <option value="">'._('Quick Jump To...').'</option>';
599 for ($i = 0; $i < db_numrows($res); $i++) {
600 $group_id = db_result($res, $i, 'group_id');
601 $menu =& $this->navigation->getProjectMenu($group_id);
604 <option value="' . $menu['starturl'] . '">'
605 . $menu['name'] .'</option>';
607 for ($j = 0; $j < count($menu['urls']); $j++) {
609 <option value="' . $menu['urls'][$j] .'"> '
610 . $menu['titles'][$j] . '</option>';
611 if ($menu['adminurls'][$j]) {
613 <option value="' . $menu['adminurls'][$j]
614 . '"> '
615 . _('Admin') . '</option>';
627 * projectTabs() - Prints out the project tabs, contained here in case
628 * we want to allow it to be overriden
630 * @param string Is the tab currently selected
631 * @param string Is the group we should look up get title info
633 function projectTabs($toptab, $group_id) {
634 // get group info using the common result set
635 $menu =& $this->navigation->getProjectMenu($group_id, $toptab);
637 echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
640 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
642 $count=count($TABS_DIRS);
643 $width=intval((100/$count));
648 <table class="tabGenerator" ';
650 if ($total_width != '100%') {
651 $return .= 'style="width:' . $total_width . ';"';
661 for ($i=0; $i<$count; $i++) {
664 // this is the first tab, choose an image with end-name
667 $issel=($selected==$i);
668 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
669 // $rowspan=(($issel)?'rowspan="2" ' : '');
672 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
673 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
674 '<td '.$rowspan.'style="background:url('.$this->imgbaseurl . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
675 } elseif ($i==$count-1) {
677 // this is the last tab, choose an image with name-end
679 $wassel=($selected==$i-1);
680 $issel=($selected==$i);
681 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
682 // $rowspan=(($issel)?'rowspan="2" ' : '');
684 // Build image between current and prior tab
687 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
688 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
689 '<td '.$rowspan.'style="background:url('.$this->imgbaseurl . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
691 // Last graphic on right-side
694 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
695 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
701 $wassel=($selected==$i-1);
702 $issel=($selected==$i);
703 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
704 // $rowspan=(($issel)?'rowspan="2" ' : '');
706 // Build image between current and prior tab
709 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
710 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
711 '<td '.$rowspan.'style="background:url('.$this->imgbaseurl . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
718 // Building a bottom row in this table, which will be darker
720 if ($selected == 0) {
722 $end_cols=((count($TABS_DIRS)*3)-3);
723 } elseif ($selected == (count($TABS_DIRS)-1)) {
724 $beg_cols=((count($TABS_DIRS)*3)-3);
727 $beg_cols=($selected*3);
728 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
732 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
734 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
736 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
748 function searchBox() {
749 echo $this->navigation->getSearchBox();
753 * beginSubMenu() - Opening a submenu.
755 * @return string Html to start a submenu.
757 function beginSubMenu () {
764 * endSubMenu() - Closing a submenu.
766 * @return string Html to end a submenu.
768 function endSubMenu () {
769 $return = '</strong></p>';
774 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
776 * @param array The array of titles.
777 * @param array The array of title links.
778 * @return string Html to build a submenu.
780 function printSubMenu ($title_arr,$links_arr) {
781 $count=count($title_arr);
785 for ($i=0; $i<$count; $i++) {
786 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
788 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
793 * subMenu() - Takes two array of titles and links and build a menu.
795 * @param array The array of titles.
796 * @param array The array of title links.
797 * @return string Html to build a submenu.
799 function subMenu ($title_arr,$links_arr) {
800 $return = $this->beginSubMenu () ;
801 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
802 $return .= $this->endSubMenu () ;
807 * multiTableRow() - create a mutlilevel row in a table
809 * @param string the row attributes
810 * @param array the array of cell data, each element is an array,
811 * the first item being the text,
812 * the subsequent items are attributes (dont include
813 * the bgcolor for the title here, that will be
814 * handled by $istitle
815 * @param boolean is this row part of the title ?
818 function multiTableRow($row_attr, $cell_data, $istitle) {
822 $return .=' class="align-center multiTableRowTitle"';
825 for ( $c = 0; $c < count($cell_data); $c++ ) {
827 for ( $a=1; $a < count($cell_data[$c]); $a++) {
828 $return .= $cell_data[$c][$a].' ';
832 $return .='<span class="multiTableRowTitle">';
834 $return .= $cell_data[$c][0];
848 * feedback() - returns the htmlized feedback string when an action is performed.
850 * @param string feedback string
851 * @return string htmlized feedback
853 function feedback($feedback) {
858 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
862 * warning_msg() - returns the htmlized warning string when an action is performed.
864 * @param string msg string
865 * @return string htmlized warning
867 function warning_msg($msg) {
872 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
877 * error_msg() - returns the htmlized error string when an action is performed.
879 * @param string msg string
880 * @return string htmlized error
882 function error_msg($msg) {
887 <div class="error">'.strip_tags($msg, '<br>').'</div>';
893 * getThemeIdFromName()
895 * @param string the dirname of the theme
896 * @return integer the theme id
898 function getThemeIdFromName($dirname) {
899 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
901 return db_result($res,0,'theme_id');
904 function confirmBox($msg, $params, $buttons, $image='*none*') {
905 if ($image == '*none*') {
906 $image = html_image('stop.png','48','48',array());
909 foreach ($params as $b => $v) {
910 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
912 $prm = join(' ', $prms);
914 foreach ($buttons as $b => $v) {
915 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
917 $btn = join(' '."\n ", $btns);
920 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
921 <table align="center">
924 <td>'.$msg.'<br/></td>
927 <td colspan="2" align="center">
929 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
940 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
944 $return = '<div class="field-holder">
947 $return .= '<label for="' . $id . '">' . $label . '</label>
950 $return .= '<input id="' . $id . '" type="' . $type . '"';
951 //if input is a submit then name is not present
953 $return .= ' name="' . $name . '"';
956 $return .= ' value="' . $value . '"';
958 if (is_array($extra_params)) {
959 foreach ($extra_params as $key => $extra_params_value) {
960 $return .= $key . '="' . $extra_params_value . '" ';
968 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
972 $return = '<div class="field-holder">
974 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
976 $return .= 'checked="checked" ';
978 if (is_array($extra_params)) {
979 foreach ($extra_params as $key => $extra_params_value) {
980 $return .= $key . '="' . $extra_params_value . '" ';
985 $return .= '<label for="' . $id . '">' . $label . '</label>
992 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1000 $img_alt = $img_title;
1002 $return = '<div class="field-holder">
1005 $return .= '<label for="' . $id . '">' . $label . '</label>
1008 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1010 $return .= ' value="' . $value . '"';
1012 if (is_array($extra_params)) {
1013 foreach ($extra_params as $key => $extra_params_value) {
1014 $return .= $key . '="' . $extra_params_value . '" ';
1018 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1019 if (is_array($img_extra_params)) {
1020 foreach ($img_extra_params as $key => $img_extra_params_value) {
1021 $return .= $key . '="' . $img_extra_params_value . '" ';
1029 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1033 $return = '<div class="field-holder">
1036 $return .= '<label for="' . $id . '">' . $label . '</label>
1039 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1040 if (is_array($extra_params)) {
1041 foreach ($extra_params as $key => $extra_params_value) {
1042 $return .= $key . '="' . $extra_params_value . '" ';
1046 $rows = count($vals);
1047 for ($i = 0; $i < $rows; $i++) {
1048 if ( $text_is_value ) {
1050 <option value="' . $vals[$i] . '"';
1051 if ($vals[$i] == $checked_val) {
1052 $return .= ' selected="selected"';
1056 <option value="' . $i . '"';
1057 if ($i == $checked_val) {
1058 $return .= ' selected="selected"';
1061 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1069 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1073 $return = '<div class="field-holder">
1076 $return .= '<label for="' . $id . '">' . $label . '</label>
1079 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1080 if (is_array($extra_params)) {
1081 foreach ($extra_params as $key => $extra_params_value) {
1082 $return .= $key . '="' . $extra_params_value . '" ';
1089 $return .= '</textarea>
1094 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1095 $return = '<table summary="' . $summary . '" ';
1097 $return .= 'class="' . $class . '" ';
1099 if (is_array($extra_params)) {
1100 foreach ($extra_params as $key => $extra_params_value) {
1101 $return .= $key . '="' . $extra_params_value . '" ';
1105 $return .= '<thead><tr>';
1106 $nbCols = count($cols);
1107 for ($i = 0; $i < $nbCols; $i++) {
1108 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1110 $return .= '</tr></thead>';
1114 function getMonitorPic($title = '', $alt = '') {
1115 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1118 function getReleaseNotesPic($title = '', $alt = '') {
1119 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1122 /* no picto for download */
1123 function getDownloadPic($title = '', $alt = '') {
1124 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1127 function getHomePic($title = '', $alt = '') {
1128 return $this->getPicto('ic/home16b.png', $title, $alt);
1131 function getFollowPic($title = '', $alt = '') {
1132 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1135 function getForumPic($title = '', $alt = '') {
1136 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1139 function getDocmanPic($title = '', $alt = '') {
1140 return $this->getPicto('ic/docman16b.png', $title, $alt);
1143 function getMailPic($title = '', $alt = '') {
1144 return $this->getPicto('ic/mail16b.png', $title, $alt);
1147 function getPmPic($title = '', $alt = '') {
1148 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1151 function getSurveyPic($title = '', $alt = '') {
1152 return $this->getPicto('ic/survey16b.png', $title, $alt);
1155 function getScmPic($title = '', $alt = '') {
1156 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1159 function getFtpPic($title = '', $alt = '') {
1160 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1163 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1167 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1171 * toSlug() - protect a string to be used as a link or an anchor
1173 * @param string $string the string used as a link or an anchor
1174 * @param string $space the caracter used as a replacement for a space
1175 * @return a protected string with only alphanumeric caracters
1177 function toSlug($string, $space = "-") {
1178 if (function_exists('iconv')) {
1179 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1181 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1182 $string = strtolower($string);
1183 $string = str_replace(" ", $space, $string);
1191 // c-file-style: "bsd"