/** * @param string $json_column_array * @param string $json_argument_array * @param string $css_page_id * @param string $css_row_sort_id * @param string $entries_per_page * @param string $page * @param string $sortvalue * @param string $sortmethod * @return string * @throws BaseAjaxArgumentMissingException */ public static function list_items($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod) { $argument_array = json_decode($json_argument_array); if (is_array($argument_array)) { $string = $argument_array[0][1]; $item_type_array = $argument_array[1][1]; $language_id = $argument_array[2][1]; $list_request = new ListRequest_IO(); $list_request->set_column_array($json_column_array); if (!is_numeric($entries_per_page) or $entries_per_page < 1) { $entries_per_page = 20; } $list_array = Item_Wrapper::list_fulltext_search($string, $item_type_array, $language_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page); if (is_array($list_array) and count($list_array) >= 1) { $item_type_array = Item::list_types(); foreach ($list_array as $key => $value) { $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']); $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false); $sample_paramquery = array(); $sample_paramquery['username'] = $_GET['username']; $sample_paramquery['session_id'] = $_GET['session_id']; $sample_paramquery['nav'] = "sample"; $sample_paramquery['run'] = "detail"; $sample_paramquery['sample_id'] = $value['sample_id']; $sample_params = http_build_query($sample_paramquery, '', '&'); $tmp_sample_name = $list_array[$key]['sample_name']; unset($list_array[$key]['sample_name']); $list_array[$key]['sample_name']['content'] = $tmp_sample_name; $list_array[$key]['sample_name']['link'] = $sample_params; if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $item_key => $item_value) { if ($value[$item_key . "_id"] != null) { $list_array[$key]['type'] = $item_value::get_generic_name($item_key, null); $tmp_item_name = $list_array[$key]['name']; unset($list_array[$key]['name']); $list_array[$key]['name']['content'] = $tmp_item_name; $list_array[$key]['name']['link'] = $item_value::get_generic_link($item_key, $value[$item_key . "_id"]); $list_array[$key]['symbol']['content'] = $item_value::get_generic_symbol($item_key, $value[$item_key . "_id"]); $list_array[$key]['symbol']['link'] = $item_value::get_generic_link($item_key, $value[$item_key . "_id"]); } } } } } else { $list_request->empty_message("<span class='italic'>No results found!</span>"); } $list_request->set_array($list_array); return $list_request->get_page($page); } else { throw new BaseAjaxArgumentMissingException(); } }
/** * @see ProjectInterface::is_sub_item_required() * @param integer $parent_pos_id * @param integer $status_id * @param integer $sub_item_pos_id * @return integer */ public function is_sub_item_required($parent_pos_id, $status_id, $sub_item_pos_id) { if ($this->project_id and $this->project and is_numeric($status_id)) { $project_template = new ProjectTemplate($this->project->get_template_id()); $start_status = false; $all_status_array = $project_template->get_all_status(); foreach ($all_status_array as $key => $current_status_id) { if ($current_status_id == $status_id) { $start_status = true; } if ($start_status === true) { $requirements_array = $project_template->get_status_requirements($current_status_id); $counter = 0; $sub_item_counter = 0; $fulfilled_counter = 0; $in_item = false; if (is_array($requirements_array) and count($requirements_array) >= 1) { $project_item = new ProjectItem($this->project_id); $item_array = $project_item->get_project_status_items_with_pos_id($current_status_id); $item_type_array = Item::list_types(); foreach ($requirements_array as $key => $value) { // ITEM if ($value['xml_element'] == "item" and !$value['close']) { $in_item = true; if ($value['pos_id']) { $pos_id = $value['pos_id']; } else { $pos_id = $counter; } if ($pos_id != $parent_pos_id) { continue; } else { if (is_array($item_array) and count($item_array) >= 1) { $item_instance_array = array(); foreach ($item_array as $item_key => $item_value) { if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $item_type => $item_handling_class) { if (class_exists($item_handling_class)) { if ($item_handling_class::is_kind_of($item_type, $item_value['item_id']) == true and $item_value['pos_id'] == $pos_id and $item_value['pos_id'] !== null and $pos_id !== null) { $item_instance_array[$fulfilled_counter] = $item_handling_class::get_instance_by_item_id($item_value['item_id']); $fulfilled_counter++; break; } } } } } if (is_array($item_instance_array) and count($item_instance_array) >= 1) { if ($value['inherit'] == "all" or $force_inherit == true) { if (is_array($item_instance_array) and count($item_instance_array) >= 1 and $fulfilled_counter >= 1) { foreach ($item_instance_array as $object_key => $object_value) { if (is_object($object_value)) { if ($object_value instanceof ItemHolderInterface) { $sub_item_array = $object_value->get_item_add_information(); if (is_array($sub_item_array) and count($sub_item_array) >= 1) { foreach ($sub_item_array as $sub_item_key => $sub_item_value) { if ($sub_item_value['pos_id'] == $sub_item_pos_id) { return $current_status_id; } } } } } } } } } else { return null; } } } } if ($value['xml_element'] == "item" and $value['close'] == "1") { $counter++; $sub_item_counter = 0; $in_item = false; } // ITEMI if ($value['xml_element'] == "itemi" and !$value['close']) { if (is_numeric($value['parent_status']) and is_numeric($value['parent_pos_id']) and is_numeric($value['pos_id'])) { if ($value['pos_id'] == $sub_item_pos_id and $value['parent_pos_id'] == $parent_pos_id) { return $current_status_id; } else { continue; } } elseif ($in_item == true and is_array($item_instance_array) and count($item_instance_array) >= 1) { foreach ($item_instance_array as $object_key => $object_value) { if (is_numeric($value['pos_id'])) { $pos_id = $value['pos_id']; } else { $pos_id = $sub_item_counter; } if ($pos_id == $sub_item_pos_id) { return $current_status_id; } else { continue; } } $sub_item_counter++; } } } } } } return null; } else { return null; } }
/** * @todo search on read-only projects */ public static function search() { global $user, $session; if ($_GET['nextpage']) { if ($_GET['sortvalue'] and $_GET['sortmethod']) { if ($_GET['nextpage'] == "2" and $_POST['string']) { $string = $_POST['string']; $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } else { $string = $session->read_value("SEARCH_DATA_STRING"); $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } } else { if ($_GET['page']) { $string = $session->read_value("SEARCH_DATA_STRING"); $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } else { if ($_GET['nextpage'] == "1") { $string = $_POST['string']; $session->delete_value("SEARCH_DATA_STRING"); $session->delete_value("SEARCH_DATA_ITEM_TYPE"); $session->delete_value("SEARCH_DATA_PROJECT_ID"); } else { $string = $_POST['string']; $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } } } $no_error = true; } else { $no_error = false; } if ($no_error == false) { $template = new HTMLTemplate("project/search/data_search.html"); $template->set_var("error", ""); $paramquery = $_GET; unset($paramquery['page']); $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $result = array(); $counter = 0; $project_array = Project::list_user_related_projects($user->get_user_id(), false); if (is_array($project_array) and count($project_array) >= 1) { foreach ($project_array as $key => $value) { $project = new Project($value); $organisation_unit = new OrganisationUnit($project->get_organisation_unit_id()); $result[$counter]['value'] = $value; $result[$counter]['content'] = $project->get_name() . " (" . $organisation_unit->get_name() . ")"; $result[$counter]['selected'] = ""; $counter++; } } $template->set_var("project_array", $result); $result = array(); $counter = 0; $item_type_array = Item::list_types(); if (is_array($item_type_array)) { foreach ($item_type_array as $key => $value) { if (class_exists($value)) { if ($value::get_sql_select_array($key) != null) { $result[$counter]['title'] = $value::get_generic_name($key, null); $result[$counter]['name'] = "item-" . $key; $result[$counter]['value'] = $key; $result[$counter]['checked'] = "checked='checked'"; $counter++; } } } } $template->set_var("item_type_array", $result); $template->output(); } else { if (!$project_id_array) { if ($_POST['project_id'] == 0) { $project_id_array = array(); $tmp_id_array = Project::list_user_related_projects($user->get_user_id(), false); if (is_array($tmp_id_array) and count($tmp_id_array) >= 1) { foreach ($tmp_id_array as $key => $value) { array_push($project_id_array, $value); } } } else { $project_id_array = array(); $project_id_array[0] = $_POST['project_id']; $project = new Project($_POST['project_id']); $search_name = $project->get_name(); } } else { if (count($project_id_array) == 1) { $project = new Project($project_id_array[0]); $search_name = $project->get_name(); } else { $search_name = "All"; } } if (!$item_type_array) { $item_type_array = array(); foreach ($_POST as $key => $value) { if (strpos($key, "item-") === 0) { array_push($item_type_array, $value); } } if (!$item_type_array) { $tmp_item_type_array = Item::list_types(); foreach ($tmp_item_type_array as $key => $value) { if (class_exists($value)) { if ($value::get_sql_select_array($key) != null) { array_push($item_type_array, $key); } } } } } $session->write_value("SEARCH_DATA_STRING", $string, true); $session->write_value("SEARCH_DATA_ITEM_TYPE", $item_type_array, true); $session->write_value("SEARCH_DATA_PROJECT_ID", $project_id_array, true); $argument_array = array(); $argument_array[0][0] = "string"; $argument_array[0][1] = $string; $argument_array[1][0] = "project_id_array"; $argument_array[1][1] = $project_id_array; $argument_array[2][0] = "item_type_array"; $argument_array[2][1] = $item_type_array; $list = new List_IO("ProjectDataSearch", "ajax.php?nav=project", "search_project_data_list_projects", "search_project_data_count_projects", $argument_array, "ProjectDataSearch"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("ProjectGeneralListColumnName", "general"), "name", true, null); $list->add_column(Language::get_message("ProjectGeneralListColumnType", "general"), "type", false, null); $list->add_column(Language::get_message("ProjectGeneralListColumnDateTime", "general"), "datetime", true, null); $list->add_column(Language::get_message("ProjectGeneralListColumnProject", "general"), "project_name", true, null); $template = new HTMLTemplate("project/search/data_search_result.html"); $paramquery = $_GET; $paramquery['nextpage'] = "2"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("string", $string); $template->set_var("list", $list->get_list()); $template->output(); } }
/** * @see SampleInterface::is_sub_item_required() * @param integer $parent_pos_id * @param integer $sub_item_pos_id * @return array */ public function is_sub_item_required($parent_pos_id, $sub_item_pos_id) { global $runtime_data; if ($this->sample_id and $this->sample) { $sample_template = new SampleTemplate($this->sample->get_template_id()); $requirements_array = $sample_template->get_requirements(); if (is_array($requirements_array) and count($requirements_array) >= 1) { if ($runtime_data->is_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_TYPE_ARRAY") == true) { $item_type_array = $runtime_data->read_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_TYPE_ARRAY"); } else { $item_type_array = Item::list_types(); $runtime_data->write_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_TYPE_ARRAY", $item_type_array); } if ($runtime_data->is_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_ARRAY") == true) { $item_array = $runtime_data->read_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_ARRAY"); } else { $sample_item = new SampleItem($this->sample_id); $item_array = $sample_item->get_sample_items_with_pos_id(); $runtime_data->write_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_ARRAY", $item_array); } $counter = 0; $sub_item_counter = 0; $fulfilled_counter = 0; $in_item = false; foreach ($requirements_array as $key => $value) { if ($value['xml_element'] == "item" and !$value['close']) { $in_item = true; if ($value['pos_id']) { $pos_id = $value['pos_id']; } else { $pos_id = $counter; } if ($pos_id != $parent_pos_id) { continue; } else { if ($value['type'] == "parentsample") { $parent_sample_array = SampleItem::list_sample_id_by_item_id_and_gid_and_parent($this->get_item_id(), $parent_pos_id); if (is_array($parent_sample_array) and count($parent_sample_array) >= 1) { foreach ($parent_sample_array as $parent_sample_key => $parent_sample_value) { $item_instance = new Sample($parent_sample_value); $item_instance_array[$fulfilled_counter] = $item_instance; $fulfilled_counter++; } } } elseif (is_array($item_array) and count($item_array) >= 1) { $item_instance_array = array(); foreach ($item_array as $item_key => $item_value) { if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $item_type => $item_handling_class) { if (class_exists($item_handling_class)) { if ($item_handling_class::is_kind_of($item_type, $item_value['item_id']) == true and $item_value['pos_id'] == $pos_id and $item_value['pos_id'] !== null and $pos_id !== null) { $item_instance_array[$fulfilled_counter] = $item_handling_class::get_instance_by_item_id($item_value['item_id']); $fulfilled_counter++; break; } } } } } } if (is_array($item_instance_array) and count($item_instance_array) >= 1) { if ($value['inherit'] == "all" or $force_inherit == true) { if (is_array($item_instance_array) and count($item_instance_array) >= 1 and $fulfilled_counter >= 1) { foreach ($item_instance_array as $object_key => $object_value) { if (is_object($object_value)) { if ($object_value instanceof ItemHolderInterface) { $sub_item_array = $object_value->get_item_add_information(); if (is_array($sub_item_array) and count($sub_item_array) >= 1) { foreach ($sub_item_array as $sub_item_key => $sub_item_value) { if ($sub_item_value['pos_id'] == $sub_item_pos_id) { return true; } } } } } } } } } else { return false; } } } if ($value['xml_element'] == "item" and $value['close'] == "1") { $counter++; $sub_item_counter = 0; $in_item = false; } if ($value['xml_element'] == "itemi" and !$value['close']) { if ($in_item == true and is_array($item_instance_array) and count($item_instance_array) >= 1) { foreach ($item_instance_array as $object_key => $object_value) { if (is_numeric($value['pos_id'])) { $pos_id = $value['pos_id']; } else { $pos_id = $sub_item_counter; } if ($pos_id == $sub_item_pos_id) { return true; } else { continue; } } $sub_item_counter++; } } } return false; } else { return false; } } else { return false; } }
public static function search() { global $session; if ($_GET['nextpage']) { if ($_GET['sortvalue'] and $_GET['sortmethod']) { if ($_GET['nextpage'] == "2" and $_POST['string']) { $string = $_POST['string']; $item_type_array = $session->read_value("SEARCH_FULL_TEXT_ITEM_TYPE"); } else { $string = $session->read_value("SEARCH_FULL_TEXT_STRING"); $item_type_array = $session->read_value("SEARCH_FULL_TEXT_ITEM_TYPE"); } } else { if ($_GET['page']) { $string = $session->read_value("SEARCH_FULL_TEXT_STRING"); $item_type_array = $session->read_value("SEARCH_FULL_TEXT_ITEM_TYPE"); } else { if ($_GET['nextpage'] == "1") { $string = $_POST['string']; $session->delete_value("SEARCH_FULL_TEXT_ITEM_TYPE"); } else { $string = $_POST['string']; $item_type_array = $session->read_value("SEARCH_FULL_TEXT_ITEM_TYPE"); } } } $no_error = true; } else { $no_error = false; } if ($no_error == false) { $template = new HTMLTemplate("item/search/full_text_search.html"); $paramquery = $_GET; unset($paramquery['page']); $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", ""); $result = array(); $counter = 0; $item_type_array = Item::list_types(); if (is_array($item_type_array)) { foreach ($item_type_array as $key => $value) { if (class_exists($value)) { if ($value::get_sql_fulltext_select_array($key) != null) { $result[$counter]['title'] = $value::get_generic_name($key, null); $result[$counter]['name'] = "item-" . $key; $result[$counter]['value'] = $key; $result[$counter]['checked'] = "checked='checked'"; $counter++; } } } } $template->set_var("item_type_array", $result); $template->output(); } else { if (!$item_type_array) { $item_type_array = array(); foreach ($_POST as $key => $value) { if (strpos($key, "item-") === 0) { array_push($item_type_array, $value); } } } $session->write_value("SEARCH_FULL_TEXT_STRING", $string, true); $session->write_value("SEARCH_FULL_TEXT_ITEM_TYPE", $item_type_array, true); $argument_array = array(); $argument_array[0][0] = "string"; $argument_array[0][1] = $string; $argument_array[1][0] = "item_type_array"; $argument_array[1][1] = $item_type_array; $argument_array[2][0] = "lanugage_id"; $argument_array[2][1] = null; $list = new List_IO("ItemFulltextSearch", "ajax.php?nav=item", "search_fulltext_list_items", "search_fulltext_count_items", $argument_array, "ItemFulltextSearch"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("ItemGeneralListColumnName", "general"), "name", true, null); $list->add_column(Language::get_message("ItemGeneralListColumnType", "general"), "type", false, null); $list->add_column(Language::get_message("ItemGeneralListColumnDateTime", "general"), "datetime", true, null); $list->add_column(Language::get_message("ItemGeneralListColumnRank", "general"), "rank", true, null); $template = new HTMLTemplate("item/search/full_text_search_result.html"); $paramquery = $_GET; $paramquery['nextpage'] = "2"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("string", $string); $template->set_var("list", $list->get_list()); $template->output(); } }
private function interpret($word) { switch ($word) { case "list": if (is_array($this->temp)) { array_push($this->stack, "list"); $this->result = $this->temp; unset($this->temp); } break; case "typeof": array_push($this->stack, "typeof"); break; case "getName": $item_type_array = Item::list_types(); if (is_array($this->result)) { $new_result = array(); foreach ($this->result as $key => $value) { if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $item_type_key => $item_type_value) { if (class_exists($item_type_value)) { if ($item_type_value::is_kind_of($item_type_key, $value)) { $instance = $item_type_value::get_instance_by_item_id($value); if (!in_array($instance->get_item_object_name(), $new_result)) { array_push($new_result, $instance->get_item_object_name()); } } } } } } $this->result = $new_result; } else { if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $key => $value) { if (class_exists($value)) { if ($value::is_kind_of($key, $this->stack[count($this->stack) - 1])) { $instance = $value::get_instance_by_item_id($this->stack[count($this->stack) - 1]); $this->result = $instance->get_item_object_name(); } } } } } break; case "parents": $item_type_array = Item::list_types(); if (is_array($item_type_array) and count($item_type_array) >= 1) { foreach ($item_type_array as $key => $value) { if (class_exists($value)) { if ($value::is_kind_of($key, $this->stack[count($this->stack) - 1])) { $instance = $value::get_instance_by_item_id($this->stack[count($this->stack) - 1]); $this->temp = $instance->get_item_parents(); } } } } break; default: if (is_numeric($word) or strpos(strtolower($word), "c") === 0) { if ($this->stack[count($this->stack) - 1] == "typeof") { if (strpos(strtolower($word), "c") === 0) { $category_id = (int) str_replace("c", "", $word); $type_id = null; } else { $category_id = null; $type_id = $word; } $handling_class = $this->handling_class; if (is_array($this->result) and count($this->result) >= 1) { $new_result = array(); foreach ($this->result as $key => $value) { if ($handling_class::is_type_or_category($category_id, $type_id, $value) == true) { array_push($new_result, $value); } } $this->result = $new_result; } } } else { $this->handling_class = Item::get_handling_class_by_type($word); $handling_class = $this->handling_class; if (class_exists($handling_class)) { if (is_array($this->temp) and count($this->temp) >= 1) { $new_temp = array(); foreach ($this->temp as $key => $value) { if ($handling_class::is_kind_of($word, $value) == true) { array_push($new_temp, $value); } } $this->temp = $new_temp; } else { // Too slow } } } break; } if (count($this->string_array) == 0) { return $this->result; } else { return $this->get_content(null, null, null, null); } }