static function getForQuery($search_query, $project = NULL) { $count_overall = 0; $results = array(); global $PH; require_once confGet('DIR_STREBER') . "db/class_company.inc.php"; $args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query); foreach ($companies = Company::getAll($args) as $company) { $rate = RATE_TYPE_COMPANY; $rate *= SearchResult::RateItem($company); $rate *= SearchResult::RateTitle($company, $search_query); $results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company)); } require_once confGet('DIR_STREBER') . "db/class_person.inc.php"; foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) { $rate = RATE_TYPE_PERSON; $rate *= SearchResult::RateItem($person); $rate *= SearchResult::RateTitle($person, $search_query); $results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person)); } require_once confGet('DIR_STREBER') . "db/class_project.inc.php"; $projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query)); if ($projects) { foreach ($projects as $project) { $rate = RATE_TYPE_PROJECT; if ($project->status == STATUS_TEMPLATE) { $rate *= RATE_PROJECT_IS_TEMPLATE; } else { if ($project->status < STATUS_COMPLETED) { $rate *= RATE_PROJECT_IS_OPEN; } else { $rate *= RATE_PROJECT_IS_CLOSED; } } if ($diz = SearchResult::getExtract($project, $search_query)) { $rate *= RATE_IN_DETAILS; } ### status ### global $g_status_names; $status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : ''; if ($project->status > STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_CLOSED; } else { if ($project->status >= STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_COMPLETED; } } ### for company ### $html_location = ''; if ($company = Company::getVisibleById($project->company)) { $html_location = __('for') . ' ' . $company->getLink(); } $rate *= SearchResult::RateItem($project); $rate *= SearchResult::RateTitle($project, $search_query); $results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location)); } } require_once confGet('DIR_STREBER') . "db/class_task.inc.php"; $order_str = get('sort_' . $PH->cur_page->id . "_tasks"); $tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED)); if ($tasks) { foreach ($tasks as $task) { $rate = RATE_TYPE_TASK; $rate *= SearchResult::RateItem($task); $rate *= SearchResult::RateTitle($task, $search_query); if ($task->category == TCATEGORY_FOLDER) { $rate *= RATE_TASK_IS_FOLDER; } if ($diz = SearchResult::getExtract($task, $search_query)) { $rate *= RATE_IN_DETAILS; } global $g_status_names; $status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : ''; if ($task->status > STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_CLOSED; } else { if ($task->status >= STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_COMPLETED; } } if ($project = Project::getVisibleById($task->project)) { $prj = $project->getLink(); } else { $prj = ''; } $html_location = __('in') . " <b>{$prj}</b> > " . $task->getFolderLinks(); $is_done = $task->status < STATUS_COMPLETED ? false : true; $results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query))); } } require_once confGet('DIR_STREBER') . "db/class_comment.inc.php"; $comments = Comment::getAll(array('search' => $search_query)); if ($comments) { foreach ($comments as $comment) { $rate = RATE_TYPE_COMMENT; $rate *= SearchResult::RateItem($comment); $rate *= SearchResult::RateTitle($comment, $search_query); if ($diz = SearchResult::getExtract($comment, $search_query)) { $rate *= RATE_IN_DETAILS; } if ($project = Project::getVisibleById($comment->project)) { $prj = $project->getLink(); } else { $prj = ''; } $html_location = __('on') . " <b>{$prj}</b>"; $is_done = false; if ($task = Task::getVisibleById($comment->task)) { if ($folders = $task->getFolderLinks()) { $html_location .= ' > ' . $folders; } $html_location .= ' > ' . $task->getLink(false); if ($task->status >= STATUS_COMPLETED) { $is_done = true; } } else { $html_location = ''; } $results[] = new SearchResult(array('name' => $comment->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Comment'), 'html_location' => $html_location, 'jump_id' => 'commentView', 'jump_params' => array('comment' => $comment->id, 'q' => $search_query), 'item' => $comment, 'is_done' => $is_done)); } } $count_overall += count($comments); require_once confGet('DIR_STREBER') . "db/class_effort.inc.php"; $efforts = Effort::getAll(array('search' => $search_query)); if ($efforts) { foreach ($efforts as $effort) { $rate = RATE_TYPE_EFFORT; $rate *= SearchResult::RateItem($effort); $rate *= SearchResult::RateTitle($effort, $search_query); if ($diz = SearchResult::getExtract($effort, $search_query)) { $rate *= RATE_IN_DETAILS; } if ($project = Project::getVisibleById($effort->project)) { $prj = $project->getLink(); } else { $prj = ''; } $html_location = __('on') . " <b>{$prj}</b>"; $is_done = false; if ($task = Task::getVisibleById($effort->task)) { if ($folders = $task->getFolderLinks()) { $html_location .= ' > ' . $folders; } $html_location .= ' > ' . $task->getLink(false); if ($task->status >= STATUS_COMPLETED) { $is_done = true; } } else { $html_location = ''; } $results[] = new SearchResult(array('name' => $effort->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Effort'), 'html_location' => $html_location, 'jump_id' => 'effortView', 'jump_params' => array('effort' => $effort->id, 'q' => $search_query), 'item' => $effort, 'is_done' => $is_done)); } } $count_overall += count($efforts); return $results; }