5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 - Alain Peyrat
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
9 * Copyright © 2011 Thorsten Glaser – tarent GmbH
10 * http://fusionforge.org
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 * Extends the basic Error class to add HTML functions
31 * for displaying all site dependent HTML, while allowing
32 * extendibility/overriding by themes via the Theme class.
34 * Make sure browser.php is included _before_ you create an instance
39 require_once $gfcommon.'include/constants.php';
40 require_once $gfcommon.'include/FusionForge.class.php';
41 require_once $gfcommon.'include/Navigation.class.php';
43 class Layout extends Error {
46 * Which doctype to use. Can be configured in the
47 * constructor. If set to 'strict', headerHTMLDeclaration will
48 * create a doctype definition that uses the strict doctype,
49 * otherwise it will use the transitional doctype.
50 * @var string $doctype
52 var $doctype = 'transitional';
55 * The default main page content
56 * @var string $rootindex
58 var $rootindex = 'index_std.php';
61 * The base directory of the theme in the servers file system
62 * @var string $themedir
67 * The base url of the theme
68 * @var string $themeurl
73 * The base directory of the image files in the servers file system
79 * The base url of the image files
80 * @var string $imgbaseurl
85 * The base directory of the js files in the servers file system
91 * The base url of the js files
92 * @var string $jsbaseurl
97 * The navigation object that provides the basic links. Should
103 * The color bars in pm reporting
105 var $COLOR_LTBACK1 = '#C0C0C0';
108 var $js_min = array();
109 var $javascripts = array();
111 var $css_min = array();
112 var $stylesheets = array();
115 * Layout() - Constructor
118 // parent constructor
121 $this->navigation = new Navigation();
123 // determine rootindex
124 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
125 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
127 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
130 // determine theme{dir,url}
131 $this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
132 if (!file_exists ($this->themedir)) {
133 html_error_top(_("Can't find theme directory!"));
136 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
138 // determine {css,img,js}{url,dir}
139 if (file_exists ($this->themedir . 'images/')) {
140 $this->imgdir = $this->themedir . 'images/';
141 $this->imgbaseurl = $this->themeurl . 'images/';
143 $this->imgdir = $this->themedir;
144 $this->imgbaseurl = $this->themeurl;
147 if (file_exists ($this->themedir . 'js/')) {
148 $this->jsdir = $this->themedir . 'js/';
149 $this->jsbaseurl = $this->themeurl . 'js/';
151 $this->jsdir = $this->themedir;
152 $this->jsbaseurl = $this->themeurl;
155 $this->addStylesheet('/themes/css/fusionforge.css');
160 * Constructs a list of Javascript files followed by some timestamp
162 * TODO document the purpose of this : probably to avoid caching versions updated on the server
163 * @param string $js path to the JS file
165 function addJavascript($js) {
166 // TODO : what's the point of this ? ... unused ?
167 if (isset($this->js_min[$js])) {
168 $js = $this->js_min[$js];
170 if ($js && !isset($this->js[$js])) {
171 $this->js[$js] = true;
172 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
173 if (file_exists($filename)) {
174 $js .= '?'.date ("U", filemtime($filename));
176 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $js);
177 if (file_exists($filename)) {
178 $js .= '?'.date ("U", filemtime($filename));
181 $this->javascripts[] = $js;
185 function addStylesheet($css, $media='') {
186 if (isset($this->css_min[$css])) {
187 $css = $this->css_min[$css];
189 if (!isset($this->css[$css])) {
190 $this->css[$css] = true;
191 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
192 if (file_exists($filename)) {
193 $css .= '?'.date ("U", filemtime($filename));
195 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $css);
196 if (file_exists($filename)) {
197 $css .= '?'.date ("U", filemtime($filename));
200 $this->stylesheets[] = array('css' => $css, 'media' => $media);
204 function getJavascripts() {
206 foreach ($this->javascripts as $js) {
208 $code .= '<script type="text/javascript" src="'.$js.'"></script>'."\n";
213 function getStylesheets() {
215 foreach ($this->stylesheets as $c) {
218 $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
220 $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
227 * header() - generates the complete header of page by calling
228 * headerStart() and bodyHeader().
230 function header($params) {
231 $this->headerStart($params); ?>
234 $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 plugin_hook('htmlhead', array());
253 $this->headerTitle($params);
254 $this->headerFavIcon();
256 $this->headerSearch();
259 $this->headerForgepluckerMeta();
266 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
267 * XML declaration, the doctype definition, and the opening <html>.
270 function headerHTMLDeclaration() {
271 global $sysDTDs, $sysXMLNSs;
273 print '<?xml version="1.0" encoding="utf-8"?>'."\n";
274 if (!util_ifsetor($this->doctype) || !util_ifsetor($sysDTDs[$this->doctype])) {
275 $this->doctype = 'transitional';
277 echo $sysDTDs[$this->doctype]['doctype'] . "\n";
278 echo '<html xml:lang="' . _('en') . '" lang="' . _('en') .
279 '" ' . $sysXMLNSs . ">\n";
283 * headerTitle() - creates the <title> header
285 * @param array Header parameters array
287 function headerTitle($params) {
288 echo $this->navigation->getTitle($params);
293 * headerFavIcon() - creates the favicon <link> headers.
296 function headerFavIcon() {
297 echo $this->navigation->getFavIcon();
301 * headerRSS() - creates the RSS <link> headers.
304 function headerRSS() {
305 echo $this->navigation->getRSS();
309 * headerSearch() - creates the search <link> header.
312 function headerSearch() {
313 echo '<link rel="search" title="'
314 . forge_get_config ('forge_name').'" href="'
315 . util_make_url ('/export/search_plugin.php')
316 . '" type="application/opensearchdescription+xml"/>'."\n";
320 * Create the CSS headers for all cssfiles in $cssfiles and
321 * calls the plugin cssfile hook.
323 function headerCSS() {
324 plugin_hook ('cssfile',$this);
325 echo $this->getStylesheets();
329 * headerJS() - creates the JS headers and calls the plugin javascript hook
330 * @todo generalize this
332 function headerJS() {
334 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
335 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
336 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
337 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
338 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
339 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
340 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
341 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
342 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */';
343 plugin_hook ("javascript",false);
346 plugin_hook ("javascript_file",false);
347 echo $this->getJavascripts();
349 // invoke the 'javascript' hook for custom javascript addition
350 $params = array('return' => false);
351 plugin_hook("javascript",$params);
352 $javascript = $params['return'];
354 echo '<script type="text/javascript">';
361 function headerForgepluckerMeta() {
363 * Forge-Identification Meta Header, Version 1.0
364 * cf. http://home.gna.org/forgeplucker/forge-identification.html
367 $ff = new FusionForge();
368 printf('<meta name="Forge-Identification" content="%s:%s" />',
369 $ff->software_type, $ff->software_version);
373 function bodyHeader($params){
376 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
378 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
379 <td><?php $this->searchBox(); ?></td>
380 <td align="right"><?php
381 $items = $this->navigation->getUserLinks();
382 for ($j = 0; $j < count($items['titles']); $j++) {
383 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
386 $params['template'] = ' {menu}';
387 plugin_hook('headermenu', $params);
392 <td> </td>
397 <table border="0" width="100%" cellspacing="0" cellpadding="0">
403 <?php echo $this->outerTabs($params); ?>
410 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
411 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
412 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
413 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
414 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
419 <!-- Outer body row -->
421 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
422 <td valign="top" width="99%" class="toptab" colspan="3">
424 <!-- Inner Tabs / Shell -->
426 <table border="0" width="100%" cellspacing="0" cellpadding="0">
430 if (isset($params['group']) && $params['group']) {
438 echo $this->projectTabs($params['toptab'],$params['group']);
448 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
449 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
450 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
454 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
455 <td valign="top" width="99%" class="projecttab">
461 function footer($params) {
465 <!-- end main body row -->
468 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
471 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
472 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
473 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
477 <!-- end inner body row -->
480 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
483 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
484 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
485 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
489 $this->footerEnd($params);
492 function footerEnd($params) { ?>
494 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
496 <?php echo $this->navigation->getPoweredBy(); ?>
499 <?php echo $this->navigation->getShowSource(); ?>
507 function getRootIndex() {
508 return $this->rootindex;
512 * boxTop() - Top HTML box.
514 * @param string Box title
515 * @return string the html code
517 function boxTop($title) {
519 <!-- Box Top Start -->
521 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
522 <tr class="align-center">
523 <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>
524 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
525 <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>
529 <table cellspacing="2" cellpadding="2" width="100%" border="0">
533 <!-- Box Top End -->';
537 * boxMiddle() - Middle HTML box.
539 * @param string Box title
540 * @return string The html code
542 function boxMiddle($title) {
544 <!-- Box Middle Start -->
547 <tr class="align-center">
548 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
552 <!-- Box Middle End -->';
556 * boxBottom() - Bottom HTML box.
558 * @return string the html code
560 function boxBottom() {
562 <!-- Box Bottom Start -->
569 <!-- Box Bottom End -->';
573 * boxGetAltRowStyle() - Get an alternating row style for tables.
575 * @param int Row number
576 * @return string the class code
578 function boxGetAltRowStyle($i) {
580 return ' class="altRowStyleEven"';
582 return ' class="altRowStyleOdd"';
587 * listTableTop() - Takes an array of titles and builds the first row of a new table.
589 * @param array The array of titles
590 * @param array The array of title links
591 * @param string The css classes to add (optional)
592 * @param string The id of the table (needed by sortable for example)
593 * @param array specific class for th column
594 * @return string the html code
596 function listTableTop($titleArray, $linksArray=false, $class='', $id='', $thClassArray=array()) {
599 $args .= ' class="listing '.$class.'"';
601 $args .= ' class="listing full"';
604 $args .= ' id="'.$id.'"';
609 if (count($titleArray)) {
610 $return .= '<thead><tr>';
612 $count=count($titleArray);
613 for ($i=0; $i<$count; $i++) {
615 if ($thClassArray && $thClassArray[$i]) {
616 $th .= ' class="'.$thClassArray[$i].'"';
618 $cell = $titleArray[$i];
620 $cell = util_make_link($linksArray[$i],$titleArray[$i]);
622 $return .= "\n".' <th'.$th.'>'.$cell.'</th>';
624 $return .= "\n".'</tr></thead>'."\n";
626 $return .= '<tbody>';
630 function listTableBottom() {
631 return '</tbody>'."\n".'</table>';
634 function outerTabs($params) {
635 $menu = $this->navigation->getSiteMenu();
636 echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], false, $menu['selected'], '');
640 * Prints out the quicknav menu, contained here in case we
641 * want to allow it to be overridden.
643 function quickNav() {
644 if (!session_loggedin()) {
647 // get all projects that the user belongs to
648 $groups = session_get_user()->getGroups();
650 if (count($groups) < 1) {
653 sortProjectList($groups);
656 <form id="quicknavform" name="quicknavform" action=""><div>
657 <select name="quicknav" id="quicknav" onchange="location.href=document.quicknavform.quicknav.value">
658 <option value="">'._('Quick Jump To...').'</option>';
660 foreach ($groups as $g) {
661 $group_id = $g->getID();
662 $menu = $this->navigation->getProjectMenu($group_id);
665 <option value="' . $menu['starturl'] . '">'
666 . $menu['name'] .'</option>';
668 for ($j = 0; $j < count($menu['urls']); $j++) {
670 <option value="' . $menu['urls'][$j] .'"> '
671 . $menu['titles'][$j] . '</option>';
672 if (@$menu['adminurls'][$j]) {
674 <option value="' . $menu['adminurls'][$j]
675 . '"> '
676 . _('Admin') . '</option>';
688 * projectTabs() - Prints out the project tabs, contained here in case
689 * we want to allow it to be overriden.
691 * @param string Is the tab currently selected
692 * @param string Is the group we should look up get title info
694 function projectTabs($toptab, $group_id) {
695 // get group info using the common result set
696 $menu = $this->navigation->getProjectMenu($group_id, $toptab);
697 echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], true, $menu['selected'], 'white');
700 function tabGenerator($TABS_DIRS, $TABS_TITLES, $TABS_TOOLTIPS, $nested=false, $selected=false, $sel_tab_bgcolor='white', $total_width='100%') {
702 $count=count($TABS_DIRS);
703 $width=intval((100/$count));
708 <table class="tabGenerator" ';
710 if ($total_width != '100%') {
711 $return .= 'style="width:' . $total_width . ';"';
721 for ($i=0; $i<$count; $i++) {
724 // this is the first tab, choose an image with end-name
727 $issel=($selected==$i);
728 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
729 // $rowspan=(($issel)?'rowspan="2" ' : '');
732 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
733 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" 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>';
735 } elseif ($i==$count-1) {
737 // this is the last tab, choose an image with name-end
739 $wassel=($selected==$i-1);
740 $issel=($selected==$i);
741 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
742 // $rowspan=(($issel)?'rowspan="2" ' : '');
744 // Build image between current and prior tab
747 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
748 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
749 '<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>';
751 // Last graphic on right-side
754 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
755 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
761 $wassel=($selected==$i-1);
762 $issel=($selected==$i);
763 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
764 // $rowspan=(($issel)?'rowspan="2" ' : '');
766 // Build image between current and prior tab
769 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
770 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
771 '<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>';
778 // Building a bottom row in this table, which will be darker
780 if ($selected == 0) {
782 $end_cols=((count($TABS_DIRS)*3)-3);
783 } elseif ($selected == (count($TABS_DIRS)-1)) {
784 $beg_cols=((count($TABS_DIRS)*3)-3);
787 $beg_cols=($selected*3);
788 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
792 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
794 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
796 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
808 function searchBox() {
809 echo $this->navigation->getSearchBox();
813 * beginSubMenu() - Opening a submenu.
815 * @return string Html to start a submenu.
817 function beginSubMenu() {
824 * endSubMenu() - Closing a submenu.
826 * @return string Html to end a submenu.
828 function endSubMenu() {
829 $return = '</strong></p>';
834 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
836 * @param array The array of titles.
837 * @param array The array of title links.
838 * @param array The array of string for title attributes.
839 * @return string Html to build a submenu.
841 function printSubMenu($title_arr, $links_arr, $attr_arr) {
842 $count=count($title_arr);
846 for ($i=0; $i<$count; $i++) {
847 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]). $this->subMenuSeparator();
849 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]);
854 * subMenuSeparator() - returns the separator used between submenus
856 * @return string Html to build a submenu separator.
858 function subMenuSeparator() {
863 * subMenu() - Takes two array of titles and links and build a menu.
865 * @param array The array of titles.
866 * @param array The array of title links.
867 * @param array The array of string for title attributes.
868 * @return string Html to build a submenu.
870 function subMenu($title_arr, $links_arr, $attr_arr = false) {
871 $return = $this->beginSubMenu();
872 $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr);
873 $return .= $this->endSubMenu();
878 * multiTableRow() - create a mutlilevel row in a table
880 * @param string the row attributes
881 * @param array the array of cell data, each element is an array,
882 * the first item being the text,
883 * the subsequent items are attributes (dont include
884 * the bgcolor for the title here, that will be
885 * handled by $istitle
886 * @param boolean is this row part of the title ?
887 * @return string the html code
889 function multiTableRow($row_attr, $cell_data, $istitle) {
893 $return .=' class="align-center multiTableRowTitle"';
896 for ( $c = 0; $c < count($cell_data); $c++ ) {
898 for ( $a=1; $a < count($cell_data[$c]); $a++) {
899 $return .= $cell_data[$c][$a].' ';
903 $return .='<span class="multiTableRowTitle">';
905 $return .= $cell_data[$c][0];
919 * feedback() - returns the htmlized feedback string when an action is performed.
921 * @param string feedback string
922 * @return string htmlized feedback
924 function feedback($feedback) {
929 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
933 * warning_msg() - returns the htmlized warning string when an action is performed.
935 * @param string msg string
936 * @return string htmlized warning
938 function warning_msg($msg) {
943 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
948 * error_msg() - returns the htmlized error string when an action is performed.
950 * @param string msg string
951 * @return string htmlized error
953 function error_msg($msg) {
958 <div class="error">' .
959 util_pwrap(strip_tags($msg, '<br>')) .
966 * getThemeIdFromName()
968 * @param string the dirname of the theme
969 * @return integer the theme id
971 function getThemeIdFromName($dirname) {
972 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
974 return db_result($res,0,'theme_id');
977 function confirmBox($msg, $params, $buttons, $image='*none*') {
978 if ($image == '*none*') {
979 $image = html_image('stop.png','48','48',array());
982 foreach ($params as $b => $v) {
983 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
985 $prm = join(' ', $prms);
987 foreach ($buttons as $b => $v) {
988 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
990 $btn = join(' '."\n ", $btns);
993 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
994 <table align="center">
997 <td>'.$msg.'<br/></td>
1000 <td colspan="2" align="center">
1002 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
1013 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
1017 $return = '<div class="field-holder">
1020 $return .= '<label for="' . $id . '">' . $label . '</label>
1023 $return .= '<input id="' . $id . '" type="' . $type . '"';
1024 //if input is a submit then name is not present
1026 $return .= ' name="' . $name . '"';
1029 $return .= ' value="' . $value . '"';
1031 if (is_array($extra_params)) {
1032 foreach ($extra_params as $key => $extra_params_value) {
1033 $return .= $key . '="' . $extra_params_value . '" ';
1041 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1045 $return = '<div class="field-holder">
1047 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1049 $return .= 'checked="checked" ';
1051 if (is_array($extra_params)) {
1052 foreach ($extra_params as $key => $extra_params_value) {
1053 $return .= $key . '="' . $extra_params_value . '" ';
1058 $return .= '<label for="' . $id . '">' . $label . '</label>
1061 $return .= '</div>';
1065 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1073 $img_alt = $img_title;
1075 $return = '<div class="field-holder">
1078 $return .= '<label for="' . $id . '">' . $label . '</label>
1081 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1083 $return .= ' value="' . $value . '"';
1085 if (is_array($extra_params)) {
1086 foreach ($extra_params as $key => $extra_params_value) {
1087 $return .= $key . '="' . $extra_params_value . '" ';
1091 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . util_html_secure($img_alt) . '" title="' . util_html_secure($img_title) . '"';
1092 if (is_array($img_extra_params)) {
1093 foreach ($img_extra_params as $key => $img_extra_params_value) {
1094 $return .= $key . '="' . $img_extra_params_value . '" ';
1102 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1106 $return = '<div class="field-holder">
1109 $return .= '<label for="' . $id . '">' . $label . '</label>
1112 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1113 if (is_array($extra_params)) {
1114 foreach ($extra_params as $key => $extra_params_value) {
1115 $return .= $key . '="' . $extra_params_value . '" ';
1119 $rows = count($vals);
1120 for ($i = 0; $i < $rows; $i++) {
1121 if ( $text_is_value ) {
1123 <option value="' . $vals[$i] . '"';
1124 if ($vals[$i] == $checked_val) {
1125 $return .= ' selected="selected"';
1129 <option value="' . $i . '"';
1130 if ($i == $checked_val) {
1131 $return .= ' selected="selected"';
1134 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1142 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1146 $return = '<div class="field-holder">
1149 $return .= '<label for="' . $id . '">' . $label . '</label>
1152 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1153 if (is_array($extra_params)) {
1154 foreach ($extra_params as $key => $extra_params_value) {
1155 $return .= $key . '="' . $extra_params_value . '" ';
1162 $return .= '</textarea>
1168 * @todo use listTableTop and make this function deprecated ?
1170 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1171 $return = '<table summary="' . $summary . '" ';
1173 $return .= 'class="' . $class . '" ';
1175 if (is_array($extra_params)) {
1176 foreach ($extra_params as $key => $extra_params_value) {
1177 $return .= $key . '="' . $extra_params_value . '" ';
1181 $return .= '<thead><tr>';
1182 $nbCols = count($cols);
1183 for ($i = 0; $i < $nbCols; $i++) {
1184 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1186 $return .= '</tr></thead>';
1190 function getMonitorPic($title = '', $alt = '') {
1191 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1194 function getReleaseNotesPic($title = '', $alt = '') {
1195 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1198 /* no picto for download */
1199 function getDownloadPic($title = '', $alt = '') {
1200 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1203 function getHomePic($title = '', $alt = '') {
1204 return $this->getPicto('ic/home16b.png', $title, $alt);
1207 function getFollowPic($title = '', $alt = '') {
1208 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1211 function getForumPic($title = '', $alt = '') {
1212 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1215 function getDocmanPic($title = '', $alt = '') {
1216 return $this->getPicto('ic/docman16b.png', $title, $alt);
1219 function getMailPic($title = '', $alt = '') {
1220 return $this->getPicto('ic/mail16b.png', $title, $alt);
1223 function getPmPic($title = '', $alt = '') {
1224 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1227 function getSurveyPic($title = '', $alt = '') {
1228 return $this->getPicto('ic/survey16b.png', $title, $alt);
1231 function getScmPic($title = '', $alt = '') {
1232 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1235 function getFtpPic($title = '', $alt = '') {
1236 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1239 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1243 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1247 * toSlug() - protect a string to be used as a link or an anchor
1249 * @param string $string the string used as a link or an anchor
1250 * @param string $space the caracter used as a replacement for a space
1251 * @return a protected string with only alphanumeric caracters
1253 function toSlug($string, $space = "-") {
1254 if (function_exists('iconv')) {
1255 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1257 $string = preg_replace("/[^a-zA-Z0-9_:. -]/", "-", $string);
1258 $string = strtolower($string);
1259 $string = str_replace(" ", $space, $string);
1260 if (!preg_match("/^[a-zA-Z:_]/", $string)) {
1261 /* some chars aren't allowed at the begin */
1262 $string = "_" . $string;
1267 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1268 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1269 echo '<div class="widget" id="'. $element_id . "\">\n";
1270 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') . "\">\n";
1271 echo '<div class="widget_titlebar_title">'. $widget->getTitle() . "</div>\n";
1273 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>\n";
1274 if ($is_minimized) {
1275 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>\n";
1277 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>\n";
1279 if (strlen($widget->hasPreferences())) {
1280 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>\n";
1283 if ($widget->hasRss()) {
1284 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type) . "\">rss</a></div>\n";
1288 if ($is_minimized) {
1289 $style = 'display:none;';
1291 echo '<div class="widget_content" style="'. $style . "\">\n";
1292 if (!$readonly && $display_preferences) {
1293 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) . "</div>\n";
1295 if ($widget->isAjax()) {
1296 echo '<div id="'. $element_id .'-ajax">';
1297 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1300 echo $widget->getContent();
1303 if ($widget->isAjax()) {
1304 echo '<script language="JavaScript" type="text/javascript">/* <![CDATA[ */'."
1305 document.observe('dom:loaded', function () {
1306 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
1307 new Ajax.Updater('$element_id-ajax',
1308 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1311 /* ]]> */</script>";
1316 function _getTogglePlusForWidgets() {
1317 return 'ic/toggle_plus.png';
1320 function _getToggleMinusForWidgets() {
1321 return 'ic/toggle_minus.png';
1324 /* Get the navigation links for the software map pages (trove,
1325 * tag cloud, full project list) according to what's enabled
1327 function printSoftwareMapLinks() {
1328 $subMenuTitle = array();
1329 $subMenuUrl = array();
1330 $subMenuAttr = array();
1332 if (forge_get_config('use_project_tags')) {
1333 $subMenuTitle[] = _('Tag cloud');
1334 $subMenuUrl[] = '/softwaremap/tag_cloud.php';
1335 $subMenuAttr[] = array('title' => _('Browse per tags defined by the projects.'), 'class' => 'tabtitle-nw');
1338 if (forge_get_config('use_trove')) {
1339 $subMenuTitle[] = _('Project Tree');
1340 $subMenuUrl[] = '/softwaremap/trove_list.php';
1341 $subMenuAttr[] = array('title' => _('Browse per category.'), 'class' => 'tabtitle');
1344 if (forge_get_config('use_project_full_list')) {
1345 $subMenuTitle[] = _('Project List');
1346 $subMenuUrl[] = '/softwaremap/full_list.php';
1347 $subMenuAttr[] = array('title' => _('Complete listing of available projects.'), 'class' => 'tabtitle');
1350 echo $this->subMenu($subMenuTitle, $subMenuUrl, $subMenuAttr);
1356 // c-file-style: "bsd"