updated core to 7.58 (right after the site was hacked)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which shows a label of a entity.
|
||||
*
|
||||
* @todo Remove this once http://drupal.org/node/1435418 is through.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_entity_label extends views_handler_field_entity {
|
||||
|
||||
function render($values) {
|
||||
if ($entity = $this->get_value($values)) {
|
||||
return $entity->label();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the tmgmt_handler_field_tmgmt_job_item_count field handler.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler to show the amount of job items per job.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_job_item_count extends views_handler_field {
|
||||
/**
|
||||
* @var views_plugin_query_default
|
||||
*/
|
||||
var $query;
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['state'] = array('default' => '');
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$options = array('' => t('- All -'));
|
||||
$options += tmgmt_job_item_states();
|
||||
$form['state'] = array(
|
||||
'#title' => t('Job item status'),
|
||||
'#description' => t('Count only job items of a certain status.'),
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['state'],
|
||||
);
|
||||
}
|
||||
|
||||
function use_group_by() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
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'] = $this->real_field;
|
||||
$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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which shows the operations for a job item.
|
||||
*
|
||||
* @todo Remove this once http://drupal.org/node/1435662 is through.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_job_item_operations extends views_handler_field_entity {
|
||||
|
||||
function render($values) {
|
||||
$item = $this->get_value($values);
|
||||
$element = array();
|
||||
$element['#theme'] = 'links';
|
||||
$element['#attributes'] = array('class' => array('inline'));
|
||||
$uri = $item->uri();
|
||||
if ($item->getCountTranslated() > 0 && entity_access('accept', 'tmgmt_job_item', $item)) {
|
||||
$element['#links']['review'] = array(
|
||||
'href' => $uri['path'],
|
||||
'query' => array('destination' => current_path()),
|
||||
'title' => t('review'),
|
||||
);
|
||||
}
|
||||
// Do not display view on unprocessed jobs.
|
||||
elseif (!$item->getJob()->isUnprocessed()) {
|
||||
$element['#links']['view'] = array(
|
||||
'href' => $uri['path'],
|
||||
'query' => array('destination' => current_path()),
|
||||
'title' => t('view'),
|
||||
);
|
||||
}
|
||||
if (user_access('administer tmgmt') && !$item->isAccepted()) {
|
||||
$element['#links']['delete'] = array(
|
||||
'href' => 'admin/tmgmt/items/' . $item->tjiid . '/delete',
|
||||
'query' => array('destination' => current_path()),
|
||||
'title' => t('delete'),
|
||||
);
|
||||
}
|
||||
return drupal_render($element);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which shows the type of a job item.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_job_item_type extends views_handler_field_entity {
|
||||
|
||||
function render($values) {
|
||||
if ($entity = $this->get_value($values)) {
|
||||
return $entity->getSourceType();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which shows the operations for a job.
|
||||
*
|
||||
* @todo Remove this once http://drupal.org/node/1435662 is through.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_job_operations extends views_handler_field_entity {
|
||||
|
||||
function render($values) {
|
||||
$job = $this->get_value($values);
|
||||
$element = array();
|
||||
$element['#theme'] = 'links';
|
||||
$element['#attributes'] = array('class' => array('inline'));
|
||||
$uri = $job->uri();
|
||||
if ($job->isSubmittable() && entity_access('submit', 'tmgmt_job', $job)) {
|
||||
$element['#links']['submit'] = array(
|
||||
'href' => $uri['path'],
|
||||
'query' => array('destination' => current_path()),
|
||||
'title' => t('submit'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$element['#links']['manage'] = array(
|
||||
'href' => $uri['path'],
|
||||
'title' => t('manage'),
|
||||
);
|
||||
}
|
||||
if ($job->isAbortable() && entity_access('submit', 'tmgmt_job', $job)) {
|
||||
$element['#links']['cancel'] = array(
|
||||
'href' => 'admin/tmgmt/jobs/' . $job->tjid . '/abort',
|
||||
'query' => array('destination' => current_path()),
|
||||
'title' => t('abort'),
|
||||
);
|
||||
}
|
||||
if ($job->isDeletable() && user_access('administer tmgmt')) {
|
||||
$element['#links']['delete'] = array(
|
||||
'href' => 'admin/tmgmt/jobs/' . $job->tjid . '/delete',
|
||||
'query' => array('destination' => current_path()),
|
||||
'title' => t('delete'),
|
||||
);
|
||||
}
|
||||
return drupal_render($element);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which allows to render the job message with replaced variables.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_message_message extends views_handler_field_xss {
|
||||
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
$this->additional_fields['variables'] = 'variables';
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['format'] = array('default' => 'formatted');
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['format'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Format'),
|
||||
'#description' => t("Choose whether the field should display the raw text or display formatted text with replaced variables with it's values."),
|
||||
'#default_value' => $this->options['format'],
|
||||
'#options' => array(
|
||||
'formatted' => t('Formatted'),
|
||||
'raw' => t('Raw'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
if ($message = $this->get_value($values)) {
|
||||
if ($this->options['format'] == 'formatted') {
|
||||
$message = $this->sanitize_value(t($message, unserialize($this->get_value($values, 'variables'))), 'xss');
|
||||
}
|
||||
else {
|
||||
$message = $this->sanitize_value($message, 'xss');
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which shows the progressbar.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_progress extends views_handler_field_entity {
|
||||
|
||||
/**
|
||||
* Prefetch statistics for all jobs.
|
||||
*/
|
||||
function pre_render(&$values) {
|
||||
parent::pre_render($values);
|
||||
|
||||
// In case of jobs, pre-fetch the statistics in a single query and add them
|
||||
// to the static cache.
|
||||
if ($this->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 '<div id="progress' . $id . '"></div>';
|
||||
}
|
||||
$title = t('Accepted: @accepted, reviewed: @reviewed, translated: @translated, pending: @pending.', $counts);
|
||||
return sprintf('<span title="%s">%s</span>', $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;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains tmgmt_handler_field_tmgmt_translator.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler which shows the translator of a job.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_translator extends views_handler_field_entity {
|
||||
|
||||
function render($values) {
|
||||
if ($entity = $this->get_value($values)) {
|
||||
$translators = tmgmt_translator_labels();
|
||||
return isset($translators[$entity->translator]) ? check_plain($translators[$entity->translator]) : t('Missing translator');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Field handler which shows the word count.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class tmgmt_handler_field_tmgmt_wordcount extends views_handler_field_entity {
|
||||
|
||||
/**
|
||||
* Prefetch statistics for all jobs.
|
||||
*/
|
||||
function pre_render(&$values) {
|
||||
parent::pre_render($values);
|
||||
|
||||
// In case of jobs, pre-fetch the statistics in a single query and add them
|
||||
// to the static cache.
|
||||
if ($this->entity_type == 'tmgmt_job') {
|
||||
$tjids = array();
|
||||
foreach ($values as $value) {
|
||||
$tjids[] = $value->tjid;
|
||||
}
|
||||
tmgmt_job_statistics_load($tjids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function render($values) {
|
||||
$object = $this->get_value($values);
|
||||
return $object->getWordCount();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user