function tmgmt_local_task_handler_field_job_item_count::query in Translation Management Tool 7
Called to add the field to a query.
Overrides views_handler_field::query
File
- translators/
tmgmt_local/ views/ handlers/ tmgmt_local_task_handler_field_job_item_count.inc, line 38
Class
- tmgmt_local_task_handler_field_job_item_count
- Field handler to show the amount of job items per task.
Code
function query() {
$this
->ensure_my_table();
// Therefore construct the join.
$join = new views_join();
$join->definition['left_table'] = $this->table_alias;
$join->definition['left_field'] = 'tjid';
$join->definition['table'] = 'tmgmt_job_item';
$join->definition['field'] = 'tjid';
$join->definition['type'] = 'LEFT';
if (!empty($this->options['state'])) {
$join->extra = array(
array(
'field' => 'state',
'value' => $this->options['state'],
),
);
}
$join
->construct();
// Add the join to the tmgmt_job_item table.
$this->table_alias = $this->query
->add_table('tmgmt_job_item', $this->relationship, $join);
// And finally add the count of the job items field.
$params = array(
'function' => 'count',
);
$this->field_alias = $this->query
->add_field($this->table_alias, 'tjiid', NULL, $params);
$this
->add_additional_fields();
}