Beispiel #1
0
 /**
  * Builds the translation form element for a data item.
  *
  * @param array $item_element
  *   The form element for the data item.
  * @param int $rows
  *   The number of rows that should be displayed.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state.
  *
  * @return array
  *   The form element for the data item.
  */
 protected function buildTranslation($item_element, $data_item, $rows, FormStateInterface $form_state)
 {
     if (!empty($data_item['#format']) && $this->config('tmgmt.settings')->get('respect_text_format') && !$form_state->has('accept_item')) {
         $item_element['translation'] = array('#type' => 'text_format', '#default_value' => isset($data_item['#translation']['#text']) ? $data_item['#translation']['#text'] : NULL, '#title' => t('Translation'), '#disabled' => $this->entity->isAccepted(), '#rows' => $rows, '#allowed_formats' => array($data_item['#format']));
     } elseif ($form_state->has('accept_item')) {
         $item_element['translation'] = array('#type' => 'textarea', '#title' => t('Translation'), '#value' => t('This field has been disabled because you do not have sufficient permissions to edit it. It is not possible to review or accept this job item.'), '#disabled' => TRUE, '#rows' => $rows);
     } else {
         $item_element['translation'] = array('#type' => 'textarea', '#default_value' => isset($data_item['#translation']['#text']) ? $data_item['#translation']['#text'] : NULL, '#title' => t('Translation'), '#disabled' => $this->entity->isAccepted(), '#rows' => $rows);
         if (!empty($data_item['#max_length'])) {
             $item_element['translation']['#max_length'] = $data_item['#max_length'];
             $item_element['translation']['#element_validate'] = ['::validateMaxLength'];
         }
     }
     if (!empty($data_item['#translation']['#text_revisions'])) {
         $revisions = array();
         foreach ($data_item['#translation']['#text_revisions'] as $revision) {
             $revisions[] = t('Origin: %origin, Created: %created<br />%text', array('%origin' => $revision['#origin'], '%created' => format_date($revision['#timestamp']), '%text' => Xss::filter($revision['#text'])));
         }
         $item_element['below']['revisions_wrapper'] = array('#type' => 'details', '#title' => t('Translation revisions'), '#open' => TRUE);
         $item_element['below']['revisions_wrapper']['revisions'] = array('#theme' => 'item_list', '#items' => $revisions);
     }
     return $item_element;
 }
 /**
  * {@inheritdoc}
  */
 public function getPreviewUrl(JobItemInterface $job_item)
 {
     if ($job_item->getJob()->isActive() && !($job_item->isAborted() || $job_item->isAccepted())) {
         return new Url('tmgmt_content.job_item_preview', ['tmgmt_job_item' => $job_item->id()], ['query' => ['key' => \Drupal::service('tmgmt_content.key_access')->getKey($job_item)]]);
     } else {
         return NULL;
     }
 }