예제 #1
0
 public function test_parent_field()
 {
     midcom::get('auth')->request_sudo('midcom.helper.datamanager2');
     $project_title = 'PROJECT_TEST_' . __CLASS__ . '_' . time();
     $project = $this->create_object('org_openpsa_projects_project', array('title' => $project_title));
     $task_properties = array('project' => $project->id, 'title' => 'TASK_TEST_' . __CLASS__ . '_' . time());
     $task = $this->create_object('org_openpsa_projects_task_dba', $task_properties);
     $request = array('component' => 'org.openpsa.projects', 'class' => 'org_openpsa_projects_task_dba', 'id_field' => 'id', 'searchfields' => array('title', 'project.title'), 'titlefield' => 'title', 'result_headers' => array(array('title' => 'title', 'name' => 'title')), 'term' => $project_title);
     $handler = new midcom_helper_datamanager2_ajax_autocomplete($request);
     $res = $handler->get_results();
     midcom::get('auth')->drop_sudo();
     $this->assertEquals(1, sizeof($res));
     $this->assertEquals($res[0]['label'], $task->title);
 }
예제 #2
0
<?php

/**
 * Handler for autocomplete searches
 *
 * @package midcom.helper.datamanager2
 * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/
 * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 */
$handler = new midcom_helper_datamanager2_ajax_autocomplete($_REQUEST);
// Common headers
midcom::get('cache')->content->content_type('application/json');
midcom::get()->header('Content-type: application/json; charset=UTF-8');
echo json_encode($handler->get_results());
midcom::get()->finish();