function mortgagespeak_menu_link(array $variables)
{
    global $user;
    $show_purple_tooltip = 0;
    $user_info = user_load($user->uid);
    if (isset($user_info->field_show_got_it_box) && !empty($user_info->field_show_got_it_box)) {
        $show_purple_tooltip = $user_info->field_show_got_it_box['und'][0]['value'];
    }
    $sub_menu = '';
    $element = $variables['element'];
    if ($element['#below']) {
        $sub_menu = drupal_render($element['#below']);
    }
    $variables['element']['#attributes']['class'][] = 'active';
    $variables['element']['#localized_options']['attributes']['class'][] = 'active';
    $output = l($element['#title'], $element['#href'], $options = $element['#localized_options']);
    if ($show_purple_tooltip == 1) {
        if ($element['#original_link']['menu_name'] == 'main-menu' && $element['#href'] == 'my-page/tracked-news') {
            return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "<div id='purple-tooltip' class='purple-main-container'><div class='purple-inner'><div class='purple-text'>Access your Custom News Page here.</div><div class='purple-button'>ok, Got it</div></div></div></li>\n";
        } else {
            return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
        }
    } else {
        return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
    }
}
Exemple #2
0
/**
 * Overrides theme_file_widget().
 */
function bootstrap_file_widget($variables)
{
    $output = '';
    $element = $variables['element'];
    $element['upload_button']['#attributes']['class'][] = 'btn-primary';
    $element['upload_button']['#prefix'] = '<span class="input-group-btn">';
    $element['upload_button']['#suffix'] = '</span>';
    // The "form-managed-file" class is required for proper Ajax functionality.
    if (!empty($element['filename'])) {
        $output .= '<div class="file-widget form-managed-file clearfix">';
        // Add the file size after the file name.
        $element['filename']['#markup'] .= ' <span class="file-size badge">' . format_size($element['#file']->filesize) . '</span>';
    } else {
        $output .= '<div class="file-widget form-managed-file clearfix input-group">';
    }
    // Immediately render hidden elements before the rest of the output.
    // The uploadprogress extension requires that the hidden identifier input
    // element appears before the file input element. They must also be siblings
    // inside the same parent element.
    // @see https://www.drupal.org/node/2155419
    foreach (element_children($element) as $child) {
        if (isset($element[$child]['#type']) && $element[$child]['#type'] === 'hidden') {
            $output .= drupal_render($element[$child]);
        }
    }
    // Render the rest of the element.
    $output .= drupal_render_children($element);
    $output .= '</div>';
    return $output;
}
Exemple #3
0
 /**
  * Checks that special characters are correctly escaped.
  *
  * @see http://drupal.org/node/1211668
  */
 function testFeedIconEscaping()
 {
     $variables = array('#theme' => 'feed_icon', '#url' => 'node', '#title' => '<>&"\'');
     $text = drupal_render($variables);
     preg_match('/title="(.*?)"/', $text, $matches);
     $this->assertEqual($matches[1], 'Subscribe to &amp;&quot;&#039;', 'feed_icon template escapes reserved HTML characters.');
 }
 /**
  * Tests the bubbling of cache tags.
  */
 public function testCacheTags()
 {
     // Create the entity that will be commented upon.
     $commented_entity = entity_create('entity_test', array('name' => $this->randomMachineName()));
     $commented_entity->save();
     // Verify cache tags on the rendered entity before it has comments.
     $build = \Drupal::entityManager()->getViewBuilder('entity_test')->view($commented_entity);
     drupal_render($build);
     $expected_cache_tags = array('entity_test_view', 'entity_test:' . $commented_entity->id(), 'comment_list');
     sort($expected_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_cache_tags, 'The test entity has the expected cache tags before it has comments.');
     // Create a comment on that entity. Comment loading requires that the uid
     // also exists in the {users} table.
     $user = $this->createUser();
     $user->save();
     $comment = entity_create('comment', array('subject' => 'Llama', 'comment_body' => array('value' => 'Llamas are cool!', 'format' => 'plain_text'), 'entity_id' => $commented_entity->id(), 'entity_type' => 'entity_test', 'field_name' => 'comment', 'comment_type' => 'comment', 'status' => CommentInterface::PUBLISHED, 'uid' => $user->id()));
     $comment->save();
     // Load commented entity so comment_count gets computed.
     // @todo Remove the $reset = TRUE parameter after
     //   https://www.drupal.org/node/597236 lands. It's a temporary work-around.
     $commented_entity = entity_load('entity_test', $commented_entity->id(), TRUE);
     // Verify cache tags on the rendered entity when it has comments.
     $build = \Drupal::entityManager()->getViewBuilder('entity_test')->view($commented_entity);
     drupal_render($build);
     $expected_cache_tags = array('entity_test_view', 'entity_test:' . $commented_entity->id(), 'comment_list', 'comment_view', 'comment:' . $comment->id(), 'config:filter.format.plain_text', 'user_view', 'user:2');
     sort($expected_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_cache_tags, 'The test entity has the expected cache tags when it has comments.');
 }
