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 * The color bars in pm reporting
122 var $COLOR_LTBACK1 = '#C0C0C0';
126 * Layout() - Constructor
129 // parent constructor
132 $this->navigation = new Navigation();
134 // determine rootindex
135 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
136 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
138 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
141 // determine theme{dir,url}
142 $this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
143 if (!file_exists ($this->themedir)) {
144 html_error_top(_("Can't find theme directory!"));
147 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
149 // determine {css,img,js}{url,dir}
150 if (file_exists ($this->themedir . 'css/')) {
151 $this->cssdir = $this->themedir . 'css/';
152 $this->cssbaseurl = $this->themeurl . 'css/';
154 $this->cssdir = $this->themedir;
155 $this->cssbaseurl = $this->themeurl;
158 if (file_exists ($this->themedir . 'images/')) {
159 $this->imgdir = $this->themedir . 'images/';
160 $this->imgbaseurl = $this->themeurl . 'images/';
162 $this->imgdir = $this->themedir;
163 $this->imgbaseurl = $this->themeurl;
166 if (file_exists ($this->themedir . 'js/')) {
167 $this->jsdir = $this->themedir . 'js/';
168 $this->jsbaseurl = $this->themeurl . 'js/';
170 $this->jsdir = $this->themedir;
171 $this->jsbaseurl = $this->themeurl;
174 // determine CSS stylesheets
175 $this->cssurls[] = util_make_url ('/themes/css/fusionforge.css');
177 /* check if a personalized css stylesheet exist, if yes include only
178 this stylesheet. New stylesheets should use the <themename>.css file.
180 $theme_cssfile = forge_get_config('default_theme') . '.css';
181 if (file_exists($this->cssdir . $theme_cssfile)) {
182 $this->cssurls[] = $this->cssbaseurl . $theme_cssfile;
184 /* if this is not the case, then include the compatibility stylesheet
185 that contains all removed styles from the code and check if a
186 custom stylesheet exists.
187 Used for compatibility with existing stylesheets
189 $this->cssurls[] = util_make_url('/themes/css/gforge-compat.css');
190 if (file_exists($this->cssdir . 'theme.css')) {
191 $this->cssurls[] = $this->cssbaseurl . 'theme.css';
195 // for backward compatibility
196 $this->themeroot = $this->themedir;
197 $this->imgroot = $this->imgbaseurl;
200 function addJavascript($js) {
201 if (isset($this->js_min[$js])) {
202 $js = $this->js_min[$js];
204 if (!isset($this->js[$js])) {
205 $this->js[$js] = true;
206 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
207 if (file_exists($filename)) {
208 $js .= '?'.date ("U", filemtime($filename));
210 echo '<script type="text/javascript" src="'.$js.'"></script>'."\n";
214 function addStylesheet($css, $media) {
215 if (isset($this->css_min[$css])) {
216 $css = $this->css_min[$css];
218 if (!isset($this->css[$css])) {
219 $this->css[$css] = true;
220 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
221 if (file_exists($filename)) {
222 $css .= '?'.date ("U", filemtime($filename));
225 $media = ' media="'.$media.'"';
227 echo ' <link rel="stylesheet" type="text/css" href="'.$css.'"'.$media.' />'."\n";
232 * header() - generates the complete header of page by calling
233 * headerStart() and bodyHeader().
235 function header($params) {
236 $this->headerStart($params); ?>
239 $this->bodyHeader($params);
244 * headerStart() - generates the header code for all themes up to the
246 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
247 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
248 * headerJS() to adapt your theme.
250 * @param array Header parameters array
252 function headerStart($params) {
253 $this->headerHTMLDeclaration();
256 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
258 $this->headerTitle($params);
259 $this->headerFavIcon();
261 $this->headerSearch();
270 * headerLink() - creates the link headers of the page (FavIcon, RSS and Search)
271 * @deprecated deprecated since 4.9, use the individual header-functions
272 * @todo remove in 5.0
274 function headerLink() {
275 $this->headerFavIcon();
277 $this->headerSearch();
281 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
282 * XML declaration, the doctype definition, and the opening <html>.
285 function headerHTMLDeclaration() {
286 print '<?xml version="1.0" encoding="utf-8"?>';
287 if ($this->doctype=='strict') {
288 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
290 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
292 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
293 . _('en') . '" lang="' . _('en') . '">';
297 * headerTitle() - creates the <title> header
299 * @param array Header parameters array
301 function headerTitle($params) {
302 echo $this->navigation->getTitle($params);
307 * headerFavIcon() - creates the favicon <link> headers
310 function headerFavIcon() {
311 echo $this->navigation->getFavIcon();
315 * headerRSS() - creates the RSS <link> headers
318 function headerRSS() {
319 echo $this->navigation->getRSS();
323 * headerSearch() - creates the search <link> header
326 function headerSearch() {
327 echo '<link rel="search" title="'
328 . forge_get_config ('forge_name').'" href="'
329 . util_make_url ('/export/search_plugin.php')
330 . '" type="application/opensearchdescription+xml"/>';
334 * Create the CSS headers for all cssfiles in $cssfiles and
335 * calls the plugin cssfile hook.
337 function headerCSS() {
338 // include the common css
339 foreach ($this->cssurls as $cssurl) {
340 echo '<link rel="stylesheet" type="text/css" href="' . $cssurl . '" />';
343 plugin_hook ('cssfile',$this);
347 * headerJS() - creates the JS headers and calls the plugin javascript hook
348 * @todo generalize this
350 function headerJS() {
352 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
353 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
354 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
355 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
356 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
357 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
358 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
359 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
360 <script type="text/javascript">';
361 plugin_hook ("javascript",false);
364 plugin_hook ("javascript_file",false);
367 function bodyHeader($params){
370 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
372 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
373 <td><?php $this->searchBox(); ?></td>
374 <td align="right"><?php
375 $items = $this->navigation->getUserLinks();
376 for ($j = 0; $j < count($items['titles']); $j++) {
377 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
380 $params['template'] = ' {menu}';
381 plugin_hook ('headermenu', $params);
386 <td> </td>
391 <table border="0" width="100%" cellspacing="0" cellpadding="0">
397 <?php echo $this->outerTabs($params); ?>
404 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
405 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
406 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
407 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
408 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
413 <!-- Outer body row -->
415 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
416 <td valign="top" width="99%" class="toptab" colspan="3">
418 <!-- Inner Tabs / Shell -->
420 <table border="0" width="100%" cellspacing="0" cellpadding="0">
424 if (isset($params['group']) && $params['group']) {
432 echo $this->projectTabs($params['toptab'],$params['group']);
442 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
443 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
444 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
448 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
449 <td valign="top" width="99%" class="projecttab">
455 function footer($params) {
459 <!-- end main body row -->
463 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
466 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
467 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
468 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
472 <!-- end inner body row -->
475 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
478 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
479 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
480 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
484 $this->footerEnd($params);
487 function footerEnd($params) { ?>
489 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
491 <?php echo $this->navigation->getPoweredBy(); ?>
494 <?php echo $this->navigation->getShowSource(); ?>
503 function getRootIndex() {
504 return $this->rootindex;
508 * boxTop() - Top HTML box
510 * @param string Box title
511 * @param bool Whether to echo or return the results
512 * @param string The box background color
514 function boxTop($title) {
516 <!-- Box Top Start -->
518 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
519 <tr class="align-center">
520 <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>
521 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
522 <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>
526 <table cellspacing="2" cellpadding="2" width="100%" border="0">
530 <!-- Box Top End -->';
534 * boxMiddle() - Middle HTML box
536 * @param string Box title
537 * @param string The box background color
539 function boxMiddle($title) {
541 <!-- Box Middle Start -->
544 <tr class="align-center">
545 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
549 <!-- Box Middle End -->';
553 * boxBottom() - Bottom HTML box
555 * @param bool Whether to echo or return the results
557 function boxBottom() {
559 <!-- Box Bottom Start -->
566 <!-- Box Bottom End -->';
570 * boxGetAltRowStyle() - Get an alternating row style for tables
572 * @param int Row number
574 function boxGetAltRowStyle($i) {
576 return ' class="altRowStyleEven"';
578 return ' class="altRowStyleOdd"';
583 * listTableTop() - Takes an array of titles and builds the first row of a new table.
585 * @param array The array of titles
586 * @param array The array of title links
588 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
590 <table cellspacing="0" cellpadding="0" width="100%" border="0">
591 <tr class="align-center">
592 <!-- <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> -->
593 <td style="background:url('.$this->imgbaseurl.'box-grad.png)">
594 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
595 <tr class="tableheading">';
596 $count=count($title_arr);
598 for ($i=0; $i<$count; $i++) {
599 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
602 for ($i=0; $i<$count; $i++) {
604 <td>'.$title_arr[$i].'</td>';
607 return $return.'</tr>';
610 function listTableBottom() {
611 return '</table></td>
612 <!-- <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> -->
616 function outerTabs($params) {
617 $menu = $this->navigation->getSiteMenu();
619 echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
624 * Prints out the quicknav menu, contained here in case we
625 * want to allow it to be overridden.
627 function quickNav() {
628 if (!session_loggedin()) {
631 // get all projects that the user belongs to
632 $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',
636 if (!$res || db_numrows($res) < 1) {
640 <form id="quicknavform" name="quicknavform" action=""><div>
641 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
642 <option value="">'._('Quick Jump To...').'</option>';
644 for ($i = 0; $i < db_numrows($res); $i++) {
645 $group_id = db_result($res, $i, 'group_id');
646 $menu =& $this->navigation->getProjectMenu($group_id);
649 <option value="' . $menu['starturl'] . '">'
650 . $menu['name'] .'</option>';
652 for ($j = 0; $j < count($menu['urls']); $j++) {
654 <option value="' . $menu['urls'][$j] .'"> '
655 . $menu['titles'][$j] . '</option>';
656 if (@$menu['adminurls'][$j]) {
658 <option value="' . $menu['adminurls'][$j]
659 . '"> '
660 . _('Admin') . '</option>';
672 * projectTabs() - Prints out the project tabs, contained here in case
673 * we want to allow it to be overriden
675 * @param string Is the tab currently selected
676 * @param string Is the group we should look up get title info
678 function projectTabs($toptab, $group_id) {
679 // get group info using the common result set
680 $menu =& $this->navigation->getProjectMenu($group_id, $toptab);
682 echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
685 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
687 $count=count($TABS_DIRS);
688 $width=intval((100/$count));
693 <table class="tabGenerator" ';
695 if ($total_width != '100%') {
696 $return .= 'style="width:' . $total_width . ';"';
706 for ($i=0; $i<$count; $i++) {
709 // this is the first tab, choose an image with end-name
712 $issel=($selected==$i);
713 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
714 // $rowspan=(($issel)?'rowspan="2" ' : '');
717 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
718 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
719 '<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>';
720 } elseif ($i==$count-1) {
722 // this is the last tab, choose an image with name-end
724 $wassel=($selected==$i-1);
725 $issel=($selected==$i);
726 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
727 // $rowspan=(($issel)?'rowspan="2" ' : '');
729 // Build image between current and prior tab
732 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
733 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
734 '<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>';
736 // Last graphic on right-side
739 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
740 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
746 $wassel=($selected==$i-1);
747 $issel=($selected==$i);
748 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
749 // $rowspan=(($issel)?'rowspan="2" ' : '');
751 // Build image between current and prior tab
754 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
755 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
756 '<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>';
763 // Building a bottom row in this table, which will be darker
765 if ($selected == 0) {
767 $end_cols=((count($TABS_DIRS)*3)-3);
768 } elseif ($selected == (count($TABS_DIRS)-1)) {
769 $beg_cols=((count($TABS_DIRS)*3)-3);
772 $beg_cols=($selected*3);
773 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
777 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
779 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
781 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
793 function searchBox() {
794 echo $this->navigation->getSearchBox();
798 * beginSubMenu() - Opening a submenu.
800 * @return string Html to start a submenu.
802 function beginSubMenu () {
809 * endSubMenu() - Closing a submenu.
811 * @return string Html to end a submenu.
813 function endSubMenu () {
814 $return = '</strong></p>';
819 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
821 * @param array The array of titles.
822 * @param array The array of title links.
823 * @return string Html to build a submenu.
825 function printSubMenu ($title_arr,$links_arr) {
826 $count=count($title_arr);
830 for ($i=0; $i<$count; $i++) {
831 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
833 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
838 * subMenu() - Takes two array of titles and links and build a menu.
840 * @param array The array of titles.
841 * @param array The array of title links.
842 * @return string Html to build a submenu.
844 function subMenu ($title_arr,$links_arr) {
845 $return = $this->beginSubMenu () ;
846 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
847 $return .= $this->endSubMenu () ;
852 * multiTableRow() - create a mutlilevel row in a table
854 * @param string the row attributes
855 * @param array the array of cell data, each element is an array,
856 * the first item being the text,
857 * the subsequent items are attributes (dont include
858 * the bgcolor for the title here, that will be
859 * handled by $istitle
860 * @param boolean is this row part of the title ?
863 function multiTableRow($row_attr, $cell_data, $istitle) {
867 $return .=' class="align-center multiTableRowTitle"';
870 for ( $c = 0; $c < count($cell_data); $c++ ) {
872 for ( $a=1; $a < count($cell_data[$c]); $a++) {
873 $return .= $cell_data[$c][$a].' ';
877 $return .='<span class="multiTableRowTitle">';
879 $return .= $cell_data[$c][0];
893 * feedback() - returns the htmlized feedback string when an action is performed.
895 * @param string feedback string
896 * @return string htmlized feedback
898 function feedback($feedback) {
903 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
907 * warning_msg() - returns the htmlized warning string when an action is performed.
909 * @param string msg string
910 * @return string htmlized warning
912 function warning_msg($msg) {
917 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
922 * error_msg() - returns the htmlized error string when an action is performed.
924 * @param string msg string
925 * @return string htmlized error
927 function error_msg($msg) {
932 <div class="error">'.strip_tags($msg, '<br>').'</div>';
938 * getThemeIdFromName()
940 * @param string the dirname of the theme
941 * @return integer the theme id
943 function getThemeIdFromName($dirname) {
944 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
946 return db_result($res,0,'theme_id');
949 function confirmBox($msg, $params, $buttons, $image='*none*') {
950 if ($image == '*none*') {
951 $image = html_image('stop.png','48','48',array());
954 foreach ($params as $b => $v) {
955 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
957 $prm = join(' ', $prms);
959 foreach ($buttons as $b => $v) {
960 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
962 $btn = join(' '."\n ", $btns);
965 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
966 <table align="center">
969 <td>'.$msg.'<br/></td>
972 <td colspan="2" align="center">
974 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
985 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
989 $return = '<div class="field-holder">
992 $return .= '<label for="' . $id . '">' . $label . '</label>
995 $return .= '<input id="' . $id . '" type="' . $type . '"';
996 //if input is a submit then name is not present
998 $return .= ' name="' . $name . '"';
1001 $return .= ' value="' . $value . '"';
1003 if (is_array($extra_params)) {
1004 foreach ($extra_params as $key => $extra_params_value) {
1005 $return .= $key . '="' . $extra_params_value . '" ';
1013 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1017 $return = '<div class="field-holder">
1019 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1021 $return .= 'checked="checked" ';
1023 if (is_array($extra_params)) {
1024 foreach ($extra_params as $key => $extra_params_value) {
1025 $return .= $key . '="' . $extra_params_value . '" ';
1030 $return .= '<label for="' . $id . '">' . $label . '</label>
1033 $return .= '</div>';
1037 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1045 $img_alt = $img_title;
1047 $return = '<div class="field-holder">
1050 $return .= '<label for="' . $id . '">' . $label . '</label>
1053 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1055 $return .= ' value="' . $value . '"';
1057 if (is_array($extra_params)) {
1058 foreach ($extra_params as $key => $extra_params_value) {
1059 $return .= $key . '="' . $extra_params_value . '" ';
1063 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1064 if (is_array($img_extra_params)) {
1065 foreach ($img_extra_params as $key => $img_extra_params_value) {
1066 $return .= $key . '="' . $img_extra_params_value . '" ';
1074 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1078 $return = '<div class="field-holder">
1081 $return .= '<label for="' . $id . '">' . $label . '</label>
1084 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1085 if (is_array($extra_params)) {
1086 foreach ($extra_params as $key => $extra_params_value) {
1087 $return .= $key . '="' . $extra_params_value . '" ';
1091 $rows = count($vals);
1092 for ($i = 0; $i < $rows; $i++) {
1093 if ( $text_is_value ) {
1095 <option value="' . $vals[$i] . '"';
1096 if ($vals[$i] == $checked_val) {
1097 $return .= ' selected="selected"';
1101 <option value="' . $i . '"';
1102 if ($i == $checked_val) {
1103 $return .= ' selected="selected"';
1106 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1114 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1118 $return = '<div class="field-holder">
1121 $return .= '<label for="' . $id . '">' . $label . '</label>
1124 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1125 if (is_array($extra_params)) {
1126 foreach ($extra_params as $key => $extra_params_value) {
1127 $return .= $key . '="' . $extra_params_value . '" ';
1134 $return .= '</textarea>
1139 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1140 $return = '<table summary="' . $summary . '" ';
1142 $return .= 'class="' . $class . '" ';
1144 if (is_array($extra_params)) {
1145 foreach ($extra_params as $key => $extra_params_value) {
1146 $return .= $key . '="' . $extra_params_value . '" ';
1150 $return .= '<thead><tr>';
1151 $nbCols = count($cols);
1152 for ($i = 0; $i < $nbCols; $i++) {
1153 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1155 $return .= '</tr></thead>';
1159 function getMonitorPic($title = '', $alt = '') {
1160 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1163 function getReleaseNotesPic($title = '', $alt = '') {
1164 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1167 /* no picto for download */
1168 function getDownloadPic($title = '', $alt = '') {
1169 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1172 function getHomePic($title = '', $alt = '') {
1173 return $this->getPicto('ic/home16b.png', $title, $alt);
1176 function getFollowPic($title = '', $alt = '') {
1177 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1180 function getForumPic($title = '', $alt = '') {
1181 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1184 function getDocmanPic($title = '', $alt = '') {
1185 return $this->getPicto('ic/docman16b.png', $title, $alt);
1188 function getMailPic($title = '', $alt = '') {
1189 return $this->getPicto('ic/mail16b.png', $title, $alt);
1192 function getPmPic($title = '', $alt = '') {
1193 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1196 function getSurveyPic($title = '', $alt = '') {
1197 return $this->getPicto('ic/survey16b.png', $title, $alt);
1200 function getScmPic($title = '', $alt = '') {
1201 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1204 function getFtpPic($title = '', $alt = '') {
1205 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1208 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1212 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1216 * toSlug() - protect a string to be used as a link or an anchor
1218 * @param string $string the string used as a link or an anchor
1219 * @param string $space the caracter used as a replacement for a space
1220 * @return a protected string with only alphanumeric caracters
1222 function toSlug($string, $space = "-") {
1223 if (function_exists('iconv')) {
1224 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1226 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1227 $string = strtolower($string);
1228 $string = str_replace(" ", $space, $string);
1231 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1232 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1233 echo '<div class="widget" id="'. $element_id .'">';
1234 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') .'">';
1235 echo '<div class="widget_titlebar_title">'. $widget->getTitle() .'</div>';
1237 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>';
1238 if ($is_minimized) {
1239 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>';
1241 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>';
1243 if (strlen($widget->hasPreferences())) {
1244 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>';
1247 if ($widget->hasRss()) {
1248 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type).'">rss</a></div>';
1252 if ($is_minimized) {
1253 $style = 'display:none;';
1255 echo '<div class="widget_content" style="'. $style .'">';
1256 if (!$readonly && $display_preferences) {
1257 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) .'</div>';
1259 if ($widget->isAjax()) {
1260 echo '<div id="'. $element_id .'-ajax">';
1261 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1264 echo $widget->getContent();
1267 if ($widget->isAjax()) {
1268 echo '<script type="text/javascript">'."
1269 document.observe('dom:loaded', function () {
1270 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
1271 new Ajax.Updater('$element_id-ajax',
1272 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1279 function _getTogglePlusForWidgets() {
1280 return 'ic/toggle_plus.png';
1282 function _getToggleMinusForWidgets() {
1283 return 'ic/toggle_minus.png';
1290 // c-file-style: "bsd"