/** * generate html for one attachment and for the add attachment button * @param string $list_title title of current list * @param int $attachment_id id of the attachment to generate * @param string $attachment_specifications specifications of attachment * return string resulting html */ function get_list_record_attachment($list_title, $attachment_id, $attachment_specifications) { global $logging; $logging->trace("getting list_record_attachment (attachment_specs={$attachment_specifications}"); $attachment_array = explode("|", $attachment_specifications); $tmp_file_name = $attachment_array[0]; $file_type = $attachment_array[1]; $file_size = $attachment_array[2]; $file_name = $attachment_array[3]; $logging->info("id={$attachment_id}, tmp_file_name={$tmp_file_name}, type={$file_type}, size={$file_size}, name={$file_name}"); $db_field_name = ListTable::_get_db_field_name(DB_ATTACHMENTS_NAME); # set name and id of input $input_name = $db_field_name . GENERAL_SEPARATOR . FIELD_TYPE_DEFINITION_ATTACHMENTS . GENERAL_SEPARATOR . $attachment_id; if ($attachment_id == 0) { $html_str = " <div id=\"upload_line\" class=\"upload_line\">\n"; $html_str .= " <span class=\"invisible_collapsed\" id=\"upload_attachment_id\">1</span>"; $html_str .= "<input class=\"invisible_collapsed\" name=\"{$input_name}\" id=\"{$input_name}\" value=\"" . LISTTABLEATTACHMENT_EMPTY_ATTACHMENT . "|-|-|-\">"; $html_str .= "<span id=\"upload_animation\"></span>"; $html_str .= "<span id=\"button_upload\" class=\"icon icon_add\">" . translate("BUTTON_SELECT_UPLOAD_FILE") . "</a></span>\n"; $html_str .= " </div>\n"; } else { $html_str = " <div id=\"attachment_{$attachment_id}\" class=\"attachment_line\">\n"; $html_str .= " <span id=\"attachment_name_{$attachment_id}\">"; $html_str .= "<input class=\"invisible_collapsed\" name=\"{$input_name}\" id=\"{$input_name}\" value=\"{$attachment_specifications}\">"; # existing attachments get a clickable link if ($tmp_file_name == LISTTABLEATTACHMENT_EXISTING_ATTACHMENT) { $html_str .= get_href(get_onclick(ACTION_DOWNLOAD_ATTACHMENT, HTML_NO_PERMISSION_CHECK, "", "", "('{$list_title}', '{$attachment_id}')"), str_replace(" ", " ", $file_name), "icon_attachment") . " "; } else { $html_str .= str_replace(" ", " ", $file_name) . " "; } $html_str .= get_href(get_onclick(ACTION_DELETE_ATTACHMENT, HTML_NO_PERMISSION_CHECK, "", "", "('{$attachment_id}', \$('#{$input_name}').val())"), translate("BUTTON_DELETE"), "icon_delete") . "</span>\n"; $html_str .= " </div>\n"; } $logging->trace("got list_record_attachment"); return $html_str; }
/** * return the html for a tabel that contains current list that is being build * @param array $definition defintion of current list that is being build * @return string html of current list */ function get_field_definition_table($definition) { global $logging; $logging->trace("getting field definition table"); $input_html_id = "<input type=text size=\"2\" maxlength=\"2\""; $input_html_name = "<input type=text size=\"24\" maxlength=\"40\""; $input_html_options = "<input type=text size=\"32\" maxlength=\"200\""; $input_html_value_invisible = "<input style=\"visibility: hidden;\" type=text size=\"1\" maxlength=\"100\""; $html_str = ""; $html_str .= " <div class=\"corner top_left_normal\"></div>\n"; $html_str .= " <div class=\"corner top_right_normal\"></div>\n"; $html_str .= " <div class=\"listbuilder_title\">" . translate("LABEL_DEFINE_TABLE_FIELDS") . "</div>\n"; $html_str .= " <div id=\"listbuilder_contents\" class=\"listbuilder_contents\">\n"; $html_str .= " <form id=\"database_definition_form\" action=\"javascript:void(0);\" method=\"javascript:void(0);\" onsubmit=\"javascript:void(0);\">\n"; $html_str .= " <table id=\"listbuilder_definition\" align=\"left\" border=\"0\" cellspacing=\"0\">\n"; $html_str .= " <thead>\n"; $html_str .= " <tr>\n"; $html_str .= " <th>" . translate("LABEL_FIELDTYPE") . "</th>\n"; $html_str .= " <th>" . translate("LABEL_FIELDNAME") . "</th>\n"; $html_str .= " <th>" . translate("LABEL_OPTIONS") . "</th>\n"; $html_str .= " <th> </th>\n"; $html_str .= " <th colspan=\"3\"> </th>\n"; $html_str .= " </tr>\n"; $html_str .= " </thead>\n"; $html_str .= " <tbody>\n"; for ($row = 0; $row < count($definition) / 4; $row += 1) { $position_id = $row * 4; $position_type = $row * 4 + 1; $position_name = $row * 4 + 2; $position_options = $row * 4 + 3; $logging->debug("row " . $row . " (id=" . $definition[$position_id] . ", type=" . $definition[$position_type] . ", name=" . $definition[$position_name] . ", opt=" . $definition[$position_options] . ")"); # do not display a row for the attachment field if ($definition[$position_type] == FIELD_TYPE_DEFINITION_ATTACHMENTS && $definition[$position_name] == DB_ATTACHMENTS_NAME) { $html_str .= " <tr class=\"invisible_collapsed\">\n"; } else { $html_str .= " <tr>\n"; } # first an invisible column $html_str .= " <td class=\"invisible_collapsed\">" . $input_html_id . " readonly "; $html_str .= "name=\"row_" . $row . "_0\" value=\"" . $definition[$position_id] . "\"</td>\n"; # the first column - type # create a different kind of select for the first row and for the attachment row if ($row == 0 || $definition[$position_type] == FIELD_TYPE_DEFINITION_ATTACHMENTS && $definition[$position_name] == DB_ATTACHMENTS_NAME) { $html_str .= " <td id=\"row_" . $row . "_1\"><select class=\"inactive_input\" name=\"row_" . $row . "_1\">\n"; $html_str .= " <option value=\"" . $definition[$position_type] . "\" selected>" . translate($definition[$position_type]) . "</option>\n"; $html_str .= " </select></td>\n"; } else { $html_str .= " <td id=\"row_" . $row . "_1\">" . get_select("", $row, $definition[$position_type]) . "</td>\n"; } # the second column - name $html_str .= " <td id=\"row_" . $row . "_2\">" . $input_html_name . " name=\"row_" . $row . "_2\" "; if ($row == 0) { $html_str .= "readonly class=\"inactive_input\" "; } else { $html_str .= "class=\"input_box\" "; } $html_str .= "value=\"" . $definition[$position_name] . "\"></td>\n"; # the third column - options if ($definition[$position_type] == FIELD_TYPE_DEFINITION_SELECTION) { $html_str .= " <td id=\"row_" . $row . "_3\">" . $input_html_options . " name=\"row_" . $row . "_3\" value=\"" . $definition[$position_options] . "\"></td>\n"; } else { if ($definition[$position_type] == FIELD_TYPE_DEFINITION_NUMBER || $definition[$position_type] == FIELD_TYPE_DEFINITION_FLOAT) { $html_str .= " <td id=\"row_" . $row . "_3\"><select class=\"selection_box\" name=\"row_" . $row . "_3\">\n"; $html_str .= " <option value=\"" . NUMBER_COLUMN_NO_SUMMATION . "\""; if ($definition[$position_options] == NUMBER_COLUMN_NO_SUMMATION) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_NUMBER_COLUMN_NO_SUMMATION") . "</option>\n"; $html_str .= " <option value=\"" . NUMBER_COLUMN_SUMMATION . "\""; if ($definition[$position_options] == NUMBER_COLUMN_SUMMATION) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_NUMBER_COLUMN_SUMMATION") . "</option>\n"; $html_str .= " </select></td>\n"; } else { if ($definition[$position_type] == FIELD_TYPE_DEFINITION_AUTO_NUMBER) { $html_str .= " <td id=\"row_" . $row . "_3\"><select class=\"selection_box\" name=\"row_" . $row . "_3\">\n"; $html_str .= " <option value=\"" . COLUMN_SHOW . "\""; if ($definition[$position_options] == COLUMN_SHOW) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_COLUMN_SHOW") . "</option>\n"; $html_str .= " <option value=\"" . COLUMN_NO_SHOW . "\""; if ($definition[$position_options] == COLUMN_NO_SHOW) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_COLUMN_NO_SHOW") . "</option>\n"; $html_str .= " </select></td>\n"; } else { if ($definition[$position_type] == FIELD_TYPE_DEFINITION_AUTO_CREATED || $definition[$position_type] == FIELD_TYPE_DEFINITION_AUTO_MODIFIED) { $html_str .= " <td id=\"row_" . $row . "_3\"><select class=\"selection_box\" name=\"row_" . $row . "_3\">\n"; $html_str .= " <option value=\"" . NAME_DATE_OPTION_DATE_NAME . "\""; if ($definition[$position_options] == NAME_DATE_OPTION_DATE_NAME) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_DATE_NAME") . "</option>\n"; $html_str .= " <option value=\"" . NAME_DATE_OPTION_DATE . "\""; if ($definition[$position_options] == NAME_DATE_OPTION_DATE) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_DATE_ONLY") . "</option>\n"; $html_str .= " <option value=\"" . NAME_DATE_OPTION_NAME . "\""; if ($definition[$position_options] == NAME_DATE_OPTION_NAME) { $html_str .= " selected"; } $html_str .= ">" . translate("LABEL_NAME_ONLY") . "</option>\n"; $html_str .= " </select></td>\n"; } else { $html_str .= " <td> - " . $input_html_value_invisible . " name=\"row_" . $row . "_3\" value=\"\"></td>\n"; } } } } # the fourth column - remarks $html_str .= " <td>" . translate($definition[$position_type] . "_EXPLANATION") . "</td>\n"; # the fifth column - up if ($row > 1 && $row < count($definition) / 4 - 1) { $html_str .= " <td width=\"1%\">"; $html_str .= get_href(get_onclick(ACTION_MOVE_LISTBUILDER_ROW, HTML_NO_LIST_PERMISSION_CHECK, "", "", "({$row}, %27up%27, xajax.getFormValues(%27database_definition_form%27))"), " ", "icon_up"); $html_str .= "</td>\n"; } else { $html_str .= " <td width=\"1%\">"; $html_str .= "<p style=\"visibility: hidden;\">up</p>"; $html_str .= "</td>\n"; } # the sixth column - down if ($row > 0 && $row < count($definition) / 4 - 2) { $html_str .= " <td width=\"1%\">"; $html_str .= get_href(get_onclick(ACTION_MOVE_LISTBUILDER_ROW, HTML_NO_LIST_PERMISSION_CHECK, "", "", "({$row}, %27down%27, xajax.getFormValues(%27database_definition_form%27))"), " ", "icon_down"); $html_str .= "</td>\n"; } else { $html_str .= " <td width=\"1%\">"; $html_str .= "<p style=\"visibility: hidden;\">dn</p>"; $html_str .= "</td>\n"; } # the seventh column - delete if ($row > 0 && $row < count($definition) / 4 - 1) { $html_str .= " <td width=\"1%\">"; $html_str .= get_href(get_onclick(ACTION_DELETE_LISTBUILDER_ROW, HTML_NO_LIST_PERMISSION_CHECK, "", "", "({$row}, xajax.getFormValues(%27database_definition_form%27))"), translate("BUTTON_DELETE"), "icon_delete"); $html_str .= "</td>\n"; } else { $html_str .= " <td width=\"1%\">"; $html_str .= "<p style=\"visibility: hidden;\">dl</p>"; $html_str .= "</td>\n"; } $html_str .= " </tr>\n"; } $html_str .= " </tbody>\n"; $html_str .= " </table> <!-- listbuilder_general_settings -->\n"; $html_str .= " </form> <!-- database_definition_form -->\n\n"; $html_str .= " </div> <!-- listbuilder_contents -->\n"; $html_str .= " <div class=\"corner bottom_left_normal\"></div>\n"; $html_str .= " <div class=\"corner bottom_right_normal\"></div>\n"; $logging->trace("got field definition table"); return $html_str; }
/** * get html for filter * @param $database_table DatabaseTable database table object * @param $list_title string title of list * @return string returned html */ function get_filter($database_table, $list_title) { $this->_log->trace("get filter"); $html_str = ""; $this->_user->get_list_state($database_table->get_table_name()); $filter_str = $this->_list_state->get_filter_str(); $html_str .= " <div id=\"" . $this->configuration[HTML_TABLE_CSS_NAME_PREFIX] . "filter\">\n"; $html_str .= " <form name=\"filter_form_name\" id=\"filter_form\" "; $html_str .= "onsubmit=\"javascript:handleFunction('action_set_" . $this->configuration[HTML_TABLE_JS_NAME_PREFIX] . "filter', '" . $list_title . "', document.getElementById('filter_str').value); return false;\">\n"; $html_str .= " <input size=\"34\" maxlength=\"100\" value=\"" . $filter_str . "\" id=\"filter_str\">\n"; $html_str .= " " . get_href(get_onclick(ACTION_SET_LIST_FILTER, $list_title, "filter_str", "below", "(%27" . $list_title . "%27, document.getElementById(%27filter_str%27).value)"), " ", "icon_none") . "\n"; $html_str .= " </form>\n"; $html_str .= " " . get_href(get_onclick(ACTION_SET_LIST_FILTER, $list_title, "filter_str", "below", "(%27" . $list_title . "%27, %27%27)"), " ", "icon_delete") . "\n"; $html_str .= " </div>\n"; $this->_log->trace("got filter"); return $html_str; }
/** * get html to display the login status of a user * @param $response xajaxResponse response object * @return string html for login status */ function get_login_status() { global $user; global $logging; $html_str = ""; $logging->trace("getting login_status"); $html_str .= "<div id=\"header_contents_status_login_status_left\"></div>"; $html_str .= "<div id=\"header_contents_status_login_status_body\">"; if ($user->is_login()) { $html_str .= get_href(get_onclick(ACTION_LOGOUT, HTML_NO_PERMISSION_CHECK, "", "", ""), translate("BUTTON_LOGOUT") . " " . $user->get_name(), "icon_cancel") . "</div>"; } else { $html_str .= translate("LABEL_ANONYMOUS_USER") . "</div>"; } $html_str .= "<div id=\"header_contents_status_login_status_right\"></div>"; $logging->trace("got login_status"); return $html_str; }
/** * generate html for one note * this function is called only by function get_list_record_notes * @todo list of arguments is too long * @param string $db_field_name name of the field that contains this note * @param int $count the index number of this note * @param int $is_last indicates that this is the last existing note when set to 1 * @param int $id the id number of this note * @param array $note_array array describing a single note * @return string resulting html */ function get_list_record_note($db_field_name, $count, $is_last, $id, $note_array) { global $user; global $logging; $html_str = ""; # display the first note only if ($count == 0) { $class_name = ""; } else { $class_name = "invisible_collapsed"; } # set the previous and next count $previous_count = $count - 1; $next_count = $count + 1; if ($id == 0) { $next_count = -1; } # set the id's for current, previous and next note $td_id = $db_field_name . "_" . $count; $previous_td_id = $db_field_name . "_" . $previous_count; $next_td_id = $db_field_name . "_" . $next_count; # set name of textarea $textarea_name = $db_field_name . GENERAL_SEPARATOR . FIELD_TYPE_DEFINITION_NOTES_FIELD . GENERAL_SEPARATOR . $id; # set the text of note when this is not a new note if ($id != 0) { $note_str = str_replace("\n", "\\n", $note_array["_note"]); } else { $note_str = ""; } $logging->trace("getting list_record_note (count={$count}, is_last={$is_last}, id={$id})"); $html_str .= " <td id=\"{$td_id}\" class=\"{$class_name}\">\n"; # create a box around the actual note and the various buttons $html_str .= " <div class=\"note_box\">\n"; # first we will create the delete button with its containers $html_str .= " <div class=\"note_box_top_buttons\">\n"; # show reference to previous note $html_str .= " <div id=\"" . $td_id . "_ref_prev\" class=\"invisible_collapsed\">" . $previous_count . "</div>\n"; # show reference to next note $html_str .= " <div id=\"" . $td_id . "_ref_next\" class=\"invisible_collapsed\">" . $next_count . "</div>\n"; # set to 1 when this note has an add button $html_str .= " <div id=\"" . $td_id . "_ref_add\" class=\"invisible_collapsed\">" . $is_last . "</div>\n"; $html_str .= " <div id=\"" . $td_id . "_delete\" class=\"note_box_top_buttons_right\">"; # only display delete button when this is an existing note if ($id != 0) { $html_str .= get_href(get_onclick(ACTION_DELETE_NOTE, HTML_NO_PERMISSION_CHECK, "", "", "('{$db_field_name}', {$count}, \$('#" . $td_id . "_ref_prev').html(), \$('#" . $td_id . "_ref_next').html(), \$('#" . $td_id . "_ref_add').html())"), translate("BUTTON_DELETE_NOTE"), "icon_delete"); } else { $html_str .= get_inactive_button(translate("BUTTON_DELETE_NOTE")); } $html_str .= "</div>\n"; $html_str .= " </div>\n"; # next we will display info about the creator of this note only when this is not a new note $html_str .= " <div class=\"note_box_header\">"; if ($id != 0) { $html_str .= str_replace('-', '‑', get_date_str(DATE_FORMAT_NORMAL, $note_array[DB_TS_CREATED_FIELD_NAME], $user->get_date_format())); $html_str .= " (" . $note_array[DB_CREATOR_FIELD_NAME] . ")"; } else { $html_str .= translate("LABEL_NEW_NOTE") . " (" . $user->get_name() . ")"; } $html_str .= "</div>\n"; $html_str .= " <textarea cols=60 rows=4 name=\"{$textarea_name}\" id=\"" . $td_id . "_note\" class=\"note_text\">{$note_str}</textarea>\n"; $html_str .= " <div class=\"note_box_bottom_buttons\">\n"; $html_str .= " <div id=\"" . $td_id . "_previous" . "\" class=\"note_box_bottom_buttons_left\">"; # display button to go to the previous note when this is note the first note if ($count != 0) { $html_str .= get_href(get_onclick(ACTION_PREVIOUS_NOTE, HTML_NO_PERMISSION_CHECK, "", "", "('{$db_field_name}', {$count}, \$('#" . $td_id . "_ref_prev').html())"), translate("BUTTON_PREVIOUS_NOTE"), "icon_back"); } else { $html_str .= get_inactive_button(translate("BUTTON_PREVIOUS_NOTE")); } $html_str .= "</div>\n"; $html_str .= " <div id=\"" . $td_id . "_next" . "\" class=\"note_box_bottom_buttons_right\">"; # display inactive buttion when there is no next note if ($id == 0) { $html_str .= get_inactive_button(translate("BUTTON_ADD_NOTE")); } else { if ($is_last == 1) { $html_str .= get_href(get_onclick(ACTION_ADD_NOTE, HTML_NO_PERMISSION_CHECK, "", "", "('{$db_field_name}', {$count}, \$('#" . $td_id . "_ref_next').html())"), translate("BUTTON_ADD_NOTE"), "icon_add"); } else { $html_str .= get_href(get_onclick(ACTION_NEXT_NOTE, HTML_NO_PERMISSION_CHECK, "", "", "('{$db_field_name}', {$count}, \$('#" . $td_id . "_ref_next').html())"), translate("BUTTON_NEXT_NOTE"), "icon_next"); } } $html_str .= " </div>\n"; $html_str .= " </div>\n"; $html_str .= " </div>\n"; $html_str .= " </td>\n"; $logging->trace("got list_record_note"); return $html_str; }