/**
 * Overrides theme_menu_link() for book module.
 */
function bootstrap_menu_link__book_toc(array $variables)
{
    $element = $variables['element'];
    $sub_menu = drupal_render($element['#below']);
    $title = $element['#title'];
    $href = $element['#href'];
    $options = !empty($element['#localized_options']) ? $element['#localized_options'] : array();
    $attributes = !empty($element['#attributes']) ? $element['#attributes'] : array();
    $attributes['role'] = 'presentation';
    // Header.
    $link = TRUE;
    if ($title && $href === FALSE) {
        $attributes['class'][] = 'dropdown-header';
        $link = FALSE;
    } elseif ($title === FALSE && $href === FALSE) {
        $attributes['class'][] = 'divider';
        $link = FALSE;
    } elseif (($href == $_GET['q'] || $href == '<front>' && drupal_is_front_page()) && empty($options['language'])) {
        $attributes['class'][] = 'active';
    }
    // Filter the title if the "html" is set, otherwise l() will automatically
    // sanitize using check_plain(), so no need to call that here.
    if (!empty($options['html'])) {
        $title = _bootstrap_filter_xss($title);
    }
    // Convert to a link.
    if ($link) {
        $title = l($title, $href, $options);
    }
    return '<li' . drupal_attributes($attributes) . '>' . $title . $sub_menu . "</li>\n";
}
Exemple #6
0
 /**
  * Tests the raw filter inside an autoescape tag.
  */
 public function testAutoescapeRaw()
 {
     $test = array('#theme' => 'twig_raw_test', '#script' => '<script>alert("This alert is real because I will put it through the raw filter!");</script>');
     $rendered = drupal_render($test);
     $this->drupalSetContent($rendered);
     $this->assertRaw('<script>alert("This alert is real because I will put it through the raw filter!");</script>');
 }
function amity_island_search_block_form($form)
{
    $form['submit']['#type'] = 'image_button';
    $form['submit']['#src'] = drupal_get_path('theme', 'amity_island') . '/images/magnifying_glass.jpg';
    $form['submit']['#attributes']['class'] = 'btn';
    return '<div id="search" class="container-inline">' . drupal_render($form) . '</div>';
}
 /**
  * Tests the mapping of fields.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to test.
  *
  * @return string
  *   The view rendered as HTML.
  */
 protected function mappedOutputHelper($view)
 {
     $output = $view->preview();
     $rendered_output = drupal_render($output);
     $this->storeViewPreview($rendered_output);
     $rows = $this->elements->body->div->div->div;
     $data_set = $this->dataSet();
     $count = 0;
     foreach ($rows as $row) {
         $attributes = $row->attributes();
         $class = (string) $attributes['class'][0];
         $this->assertTrue(strpos($class, 'views-row-mapping-test') !== FALSE, 'Make sure that each row has the correct CSS class.');
         foreach ($row->div as $field) {
             // Split up the field-level class, the first part is the mapping name
             // and the second is the field ID.
             $field_attributes = $field->attributes();
             $name = strtok((string) $field_attributes['class'][0], '-');
             $field_id = strtok('-');
             // The expected result is the mapping name and the field value,
             // separated by ':'.
             $expected_result = $name . ':' . $data_set[$count][$field_id];
             $actual_result = (string) $field;
             $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
         }
         $count++;
     }
     return $rendered_output;
 }
