entity_type == 'tmgmt_job') { $tjids = array(); foreach ($values as $value) { // Do not load statistics for aborted jobs. if ($value->tmgmt_job_state == TMGMT_JOB_STATE_ABORTED) { continue; } $tjids[] = $value->tjid; } tmgmt_job_statistics_load($tjids); } } /** * {@inheritdoc} */ function render($values) { /** @var TMGMTJobItem|TMGMTJob $object */ $object = $this->get_value($values); // If job has been aborted the status info is not applicable. if ($object->isAborted()) { return t('N/A'); } $counts = array( '@accepted' => $object->getCountAccepted(), '@reviewed' => $object->getCountReviewed(), '@translated' => $object->getCountTranslated(), '@pending' => $object->getCountPending(), ); $id = $object->internalIdentifier(); if (module_exists('google_chart_tools')) { draw_chart($this->build_progressbar_settings($id, $counts)); return '
'; } $title = t('Accepted: @accepted, reviewed: @reviewed, translated: @translated, pending: @pending.', $counts); return sprintf('%s', $title, implode('/', $counts)); } /** * Creates a settings array for the google chart tools. * * The settings are preset with values to display a progress bar for either * a job or job item. * * @param $id * The id of the chart. * @param $counts * Array with the counts for accepted, translated and pending. * @param $prefix * Prefix to id. * @return * Settings array. */ function build_progressbar_settings($id, $counts, $prefix = 'progress') { $settings['chart'][$prefix . $id] = array( 'header' => array(t('Accepted'), t('Reviewed'), t('Translated'), t('Pending')), 'rows' => array( array($counts['@accepted'], $counts['@reviewed'], $counts['@translated'], $counts['@pending']), ), 'columns' => array(''), 'chartType' => 'PieChart', 'containerId' => $prefix . $id, 'options' => array( 'backgroundColor' => 'transparent', 'colors' => array('#00b600', '#60ff60', '#ffff00', '#6060ff'), 'forceIFrame' => FALSE, 'chartArea' => array( 'left' => 0, 'top' => 0, 'width' => '50%', 'height' => '100%', ), 'fontSize' => 9, 'title' => t('Progress'), 'titlePosition' => 'none', 'width' => 60, 'height' => 50, 'isStacked' => TRUE, 'legend' => array('position' => 'none'), 'pieSliceText' => 'none', ) ); return $settings; } }