* Copyright 1999-2001 (c) VA Linux Systems
* http://sourceforge.net
*
- * @version $Id$
*/
/**
* @param string The feedback.
*/
function html_feedback_top($feedback) {
- if (!$feedback)
- return '';
- print '
- <h3><span style="color:red">'.$feedback.'</span></h3>';
+ global $HTML;
+ echo $HTML->feedback($feedback);
+}
+
+/**
+ * html_warning_top() - Show the warning output at the top of the page.
+ *
+ * @param string The warning message.
+ */
+function html_warning_top($msg) {
+ global $HTML;
+ echo $HTML->warning_msg($msg);
+}
+
+/**
+ * html_error_top() - Show the error output at the top of the page.
+ *
+ * @param string The error message.
+ */
+function html_error_top($msg) {
+ global $HTML;
+ echo $HTML->error_msg($msg);
}
/**
* @param string The feedback.
*/
function html_feedback_bottom($feedback) {
- if (!$feedback)
- return '';
- print '
- <h3><span style="color:red">'.$feedback.'</span></h3>';
+ global $HTML;
+ echo $HTML->feedback($feedback);
}
/**
if (!$args) {
$args = array();
}
- $sql="SELECT width,height,version ".
- "FROM db_images WHERE id='$id'";
- $result=db_query($sql);
+ $result = db_query_params ('SELECT width,height,version
+FROM db_images WHERE id=$1',
+ array ($id));
$rows=db_numrows($result);
if (!$result || $rows < 1) {
* @param int height of the image
* @param array Any <img> tag parameters (i.e. 'border', 'alt', etc...)
*/
-function html_abs_image($url, $width, $height, $args)
-{
+function html_abs_image($url, $width, $height, $args) {
$return = ('<img src="' . $url . '"');
reset($args);
while(list($k,$v) = each($args)) {
}
/**
- * html_get_language_popup() - Pop up box of supported languages
+ * html_get_language_popup() - Pop up box of supported languages.
+ *
+ * @param string The title of the popup box.
+ * @param string Which element of the box is to be selected.
+ * @return string The html select box.
+ */
+function html_get_language_popup ($title='language_id',$selected='xzxz') {
+ $res = db_query_params ('SELECT * FROM supported_languages ORDER BY name ASC',
+ array ());
+ return html_build_select_box ($res,$title,$selected,false);
+}
+
+/**
+ * html_get_theme_popup() - Pop up box of supported themes.
+ *
+ * @param string The title of the popup box.
+ * @param string Which element of the box is to be selected.
+ * @return string The html select box.
+ */
+function html_get_theme_popup ($title='theme_id',$selected='xzxz') {
+ $res=db_query_params ('SELECT theme_id, fullname FROM themes WHERE enabled=true',
+ array());
+ $nbTheme = db_numrows($res);
+ if($nbTheme < 2) {
+ return("");
+ }
+ else {
+ return html_build_select_box($res,$title,$selected,false);
+ }
+}
+
+/**
+ * html_get_ccode_popup() - Pop up box of supported country_codes.
*
- * @param object BaseLanguage object
- * @param string The title of the popup box
- * @param string Which element of the box is to be selected
+ * @param string The title of the popup box.
+ * @param string Which element of the box is to be selected.
+ * @return string The html select box.
*/
-function html_get_language_popup ($Language,$title='language_id',$selected='xzxzxz') {
- $res=$Language->getLanguages();
+function html_get_ccode_popup ($title='ccode',$selected='xzxz') {
+ $res=db_query_params ('SELECT ccode,country_name FROM country_code ORDER BY country_name',
+ array());
return html_build_select_box ($res,$title,$selected,false);
}
/**
- * html_get_timezone_popup() - Pop up box of supported Timezones
- * Assumes you have included Timezones array file
+ * html_get_timezone_popup() - Pop up box of supported Timezones.
+ * Assumes you have included Timezones array file.
*
- * @param string The title of the popup box
- * @param string Which element of the box is to be selected
+ * @param string The title of the popup box.
+ * @param string Which element of the box is to be selected.
+ * @return string The html select box.
*/
function html_get_timezone_popup ($title='timezone',$selected='xzxz') {
global $TZs;
return html_build_select_box_from_arrays ($TZs,$TZs,$title,$selected,false);
}
+
+/**
+ * html_build_select_box_from_assoc() - Takes one assoc array and returns a pop-up box.
+ *
+ * @param array An array of items to use.
+ * @param string The name you want assigned to this form element.
+ * @param string The value of the item that should be checked.
+ * @param boolean Whether we should swap the keys / names.
+ * @param bool Whether or not to show the '100 row'.
+ * @param string What to call the '100 row' defaults to none.
+ */
+function html_build_select_box_from_assoc ($arr,$select_name,$checked_val='xzxz',$swap=false,$show_100=false,$text_100='None') {
+ if ($swap) {
+ $keys=array_values($arr);
+ $vals=array_keys($arr);
+ } else {
+ $vals=array_values($arr);
+ $keys=array_keys($arr);
+ }
+ return html_build_select_box_from_arrays ($keys,$vals,$select_name,$checked_val,$show_100,$text_100);
+}
+
/**
* html_build_select_box_from_array() - Takes one array, with the first array being the "id"
* or value and the array being the text you want displayed.
*
- * @param string The name you want assigned to this form element
- * @param string The value of the item that should be checked
+ * @param array An array of items to use.
+ * @param string The name you want assigned to this form element.
+ * @param string The value of the item that should be checked.
*/
function html_build_select_box_from_array ($vals,$select_name,$checked_val='xzxz',$samevals = 0) {
- $return .= '
+ $return = '
<select name="'.$select_name.'">';
$rows=count($vals);
} else {
$return .= "\n\t\t<option value=\"" . $i .'"';
if ($i == $checked_val) {
- $return .= ' selected="selection"';
+ $return .= ' selected="selected"';
}
}
$return .= '>'.htmlspecialchars($vals[$i]).'</option>';
}
/**
- * html_build_select_box_from_arrays() - Takes two arrays, with the first array being the "id" or value and the other
+ * html_build_radio_buttons_from_arrays() - Takes two arrays, with the first array being the "id" or value and the other
* array being the text you want displayed.
*
* The infamous '100 row' has to do with the SQL Table joins done throughout all this code.
* @param string The item that should be checked
* @param bool Whether or not to show the '100 row'
* @param string What to call the '100 row' defaults to none
+ * @param bool Whether or not to show the 'Any row'
+ * @param string What to call the 'Any row' defaults to any
*/
-function html_build_select_box_from_arrays ($vals,$texts,$select_name,$checked_val='xzxz',$show_100=true,$text_100='none', $pos_100='top') {
- global $Language;
+function html_build_radio_buttons_from_arrays ($vals,$texts,$select_name,$checked_val='xzxz',$show_100=true,$text_100='none',$show_any=false,$text_any='any') {
if ($text_100=='none'){
- $text_100=$Language->getText('include_html','none');
+ $text_100=_('None');
}
- $return .= '
- <select name="'.$select_name.'">';
+ $return = '';
+ $rows=count($vals);
+ if (count($texts) != $rows) {
+ $return .= 'ERROR - uneven row counts';
+ }
+
+ //we don't always want the default Any row shown
+ if ($show_any) {
+ $return .= '
+ <input type="radio" name="'.$select_name.'" value=""'.(($checked_val=='') ? ' checked="checked"' : '').' /> '. $text_any .'<br />';
+ }
//we don't always want the default 100 row shown
- if ($show_100 && $pos_100=='top') {
+ if ($show_100) {
$return .= '
- <option value="100">'. $text_100 .'</option>';
+ <input type="radio" name="'.$select_name.'" value="100"'.(($checked_val==100) ? ' checked="checked"' : '').' /> '. $text_100 .'<br />';
}
+ $checked_found=false;
+
+ for ($i=0; $i<$rows; $i++) {
+ // uggh - sorry - don't show the 100 row
+ // if it was shown above, otherwise do show it
+ if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
+ $return .= '
+ <input type="radio" name="'.$select_name.'" value="'.$vals[$i].'"';
+ if ((string)$vals[$i] == (string)$checked_val) {
+ $checked_found=true;
+ $return .= ' checked="checked"';
+ }
+ $return .= ' /> '.htmlspecialchars($texts[$i]).'<br />';
+ }
+ }
+ //
+ // If the passed in "checked value" was never "SELECTED"
+ // we want to preserve that value UNLESS that value was 'xzxz', the default value
+ //
+ if (!$checked_found && $checked_val != 'xzxz' && $checked_val && $checked_val != 100) {
+ $return .= '
+ <input type="radio" value="'.$checked_val.'" checked="checked" /> '._('No Change').'<br />';
+ }
+
+ return $return;
+}
+/**
+ * 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.
+ *
+ * The infamous '100 row' has to do with the SQL Table joins done throughout all this code.
+ * There must be a related row in users, categories, et , and by default that
+ * row is 100, so almost every pop-up box has 100 as the default
+ * Most tables in the database should therefore have a row with an id of 100 in it so that joins are successful
+ *
+ * @param array The ID or value
+ * @param array Text to be displayed
+ * @param string Name to assign to this form element
+ * @param string The item that should be checked
+ * @param bool Whether or not to show the '100 row'
+ * @param string What to call the '100 row' defaults to none
+ * @param bool Whether or not to show the 'Any row'
+ * @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) {
+ if ($text_100=='none'){
+ $text_100=_('None');
+ }
+ $return = '';
+
$rows=count($vals);
if (count($texts) != $rows) {
$return .= 'ERROR - uneven row counts';
}
+ $return .= '
+ <select name="'.$select_name.'">';
+
+ //we don't always want the default Any row shown
+ if ($show_any) {
+ $return .= '
+ <option value=""'.(($checked_val=='') ? ' selected="selected"' : '').'>'. $text_any .'</option>';
+ }
+ //we don't always want the default 100 row shown
+ if ($show_100) {
+ $return .= '
+ <option value="100"'.(($checked_val==100) ? ' selected="selected"' : '').'>'. $text_100 .'</option>';
+ }
+
+ $checked_found=false;
+
for ($i=0; $i<$rows; $i++) {
// uggh - sorry - don't show the 100 row
// if it was shown above, otherwise do show it
if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
$return .= '
<option value="'.$vals[$i].'"';
- if ($vals[$i] == $checked_val) {
+ if ((string)$vals[$i] == (string)$checked_val) {
$checked_found=true;
$return .= ' selected="selected"';
}
- $return .= '>'.htmlspecialchars($texts[$i]).'</option>';
+ if (is_array($allowed) && !in_array($vals[$i], $allowed)) {
+ $return .= ' disabled="disabled" class="option_disabled"';
+ }
+ $return .= '>'./*htmlspecialchars(*/$texts[$i]/*)*/.'</option>';
}
}
//
//
if (!$checked_found && $checked_val != 'xzxz' && $checked_val && $checked_val != 100) {
$return .= '
- <option value="'.$checked_val.'" selected="selected">'.$Language->getText('include_html','no_change').'</option>';
+ <option value="'.$checked_val.'" selected="selected">'._('No Change').'</option>';
}
- if ($show_100 && $pos_100=='bottom') {
- $return .= '
- <option value="100">'. $text_100 .'</option>';
- }
-
$return .= '
</select>';
* @param bool Whether or not to show the '100 row'
* @param string What to call the '100 row'. Defaults to none.
*/
-function html_build_select_box ($result, $name, $checked_val="xzxz",$show_100=true,$text_100='none') {
- global $Language;
+function html_build_select_box ($result, $name, $checked_val="xzxz",$show_100=true,$text_100='none',$show_any=false,$text_any='Select One') {
if ($text_100=='none'){
- $text_100=$Language->getText('include_html','none');
+ $text_100=_('None');
}
- return html_build_select_box_from_arrays (util_result_column_to_array($result,0),util_result_column_to_array($result,1),$name,$checked_val,$show_100,$text_100);
+ return html_build_select_box_from_arrays (util_result_column_to_array($result,0),util_result_column_to_array($result,1),$name,$checked_val,$show_100,$text_100, $show_any, $text_any);
}
+
+/**
+ * html_build_select_box_sorted() - Takes a result set, with the first column being the "id" or value and
+ * the second column being the text you want displayed.
+ *
+ * @param int The result set
+ * @param string Text to be displayed
+ * @param string The item that should be checked
+ * @param bool Whether or not to show the '100 row'
+ * @param string What to call the '100 row'. Defaults to none.
+ */
+function html_build_select_box_sorted ($result, $name, $checked_val="xzxz",$show_100=true,$text_100='none') {
+ if ($text_100=='none'){
+ $text_100=_('None');
+ }
+ $vals = util_result_column_to_array($result, 0);
+ $texts = util_result_column_to_array($result, 1);
+ array_multisort($texts, SORT_ASC, SORT_STRING,
+ $vals);
+ return html_build_select_box_from_arrays ($vals, $texts, $name, $checked_val, $show_100, $text_100);
+}
+
/**
* html_build_multiple_select_box() - Takes a result set, with the first column being the "id" or value
* and the second column being the text you want displayed.
*
- * @param int The result set
+ * @param int The result set
* @param string Text to be displayed
* @param string The item that should be checked
* @param int The size of this box
* @param bool Whether or not to show the '100 row'
*/
function html_build_multiple_select_box ($result,$name,$checked_array,$size='8',$show_100=true) {
- global $Language;
$checked_count=count($checked_array);
- $return .= '
+ $return = '
<select name="'.$name.'" multiple="multiple" size="'.$size.'">';
if ($show_100) {
/*
$return .= ' selected="selected"';
}
}
- $return .= '>'.$Language->getText('include_html','none').'</option>';
+ $return .= '>'._('None').'</option>';
}
$rows=db_numrows($result);
-
for ($i=0; $i<$rows; $i++) {
if ((db_result($result,$i,0) != '100') || (db_result($result,$i,0) == '100' && !$show_100)) {
$return .= '
$return .= ' selected="selected"';
}
}
- $return .= '>'.$val.'-'. substr(db_result($result,$i,1),0,35). '</option>';
+ $return .= '>'. substr(db_result($result,$i,1),0,35). '</option>';
+ }
+ }
+ $return .= '
+ </select>';
+ return $return;
+}
+
+/**
+ * html_build_multiple_select_box_from_arrays() - Takes two arrays and builds a multi-select box
+ *
+ * @param array id of the field
+ * @param array Text to be displayed
+ * @param string id of the items selected
+ * @param string The item that should be checked
+ * @param int The size of this box
+ * @param bool Whether or not to show the '100 row'
+ */
+function html_build_multiple_select_box_from_arrays($ids,$texts,$name,$checked_array,$size='8',$show_100=true,$text_100='none') {
+ $checked_count=count($checked_array);
+ $return ='
+ <select name="'.$name.'" multiple="multiple" size="'.$size.'">';
+ if ($show_100) {
+ if ($text_100=='none') {
+ $text_100=_('None');
+ }
+ /*
+ Put in the default NONE box
+ */
+ $return .= '
+ <option value="100"';
+ for ($j=0; $j<$checked_count; $j++) {
+ if ($checked_array[$j] == '100') {
+ $return .= ' selected="selected"';
+ }
+ }
+ $return .= '>'.$text_100.'</option>';
+ }
+
+ $rows=count($ids);
+ for ($i=0; $i<$rows; $i++) {
+ if (( $ids[$i] != '100') || ($ids[$i] == '100' && !$show_100)) {
+ $return .='
+ <option value="'.$ids[$i].'"';
+ /*
+ Determine if it's checked
+ */
+ $val=$ids[$i];
+ for ($j=0; $j<$checked_count; $j++) {
+ if ($val == $checked_array[$j]) {
+ $return .= ' selected="selected"';
+ }
+ }
+ $return .= '>'.$texts[$i].' </option>';
}
}
$return .= '
.($checked ? 'checked="checked"' : '').'>';
}
-/**
- * html_get_priority_color() - Return the color value for the index that was passed in
- * (defined in $sys_urlroot/themes/<selected theme>/theme.php)
- *
- * @param int Index
- */
-function html_get_priority_color ($index) {
- global $bgpri;
-
- /* make sure that index is of appropriate type and range */
- $index = (int)$index;
- if ($index<1) {
- $index=1;
- } else if ($index>9) {
- $index=9;
- }
- //return "prior$index";
- return $bgpri[$index];
-}
/**
* build_priority_select_box() - Wrapper for html_build_priority_select_box()
*
* @see html_build_priority_select_box()
*/
-function build_priority_select_box ($name='priority', $checked_val='5', $nochange=false) {
+function build_priority_select_box ($name='priority', $checked_val='3', $nochange=false) {
echo html_build_priority_select_box ($name, $checked_val, $nochange);
}
* @param string The value to be checked
* @param bool Whether to make 'No Change' selected.
*/
-function html_build_priority_select_box ($name='priority', $checked_val='5', $nochange=false) {
- global $Language;
+function html_build_priority_select_box ($name='priority', $checked_val='3', $nochange=false) {
?>
<select name="<?php echo $name; ?>">
<?php if($nochange) { ?>
- <option value="100"<?php if ($nochange) {echo " selected=\"selected\"";} ?>><?php echo $Language->getText('include_html','no_change') ?></option>
+ <option value="100"<?php if ($nochange) {echo " selected=\"selected\"";} ?>><?php echo _('No Change') ?></option>
<?php } ?>
- <option value="1"<?php if ($checked_val=="1") {echo " selected=\"selected\"";} ?>>1 - <?php echo $Language->getText('include_html','priority_lowest') ?></option>
+ <option value="1"<?php if ($checked_val=="1") {echo " selected=\"selected\"";} ?>>1 - <?php echo _('Lowest') ?></option>
<option value="2"<?php if ($checked_val=="2") {echo " selected=\"selected\"";} ?>>2</option>
<option value="3"<?php if ($checked_val=="3") {echo " selected=\"selected\"";} ?>>3</option>
<option value="4"<?php if ($checked_val=="4") {echo " selected=\"selected\"";} ?>>4</option>
- <option value="5"<?php if ($checked_val=="5") {echo " selected=\"selected\"";} ?>>5 - <?php echo $Language->getText('include_html','priority_medium') ?></option>
- <option value="6"<?php if ($checked_val=="6") {echo " selected=\"selected\"";} ?>>6</option>
- <option value="7"<?php if ($checked_val=="7") {echo " selected=\"selected\"";} ?>>7</option>
- <option value="8"<?php if ($checked_val=="8") {echo " selected=\"selected\"";} ?>>8</option>
- <option value="9"<?php if ($checked_val=="9") {echo " selected=\"selected\"";} ?>>9 - <?php echo $Language->getText('include_html','priority_highest') ?></option>
+ <option value="5"<?php if ($checked_val=="5") {echo " selected=\"selected\"";} ?>>5 - <?php echo _('Highest') ?></option>
</select>
<?php
if (!$project || !is_object($project)) {
exit_error("GROUP PROBLEM","PROBLEM CREATING GROUP OBJECT");
} else if ($project->isError()) {
+ if ($project->isPermissionDeniedError() && !session_get_user()) {
+ $next = '/account/login.php?feedback='.urlencode($project->getErrorMessage());
+ if (getStringFromServer('REQUEST_METHOD') != 'POST') {
+ $next .= '&return_to='.urlencode(getStringFromServer('REQUEST_URI'));
+ }
+ // @alu: change url.
+ header("Location: $next");
+ exit;
+ }
exit_error("Group Problem",$project->getErrorMessage());
}
session_require(array('group'=>'1'));
}
+ if (isset($params['title'])){
+ $params['title']=$project->getPublicName().': '.$params['title'];
+ } else {
+ $params['title']=$project->getPublicName();
+ }
echo $HTML->header($params);
- echo html_feedback_top($GLOBALS['feedback']);
+
+ if(isset($GLOBALS['error_msg']) && $GLOBALS['error_msg']) {
+ echo html_error_top($GLOBALS['error_msg']);
+ }
+ if(isset($GLOBALS['warning_msg']) && $GLOBALS['warning_msg']) {
+ echo html_warning_top($GLOBALS['warning_msg']);
+ }
+ if(isset($GLOBALS['feedback']) && $GLOBALS['feedback']) {
+ echo html_feedback_top($GLOBALS['feedback']);
+ }
// echo $HTML->project_tabs($params['toptab'],$params['group'],$params['tabtext']);
}
*/
function site_project_footer($params) {
GLOBAL $HTML;
-
- echo html_feedback_bottom($GLOBALS['feedback']);
echo $HTML->footer($params);
}
* @param params array() must contain $user_id
*/
function site_user_header($params) {
- GLOBAL $HTML,$Language;
+ GLOBAL $HTML;
/*
Check to see if active user
Check to see if logged in
*/
echo $HTML->header($params);
- echo html_feedback_top($GLOBALS['feedback']);
- echo ($HTML->BeginSubMenu());
- echo ($HTML->PrintSubMenu(
- array($Language->getText('menu','my_personal_page'),
- $Language->getText('menu','diary_notes'),
- $Language->getText('menu','account_maintenance'),
- $Language->getText('menu','register_project'),
- $Language->getText('menu','bookmark_page')),
- array('"/my/"',
- '"/my/diary.php"',
- '"/account/"',
- '"/register/"',
- '"/my/bookmark_add.php"')));
+ echo html_feedback_top((isset($GLOBALS['feedback']) ? $GLOBALS['feedback'] : ''));
+ echo ($HTML->beginSubMenu());
+ if ($GLOBALS['sys_use_diary']) {
+ echo ($HTML->printSubMenu(
+ array(_('My Personal Page'),
+ _('Trackers dashboard'),
+ _('Diary & Notes'),
+ _('Account Maintenance'),
+ _('Register Project')),
+ array('/my/',
+ '/my/dashboard.php',
+ '/my/diary.php',
+ '/account/',
+ '/register/')));
+ } else {
+ echo ($HTML->printSubMenu(
+ array(_('My Personal Page'),
+ _('Account Maintenance'),
+ _('Register Project')),
+ array('/my/',
+ '/account/',
+ '/register/')));
+ }
plugin_hook ("usermenu", false) ;
- echo ($HTML->EndSubMenu());
+ echo ($HTML->endSubMenu());
}
/**
* @param params array() empty
*/
function site_user_footer($params) {
- GLOBAL $HTML;
-
- echo html_feedback_bottom($GLOBALS['feedback']);
- echo $HTML->footer($params);
+ site_footer($params);
}
/**
return $hashstr;
}
+/**
+ * html_build_rich_textarea() - Renders textarea control
+ *
+ * @param name (string) - the name for the control
+ * @param rows (int) - the rows for the control (number of visible text lines)
+ * @param cols (int) - the cols for the control (visible width in average character widths)
+ * @param text (string) - initial text to be displayed
+ * @param readonly (boolean) - if the text cannot be modified
+ * @return html code for control
+ */
+function html_build_rich_textarea($name,$rows,$cols,$text,$readonly) {
+ return '<textarea name="'.$name.'"'
+ .' rows="'.$rows.'"'
+ .' cols="'.$cols.'"'
+ .($readonly ? ' readonly' : ' ').'>'
+ . $text . '</textarea>';
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
?>