*
* Copyright 1999-2001 (c) VA Linux Systems
* Copyright 2010 (c) FusionForge Team
- * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
+ * Copyright (C) 2010-2012 Alain Peyrat - Alcatel-Lucent
* Copyright 2011, Franck Villaume - Capgemini
- * Copyright 2011, Franck Villaume - TrivialDev
+ * Copyright 2011-2012, Franck Villaume - TrivialDev
+ * Copyright © 2011, 2012
+ * Thorsten “mirabilos” Glaser <t.glaser@tarent.de>
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+require_once $gfcommon.'include/minijson.php';
+
+/**
+ * html_generic_fileheader() - Output <html><head> and <meta/> inside.
+ *
+ * @param string $title
+ * Mandatory content of <title> attribute,
+ * will be HTML-secured
+ */
+function html_generic_fileheader($title) {
+ global $HTML, $sysDTDs, $sysXMLNSs;
+
+ if (!$title) {
+ throw new Exception('A title is mandatory in XHTML!');
+ }
+
+ $HTML->headerHTMLDeclaration();
+ echo "<head>\n";
+ echo '<meta http-equiv="Content-Type" ' .
+ 'content="text/html; charset=utf-8" />' . "\n";
+ echo '<script language="JavaScript" type="text/javascript">//<![CDATA[' .
+ "\n\tvar sys_url_base = " . minijson_encode(util_make_url("/"),
+ false) . ";\n" .
+ "//]]></script>\n";
+ $HTML->headerForgepluckerMeta();
+ echo html_e('title', array(), util_html_secure($title)) . "\n";
+}
+
/**
* html_feedback_top() - Show the feedback output at the top of the page.
*
$res=db_query_params('SELECT theme_id, fullname FROM themes WHERE enabled=true',
array());
$nbTheme = db_numrows($res);
- if($nbTheme < 2) {
+ if ($nbTheme == 1) {
+ $thetheme = db_result($res, 0, 'fullname');
+ return util_html_secure($thetheme) . html_e('input', array(
+ 'type' => 'hidden',
+ 'name' => $title,
+ 'value' => db_result($res, 0, 'theme_id'),
+ ));
+ } elseif ($nbTheme < 1) {
return("");
- }
- else {
- return html_build_select_box($res, $title, $selected, false);
+ } else {
+ return html_build_select_box($res,$title,$selected,false);
}
}
return $return;
}
+/**
+ * html_get_tooltip_description() - Get the tooltip description of the element
+ *
+ * @param string element name
+ */
+
function html_get_tooltip_description($element_name) {
global $use_tooltips;
if ($use_tooltips) {
}
function html_use_jquery() {
- use_javascript('/scripts/jquery/jquery-1.4.2.min.js');
+ use_javascript('/scripts/jquery/jquery-1.7.2.min.js');
}
function html_use_tooltips() {
html_use_jquery();
use_javascript('/scripts/jquery-tipsy/src/javascripts/jquery.tipsy.js');
- use_javascript('/js/tooltips.js');
+ use_javascript('/js/jquery-common.js');
use_stylesheet('/scripts/jquery-tipsy/src/stylesheets/tipsy.css');
}
use_javascript('/scripts/jquery-storage/jquery.Storage.js');
}
+function html_use_simplemenu() {
+ html_use_jquery();
+ use_javascript('/scripts/jquery-simpletreemenu/js/jquery-simpleTreeMenu-1.1.0.js');
+ use_stylesheet('/scripts/jquery-simpletreemenu/css/jquery-simpleTreeMenu-1.1.0.css');
+}
+
+function html_use_coolfieldset() {
+ html_use_jquery();
+ use_javascript('/scripts/coolfieldset/js/jquery.coolfieldset.js');
+ use_javascript('/js/jquery-common.js');
+ use_stylesheet('/scripts/coolfieldset/css/jquery.coolfieldset.css');
+}
+
+function html_use_jqueryui() {
+ html_use_jquery();
+ use_javascript('/scripts/jquery-ui/js/jquery-ui-1.8.22.custom.min.js');
+ use_stylesheet('/scripts/jquery-ui/css/overcast/jquery-ui-1.8.22.custom.css');
+}
+
+function html_use_jqueryjqplot() {
+ html_use_jquery();
+ use_javascript('/scripts/jquery-jqplot/jquery.jqplot.js');
+ use_stylesheet('/scripts/jquery-jqplot/jquery.jqplot.css');
+ use_javascript('/scripts/jquery-jqplot/excanvas.js');
+}
+
+function html_use_jqueryjqplotpluginCanvas() {
+ html_use_jqueryjqplot();
+ use_javascript('/scripts/jquery-jqplot/plugins/jqplot.canvasTextRenderer.js');
+ use_javascript('/scripts/jquery-jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
+}
+
+function html_use_jqueryjqplotpluginBar() {
+ html_use_jqueryjqplot();
+ use_javascript('/scripts/jquery-jqplot/plugins/jqplot.barRenderer.js');
+ use_javascript('/scripts/jquery-jqplot/plugins/jqplot.categoryAxisRenderer.js');
+ use_javascript('/scripts/jquery-jqplot/plugins/jqplot.pointLabels.js');
+}
+
/**
* html_build_select_box_from_arrays() - Takes two arrays, with the first array being the "id" or value and the other
* array being the text you want displayed.
* @param string What to call the 'Any row' defaults to any
* @param array Array of all allowed values from the full list.
*/
-function html_build_select_box_from_arrays ($vals,$texts,$select_name,$checked_val='xzxz',$show_100=true,$text_100='none',$show_any=false,$text_any='any', $allowed=false) {
+function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked_val = 'xzxz', $show_100 = true, $text_100 = 'none', $show_any = false, $text_any = 'any', $allowed = false) {
+ $have_a_subelement = false;
+
if ($text_100=='none'){
- $text_100=_('None');
+ $text_100 = _('None');
}
$return = '';
- $rows=count($vals);
+ $rows = count($vals);
if (count($texts) != $rows) {
- $return .= 'ERROR - uneven row counts';
+ $return .= _('ERROR - uneven row counts');
}
+ //TODO: remove this ugly ack to get something more generic...
$title = html_get_tooltip_description($select_name);
$id = '';
if ($title) {
}
}
- $title = html_get_tooltip_description($select_name);
$return .= '
<select'.$id.' name="'.$select_name.'" title="'.util_html_secure($title).'">';
if ($show_any) {
$return .= '
<option value=""'.(($checked_val=='') ? ' selected="selected"' : '').'>'. util_html_secure($text_any) .'</option>';
+ $have_a_subelement = true;
}
//we don't always want the default 100 row shown
if ($show_100) {
$return .= '
<option value="100"'.(($checked_val==100) ? ' selected="selected"' : '').'>'. util_html_secure($text_100) .'</option>';
+ $have_a_subelement = true;
}
$checked_found=false;
$return .= ' disabled="disabled" class="option_disabled"';
}
$return .= '>'.util_html_secure($texts[$i]).'</option>';
+ $have_a_subelement = true;
}
}
//
if (!$checked_found && $checked_val != 'xzxz' && $checked_val && $checked_val != 100) {
$return .= '
<option value="'.util_html_secure($checked_val).'" selected="selected">'._('No Change').'</option>';
+ $have_a_subelement = true;
+ }
+
+ if (!$have_a_subelement) {
+ /* <select></select> without <option/> in between is invalid */
+ return '<!-- select without options -->';
}
$return .= '
Check to see if active user
Check to see if logged in
*/
- echo $HTML->header($params);
+ $HTML->header($params);
}
/**
if (!$project || !is_object($project)) {
exit_no_group();
- } else if ($project->isError()) {
+ } elseif ($project->isError()) {
if ($project->isPermissionDeniedError()) {
if (!session_get_user()) {
$next = '/account/login.php?error_msg='.urlencode($project->getErrorMessage());
$params['h1'] = $h1;
}
+ if ($project->getDescription()) {
+ $params['meta-description'] = $project->getDescription();
+ }
+
+ if (forge_get_config('use_project_tags')) {
+ $res = db_query_params('SELECT name FROM project_tags WHERE group_id = $1', array($group_id));
+ if ($res && db_numrows($res) > 0) {
+ while ($row = db_fetch_array($res)) {
+ $array[] = $row['name'];
+ }
+ $params['meta-keywords'] = htmlspecialchars(join(', ', $array));
+ }
+ }
+
site_header($params);
}
$arr_l[] = '/my/';
$arr_attr[] = array('title' => _('View your personal page, a selection of widgets to follow the informations from projects.'), 'class' => 'tabtitle-nw');
-
- $arr_t[] = _('Trackers dashboard');
- $arr_l[] = '/my/dashboard.php';
- $arr_attr[] = array('title' => _('View your tasks and artifacts.'), 'class' => 'tabtitle');
+ if (forge_get_config('use_tracker')) {
+ $arr_t[] = _('Trackers dashboard');
+ $arr_l[] = '/my/dashboard.php';
+ $arr_attr[] = array('title' => _('View your tasks and artifacts.'), 'class' => 'tabtitle');
+ }
if (forge_get_config('use_diary')) {
echo ($HTML->printSubMenu($arr_t, $arr_l, $arr_attr));
if ( plugin_hook_listeners("usermenu") > 0 ) {
- echo $HTML->printSubMenuSeparator();
+ echo $HTML->subMenuSeparator();
}
plugin_hook("usermenu", false);
echo ($HTML->endSubMenu());
return $hashstr;
}
+function relative_date ($date) {
+ $delta = time() - $date;
+ if ($delta<60)
+ return sprintf(ngettext('%d second ago', '%d seconds ago', $delta), $delta);
+
+ $delta = round($delta/60);
+ if ($delta<60)
+ return sprintf(ngettext('%d minute ago', '%d minutes ago', $delta), $delta);
+
+ $delta = round($delta/60);
+ if ($delta<24)
+ return sprintf(ngettext('%d hour ago', '%d hours ago', $delta), $delta);
+
+ $delta = round($delta/24);
+ if ($delta<7)
+ return sprintf(ngettext('%d day ago', '%d days ago', $delta), $delta);
+
+ $delta = round($delta/7);
+ if ($delta<4)
+ return sprintf(ngettext('%d week ago', '%d weeks ago', $delta), $delta);
+
+ return date(_('Y-m-d H:i'), $date);
+}
+
+/* TODO: think about beautifying output */
+
+/**
+ * html_eo() - Return proper element XHTML start tag
+ *
+ * @param string $name
+ * element name
+ * @param array $attrs
+ * (optional) associative array of element attributes
+ * values: arrays are space-imploded;
+ * false values and empty arrays ignored
+ * @return string
+ * XHTML string suitable for echo'ing
+ */
+function html_eo($name, $attrs=array()) {
+ $rv = '<' . $name;
+ foreach ($attrs as $key => $value) {
+ if (is_array($value)) {
+ $value = count($value) ? implode(" ", $value) : false;
+ }
+ if ($value === false) {
+ continue;
+ }
+ $rv .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
+ }
+ $rv .= '>';
+ return $rv;
+}
+
+/**
+ * html_e() - Return proper element XHTML start/end sequence
+ *
+ * @param string $name
+ * element name
+ * @param array $attrs
+ * (optional) associative array of element attributes
+ * values: arrays are space-imploded;
+ * false values and empty arrays ignored
+ * @param string $content
+ * (optional) XHTML to be placed inside
+ * @param bool $shortform
+ * (optional) allow short open-close form
+ * (default: true)
+ * @return string
+ * XHTML string suitable for echo'ing
+ */
+function html_e($name, $attrs=array(), $content="", $shortform=true) {
+ $rv = '<' . $name;
+ foreach ($attrs as $key => $value) {
+ if (is_array($value)) {
+ $value = count($value) ? implode(" ", $value) : false;
+ }
+ if ($value === false) {
+ continue;
+ }
+ $rv .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
+ }
+ if ($content === "" && $shortform) {
+ $rv .= ' />';
+ } else {
+ $rv .= '>' . $content . '</' . $name . '>';
+ }
+ return $rv;
+}
+
+$html_autoclose_stack = array();
+$html_autoclose_pos = 0;
+
+/**
+ * html_ap() - Return XHTML element autoclose stack position
+ *
+ * @return integer
+ */
+function html_ap() {
+ global $html_autoclose_pos;
+
+ return $html_autoclose_pos;
+}
+
+/**
+ * html_ao() - Return proper element XHTML start tag, with autoclose
+ *
+ * @param string $name
+ * element name
+ * @param array $attrs
+ * (optional) associative array of element attributes
+ * values: arrays are space-imploded;
+ * false values and empty arrays ignored
+ * @return string
+ * XHTML string suitable for echo'ing
+ */
+function html_ao($name, $attrs=array()) {
+ global $html_autoclose_pos, $html_autoclose_stack;
+
+ $html_autoclose_stack[$html_autoclose_pos++] = array(
+ 'name' => $name,
+ 'attr' => $attrs,
+ );
+ return html_eo($name, $attrs);
+}
+
+/**
+ * html_aonce() - Return once proper element XHTML start tag, with autoclose
+ *
+ * @param ref &$sptr
+ initialise this to false; will be modified
+ * @param string $name
+ * element name
+ * @param array $attrs
+ * (optional) associative array of element attributes
+ * values: arrays are space-imploded;
+ * false values and empty arrays ignored
+ * @return string
+ * XHTML string suitable for echo'ing
+ */
+function html_aonce(&$sptr, $name, $attrs=array()) {
+ if ($sptr !== false) {
+ /* already run */
+ return "";
+ }
+ $sptr = html_ap();
+ return html_ao($name, $attrs);
+}
+
+/**
+ * html_ac() - Return proper element XHTML end tags, autoclosing
+ *
+ * @param integer $spos
+ * stack position to return to
+ * (nothing is done if === false)
+ * @return string
+ * XHTML string suitable for echo'ing
+ */
+function html_ac($spos) {
+ global $html_autoclose_pos, $html_autoclose_stack;
+
+ if ($spos === false) {
+ /* support for html_aonce() */
+ return "";
+ }
+
+ if ($html_autoclose_pos < $spos) {
+ $e = "html_autoclose stack underflow; closing down to " .
+ $spos . " but we're down to " . $html_autoclose_pos .
+ " already!";
+ throw new Exception($e);
+ }
+
+ $rv = "";
+ while ($html_autoclose_pos > $spos) {
+ --$html_autoclose_pos;
+ $rv .= '</' . $html_autoclose_stack[$html_autoclose_pos]['name'] . '>';
+ unset($html_autoclose_stack[$html_autoclose_pos]);
+ }
+ return $rv;
+}
+
+/**
+ * html_a_copy() - Return a copy of part of the autoclose stack
+ *
+ * @param integer $spos
+ * stack position caller will return to
+ * @return opaque
+ * argument suitable for html_a_apply()
+ */
+function html_a_copy($spos) {
+ global $html_autoclose_pos, $html_autoclose_stack;
+
+ if ($spos === false) {
+ return array();
+ }
+
+ if ($spos > $html_autoclose_pos) {
+ $e = "html_autoclose stack underflow; closing down to " .
+ $spos . " but we're down to " . $html_autoclose_pos .
+ " already!";
+ throw new Exception($e);
+ }
+
+ $rv = array();
+ while ($spos < $html_autoclose_pos) {
+ $rv[] = $html_autoclose_stack[$spos++];
+ }
+ return $rv;
+}
+
+/**
+ * html_a_apply() - Reopen tags based on an autoclose stack copy
+ *
+ * @param opaque $scopy
+ * return value from html_a_copy()
+ * @return string
+ * XHTML string suitable for echo'ing
+ */
+function html_a_apply($scopy) {
+ /* array_reduce() would be useful here... IF IT WORKED, FFS! */
+ $rv = "";
+ foreach ($scopy as $value) {
+ $rv .= html_ao($value['name'], $value['attr']);
+ }
+ return $rv;
+}
+
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
-
-?>