while ($row = $database->fetch($query_result)) { #echo " found list <strong>".$row[0]."</strong><br>"; array_push($all_lists, array($row[0], $row[1])); } } else { fatal("could not find any lists"); } foreach ($all_lists as $row) { $list_name = $row[0]; $table_name = ListTable::_convert_list_name_to_table_name($list_name); $definition = (array) $json->decode(html_entity_decode(html_entity_decode($row[1], ENT_QUOTES), ENT_QUOTES)); $db_field_names = array_keys($definition); foreach ($db_field_names as $db_field_name) { $field_definition = $definition[$db_field_name]; $field_type = $field_definition[0]; $field_name = ListTable::_get_field_name($db_field_name); if ($field_type == "LABEL_DEFINITION_DATE") { $new_field_type = FIELD_TYPE_DEFINITION_DATETIME; } $new_field_type = $field_type; $new_field_definition = array(); array_push($new_field_definition, $new_field_type); array_push($new_field_definition, $field_definition[1]); $definition[$field_name] = $new_field_definition; # update auto created or auto update field if ($field_type == "LABEL_DEFINITION_DATE") { # update list table description echo " update field <strong>{$field_name}</strong> of list <strong>{$list_name}</strong><br>"; $query = "ALTER TABLE {$table_name} MODIFY COLUMN {$db_field_name} " . DB_DATATYPE_DATETIME; echo $query . "<br>\n"; $result = $database->query($query);
/** * set the html for the listbuilder page * this function is registered in xajax * @param string $list_title title of list * @return xajaxResponse every xajax registered function needs to return this object */ function action_get_listbuilder_page($list_title) { global $logging; global $user; global $list_table_description; global $firstthingsfirst_field_descriptions; global $user_start_time_array; $field_types = array_keys($firstthingsfirst_field_descriptions); $old_list_loaded = FALSE; $logging->info("USER_ACTION " . __METHOD__ . " (user="******")"); # store start time $user_start_time_array[__METHOD__] = microtime(TRUE); # create necessary objects $response = new xajaxResponse(); $json = new Services_JSON(); # load list details when list title has been given if (strlen($list_title)) { $counter = 0; $definition = array(); $record = $list_table_description->select_record($list_title); # just create an empty list when list could not be loaded if (count($record) == 0) { $definition = array(0, FIELD_TYPE_DEFINITION_AUTO_NUMBER, "id", "", 1, FIELD_TYPE_DEFINITION_TEXT_LINE, "", "", 2, FIELD_TYPE_DEFINITION_ATTACHMENTS, DB_ATTACHMENTS_NAME, ""); $old_definition = htmlentities($json->encode($definition), ENT_QUOTES); $largest_id = 2; } else { $old_definition = $record[LISTTABLEDESCRIPTION_DEFINITION_FIELD_NAME]; $field_names = array_keys($old_definition); $largest_id = count($field_names) - 1; # create definition array from stored definition foreach ($field_names as $field_name) { $row = $old_definition[$field_name]; $definition[$counter * 4] = $counter; $definition[$counter * 4 + 1] = $row[0]; $definition[$counter * 4 + 2] = ListTable::_get_field_name($field_name); $definition[$counter * 4 + 3] = $row[1]; # copy in field_visible_in_overview if ($field_name == DB_ID_FIELD_NAME) { $definition[$counter * 4 + 3] = $row[2]; } $counter += 1; } $old_definition = htmlentities($json->encode($definition), ENT_QUOTES); $old_list_loaded = TRUE; } } else { $definition = array(0, FIELD_TYPE_DEFINITION_AUTO_NUMBER, "id", "", 1, FIELD_TYPE_DEFINITION_TEXT_LINE, "", "", 2, FIELD_TYPE_DEFINITION_ATTACHMENTS, DB_ATTACHMENTS_NAME, ""); $old_definition = htmlentities($json->encode($definition), ENT_QUOTES); $largest_id = 2; } # different page title when list title has been given if ($old_list_loaded == TRUE) { $page_title = translate("LABEL_MODIFY_LIST") . " '" . $record[LISTTABLEDESCRIPTION_TITLE_FIELD_NAME] . "'"; } else { $page_title = translate("LABEL_CONFIGURE_NEW_LIST"); } $html_str = ""; $html_str .= "\n\n <div id=\"listbuilder_statics_pane\" class=\"listbuilder_pane\">\n"; $html_str .= " </div> <!-- listbuilder_pane -->\n"; $html_str .= " <div id=\"listbuilder_configuration_pane\" class=\"listbuilder_pane\">\n"; $html_str .= " </div> <!-- listbuilder_pane -->\n"; #action bar $html_str .= " <div id=\"action_bar\" align=\"left\" valign=\"top\">\n"; $html_str .= " <div class=\"corner top_left_normal\"></div>\n"; $html_str .= " <div class=\"corner top_right_normal\"></div>\n"; # display the selection box to add a new column $html_str .= " " . get_select("add_select", 0, "") . "\n"; $args_str = "(document.getElementById('add_select').value, xajax.getFormValues('database_definition_form'), "; $args_str .= "document.getElementById('largest_id').innerHTML)"; $html_str .= " <span id=\"action_bar_button_add\">"; $html_str .= get_href(get_onclick(ACTION_INSERT_LISTBUILDER_ROW, HTML_NO_PERMISSION_CHECK, "", "", $args_str), translate("BUTTON_ADD_FIELD"), "icon_add"); $html_str .= "</span>\n"; # display the modify button when a title has been given if ($old_list_loaded == TRUE) { $args_str = "handleFunction(%22" . ACTION_MODIFY_LIST . "%22, %22" . $record[LISTTABLEDESCRIPTION_TITLE_FIELD_NAME] . "%22, document.getElementById(%22listbuilder_list_title_id%22).value, "; $args_str .= "document.getElementById(%22listbuilder_list_description_id%22).value, "; $args_str .= "xajax.getFormValues(%22database_definition_form%22))"; $html_str .= " <span id=\"action_bar_button_modify\">"; $html_str .= get_href(get_onclick_confirm(ACTION_MODIFY_LIST, $list_title, "action_bar_button_modify", "above", $args_str, translate("LABEL_CONFIRM_MODIFY")), translate("BUTTON_MODIFY_LIST"), "icon_accept"); $html_str .= "</span>\n"; } else { $args_str = "(document.getElementById(%27listbuilder_list_title_id%27).value, "; $args_str .= "document.getElementById(%27listbuilder_list_description_id%27).value, "; $args_str .= "xajax.getFormValues(%27database_definition_form%27))"; $html_str .= " <span id=\"action_bar_button_create\">"; $html_str .= get_href(get_onclick(ACTION_CREATE_LIST, HTML_NO_LIST_PERMISSION_CHECK, "action_bar_button_create", "above", $args_str), translate("BUTTON_CREATE_LIST"), "icon_accept"); $html_str .= "</span>\n"; } # add largest id $html_str .= " <span id=\"largest_id\" class=\"invisible_collapsed\">" . $largest_id . "</span>\n"; $html_str .= " <div class=\"corner bottom_left_normal\"></div>\n"; $html_str .= " <div class=\"corner bottom_right_normal\"></div>\n"; $html_str .= " </div> <!-- action_bar -->\n"; $response->assign("page_title", "innerHTML", $page_title); $response->assign("navigation_container", "innerHTML", get_page_navigation(PAGE_TYPE_LISTBUILDER)); $response->assign("main_body", "innerHTML", $html_str); # set html for listbuilder statics pane $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_GENERAL_SETTINGS") . "</div>\n"; $html_str .= " <div class=\"listbuilder_contents\">\n"; $html_str .= " <div class=\"listbuilder_contents_line\">\n"; $html_str .= " <div class=\"listbuilder_contents_line_left\">" . translate("LABEL_TITLE_OF_THIS_LIST") . "</div>\n"; $html_str .= " <div class=\"listbuilder_contents_line_right\">"; # set value for title when list title has been given if ($old_list_loaded == TRUE) { $html_str .= "<input size=\"20\" maxlength=\"100\" id=\"listbuilder_list_title_id\""; $html_str .= " value=\"" . $record[LISTTABLEDESCRIPTION_TITLE_FIELD_NAME] . "\" type=\"text\"></div>\n"; } else { $html_str .= "<input size=\"20\" maxlength=\"100\" id=\"listbuilder_list_title_id\" type=\"text\"></div>\n"; } $html_str .= " </div> <!-- listbuilder_contents_line -->\n"; $html_str .= " <div class=\"listbuilder_contents_line\">\n"; $html_str .= " <div class=\"listbuilder_contents_line_left\">" . translate("LABEL_SHORT_DESCRIPTION_OF_THIS_LIST") . "</div>\n"; $html_str .= " <div class=\"listbuilder_contents_line_right\">"; # set value for description when list title has been given if ($old_list_loaded == TRUE) { $html_str .= "<textarea cols=\"60\" rows=\"4\" id=\"listbuilder_list_description_id\">"; $html_str .= $record[LISTTABLEDESCRIPTION_DESCRIPTION_FIELD_NAME] . "</textarea></div>\n"; } else { $html_str .= "<textarea cols=\"60\" rows=\"4\" id=\"listbuilder_list_description_id\"></textarea></div>\n"; } $html_str .= " </div> <!-- listbuilder_contents_line -->\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"; $response->custom_response->assign_with_effect("listbuilder_statics_pane", $html_str); # set html for listbuilder configuration pane $html_str = get_field_definition_table($definition); $response->custom_response->assign_with_effect("listbuilder_configuration_pane", $html_str); $response->assign("largest_id", "innerHTML", $largest_id); $response->assign("footer_text", "innerHTML", " "); if ($old_list_loaded == FALSE && strlen($list_title) > 0) { $error_message_str = $list_table_description->get_error_message_str(); $error_log_str = $list_table_description->get_error_log_str(); $error_str = $list_table_description->get_error_str(); set_error_message("tab_listbuilder_id", "below", $error_message_str, $error_log_str, $error_str, $response); } # log total time for this function $logging->info(get_function_time_str(__METHOD__)); return $response; }