5 * Copyright 1999-2001 (c) VA Linux Systems
6 * http://fusionforge.org
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Extends the basic Error class to add HTML functions
28 * for displaying all site dependent HTML, while allowing
29 * extendibility/overriding by themes via the Theme class.
31 * Make sure browser.php is included _before_ you create an instance
36 require_once $gfcommon.'include/constants.php';
37 require_once $gfcommon.'include/Navigation.class.php';
39 class Layout extends Error {
42 * Which doctype to use. Can be configured in the
43 * constructor. If set to 'strict', headerHTMLDeclaration will
44 * create a doctype definition that uses the strict doctype,
45 * otherwise it will use the transitional doctype.
46 * @var string $doctype
48 var $doctype = 'transitional';
51 * Which cssfiles to use. Can be configured in the
54 * @var array $cssurls is a list of urls that should point to
55 * the used stylesheets.
60 * The default main page content
61 * @var string $rootindex
63 var $rootindex = 'index_std.php';
66 * The base directory of the theme in the servers file system
67 * @var string $themedir
72 * The base url of the theme
73 * @var string $themeurl
78 * The base directory of the css files in the servers file system
84 * The base url of the css files
85 * @var string $cssbaseurl
90 * The base directory of the image files in the servers file system
96 * The base url of the image files
97 * @var string $imgbaseurl
102 * The base directory of the js files in the servers file system
108 * The base url of the js files
109 * @var string $jsbaseurl
114 * kept for backwards compatibility
117 * The base directory of the theme
118 * @var string $themeroot
119 * @todo: remove in 5.0
120 * @deprecated deprecated since 4.9
125 * The navigation object that provides the basic links. Should
132 * The color bars in pm reporting
134 var $COLOR_LTBACK1 = '#C0C0C0';
138 var $js_min = array();
139 var $javascripts = array();
141 var $css_min = array();
142 var $stylesheets = array();
145 * Layout() - Constructor
148 // parent constructor
151 $this->navigation = new Navigation();
153 // determine rootindex
154 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
155 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
157 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
160 // determine theme{dir,url}
161 $this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
162 if (!file_exists ($this->themedir)) {
163 html_error_top(_("Can't find theme directory!"));
166 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
168 // determine {css,img,js}{url,dir}
169 if (file_exists ($this->themedir . 'css/')) {
170 $this->cssdir = $this->themedir . 'css/';
171 $this->cssbaseurl = $this->themeurl . 'css/';
173 $this->cssdir = $this->themedir;
174 $this->cssbaseurl = $this->themeurl;
177 if (file_exists ($this->themedir . 'images/')) {
178 $this->imgdir = $this->themedir . 'images/';
179 $this->imgbaseurl = $this->themeurl . 'images/';
181 $this->imgdir = $this->themedir;
182 $this->imgbaseurl = $this->themeurl;
185 if (file_exists ($this->themedir . 'js/')) {
186 $this->jsdir = $this->themedir . 'js/';
187 $this->jsbaseurl = $this->themeurl . 'js/';
189 $this->jsdir = $this->themedir;
190 $this->jsbaseurl = $this->themeurl;
193 // determine CSS stylesheets
194 $this->cssurls[] = util_make_url ('/themes/css/fusionforge.css');
196 /* check if a personalized css stylesheet exist, if yes include only
197 this stylesheet. New stylesheets should use the <themename>.css file.
199 $theme_cssfile = forge_get_config('default_theme') . '.css';
200 if (file_exists($this->cssdir . $theme_cssfile)) {
201 $this->cssurls[] = $this->cssbaseurl . $theme_cssfile;
203 /* if this is not the case, then include the compatibility stylesheet
204 that contains all removed styles from the code and check if a
205 custom stylesheet exists.
206 Used for compatibility with existing stylesheets
208 if (file_exists($this->cssdir . 'theme.css')) {
209 $this->cssurls[] = $this->cssbaseurl . 'theme.css';
213 // for backward compatibility
214 $this->imgroot = $this->imgbaseurl;
217 function addJavascript($js) {
218 if (isset($this->js_min[$js])) {
219 $js = $this->js_min[$js];
221 if (!isset($this->js[$js])) {
222 $this->js[$js] = true;
223 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
224 if (file_exists($filename)) {
225 $js .= '?'.date ("U", filemtime($filename));
227 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $js);
228 if (file_exists($filename)) {
229 $js .= '?'.date ("U", filemtime($filename));
232 $this->javascripts[] = $js;
236 function addStylesheet($css, $media='') {
237 if (isset($this->css_min[$css])) {
238 $css = $this->css_min[$css];
240 if (!isset($this->css[$css])) {
241 $this->css[$css] = true;
242 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
243 if (file_exists($filename)) {
244 $css .= '?'.date ("U", filemtime($filename));
246 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $css);
247 if (file_exists($filename)) {
248 $css .= '?'.date ("U", filemtime($filename));
251 $this->stylesheets[] = array('css' => $css, 'media' => $media);
255 function getJavascripts() {
257 foreach ($this->javascripts as $js) {
258 $code .= ' <script type="text/javascript" src="'.$js.'"></script>'."\n";
263 function getStylesheets() {
265 foreach ($this->stylesheets as $c) {
267 $code .= ' <link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
269 $code .= ' <link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
276 * header() - generates the complete header of page by calling
277 * headerStart() and bodyHeader().
279 function header($params) {
280 $this->headerStart($params); ?>
283 $this->bodyHeader($params);
288 * headerStart() - generates the header code for all themes up to the
290 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
291 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
292 * headerJS() to adapt your theme.
294 * @param array Header parameters array
296 function headerStart($params) {
297 $this->headerHTMLDeclaration();
300 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
302 $this->headerTitle($params);
303 $this->headerFavIcon();
305 $this->headerSearch();
314 * headerLink() - creates the link headers of the page (FavIcon, RSS and Search)
315 * @deprecated deprecated since 4.9, use the individual header-functions
316 * @todo remove in 5.0
318 function headerLink() {
319 $this->headerFavIcon();
321 $this->headerSearch();
325 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
326 * XML declaration, the doctype definition, and the opening <html>.
329 function headerHTMLDeclaration() {
330 print '<?xml version="1.0" encoding="utf-8"?>';
331 if ($this->doctype=='strict') {
332 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
334 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
336 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
337 . _('en') . '" lang="' . _('en') . '">';
341 * headerTitle() - creates the <title> header
343 * @param array Header parameters array
345 function headerTitle($params) {
346 echo $this->navigation->getTitle($params);
351 * headerFavIcon() - creates the favicon <link> headers
354 function headerFavIcon() {
355 echo $this->navigation->getFavIcon();
359 * headerRSS() - creates the RSS <link> headers
362 function headerRSS() {
363 echo $this->navigation->getRSS();
367 * headerSearch() - creates the search <link> header
370 function headerSearch() {
371 echo '<link rel="search" title="'
372 . forge_get_config ('forge_name').'" href="'
373 . util_make_url ('/export/search_plugin.php')
374 . '" type="application/opensearchdescription+xml"/>';
378 * Create the CSS headers for all cssfiles in $cssfiles and
379 * calls the plugin cssfile hook.
381 function headerCSS() {
382 // include the common css
383 foreach ($this->cssurls as $cssurl) {
384 echo '<link rel="stylesheet" type="text/css" href="' . $cssurl . '" />';
387 plugin_hook ('cssfile',$this);
388 echo $this->getStylesheets();
392 * headerJS() - creates the JS headers and calls the plugin javascript hook
393 * @todo generalize this
395 function headerJS() {
397 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
398 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
399 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
400 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
401 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
402 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
403 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
404 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
405 <script type="text/javascript">';
406 plugin_hook ("javascript",false);
409 plugin_hook ("javascript_file",false);
410 echo $this->getJavascripts();
413 function bodyHeader($params){
416 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
418 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
419 <td><?php $this->searchBox(); ?></td>
420 <td align="right"><?php
421 $items = $this->navigation->getUserLinks();
422 for ($j = 0; $j < count($items['titles']); $j++) {
423 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
426 $params['template'] = ' {menu}';
427 plugin_hook ('headermenu', $params);
432 <td> </td>
437 <table border="0" width="100%" cellspacing="0" cellpadding="0">
443 <?php echo $this->outerTabs($params); ?>
450 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
451 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
452 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
453 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
454 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
459 <!-- Outer body row -->
461 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
462 <td valign="top" width="99%" class="toptab" colspan="3">
464 <!-- Inner Tabs / Shell -->
466 <table border="0" width="100%" cellspacing="0" cellpadding="0">
470 if (isset($params['group']) && $params['group']) {
478 echo $this->projectTabs($params['toptab'],$params['group']);
488 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
489 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
490 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
494 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
495 <td valign="top" width="99%" class="projecttab">
501 function footer($params) {
505 <!-- end main body row -->
509 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
512 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
513 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
514 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
518 <!-- end inner body row -->
521 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
524 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
525 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
526 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
530 $this->footerEnd($params);
533 function footerEnd($params) { ?>
535 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
537 <?php echo $this->navigation->getPoweredBy(); ?>
540 <?php echo $this->navigation->getShowSource(); ?>
549 function getRootIndex() {
550 return $this->rootindex;
554 * boxTop() - Top HTML box
556 * @param string Box title
557 * @param bool Whether to echo or return the results
558 * @param string The box background color
560 function boxTop($title) {
562 <!-- Box Top Start -->
564 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
565 <tr class="align-center">
566 <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>
567 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
568 <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>
572 <table cellspacing="2" cellpadding="2" width="100%" border="0">
576 <!-- Box Top End -->';
580 * boxMiddle() - Middle HTML box
582 * @param string Box title
583 * @param string The box background color
585 function boxMiddle($title) {
587 <!-- Box Middle Start -->
590 <tr class="align-center">
591 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
595 <!-- Box Middle End -->';
599 * boxBottom() - Bottom HTML box
601 * @param bool Whether to echo or return the results
603 function boxBottom() {
605 <!-- Box Bottom Start -->
612 <!-- Box Bottom End -->';
616 * boxGetAltRowStyle() - Get an alternating row style for tables
618 * @param int Row number
620 function boxGetAltRowStyle($i) {
622 return ' class="altRowStyleEven"';
624 return ' class="altRowStyleOdd"';
629 * listTableTop() - Takes an array of titles and builds the first row of a new table.
631 * @param array The array of titles
632 * @param array The array of title links
634 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
636 <table cellspacing="0" cellpadding="0" width="100%" border="0">
637 <tr class="align-center">
638 <!-- <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> -->
639 <td style="background:url('.$this->imgbaseurl.'box-grad.png)">
640 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
641 <tr class="tableheading">';
642 $count=count($title_arr);
644 for ($i=0; $i<$count; $i++) {
645 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
648 for ($i=0; $i<$count; $i++) {
650 <td>'.$title_arr[$i].'</td>';
653 return $return.'</tr>';
656 function listTableBottom() {
657 return '</table></td>
658 <!-- <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> -->
662 function outerTabs($params) {
663 $menu = $this->navigation->getSiteMenu();
665 echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
670 * Prints out the quicknav menu, contained here in case we
671 * want to allow it to be overridden.
673 function quickNav() {
674 if (!session_loggedin()) {
677 // get all projects that the user belongs to
678 $groups = session_get_user()->getGroups () ;
680 if (count ($groups) < 1) {
683 sortProjectList ($groups) ;
686 <form id="quicknavform" name="quicknavform" action=""><div>
687 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
688 <option value="">'._('Quick Jump To...').'</option>';
690 foreach ($groups as $g) {
691 $group_id = $g->getID() ;
692 $menu =& $this->navigation->getProjectMenu($group_id);
695 <option value="' . $menu['starturl'] . '">'
696 . $menu['name'] .'</option>';
698 for ($j = 0; $j < count($menu['urls']); $j++) {
700 <option value="' . $menu['urls'][$j] .'"> '
701 . $menu['titles'][$j] . '</option>';
702 if (@$menu['adminurls'][$j]) {
704 <option value="' . $menu['adminurls'][$j]
705 . '"> '
706 . _('Admin') . '</option>';
718 * projectTabs() - Prints out the project tabs, contained here in case
719 * we want to allow it to be overriden
721 * @param string Is the tab currently selected
722 * @param string Is the group we should look up get title info
724 function projectTabs($toptab, $group_id) {
725 // get group info using the common result set
726 $menu =& $this->navigation->getProjectMenu($group_id, $toptab);
728 echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
731 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
733 $count=count($TABS_DIRS);
734 $width=intval((100/$count));
739 <table class="tabGenerator" ';
741 if ($total_width != '100%') {
742 $return .= 'style="width:' . $total_width . ';"';
752 for ($i=0; $i<$count; $i++) {
755 // this is the first tab, choose an image with end-name
758 $issel=($selected==$i);
759 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
760 // $rowspan=(($issel)?'rowspan="2" ' : '');
763 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
764 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
765 '<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>';
766 } elseif ($i==$count-1) {
768 // this is the last tab, choose an image with name-end
770 $wassel=($selected==$i-1);
771 $issel=($selected==$i);
772 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
773 // $rowspan=(($issel)?'rowspan="2" ' : '');
775 // Build image between current and prior tab
778 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
779 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
780 '<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>';
782 // Last graphic on right-side
785 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
786 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
792 $wassel=($selected==$i-1);
793 $issel=($selected==$i);
794 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
795 // $rowspan=(($issel)?'rowspan="2" ' : '');
797 // Build image between current and prior tab
800 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
801 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
802 '<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>';
809 // Building a bottom row in this table, which will be darker
811 if ($selected == 0) {
813 $end_cols=((count($TABS_DIRS)*3)-3);
814 } elseif ($selected == (count($TABS_DIRS)-1)) {
815 $beg_cols=((count($TABS_DIRS)*3)-3);
818 $beg_cols=($selected*3);
819 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
823 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
825 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
827 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
839 function searchBox() {
840 echo $this->navigation->getSearchBox();
844 * beginSubMenu() - Opening a submenu.
846 * @return string Html to start a submenu.
848 function beginSubMenu () {
855 * endSubMenu() - Closing a submenu.
857 * @return string Html to end a submenu.
859 function endSubMenu () {
860 $return = '</strong></p>';
865 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
867 * @param array The array of titles.
868 * @param array The array of title links.
869 * @return string Html to build a submenu.
871 function printSubMenu ($title_arr,$links_arr) {
872 $count=count($title_arr);
876 for ($i=0; $i<$count; $i++) {
877 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
879 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
884 * subMenu() - Takes two array of titles and links and build a menu.
886 * @param array The array of titles.
887 * @param array The array of title links.
888 * @return string Html to build a submenu.
890 function subMenu ($title_arr,$links_arr) {
891 $return = $this->beginSubMenu () ;
892 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
893 $return .= $this->endSubMenu () ;
898 * multiTableRow() - create a mutlilevel row in a table
900 * @param string the row attributes
901 * @param array the array of cell data, each element is an array,
902 * the first item being the text,
903 * the subsequent items are attributes (dont include
904 * the bgcolor for the title here, that will be
905 * handled by $istitle
906 * @param boolean is this row part of the title ?
909 function multiTableRow($row_attr, $cell_data, $istitle) {
913 $return .=' class="align-center multiTableRowTitle"';
916 for ( $c = 0; $c < count($cell_data); $c++ ) {
918 for ( $a=1; $a < count($cell_data[$c]); $a++) {
919 $return .= $cell_data[$c][$a].' ';
923 $return .='<span class="multiTableRowTitle">';
925 $return .= $cell_data[$c][0];
939 * feedback() - returns the htmlized feedback string when an action is performed.
941 * @param string feedback string
942 * @return string htmlized feedback
944 function feedback($feedback) {
949 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
953 * warning_msg() - returns the htmlized warning string when an action is performed.
955 * @param string msg string
956 * @return string htmlized warning
958 function warning_msg($msg) {
963 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
968 * error_msg() - returns the htmlized error string when an action is performed.
970 * @param string msg string
971 * @return string htmlized error
973 function error_msg($msg) {
978 <div class="error">'.strip_tags($msg, '<br>').'</div>';
984 * getThemeIdFromName()
986 * @param string the dirname of the theme
987 * @return integer the theme id
989 function getThemeIdFromName($dirname) {
990 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
992 return db_result($res,0,'theme_id');
995 function confirmBox($msg, $params, $buttons, $image='*none*') {
996 if ($image == '*none*') {
997 $image = html_image('stop.png','48','48',array());
1000 foreach ($params as $b => $v) {
1001 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
1003 $prm = join(' ', $prms);
1005 foreach ($buttons as $b => $v) {
1006 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
1008 $btn = join(' '."\n ", $btns);
1011 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
1012 <table align="center">
1015 <td>'.$msg.'<br/></td>
1018 <td colspan="2" align="center">
1020 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
1031 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
1035 $return = '<div class="field-holder">
1038 $return .= '<label for="' . $id . '">' . $label . '</label>
1041 $return .= '<input id="' . $id . '" type="' . $type . '"';
1042 //if input is a submit then name is not present
1044 $return .= ' name="' . $name . '"';
1047 $return .= ' value="' . $value . '"';
1049 if (is_array($extra_params)) {
1050 foreach ($extra_params as $key => $extra_params_value) {
1051 $return .= $key . '="' . $extra_params_value . '" ';
1059 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1063 $return = '<div class="field-holder">
1065 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1067 $return .= 'checked="checked" ';
1069 if (is_array($extra_params)) {
1070 foreach ($extra_params as $key => $extra_params_value) {
1071 $return .= $key . '="' . $extra_params_value . '" ';
1076 $return .= '<label for="' . $id . '">' . $label . '</label>
1079 $return .= '</div>';
1083 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1091 $img_alt = $img_title;
1093 $return = '<div class="field-holder">
1096 $return .= '<label for="' . $id . '">' . $label . '</label>
1099 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1101 $return .= ' value="' . $value . '"';
1103 if (is_array($extra_params)) {
1104 foreach ($extra_params as $key => $extra_params_value) {
1105 $return .= $key . '="' . $extra_params_value . '" ';
1109 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1110 if (is_array($img_extra_params)) {
1111 foreach ($img_extra_params as $key => $img_extra_params_value) {
1112 $return .= $key . '="' . $img_extra_params_value . '" ';
1120 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1124 $return = '<div class="field-holder">
1127 $return .= '<label for="' . $id . '">' . $label . '</label>
1130 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1131 if (is_array($extra_params)) {
1132 foreach ($extra_params as $key => $extra_params_value) {
1133 $return .= $key . '="' . $extra_params_value . '" ';
1137 $rows = count($vals);
1138 for ($i = 0; $i < $rows; $i++) {
1139 if ( $text_is_value ) {
1141 <option value="' . $vals[$i] . '"';
1142 if ($vals[$i] == $checked_val) {
1143 $return .= ' selected="selected"';
1147 <option value="' . $i . '"';
1148 if ($i == $checked_val) {
1149 $return .= ' selected="selected"';
1152 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1160 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1164 $return = '<div class="field-holder">
1167 $return .= '<label for="' . $id . '">' . $label . '</label>
1170 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1171 if (is_array($extra_params)) {
1172 foreach ($extra_params as $key => $extra_params_value) {
1173 $return .= $key . '="' . $extra_params_value . '" ';
1180 $return .= '</textarea>
1185 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1186 $return = '<table summary="' . $summary . '" ';
1188 $return .= 'class="' . $class . '" ';
1190 if (is_array($extra_params)) {
1191 foreach ($extra_params as $key => $extra_params_value) {
1192 $return .= $key . '="' . $extra_params_value . '" ';
1196 $return .= '<thead><tr>';
1197 $nbCols = count($cols);
1198 for ($i = 0; $i < $nbCols; $i++) {
1199 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1201 $return .= '</tr></thead>';
1205 function getMonitorPic($title = '', $alt = '') {
1206 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1209 function getReleaseNotesPic($title = '', $alt = '') {
1210 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1213 /* no picto for download */
1214 function getDownloadPic($title = '', $alt = '') {
1215 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1218 function getHomePic($title = '', $alt = '') {
1219 return $this->getPicto('ic/home16b.png', $title, $alt);
1222 function getFollowPic($title = '', $alt = '') {
1223 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1226 function getForumPic($title = '', $alt = '') {
1227 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1230 function getDocmanPic($title = '', $alt = '') {
1231 return $this->getPicto('ic/docman16b.png', $title, $alt);
1234 function getMailPic($title = '', $alt = '') {
1235 return $this->getPicto('ic/mail16b.png', $title, $alt);
1238 function getPmPic($title = '', $alt = '') {
1239 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1242 function getSurveyPic($title = '', $alt = '') {
1243 return $this->getPicto('ic/survey16b.png', $title, $alt);
1246 function getScmPic($title = '', $alt = '') {
1247 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1250 function getFtpPic($title = '', $alt = '') {
1251 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1254 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1258 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1262 * toSlug() - protect a string to be used as a link or an anchor
1264 * @param string $string the string used as a link or an anchor
1265 * @param string $space the caracter used as a replacement for a space
1266 * @return a protected string with only alphanumeric caracters
1268 function toSlug($string, $space = "-") {
1269 if (function_exists('iconv')) {
1270 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1272 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1273 $string = strtolower($string);
1274 $string = str_replace(" ", $space, $string);
1277 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1278 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1279 echo '<div class="widget" id="'. $element_id .'">';
1280 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') .'">';
1281 echo '<div class="widget_titlebar_title">'. $widget->getTitle() .'</div>';
1283 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>';
1284 if ($is_minimized) {
1285 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>';
1287 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>';
1289 if (strlen($widget->hasPreferences())) {
1290 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>';
1293 if ($widget->hasRss()) {
1294 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type).'">rss</a></div>';
1298 if ($is_minimized) {
1299 $style = 'display:none;';
1301 echo '<div class="widget_content" style="'. $style .'">';
1302 if (!$readonly && $display_preferences) {
1303 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) .'</div>';
1305 if ($widget->isAjax()) {
1306 echo '<div id="'. $element_id .'-ajax">';
1307 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1310 echo $widget->getContent();
1313 if ($widget->isAjax()) {
1314 echo '<script type="text/javascript">'."
1315 document.observe('dom:loaded', function () {
1316 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
1317 new Ajax.Updater('$element_id-ajax',
1318 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1325 function _getTogglePlusForWidgets() {
1326 return 'ic/toggle_plus.png';
1328 function _getToggleMinusForWidgets() {
1329 return 'ic/toggle_minus.png';
1336 // c-file-style: "bsd"