Exemple #9
0
  /**
   * Lists all instances of fields on any views.
   *
   * @return array
   *   The Views fields report page.
   */
  public function nodeMarkup($node, $key = 'default') {
    $node = Node::load($node);

    $builded_entity = entity_view($node, $key);
    $markup = drupal_render($builded_entity);

    $links = array();
    $links['default'] = array(
      'title' => 'Default',
      'url' => Url::fromRoute('ds_devel.markup', array('node' => $node->id())),
    );
    $view_modes = \Drupal::entityManager()->getViewModes('node');
    foreach ($view_modes as $id => $info) {
      if (!empty($info['status'])) {
        $links[] = array(
          'title' => $info['label'],
          'url' => Url::fromRoute('ds_devel.markup_view_mode', array('node' => $node->id(), 'key' => $id)),
        );
      }
    }

    $build['links'] = array(
      '#theme' => 'links',
      '#links' => $links,
      '#prefix' => '<div>',
      '#suffix' => '</div><hr />',
    );
    $build['markup'] = [
      '#markup' => '<code><pre>' . Html::escape($markup) . '</pre></code>',
      '#allowed_tags' => ['code', 'pre'],
    ];

    return $build;
  }
Exemple #10
0
 /**
  * Helper function for testTextfieldWidgets().
  */
 function _testTextfieldWidgets($field_type, $widget_type)
 {
     // Create a field.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $field_storage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => $field_type));
     $field_storage->save();
     entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => 'entity_test', 'label' => $this->randomMachineName() . '_label'))->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => $widget_type, 'settings' => array('placeholder' => 'A placeholder on ' . $widget_type)))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name)->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
     $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
     $this->assertRaw(format_string('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type)));
     // Submit with some value.
     $value = $this->randomMachineName();
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
     // Display the entity.
     $entity = entity_load('entity_test', $id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(drupal_render($content));
     $this->assertText($value, 'Filtered tags are not displayed');
 }
}
function theme_block_filter_opening($form, $language)
{
    $output = '<div id="block-filter-opening">';
    $output .= '	<h3>' . t('By exceptional opening and launch', array(), $language) . ' :</h3>';
    $output .= '	<div id="filter_opening" class="layer">';
    $output .= drupal_render($form);
Exemple #12
0
/**
 * Returns HTML for a set of filter tips.
 *
 * @param array $variables
 *   An associative array containing:
 *   - tips: An array containing descriptions and a CSS ID in the form of
 *     'module-name/filter-id' (only used when $long is TRUE) for each
 *     filter in one or more text formats. Example:
 *     @code
 *       array(
 *         'Full HTML' => array(
 *           0 => array(
 *             'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
 *             'id' => 'filter/2',
 *           ),
 *         ),
 *       );
 *     @endcode
 *   - long: (optional) Whether the passed-in filter tips contain extended
 *     explanations, i.e. intended to be output on the path 'filter/tips'
 *     (TRUE), or are in a short format, i.e. suitable to be displayed below a
 *     form element. Defaults to FALSE.
 *
 * @return string
 *   The constructed HTML.
 *
 * @see theme_filter_tips()
 * @see _filter_tips()
 *
 * @ingroup theme_functions
 */
function bootstrap_filter_tips($variables)
{
    $format_id = arg(2);
    $current_path = current_path();
    $tips = _filter_tips(-1, TRUE);
    // Create a place holder for the tabs.
    $build['tabs'] = array('#theme' => 'item_list', '#items' => array(), '#attributes' => array('class' => array('nav', 'nav-tabs'), 'role' => 'tablist'));
    // Create a placeholder for the panes.
    $build['panes'] = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-content')));
    foreach ($tips as $name => $list) {
        $machine_name = str_replace('-', '_', drupal_html_class($name));
        $tab = array('data' => array('#type' => 'link', '#title' => check_plain($name), '#href' => $current_path, '#attributes' => array('role' => 'tab', 'data-toggle' => 'tab'), '#options' => array('fragment' => $machine_name)));
        if (!$format_id || $format_id === $machine_name) {
            $tab['class'][] = 'active';
            $format_id = $machine_name;
        }
        $build['tabs']['#items'][] = $tab;
        // Extract the actual tip.
        $tiplist = array();
        foreach ($list as $tip) {
            $tiplist[] = $tip['tip'];
        }
        // Construct the pane.
        $pane = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-pane', 'fade'), 'id' => $machine_name), 'list' => array('#theme' => 'item_list', '#items' => $tiplist));
        if ($format_id === $machine_name) {
            $pane['#attributes']['class'][] = 'active';
            $pane['#attributes']['class'][] = 'in';
            $format_id = $machine_name;
        }
        $build['panes'][] = $pane;
    }
    return drupal_render($build);
}
 /**
  * Tests the handlers.
  */
 public function testHandlers()
 {
     $nodes = array();
     $nodes[] = $this->drupalCreateNode();
     $nodes[] = $this->drupalCreateNode();
     $account = $this->drupalCreateUser();
     $this->drupalLogin($account);
     $GLOBALS['user'] = $account;
     db_insert('history')->fields(array('uid' => $account->id(), 'nid' => $nodes[0]->id(), 'timestamp' => REQUEST_TIME - 100))->execute();
     db_insert('history')->fields(array('uid' => $account->id(), 'nid' => $nodes[1]->id(), 'timestamp' => REQUEST_TIME + 100))->execute();
     $column_map = array('nid' => 'nid');
     // Test the history field.
     $view = Views::getView('test_history');
     $view->setDisplay('page_1');
     $this->executeView($view);
     $this->assertEqual(count($view->result), 2);
     $output = $view->preview();
     $this->drupalSetContent(drupal_render($output));
     $result = $this->xpath('//span[@class=:class]', array(':class' => 'marker'));
     $this->assertEqual(count($result), 1, 'Just one node is marked as new');
     // Test the history filter.
     $view = Views::getView('test_history');
     $view->setDisplay('page_2');
     $this->executeView($view);
     $this->assertEqual(count($view->result), 1);
     $this->assertIdenticalResultset($view, array(array('nid' => $nodes[0]->id())), $column_map);
 }
Exemple #14
0
 /**
  * {@inheritdoc}
  */
 public function preBuild(array &$build, ObjectInterface $context = NULL)
 {
     $map_id = $context->getId();
     $layers = $this->getOption('layers', array());
     $items = array();
     $map_layers = $context->getObjects('layer');
     $element_type = $this->getOption('multiselect', FALSE) ? 'checkbox' : 'radio';
     // Only handle layers available in the map and configured in the control.
     // @TODO: use Form API (with form_process_* and stuff)
     $labels = $this->getOption('layer_labels', array());
     foreach ($map_layers as $i => $map_layer) {
         if (isset($layers[$map_layer->getMachineName()])) {
             $classes = array(drupal_html_class($map_layer->getMachineName()));
             $checked = '';
             if ($element_type == 'checkbox') {
                 if ($map_layer->getOption('visible', 1)) {
                     $checked = 'checked ';
                     $classes[] = 'active';
                 }
             }
             $label = $map_layer->getName();
             if (isset($labels[$map_layer->getMachineName()])) {
                 $label = openlayers_i18n_string('openlayers:layerswitcher:' . $this->getMachineName() . ':' . $map_layer->getMachineName() . ':label', $labels[$map_layer->getMachineName()], array('sanitize' => TRUE));
             }
             $items[] = array('data' => '<label><input type="' . $element_type . '" name="layer" ' . $checked . 'value="' . $map_layer->getMachineName() . '">' . $label . '</label>', 'id' => drupal_html_id($map_id . '-' . $map_layer->getMachineName()), 'class' => $classes);
         }
     }
     $title = openlayers_i18n_string('openlayers:layerswitcher:' . $this->getMachineName() . ':title', $this->getOption('label', 'Layers'), array('sanitize' => TRUE));
     $layerswitcher = array('#theme' => 'item_list', '#type' => 'ul', '#title' => $title, '#items' => $items, '#attributes' => array('id' => drupal_html_id($this->getMachineName() . '-items')));
     $this->setOption('element', '<div id="' . drupal_html_id($this->getMachineName()) . '" class="' . drupal_html_class($this->getMachineName()) . ' layerswitcher">' . drupal_render($layerswitcher) . '</div>');
     // Allow the parent class to perform it's pre-build actions.
     parent::preBuild($build, $context);
 }
Exemple #15
0
function iha_preprocess_page(&$variables)
{
    $search_box = drupal_render(drupal_get_form('search_form'));
    $variables['search_box'] = $search_box;
    if (drupal_is_front_page()) {
        unset($variables['page']['content']['system_main']['default_message']);
        //will remove message "no front page content is created"
        drupal_set_title('');
        //removes welcome message (page title)
    }
    if (arg(0) == 'node') {
        $variables['node_content'] =& $variables['page']['content']['system_main']['nodes'][arg(1)];
    }
    if (isset($variables['node']->type)) {
        $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
    }
    // Prepare the mobile menu.
    $user_menu = menu_tree('user-menu');
    $main_menu = menu_tree('main-menu');
    $menu_tree = array_merge($main_menu, $user_menu);
    // FYI for future dev's - If need to add more menu items, then load the other menu through menu tree as well and do a
    // array merge or for loop to attach the items to the $menu_tree.
    $mobile_menu = '<ul class="list-unstyled main-menu">';
    foreach ($menu_tree as $mlid => $mm) {
        if (is_int($mlid)) {
            $mobile_menu .= iha_render_mobile_menu($mm);
        }
    }
    $mobile_menu .= '</ul>';
    $variables['mobile_menu'] = $mobile_menu;
}
Exemple #16
0
 /**
  * Tests email field.
  */
 function testEmailField()
 {
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'email'));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test'));
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'email_default', 'settings' => array('placeholder' => '*****@*****.**')))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'email_mailto'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
     $this->assertRaw('placeholder="*****@*****.**"');
     // Submit a valid email address and ensure it is accepted.
     $value = '*****@*****.**';
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     $this->assertRaw($value);
     // Verify that a mailto link is displayed.
     $entity = entity_load('entity_test', $id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(drupal_render($content));
     $this->assertLinkByHref('mailto:test@example.com');
 }
 /**
  * Verifies that the datepicker can be localized.
  *
  * @see locale_library_info_alter()
  */
 public function testLibraryInfoAlter()
 {
     $attached['#attached']['library'][] = 'core/jquery.ui.datepicker';
     drupal_render($attached);
     $scripts = drupal_get_js();
     $this->assertTrue(strpos($scripts, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.');
 }
Exemple #18
0
 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     $locked = $this->tempStore->getMetadata($this->entity->id());
     $account = $this->entityManager->getStorage('user')->load($locked->owner);
     $username = array('#theme' => 'username', '#account' => $account);
     return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', array('@user' => drupal_render($username)));
 }
 /**
  * {@inheritdoc}
  */
 public function getContent()
 {
     if (null === $this->renderedContent) {
         $this->renderedContent = drupal_render($this->drupalContent);
     }
     return $this->renderedContent;
 }
Exemple #20
0
 /**
  * Formats the analyze result into a message string.
  *
  * This is based upon the format of drupal_set_message which uses separate
  * boxes for "ok", "warning" and "error".
  */
 public function formatMessages(array $messages)
 {
     if (empty($messages)) {
         $messages = array(static::formatMessage(t('View analysis can find nothing to report.'), 'ok'));
     }
     $types = array('ok' => array(), 'warning' => array(), 'error' => array());
     foreach ($messages as $message) {
         if (empty($types[$message['type']])) {
             $types[$message['type']] = array();
         }
         $types[$message['type']][] = $message['message'];
     }
     $output = '';
     foreach ($types as $type => $messages) {
         $type .= ' messages';
         $message = '';
         if (count($messages) > 1) {
             $item_list = array('#theme' => 'item_list', '#items' => $messages);
             $message = drupal_render($item_list);
         } elseif ($messages) {
             $message = array_shift($messages);
         }
         if ($message) {
             $output .= "<div class=\"{$type}\">{$message}</div>";
         }
     }
     return $output;
 }
Exemple #21
0
/**
 * Theme override for user edit form.
 *
 * The function is named themename_formid.
 *
 * function Ourmedia3_user_profile_form($form) {
 */

function ourmedia3_user_login_block($form) {
  $output = '';
  // Print out the $form array to see all the elements we are working with.
  //$output .= dsm($form);
  // Once I know which part of the array I'm after we can change it.

  // Make sure you call a drupal_render() on the entire $form to make sure you
  // still output all of the elements (particularly hidden ones needed
  // for the form to function properly.)
  //  print_r($form);
  $output .= drupal_render($form);
  $pos_form_id_start = strpos($output, "name=\"form_build_id\" id=\"form-") + 25;
  $pos_form_id_end = strpos($output, "\"", $pos_form_id_start);
  $pos_form_id = drupal_substr($output, $pos_form_id_start, $pos_form_id_end - $pos_form_id_start);

  $output = "<div id=\"signInDivider\">";

  $output .=  "<input type=\"text\" maxlength=\"60\" name=\"name\" id=\"edit-name\" size=\"15\" value=\"\" tabindex=\"1\" class=\"form-text required signIn\" />\n";
  $output .= "<input type=\"password\" name=\"pass\" id=\"edit-pass\"  maxlength=\"60\"  size=\"15\"  tabindex=\"2\" class=\"form-text required signIn\" />\n";
  $output .= "<input type=\"submit\" name=\"op\" id=\"edit-submit\" value=\"Log in\"  tabindex=\"3\" class=\"form-submit button signIn\" />";

  $output .= "</div>";
  $output .= "<div id=\"register\"><a href=\"/user/register\"><input type=\"button\" name=\"\" value=\"Register\" class=\"button\"></a></div>";

  $output .= "<input type=\"hidden\" name=\"form_build_id\" id=\"$pos_form_id\" value=\"$pos_form_id\"  />";
  $output .= "<input type=\"hidden\" name=\"form_id\" id=\"edit-user-login-block\" value=\"user_login_block\"  />";

  return $output;
}
/**
 * Implements hook_menu_link().
 */
function cignaGlobal_menu_link($variables)
{
    $element = $variables['element'];
    $sub_menu = '';
    /*if ($element['#below']) {
          $sub_menu = drupal_render($element['#below']);
      }*/
    unset($element['#attributes']['class']);
    unset($element['#attributes']['title']);
    if (!empty($element['#original_link']['depth']) && $element['#original_link']['depth'] == 1) {
        // Add our own wrapper.
        unset($element['#below']['#theme_wrappers']);
        $sub_menu = '<ul class="dropdown-menu" role="menu">' . drupal_render($element['#below']) . '</ul>';
        // Generate as standard dropdown.
        $element['#title'] = '<span class="fa fa-globe"> </span><span class="language">' . t('Language') . ' : </span>' . $element['#title'] . ' <span class="caret"></span>';
        $element['#attributes']['class'][] = 'dropdown';
        $element['#localized_options']['html'] = TRUE;
        $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
        $element['#localized_options']['attributes']['role'] = 'button';
        $element['#localized_options']['attributes']['aria-expanded'] = 'false';
        $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
    }
    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Exemple #23
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $item_list = array('#theme' => 'item_list', '#items' => array('@start -- the initial record number in the set', '@end -- the last record number in the set', '@total -- the total records in the set', '@label -- the human-readable name of the view', '@per_page -- the number of items per page', '@current_page -- the current page number', '@current_record_count -- the current page record count', '@page_count -- the total page count'));
     $list = drupal_render($item_list);
     $form['content'] = array('#title' => t('Display'), '#type' => 'textarea', '#rows' => 3, '#default_value' => $this->options['content'], '#description' => t('You may use HTML code in this field. The following tokens are supported:') . $list);
 }
Exemple #24
0
/**
 * Returns HTML for menu link.
 */
function boot_press_menu_link(array $variables)
{
    $element = $variables['element'];
    $sub_menu = '';
    if ($element['#below']) {
        if ($element['#original_link']['menu_name'] == 'management' && module_exists('navbar')) {
            $sub_menu = drupal_render($element['#below']);
        } else {
            unset($element['#below']['#theme_wrappers']);
            $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
            $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
            $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
            if (!empty($element['#original_link']['depth']) && $element['#original_link']['depth'] > 1) {
                $element['#attributes']['class'][] = 'dropdown-submenu';
            } else {
                $element['#attributes']['class'][] = 'dropdown';
                $element['#localized_options']['html'] = TRUE;
                $element['#title'] .= ' <span class="caret"></span>';
            }
            $element['#localized_options']['attributes']['data-target'] = '#';
        }
    }
    if (($element['#href'] == $_GET['q'] || $element['#href'] == '<front>' && drupal_is_front_page()) && (empty($element['#localized_options']['language']) || $element['#localized_options']['language']->language == $language_url->language)) {
        $element['#attributes']['class'][] = 'active';
    }
    $menu_output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $menu_output . $sub_menu . "</li>\n";
}
 /**
  * Overrides \Drupal\tour\Plugin\tour\tour\TipPluginInterface::getOutput().
  */
 public function getOutput()
 {
     $image = array('#theme' => 'image', '#uri' => $this->get('url'), '#alt' => $this->get('alt'));
     $output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->get('ariaId') . '-label">' . String::checkPlain($this->get('label')) . '</h2>';
     $output .= '<p class="tour-tip-image" id="tour-tip-' . $this->get('ariaId') . '-contents">' . drupal_render($image) . '</p>';
     return array('#markup' => $output);
 }
 /**
  * Tests the node summary length functionality.
  */
 public function testSummaryLength()
 {
     // Create a node to view.
     $settings = array('body' => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.')), 'promote' => 1);
     $node = $this->drupalCreateNode($settings);
     $this->assertTrue(Node::load($node->id()), 'Node created.');
     // Render the node as a teaser.
     $content = $this->drupalBuildEntityView($node, 'teaser');
     $this->assertTrue(strlen($content['body'][0]['#markup']) < 600, 'Teaser is less than 600 characters long.');
     $this->setRawContent(drupal_render($content));
     // The string 'What is a Drupalism?' is between the 200th and 600th
     // characters of the node body, so it should be included if the summary is
     // 600 characters long.
     $expected = 'What is a Drupalism?';
     $this->assertRaw($expected);
     // Change the teaser length for "Basic page" content type.
     $display = entity_get_display('node', $node->getType(), 'teaser');
     $display_options = $display->getComponent('body');
     $display_options['settings']['trim_length'] = 200;
     $display->setComponent('body', $display_options)->save();
     // Render the node as a teaser again and check that the summary is now only
     // 200 characters in length and so does not include 'What is a Drupalism?'.
     $content = $this->drupalBuildEntityView($node, 'teaser');
     $this->assertTrue(strlen($content['body'][0]['#markup']) < 200, 'Teaser is less than 200 characters long.');
     $this->setRawContent(drupal_render($content));
     $this->assertText($node->label());
     $this->assertNoRaw($expected);
 }
Exemple #27
0
 /**
  * Overrides \Drupal\views\Plugin\views\style\StylePluginBase\StylePluginBase::render().
  */
 public function render()
 {
     if (!empty($this->view->live_preview)) {
         return parent::render();
     }
     // Group the rows according to the grouping field, if specified.
     $sets = $this->renderGrouping($this->view->result, $this->options['grouping']);
     // Grab the alias of the 'id' field added by
     // entity_reference_plugin_display.
     $id_field_alias = $this->view->storage->get('base_field');
     // @todo We don't display grouping info for now. Could be useful for select
     // widget, though.
     $results = array();
     $this->view->row_index = 0;
     foreach ($sets as $records) {
         foreach ($records as $values) {
             // Sanitize HTML, remove line breaks and extra whitespace.
             $output = $this->view->rowPlugin->render($values);
             $output = drupal_render($output);
             $results[$values->{$id_field_alias}] = Xss::filterAdmin(preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', $output)));
             $this->view->row_index++;
         }
     }
     unset($this->view->row_index);
     return $results;
 }
 /**
  * Tests the setting and output of custom labels for boolean values.
  */
 public function testCustomOption()
 {
     // Add the boolean field handler to the test view.
     $view = Views::getView('test_view');
     $view->setDisplay();
     $view->displayHandlers->get('default')->overrideOption('fields', array('age' => array('id' => 'age', 'table' => 'views_test_data', 'field' => 'age', 'relationship' => 'none')));
     $this->executeView($view);
     $custom_true = 'Yay';
     $custom_false = 'Nay';
     // Set up some custom value mappings for different types.
     $custom_values = array('plain' => array('true' => $custom_true, 'false' => $custom_false, 'test' => 'assertTrue'), 'allowed tag' => array('true' => '<p>' . $custom_true . '</p>', 'false' => '<p>' . $custom_false . '</p>', 'test' => 'assertTrue'), 'disallowed tag' => array('true' => '<script>' . $custom_true . '</script>', 'false' => '<script>' . $custom_false . '</script>', 'test' => 'assertFalse'));
     // Run the same tests on each type.
     foreach ($custom_values as $type => $values) {
         $options = array('options[type]' => 'custom', 'options[type_custom_true]' => $values['true'], 'options[type_custom_false]' => $values['false']);
         $this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply');
         // Save the view.
         $this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save');
         $view = Views::getView('test_view');
         $output = $view->preview();
         $output = drupal_render($output);
         $replacements = array('%type' => $type);
         $this->{$values['test']}(strpos($output, $values['true']), format_string('Expected custom boolean TRUE value in output for %type.', $replacements));
         $this->{$values['test']}(strpos($output, $values['false']), format_string('Expected custom boolean FALSE value in output for %type', $replacements));
     }
 }
/**
 * Overrides theme_menu_link().
 */
function bootstrap_menu_link(array $variables)
{
    $element = $variables['element'];
    $sub_menu = '';
    if ($element['#below']) {
        // Prevent dropdown functions from being added to management menu so it
        // does not affect the navbar module.
        if ($element['#original_link']['menu_name'] == 'management' && module_exists('navbar')) {
            $sub_menu = drupal_render($element['#below']);
        } elseif (!empty($element['#original_link']['depth']) && $element['#original_link']['depth'] >= 1) {
            // Add our own wrapper.
            unset($element['#below']['#theme_wrappers']);
            $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
            // Generate as standard dropdown.
            //$element['#title'] .= ' <span class="caret"></span>';
            $element['#attributes']['class'][] = 'dropdown';
            $element['#localized_options']['html'] = TRUE;
            // Set dropdown trigger element to # to prevent inadvertant page loading
            // when a submenu link is clicked.
            //$element['#localized_options']['attributes']['data-target'] = '#';
            $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
            //$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
        }
    }
    // On primary navigation menu, class 'active' is not set on active menu item.
    // @see https://drupal.org/node/1896674
    if (($element['#href'] == $_GET['q'] || $element['#href'] == '<front>' && drupal_is_front_page()) && empty($element['#localized_options']['language'])) {
        $element['#attributes']['class'][] = 'active';
    }
    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Exemple #30
0
/**
 * oEmbed filter replacement callback.
 *
 * Override basic function by setting Drupal system variable
 * `oembed_resolve_link_callback` to a new function name with this signature.
 *
 * @param string $url
 *   URL to embed.
 * @param array $options
 *   oEmbed request options.
 *
 * @return string
 *   Rendered oEmbed response.
 */
function oembedinline_oembed_resolve_link($url, $options = array())
{
    // If file_entity module is enabled, treat the URL as an uploaded file.
    // Inline is used to defer the rendering of the embedded content until the
    // entity is actually viewed. This technique allows content to be cached by
    // Drupal's filter system.
    $view_mode = 'full';
    if (isset($options['view_mode'])) {
        $view_mode = $options['view_mode'];
        unset($options['view_mode']);
    }
    $url = decode_entities($url);
    $element = array();
    $file = oembed_url_to_file($url);
    $file->override = $options;
    if (isset($file->fid)) {
        $macro_params = array();
        $macro_params[] = 'entity';
        $macro_params[] = 'type=file';
        $macro_params[] = 'id=' . $file->fid;
        $macro_params[] = 'view_mode=' . $view_mode;
        $element = array('#markup' => "\r\n" . '[' . implode('|', $macro_params) . ']' . "\r\n");
    }
    $return = drupal_render($element);
    if (empty($return)) {
        $return = $url;
    }
    return $return;
}