Пример #1
0
 /**
  * Tests rendering form elements without passing through
  * \Drupal::formBuilder()->doBuildForm().
  */
 function testDrupalRenderFormElements()
 {
     // Define a series of form elements.
     $element = array('#type' => 'button', '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'submit'));
     $element = array('#type' => 'textfield', '#title' => $this->randomMachineName(), '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'text'));
     $element = array('#type' => 'password', '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'password'));
     $element = array('#type' => 'textarea', '#title' => $this->randomMachineName(), '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//textarea');
     $element = array('#type' => 'radio', '#title' => $this->randomMachineName(), '#value' => FALSE);
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'radio'));
     $element = array('#type' => 'checkbox', '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'checkbox'));
     $element = array('#type' => 'select', '#title' => $this->randomMachineName(), '#options' => array(0 => $this->randomMachineName(), 1 => $this->randomMachineName()));
     $this->assertRenderedElement($element, '//select');
     $element = array('#type' => 'file', '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'file'));
     $element = array('#type' => 'item', '#title' => $this->randomMachineName(), '#markup' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', array(':class' => 'js-form-type-item', ':markup' => $element['#markup'], ':label' => $element['#title']));
     $element = array('#type' => 'hidden', '#title' => $this->randomMachineName(), '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'hidden'));
     $element = array('#type' => 'link', '#title' => $this->randomMachineName(), '#url' => Url::fromRoute('common_test.destination'), '#options' => array('absolute' => TRUE));
     $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array(':href' => URL::fromRoute('common_test.destination')->setAbsolute()->toString(), ':title' => $element['#title']));
     $element = array('#type' => 'details', '#open' => TRUE, '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//details/summary[contains(., :title)]', array(':title' => $element['#title']));
     $element = array('#type' => 'details', '#open' => TRUE, '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//details');
     $element['item'] = array('#type' => 'item', '#title' => $this->randomMachineName(), '#markup' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', array(':class' => 'js-form-type-item', ':markup' => $element['item']['#markup']));
 }
 /**
  * {@inheritdoc}
  */
 public function getWorkspaceSwitchLinks(Request $request, Url $url)
 {
     $links = array();
     $active_workspace_id = $this->workspaceManager->getActiveWorkspace($request)->id();
     $query = array();
     parse_str($request->getQueryString(), $query);
     // If we have an error on the requested page, set links URL to be <front>.
     if (!empty($query['_exception_statuscode'])) {
         if (isset($query['workspace'])) {
             $query = array('workspace' => $query['workspace']);
         }
         $url = URL::fromRoute('<front>');
     }
     $workspaces = $this->workspaceManager->loadMultiple();
     ksort($workspaces);
     foreach ($workspaces as $workspace) {
         // @todo {@link https://www.drupal.org/node/2600382 Access check.}
         $workspace_id = $workspace->id();
         $links[$workspace_id] = array('url' => $url, 'title' => $workspace->label(), 'query' => $query);
         $links[$workspace_id]['query']['workspace'] = $workspace_id;
         if ($workspace_id == $active_workspace_id) {
             $links[$workspace_id]['attributes']['class'][] = 'session-active';
         }
     }
     return $links;
 }
Пример #3
0
 public function getAction()
 {
     $controller = $this->getAttribute('controller', NULL);
     $action = $this->getAttribute('action', NULL);
     if (!empty($controller) && !empty($action)) {
         return \URL::fromRoute($controller, $action);
     }
     return NULL;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     parent::buildForm($form, $form_state);
     $roles = tmgmt_local_translator_roles();
     if (empty($roles)) {
         drupal_set_message(t('No user role has the "provide translation services" permission. <a href="@url">Configure permissions</a> for the Drupal user module.', array('@url' => URL::fromRoute('user.admin_permissions'))), 'warning');
     }
     $form['tuid'] = array('#title' => t('Assign to'), '#type' => 'select', '#empty_option' => t('- Select user -'), '#options' => tmgmt_local_get_assignees_for_tasks([$this->getEntity()->id()]), '#required' => TRUE);
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Assign tasks'));
     return $form;
 }
Пример #5
0
 public function redirect($controller = NULL, $action = NULL, $item = NULL, $module = NULL)
 {
     if ($controller === NULL) {
         $url = \Biome\Biome::getService('request')->headers->get('referer');
     } else {
         $url = \URL::fromRoute($controller, $action, $item, $module);
     }
     Logger::info('Redirect to ' . $url);
     $this->headers->set('Location', $url);
     $this->setStatusCode(302);
     return $this;
 }
Пример #6
0
 public function getAction()
 {
     $action = $this->getAttribute('action');
     $actions = $this->fetchVariables($action);
     if (empty($actions)) {
         return $this->getURL();
     }
     $var = reset($actions);
     $raw = explode('.', $var);
     $controller = $raw[0];
     $action = $raw[1];
     return \URL::fromRoute($controller, $action);
 }
Пример #7
0
 public function getURL()
 {
     $controller = $this->getAttribute('controller', NULL);
     $action = $this->getAttribute('action', NULL);
     $item = $this->getAttribute('item', NULL);
     $module = $this->getAttribute('module', NULL);
     $page = $this->getAttribute('page', NULL);
     if ($item) {
         $item = $this->fetchValue($item);
     }
     if ($page) {
         $page = $this->fetchValue($page);
     }
     return \URL::fromRoute($controller, $action, $item, $module, $page);
 }
 /**
  * Test consider field sequences.
  */
 public function testConsiderFieldSequences()
 {
     $this->createNodeType('article1', 'Article 1', TRUE, FALSE);
     for ($i = 0; $i <= 5; $i++) {
         // Create a field.
         $field_storage = FieldStorageConfig::create(array('field_name' => 'field_' . $i, 'entity_type' => 'node', 'type' => 'text', 'cardinality' => mt_rand(1, 5), 'translatable' => TRUE));
         $field_storage->save();
         // Create an instance of the previously created field.
         $field = FieldConfig::create(array('field_name' => 'field_' . $i, 'entity_type' => 'node', 'bundle' => 'article1', 'label' => 'Field' . $i, 'description' => $this->randomString(30), 'widget' => array('type' => 'text', 'label' => $this->randomString(10))));
         $field->save();
         $this->field_names['node']['article1'][] = 'field_' . $i;
     }
     $node = $this->createTranslatableNode('article1', 'en');
     entity_get_form_display('node', 'article1', 'default')->setComponent('body', array('type' => 'text_textarea_with_summary', 'weight' => 0))->setComponent('title', array('type' => 'string_textfield', 'weight' => 1))->setComponent('field_1', array('type' => 'string_textfield', 'weight' => 2))->setComponent('field_2', array('type' => 'string_textfield', 'weight' => 5))->setComponent('field_0', array('type' => 'string_textfield', 'weight' => 6))->setComponent('field_4', array('type' => 'string_textfield', 'weight' => 7))->save();
     $job = $this->createJob('en', 'de');
     $job->translator = $this->default_translator->id();
     $job->addItem('content', $node->getEntityTypeId(), $node->id());
     $job->save();
     $job->requestTranslation();
     // Visit job item review page.
     $this->drupalGet(URL::fromRoute('entity.tmgmt_job_item.canonical', ['tmgmt_job_item' => $node->id()]));
     $review_elements = $this->xpath('//*[@id="edit-review"]/div');
     $ids = [];
     foreach ($review_elements as $review_element) {
         $ids[] = (string) $review_element['id'];
     }
     // Check are fields showing on page in desired order. Field 3 and 5 have
     // no weight set and are expected to be ordered alphabetically, at the end.
     $this->assertEqual($ids[0], 'tmgmt-ui-element-body-wrapper');
     $this->assertEqual($ids[1], 'tmgmt-ui-element-title-wrapper');
     $this->assertEqual($ids[2], 'tmgmt-ui-element-field-1-wrapper');
     $this->assertEqual($ids[3], 'tmgmt-ui-element-field-2-wrapper');
     $this->assertEqual($ids[4], 'tmgmt-ui-element-field-0-wrapper');
     $this->assertEqual($ids[5], 'tmgmt-ui-element-field-4-wrapper');
     $this->assertEqual($ids[6], 'tmgmt-ui-element-field-3-wrapper');
     $this->assertEqual($ids[7], 'tmgmt-ui-element-field-5-wrapper');
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function getSettingsLink()
 {
     $url = URL::fromRoute('ckeditor_media_embed.ckeditor_media_embed_settings_form', array('destination' => \Drupal::service('path.current')->getPath()));
     return Markup::create(\Drupal::l($this->t('CKEditor Media Embed plugin settings page'), $url));
 }
Пример #10
0
<nav class="navbar navbar-default navbar-fixed-top <?php 
echo $this->getClasses();
?>
" role="navigation">
	<div class="container-fluid">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-ex1-collapse" aria-expanded="false" aria-controls="navbar">
				<span class="sr-only">Toggle navigation</span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="<?php 
echo URL::fromRoute();
?>
"><?php 
$logo = $this->getLogo();
if (!empty($logo)) {
    echo '<img src="', URL::getAsset($logo), '" width="100%" height="100%"/>';
} else {
    echo $view->getTitle();
}
?>
</a>
		</div>

		<?php 
echo $this->getContent();
?>

	</div>