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;
194 function addJavascript($js) {
195 if (isset($this->js_min[$js])) {
196 $js = $this->js_min[$js];
198 if (!isset($this->js[$js])) {
199 $this->js[$js] = true;
200 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
201 if (file_exists($filename)) {
202 $js .= '?'.date ("U", filemtime($filename));
204 echo '<script type="text/javascript" src="'.$js.'"></script>'."\n";
208 function addStylesheet($css, $media) {
209 if (isset($this->css_min[$css])) {
210 $css = $this->css_min[$css];
212 if (!isset($this->css[$css])) {
213 $this->css[$css] = true;
214 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
215 if (file_exists($filename)) {
216 $css .= '?'.date ("U", filemtime($filename));
219 $media = ' media="'.$media.'"';
221 echo ' <link rel="stylesheet" type="text/css" href="'.$css.'"'.$media.' />'."\n";
226 * header() - generates the complete header of page by calling
227 * headerStart() and bodyHeader().
229 function header($params) {
230 $this->headerStart($params); ?>
233 $this->bodyHeader($params);
238 * headerStart() - generates the header code for all themes up to the
240 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
241 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
242 * headerJS() to adapt your theme.
244 * @param array Header parameters array
246 function headerStart($params) {
247 $this->headerHTMLDeclaration();
250 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
252 $this->headerTitle($params);
253 $this->headerFavIcon();
255 $this->headerSearch();
264 * headerLink() - creates the link headers of the page (FavIcon, RSS and Search)
265 * @deprecated deprecated since 4.9, use the individual header-functions
266 * @todo remove in 5.0
268 function headerLink() {
269 $this->headerFavIcon();
271 $this->headerSearch();
275 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
276 * XML declaration, the doctype definition, and the opening <html>.
279 function headerHTMLDeclaration() {
280 print '<?xml version="1.0" encoding="utf-8"?>';
281 if ($this->doctype=='strict') {
282 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
284 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
286 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
287 . _('en') . '" lang="' . _('en') . '">';
291 * headerTitle() - creates the <title> header
293 * @param array Header parameters array
295 function headerTitle($params) {
296 echo $this->navigation->getTitle($params);
301 * headerFavIcon() - creates the favicon <link> headers
304 function headerFavIcon() {
305 echo $this->navigation->getFavIcon();
309 * headerRSS() - creates the RSS <link> headers
312 function headerRSS() {
313 echo $this->navigation->getRSS();
317 * headerSearch() - creates the search <link> header
320 function headerSearch() {
321 echo '<link rel="search" title="'
322 . forge_get_config ('forge_name').'" href="'
323 . util_make_url ('/export/search_plugin.php')
324 . '" type="application/opensearchdescription+xml"/>';
328 * Create the CSS headers for all cssfiles in $cssfiles and
329 * calls the plugin cssfile hook.
331 function headerCSS() {
332 // include the common css
333 foreach ($this->cssurls as $cssurl) {
334 echo '<link rel="stylesheet" type="text/css" href="' . $cssurl . '" />';
337 plugin_hook ('cssfile',$this);
341 * headerJS() - creates the JS headers and calls the plugin javascript hook
342 * @todo generalize this
344 function headerJS() {
346 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
347 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
348 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
349 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
350 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
351 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
352 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
353 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
354 <script type="text/javascript">';
355 plugin_hook ("javascript",false);
358 plugin_hook ("javascript_file",false);
361 function bodyHeader($params){
364 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
366 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
367 <td><?php $this->searchBox(); ?></td>
368 <td align="right"><?php
369 $items = $this->navigation->getUserLinks();
370 for ($j = 0; $j < count($items['titles']); $j++) {
371 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
374 $params['template'] = ' {menu}';
375 plugin_hook ('headermenu', $params);
380 <td> </td>
385 <table border="0" width="100%" cellspacing="0" cellpadding="0">
391 <?php echo $this->outerTabs($params); ?>
398 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
399 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
400 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
401 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
402 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
407 <!-- Outer body row -->
409 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
410 <td valign="top" width="99%" class="toptab" colspan="3">
412 <!-- Inner Tabs / Shell -->
414 <table border="0" width="100%" cellspacing="0" cellpadding="0">
418 if (isset($params['group']) && $params['group']) {
426 echo $this->projectTabs($params['toptab'],$params['group']);
436 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
437 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
438 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
442 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
443 <td valign="top" width="99%" class="projecttab">
449 function footer($params) {
453 <!-- end main body row -->
457 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
460 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
461 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
462 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
466 <!-- end inner body row -->
469 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
472 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
473 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
474 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
478 $this->footerEnd($params);
481 function footerEnd($params) { ?>
483 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
485 <?php echo $this->navigation->getPoweredBy(); ?>
488 <?php echo $this->navigation->getShowSource(); ?>
497 function getRootIndex() {
498 return $this->rootindex;
502 * boxTop() - Top HTML box
504 * @param string Box title
505 * @param bool Whether to echo or return the results
506 * @param string The box background color
508 function boxTop($title) {
510 <!-- Box Top Start -->
512 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
513 <tr class="align-center">
514 <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>
515 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
516 <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>
520 <table cellspacing="2" cellpadding="2" width="100%" border="0">
524 <!-- Box Top End -->';
528 * boxMiddle() - Middle HTML box
530 * @param string Box title
531 * @param string The box background color
533 function boxMiddle($title) {
535 <!-- Box Middle Start -->
538 <tr class="align-center">
539 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
543 <!-- Box Middle End -->';
547 * boxBottom() - Bottom HTML box
549 * @param bool Whether to echo or return the results
551 function boxBottom() {
553 <!-- Box Bottom Start -->
560 <!-- Box Bottom End -->';
564 * boxGetAltRowStyle() - Get an alternating row style for tables
566 * @param int Row number
568 function boxGetAltRowStyle($i) {
570 return ' class="altRowStyleEven"';
572 return ' class="altRowStyleOdd"';
577 * listTableTop() - Takes an array of titles and builds the first row of a new table.
579 * @param array The array of titles
580 * @param array The array of title links
582 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
584 <table cellspacing="0" cellpadding="0" width="100%" border="0">
585 <tr class="align-center">
586 <!-- <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> -->
587 <td style="background:url('.$this->imgbaseurl.'box-grad.png)">
588 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
589 <tr class="tableheading">';
590 $count=count($title_arr);
592 for ($i=0; $i<$count; $i++) {
593 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
596 for ($i=0; $i<$count; $i++) {
598 <td>'.$title_arr[$i].'</td>';
601 return $return.'</tr>';
604 function listTableBottom() {
605 return '</table></td>
606 <!-- <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> -->
610 function outerTabs($params) {
611 $menu = $this->navigation->getSiteMenu();
613 echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
618 * Prints out the quicknav menu, contained here in case we
619 * want to allow it to be overridden.
621 function quickNav() {
622 if (!session_loggedin()) {
625 // get all projects that the user belongs to
626 $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',
630 if (!$res || db_numrows($res) < 1) {
634 <form id="quicknavform" name="quicknavform" action=""><div>
635 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
636 <option value="">'._('Quick Jump To...').'</option>';
638 for ($i = 0; $i < db_numrows($res); $i++) {
639 $group_id = db_result($res, $i, 'group_id');
640 $menu =& $this->navigation->getProjectMenu($group_id);
643 <option value="' . $menu['starturl'] . '">'
644 . $menu['name'] .'</option>';
646 for ($j = 0; $j < count($menu['urls']); $j++) {
648 <option value="' . $menu['urls'][$j] .'"> '
649 . $menu['titles'][$j] . '</option>';
650 if (@$menu['adminurls'][$j]) {
652 <option value="' . $menu['adminurls'][$j]
653 . '"> '
654 . _('Admin') . '</option>';
666 * projectTabs() - Prints out the project tabs, contained here in case
667 * we want to allow it to be overriden
669 * @param string Is the tab currently selected
670 * @param string Is the group we should look up get title info
672 function projectTabs($toptab, $group_id) {
673 // get group info using the common result set
674 $menu =& $this->navigation->getProjectMenu($group_id, $toptab);
676 echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
679 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
681 $count=count($TABS_DIRS);
682 $width=intval((100/$count));
687 <table class="tabGenerator" ';
689 if ($total_width != '100%') {
690 $return .= 'style="width:' . $total_width . ';"';
700 for ($i=0; $i<$count; $i++) {
703 // this is the first tab, choose an image with end-name
706 $issel=($selected==$i);
707 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
708 // $rowspan=(($issel)?'rowspan="2" ' : '');
711 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
712 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
713 '<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>';
714 } elseif ($i==$count-1) {
716 // this is the last tab, choose an image with name-end
718 $wassel=($selected==$i-1);
719 $issel=($selected==$i);
720 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
721 // $rowspan=(($issel)?'rowspan="2" ' : '');
723 // Build image between current and prior tab
726 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
727 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
728 '<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>';
730 // Last graphic on right-side
733 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
734 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
740 $wassel=($selected==$i-1);
741 $issel=($selected==$i);
742 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
743 // $rowspan=(($issel)?'rowspan="2" ' : '');
745 // Build image between current and prior tab
748 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
749 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
750 '<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>';
757 // Building a bottom row in this table, which will be darker
759 if ($selected == 0) {
761 $end_cols=((count($TABS_DIRS)*3)-3);
762 } elseif ($selected == (count($TABS_DIRS)-1)) {
763 $beg_cols=((count($TABS_DIRS)*3)-3);
766 $beg_cols=($selected*3);
767 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
771 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
773 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
775 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
787 function searchBox() {
788 echo $this->navigation->getSearchBox();
792 * beginSubMenu() - Opening a submenu.
794 * @return string Html to start a submenu.
796 function beginSubMenu () {
803 * endSubMenu() - Closing a submenu.
805 * @return string Html to end a submenu.
807 function endSubMenu () {
808 $return = '</strong></p>';
813 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
815 * @param array The array of titles.
816 * @param array The array of title links.
817 * @return string Html to build a submenu.
819 function printSubMenu ($title_arr,$links_arr) {
820 $count=count($title_arr);
824 for ($i=0; $i<$count; $i++) {
825 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
827 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
832 * subMenu() - Takes two array of titles and links and build a menu.
834 * @param array The array of titles.
835 * @param array The array of title links.
836 * @return string Html to build a submenu.
838 function subMenu ($title_arr,$links_arr) {
839 $return = $this->beginSubMenu () ;
840 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
841 $return .= $this->endSubMenu () ;
846 * multiTableRow() - create a mutlilevel row in a table
848 * @param string the row attributes
849 * @param array the array of cell data, each element is an array,
850 * the first item being the text,
851 * the subsequent items are attributes (dont include
852 * the bgcolor for the title here, that will be
853 * handled by $istitle
854 * @param boolean is this row part of the title ?
857 function multiTableRow($row_attr, $cell_data, $istitle) {
861 $return .=' class="align-center multiTableRowTitle"';
864 for ( $c = 0; $c < count($cell_data); $c++ ) {
866 for ( $a=1; $a < count($cell_data[$c]); $a++) {
867 $return .= $cell_data[$c][$a].' ';
871 $return .='<span class="multiTableRowTitle">';
873 $return .= $cell_data[$c][0];
887 * feedback() - returns the htmlized feedback string when an action is performed.
889 * @param string feedback string
890 * @return string htmlized feedback
892 function feedback($feedback) {
897 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
901 * warning_msg() - returns the htmlized warning string when an action is performed.
903 * @param string msg string
904 * @return string htmlized warning
906 function warning_msg($msg) {
911 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
916 * error_msg() - returns the htmlized error string when an action is performed.
918 * @param string msg string
919 * @return string htmlized error
921 function error_msg($msg) {
926 <div class="error">'.strip_tags($msg, '<br>').'</div>';
932 * getThemeIdFromName()
934 * @param string the dirname of the theme
935 * @return integer the theme id
937 function getThemeIdFromName($dirname) {
938 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
940 return db_result($res,0,'theme_id');
943 function confirmBox($msg, $params, $buttons, $image='*none*') {
944 if ($image == '*none*') {
945 $image = html_image('stop.png','48','48',array());
948 foreach ($params as $b => $v) {
949 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
951 $prm = join(' ', $prms);
953 foreach ($buttons as $b => $v) {
954 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
956 $btn = join(' '."\n ", $btns);
959 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
960 <table align="center">
963 <td>'.$msg.'<br/></td>
966 <td colspan="2" align="center">
968 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
979 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
983 $return = '<div class="field-holder">
986 $return .= '<label for="' . $id . '">' . $label . '</label>
989 $return .= '<input id="' . $id . '" type="' . $type . '"';
990 //if input is a submit then name is not present
992 $return .= ' name="' . $name . '"';
995 $return .= ' value="' . $value . '"';
997 if (is_array($extra_params)) {
998 foreach ($extra_params as $key => $extra_params_value) {
999 $return .= $key . '="' . $extra_params_value . '" ';
1007 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1011 $return = '<div class="field-holder">
1013 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1015 $return .= 'checked="checked" ';
1017 if (is_array($extra_params)) {
1018 foreach ($extra_params as $key => $extra_params_value) {
1019 $return .= $key . '="' . $extra_params_value . '" ';
1024 $return .= '<label for="' . $id . '">' . $label . '</label>
1027 $return .= '</div>';
1031 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1039 $img_alt = $img_title;
1041 $return = '<div class="field-holder">
1044 $return .= '<label for="' . $id . '">' . $label . '</label>
1047 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1049 $return .= ' value="' . $value . '"';
1051 if (is_array($extra_params)) {
1052 foreach ($extra_params as $key => $extra_params_value) {
1053 $return .= $key . '="' . $extra_params_value . '" ';
1057 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1058 if (is_array($img_extra_params)) {
1059 foreach ($img_extra_params as $key => $img_extra_params_value) {
1060 $return .= $key . '="' . $img_extra_params_value . '" ';
1068 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1072 $return = '<div class="field-holder">
1075 $return .= '<label for="' . $id . '">' . $label . '</label>
1078 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1079 if (is_array($extra_params)) {
1080 foreach ($extra_params as $key => $extra_params_value) {
1081 $return .= $key . '="' . $extra_params_value . '" ';
1085 $rows = count($vals);
1086 for ($i = 0; $i < $rows; $i++) {
1087 if ( $text_is_value ) {
1089 <option value="' . $vals[$i] . '"';
1090 if ($vals[$i] == $checked_val) {
1091 $return .= ' selected="selected"';
1095 <option value="' . $i . '"';
1096 if ($i == $checked_val) {
1097 $return .= ' selected="selected"';
1100 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1108 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1112 $return = '<div class="field-holder">
1115 $return .= '<label for="' . $id . '">' . $label . '</label>
1118 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1119 if (is_array($extra_params)) {
1120 foreach ($extra_params as $key => $extra_params_value) {
1121 $return .= $key . '="' . $extra_params_value . '" ';
1128 $return .= '</textarea>
1133 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1134 $return = '<table summary="' . $summary . '" ';
1136 $return .= 'class="' . $class . '" ';
1138 if (is_array($extra_params)) {
1139 foreach ($extra_params as $key => $extra_params_value) {
1140 $return .= $key . '="' . $extra_params_value . '" ';
1144 $return .= '<thead><tr>';
1145 $nbCols = count($cols);
1146 for ($i = 0; $i < $nbCols; $i++) {
1147 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1149 $return .= '</tr></thead>';
1153 function getMonitorPic($title = '', $alt = '') {
1154 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1157 function getReleaseNotesPic($title = '', $alt = '') {
1158 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1161 /* no picto for download */
1162 function getDownloadPic($title = '', $alt = '') {
1163 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1166 function getHomePic($title = '', $alt = '') {
1167 return $this->getPicto('ic/home16b.png', $title, $alt);
1170 function getFollowPic($title = '', $alt = '') {
1171 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1174 function getForumPic($title = '', $alt = '') {
1175 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1178 function getDocmanPic($title = '', $alt = '') {
1179 return $this->getPicto('ic/docman16b.png', $title, $alt);
1182 function getMailPic($title = '', $alt = '') {
1183 return $this->getPicto('ic/mail16b.png', $title, $alt);
1186 function getPmPic($title = '', $alt = '') {
1187 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1190 function getSurveyPic($title = '', $alt = '') {
1191 return $this->getPicto('ic/survey16b.png', $title, $alt);
1194 function getScmPic($title = '', $alt = '') {
1195 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1198 function getFtpPic($title = '', $alt = '') {
1199 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1202 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1206 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1210 * toSlug() - protect a string to be used as a link or an anchor
1212 * @param string $string the string used as a link or an anchor
1213 * @param string $space the caracter used as a replacement for a space
1214 * @return a protected string with only alphanumeric caracters
1216 function toSlug($string, $space = "-") {
1217 if (function_exists('iconv')) {
1218 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1220 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1221 $string = strtolower($string);
1222 $string = str_replace(" ", $space, $string);
1225 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1226 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1227 echo '<div class="widget" id="'. $element_id .'">';
1228 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') .'">';
1229 echo '<div class="widget_titlebar_title">'. $widget->getTitle() .'</div>';
1231 echo '<div class="widget_titlebar_close"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=widget&name['. $widget->id .'][remove]='. $widget->getInstanceId() .'&column_id='. $column_id .'&layout_id='. $layout_id .'">'. $this->getPicto('ic/close.png', 'Close','Close') .'</a></div>';
1232 if ($is_minimized) {
1233 echo '<div class="widget_titlebar_maximize"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=maximize&name['. $widget->id .']='. $widget->getInstanceId() .'&column_id='. $column_id .'&layout_id='. $layout_id .'">'. $this->getPicto($this->_getTogglePlusForWidgets(), 'Maximize', 'Maximize') .'</a></div>';
1235 echo '<div class="widget_titlebar_minimize"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=minimize&name['. $widget->id .']='. $widget->getInstanceId() .'&column_id='. $column_id .'&layout_id='. $layout_id .'">'. $this->getPicto($this->_getToggleMinusForWidgets(), 'Minimize', 'Minimize') .'</a></div>';
1237 if (strlen($widget->hasPreferences())) {
1238 echo '<div class="widget_titlebar_prefs"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=preferences&name['. $widget->id .']='. $widget->getInstanceId() .'&layout_id='. $layout_id .'">'. _('Preferences') .'</a></div>';
1241 if ($widget->hasRss()) {
1242 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type).'">rss</a></div>';
1246 if ($is_minimized) {
1247 $style = 'display:none;';
1249 echo '<div class="widget_content" style="'. $style .'">';
1250 if (!$readonly && $display_preferences) {
1251 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) .'</div>';
1253 if ($widget->isAjax()) {
1254 echo '<div id="'. $element_id .'-ajax">';
1255 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1258 echo $widget->getContent();
1261 if ($widget->isAjax()) {
1262 echo '<script type="text/javascript">'."
1263 document.observe('dom:loaded', function () {
1264 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
1265 new Ajax.Updater('$element_id-ajax',
1266 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1273 function _getTogglePlusForWidgets() {
1274 return 'ic/toggle_plus.png';
1276 function _getToggleMinusForWidgets() {
1277 return 'ic/toggle_minus.png';
1284 // c-file-style: "bsd"