当前位置: 首页>>代码示例>>PHP>>正文


PHP drupal_render函数代码示例

本文整理汇总了PHP中drupal_render函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_render函数的具体用法?PHP drupal_render怎么用?PHP drupal_render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drupal_render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mortgagespeak_menu_link

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";
    }
}
开发者ID:snehal-addweb,项目名称:Mortgagespeak,代码行数:26,代码来源:template.php

示例2: bootstrap_file_widget

/**
 * 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;
}
开发者ID:lcube45,项目名称:hyx,代码行数:33,代码来源:file-widget.func.php

示例3: testFeedIconEscaping

 /**
  * 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.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:12,代码来源:AddFeedTest.php

示例4: testCacheTags

 /**
  * 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.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:31,代码来源:CommentDefaultFormatterCacheTagsTest.php

示例5: bootstrap_menu_link__book_toc

/**
 * 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";
}
开发者ID:TheCacophonyProject,项目名称:cacophony-website-d7,代码行数:34,代码来源:menu-link.func.php

示例6: testAutoescapeRaw

 /**
  * 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>');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:TwigRawTest.php

示例7: amity_island_search_block_form

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>';
}
开发者ID:axelrrfc,项目名称:richmondrugby-legacy,代码行数:7,代码来源:template.php

示例8: mappedOutputHelper

 /**
  * 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;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:37,代码来源:StyleMappingTest.php

示例9: nodeMarkup

  /**
   * 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;
  }
开发者ID:jkyto,项目名称:agolf,代码行数:40,代码来源:DsDevelController.php

示例10: _testTextfieldWidgets

 /**
  * 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');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:31,代码来源:StringFieldTest.php

示例11: theme_block_filter_opening

}
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);
开发者ID:singhneeraj,项目名称:fr-store,代码行数:7,代码来源:filter-block-api.php

示例12: bootstrap_filter_tips

/**
 * 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);
}
开发者ID:marecar,项目名称:acadcms,代码行数:64,代码来源:filter-tips.func.php

示例13: testHandlers

 /**
  * 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);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:HistoryTimestampTest.php

示例14: preBuild

 /**
  * {@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);
 }
开发者ID:akapivo,项目名称:www.dmi.be,代码行数:36,代码来源:LayerSwitcher.php

示例15: iha_preprocess_page

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;
}
开发者ID:freighthouse,项目名称:code,代码行数:31,代码来源:template.php


注:本文中的drupal_render函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。