本文整理汇总了PHP中Drupal\Component\Utility\Html类的典型用法代码示例。如果您正苦于以下问题:PHP Html类的具体用法?PHP Html怎么用?PHP Html使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Html类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
// line 21
$context["classes"] = array(0 => "views-ui-display-tab-bucket", 1 => isset($context["name"]) ? $context["name"] : null ? \Drupal\Component\Utility\Html::getClass(isset($context["name"]) ? $context["name"] : null) : "", 2 => isset($context["overridden"]) ? $context["overridden"] : null ? "overridden" : "");
// line 27
echo "<div";
echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "html", null, true);
echo ">\n ";
// line 28
if (isset($context["title"]) ? $context["title"] : null) {
// line 29
echo "<h3 class=\"views-ui-display-tab-bucket__title\">";
echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["title"]) ? $context["title"] : null, "html", null, true);
echo "</h3>";
}
// line 31
echo " ";
if (isset($context["actions"]) ? $context["actions"] : null) {
// line 32
echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["actions"]) ? $context["actions"] : null, "html", null, true);
}
// line 34
echo " ";
echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["content"]) ? $context["content"] : null, "html", null, true);
echo "\n</div>\n";
}
开发者ID:Nouveau,项目名称:gishtips,代码行数:26,代码来源:537b616d5ca16306091c1bf8213d859e87ee856f47eacd1546f7465e0a4b26cf.php
示例2: testTableSortInit
/**
* Tests tablesort_init().
*/
function testTableSortInit()
{
// Test simple table headers.
$headers = array('foo', 'bar', 'baz');
// Reset $request->query to prevent parameters from Simpletest and Batch API
// ending up in $ts['query'].
$expected_ts = array('name' => 'foo', 'sql' => '', 'sort' => 'asc', 'query' => array());
$request = Request::createFromGlobals();
$request->query->replace(array());
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.');
// Test with simple table headers plus $_GET parameters that should _not_
// override the default.
$request = Request::createFromGlobals();
$request->query->replace(array('order' => 'bar'));
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
// Test with simple table headers plus $_GET parameters that _should_
// override the default.
$request = Request::createFromGlobals();
$request->query->replace(array('sort' => 'DESC', 'alpha' => 'beta'));
\Drupal::getContainer()->get('request_stack')->push($request);
$expected_ts['sort'] = 'desc';
$expected_ts['query'] = array('alpha' => 'beta');
$ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.');
// Test complex table headers.
$headers = array('foo', array('data' => '1', 'field' => 'one', 'sort' => 'asc', 'colspan' => 1), array('data' => '2', 'field' => 'two', 'sort' => 'desc'));
// Reset $_GET from previous assertion.
$request = Request::createFromGlobals();
$request->query->replace(array('order' => '2'));
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
$expected_ts = array('name' => '2', 'sql' => 'two', 'sort' => 'desc', 'query' => array());
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.');
// Test complex table headers plus $_GET parameters that should _not_
// override the default.
$request = Request::createFromGlobals();
$request->query->replace(array('order' => 'bar'));
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
$expected_ts = array('name' => '1', 'sql' => 'one', 'sort' => 'asc', 'query' => array());
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
// Test complex table headers plus $_GET parameters that _should_
// override the default.
$request = Request::createFromGlobals();
$request->query->replace(array('order' => '1', 'sort' => 'ASC', 'alpha' => 'beta'));
\Drupal::getContainer()->get('request_stack')->push($request);
$expected_ts = array('name' => '1', 'sql' => 'one', 'sort' => 'asc', 'query' => array('alpha' => 'beta'));
$ts = tablesort_init($headers);
$this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
$this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.');
}
示例3: at_core_submit_mobile_blocks
/**
* Submit Mobile Blocks settings.
* @param $values
* @param $theme
* @param $generated_files_path
*/
function at_core_submit_mobile_blocks($values, $theme, $generated_files_path)
{
$mobile_blocks_css = array();
// TODO entityManager() is deprecated, but how to replace?
$theme_blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => $theme]);
if (!empty($theme_blocks)) {
foreach ($theme_blocks as $block_key => $block_values) {
$block_id = $block_values->id();
if (isset($values['settings_mobile_block_show_' . $block_id]) && $values['settings_mobile_block_show_' . $block_id] == 1) {
$block_selector = '#' . Html::getUniqueId('block-' . $block_id);
$mobile_blocks_css[] = $block_selector . ' {display:none}' . "\n";
$mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:block}' . "\n";
}
if (isset($values['settings_mobile_block_hide_' . $block_id]) && $values['settings_mobile_block_hide_' . $block_id] == 1) {
$block_selector = '#' . Html::getUniqueId('block-' . $block_id);
$mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:none}' . "\n";
$mobile_blocks_css[] = $block_selector . ' {display:block}' . "\n";
}
}
}
if (!empty($mobile_blocks_css)) {
$file_name = 'mobile-blocks.css';
$filepath = $generated_files_path . '/' . $file_name;
file_unmanaged_save_data($mobile_blocks_css, $filepath, FILE_EXISTS_REPLACE);
}
}
示例4: testSystemSiteTokenReplacement
/**
* Tests the generation of all system site information tokens.
*/
public function testSystemSiteTokenReplacement()
{
$url_options = array('absolute' => TRUE, 'language' => $this->interfaceLanguage);
$slogan = '<blink>Slogan</blink>';
$safe_slogan = Xss::filterAdmin($slogan);
// Set a few site variables.
$config = $this->config('system.site');
$config->set('name', '<strong>Drupal<strong>')->set('slogan', $slogan)->set('mail', 'simpletest@example.com')->save();
// Generate and test tokens.
$tests = array();
$tests['[site:name]'] = Html::escape($config->get('name'));
$tests['[site:slogan]'] = $safe_slogan;
$tests['[site:mail]'] = $config->get('mail');
$tests['[site:url]'] = \Drupal::url('<front>', [], $url_options);
$tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('<front>', [], $url_options));
$tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options);
$base_bubbleable_metadata = new BubbleableMetadata();
$metadata_tests = [];
$metadata_tests['[site:name]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$metadata_tests['[site:slogan]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$metadata_tests['[site:mail]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$bubbleable_metadata = clone $base_bubbleable_metadata;
$metadata_tests['[site:url]'] = $bubbleable_metadata->addCacheContexts(['url.site']);
$metadata_tests['[site:url-brief]'] = $bubbleable_metadata;
$metadata_tests['[site:login-url]'] = $bubbleable_metadata;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
$output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
$this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
}
示例5: block_navbar
public function block_navbar($context, array $blocks = array())
{
// line 67
echo " ";
// line 68
$context["navbar_classes"] = array(0 => "navbar", 1 => $this->getAttribute($this->getAttribute(isset($context["theme"]) ? $context["theme"] : null, "settings", array()), "navbar_inverse", array()) ? "navbar-inverse" : "navbar-default", 2 => $this->getAttribute($this->getAttribute(isset($context["theme"]) ? $context["theme"] : null, "settings", array()), "navbar_position", array()) ? "navbar-" . \Drupal\Component\Utility\Html::getClass($this->getAttribute($this->getAttribute(isset($context["theme"]) ? $context["theme"] : null, "settings", array()), "navbar_position", array())) : "container");
// line 74
echo " <header";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["navbar_attributes"]) ? $context["navbar_attributes"] : null, "addClass", array(0 => isset($context["navbar_classes"]) ? $context["navbar_classes"] : null), "method"), "html", null, true));
echo " id=\"navbar\" role=\"banner\" style=\"border:none;background-color:white;margin-bottom:0px\"> \n <div class=\"navbar-header\">\n ";
// line 76
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["page"]) ? $context["page"] : null, "navigation", array()), "html", null, true));
echo "\n ";
// line 78
echo " <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">\n <span class=\"sr-only\">";
// line 79
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(t("Toggle navigation")));
echo "</span>\n <span class=\"icon-bar\"></span>\n <span class=\"icon-bar\"></span>\n <span class=\"icon-bar\"></span>\n </button>\n </div>\n\n ";
// line 87
echo " ";
if ($this->getAttribute(isset($context["page"]) ? $context["page"] : null, "navigation_collapsible", array())) {
// line 88
echo " <div class=\"navbar-collapse collapse\" style=\"padding-top: 80px;\">\n ";
// line 89
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["page"]) ? $context["page"] : null, "navigation_collapsible", array()), "html", null, true));
echo "\n </div>\n ";
}
// line 92
echo " </header>\n ";
}
开发者ID:Suite5,项目名称:feelmybook,代码行数:30,代码来源:27fa654ec7d3bf34559bcda763f9fc0b73787bc6847caef8542b5736c9c00030.php
示例6: testCreatePlaceholderGeneratesValidHtmlMarkup
/**
* @covers ::createPlaceholder
* @dataProvider providerCreatePlaceholderGeneratesValidHtmlMarkup
*
* Ensure that the generated placeholder markup is valid. If it is not, then
* simply using DOMDocument on HTML that contains placeholders may modify the
* placeholders' markup, which would make it impossible to replace the
* placeholders: the placeholder markup in #attached versus that in the HTML
* processed by DOMDocument would no longer match.
*/
public function testCreatePlaceholderGeneratesValidHtmlMarkup(array $element)
{
$build = $this->placeholderGenerator->createPlaceholder($element);
$original_placeholder_markup = (string) $build['#markup'];
$processed_placeholder_markup = Html::serialize(Html::load($build['#markup']));
$this->assertEquals($original_placeholder_markup, $processed_placeholder_markup);
}
示例7: getAlbumImages
/**
* Get album images by $node->id().
* @todo move function so it is easily accessible.
*/
public function getAlbumImages($nid, $limit = 10) {
$images = array();
$column = isset($_GET['field']) ? \Drupal\Component\Utility\Html::escape($_GET['field']) : '';
$sort = isset($_GET['sort']) ? \Drupal\Component\Utility\Html::escape($_GET['sort']) : '';
$term = _photos_order_value($column, $sort, $limit, array('column' => 'p.wid', 'sort' => 'asc'));
$query = db_select('file_managed', 'f')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->join('photos_image', 'p', 'p.fid = f.fid');
$query->join('users_field_data', 'u', 'f.uid = u.uid');
$query->join('node', 'n', 'n.nid = p.pid');
$query->fields('f', array('uri', 'filemime', 'created', 'filename', 'filesize'));
$query->fields('p');
$query->fields('u', array('uid', 'name'));
$query->condition('p.pid', $nid);
$query->limit($term['limit']);
$query->orderBy($term['order']['column'], $term['order']['sort']);
$query->addTag('node_access');
$result = $query->execute();
foreach ($result as $data) {
// @todo create new function to return image object.
$images[] = photos_get_info(0, $data);
}
if (isset($images[0]->fid)) {
$node = \Drupal::entityManager()->getStorage('node')->load($nid);
$images[0]->info = array(
'pid' => $node->id(),
'title' => $node->getTitle(),
'uid' => $node->getOwnerId()
);
if (isset($node->album['cover'])) {
$images[0]->info['cover'] = $node->album['cover'];
}
}
return $images;
}
示例8: testDatabaseLoaded
/**
* Tests that the database was properly loaded.
*/
public function testDatabaseLoaded()
{
foreach (['user', 'node', 'system', 'update_test_schema'] as $module) {
$this->assertEqual(drupal_get_installed_schema_version($module), 8000, SafeMarkup::format('Module @module schema is 8000', ['@module' => $module]));
}
// Ensure that all {router} entries can be unserialized. If they cannot be
// unserialized a notice will be thrown by PHP.
$result = \Drupal::database()->query("SELECT name, route from {router}")->fetchAllKeyed(0, 1);
// For the purpose of fetching the notices and displaying more helpful error
// messages, let's override the error handler temporarily.
set_error_handler(function ($severity, $message, $filename, $lineno) {
throw new \ErrorException($message, 0, $severity, $filename, $lineno);
});
foreach ($result as $route_name => $route) {
try {
unserialize($route);
} catch (\Exception $e) {
$this->fail(sprintf('Error "%s" while unserializing route %s', $e->getMessage(), Html::escape($route_name)));
}
}
restore_error_handler();
// Before accessing the site we need to run updates first or the site might
// be broken.
$this->runUpdates();
$this->assertEqual(\Drupal::config('system.site')->get('name'), 'Site-Install');
$this->drupalGet('<front>');
$this->assertText('Site-Install');
// Ensure that the database tasks have been run during set up. Neither MySQL
// nor SQLite make changes that are testable.
$database = $this->container->get('database');
if ($database->driver() == 'pgsql') {
$this->assertEqual('on', $database->query("SHOW standard_conforming_strings")->fetchField());
$this->assertEqual('escape', $database->query("SHOW bytea_output")->fetchField());
}
}
示例9: preprocessVariables
/**
* {@inheritdoc}
*/
protected function preprocessVariables(Variables $variables, $hook, array $info)
{
// Retrieve the ID, generating one if needed.
$id = $variables->getAttribute('id', Html::getUniqueId($variables->offsetGet('id', 'bootstrap-carousel')));
unset($variables['id']);
// Build slides.
foreach ($variables->slides as $key => &$slide) {
if (!isset($slide['attributes'])) {
$slide['attributes'] = [];
}
$slide['attributes'] = new Attribute($slide['attributes']);
}
// Build controls.
if ($variables->controls) {
$left_icon = Bootstrap::glyphicon('chevron-left');
$right_icon = Bootstrap::glyphicon('chevron-right');
$url = Url::fromUserInput("#{$id}");
$variables->controls = ['left' => ['#type' => 'link', '#title' => new FormattableMarkup(Element::create($left_icon)->render() . '<span class="sr-only">@text</span>', ['@text' => t('Previous')]), '#url' => $url, '#attributes' => ['class' => ['left', 'carousel-control'], 'role' => 'button', 'data-slide' => 'prev']], 'right' => ['#type' => 'link', '#title' => new FormattableMarkup(Element::create($right_icon)->render() . '<span class="sr-only">@text</span>', ['@text' => t('Next')]), '#url' => $url, '#attributes' => ['class' => ['right', 'carousel-control'], 'role' => 'button', 'data-slide' => 'next']]];
}
// Build indicators.
if ($variables->indicators) {
$variables->indicators = ['#theme' => 'item_list__bootstrap_carousel_indicators', '#list_type' => 'ol', '#items' => array_keys($variables->slides), '#target' => "#{$id}", '#start_index' => $variables->start_index];
}
// Ensure all attributes are proper objects.
$this->preprocessAttributes($variables, $hook, $info);
}
示例10: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$tags = array("set" => 27);
$filters = array("clean_class" => 29, "raw" => 37, "safe_join" => 38, "t" => 46);
$functions = array();
try {
$this->env->getExtension('sandbox')->checkSecurity(array('set'), array('clean_class', 'raw', 'safe_join', 't'), array());
} catch (Twig_Sandbox_SecurityError $e) {
$e->setTemplateFile($this->getTemplateName());
if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
$e->setTemplateLine($tags[$e->getTagName()]);
} elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
$e->setTemplateLine($filters[$e->getFilterName()]);
} elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
$e->setTemplateLine($functions[$e->getFunctionName()]);
}
throw $e;
}
// line 27
$context["body_classes"] = array(0 => isset($context["logged_in"]) ? $context["logged_in"] : null ? "user-logged-in" : "", 1 => !(isset($context["root_path"]) ? $context["root_path"] : null) ? "path-frontpage" : "path-" . \Drupal\Component\Utility\Html::getClass(isset($context["root_path"]) ? $context["root_path"] : null), 2 => isset($context["node_type"]) ? $context["node_type"] : null ? "node--type-" . \Drupal\Component\Utility\Html::getClass(isset($context["node_type"]) ? $context["node_type"] : null) : "", 3 => isset($context["db_offline"]) ? $context["db_offline"] : null ? "db-offline" : "");
// line 34
echo "<!DOCTYPE html>\n<html";
// line 35
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["html_attributes"]) ? $context["html_attributes"] : null, "html", null, true));
echo ">\n <head>\n <head-placeholder token=\"";
// line 37
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
echo "\">\n <title>";
// line 38
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar($this->env->getExtension('drupal_core')->safeJoin($this->env, isset($context["head_title"]) ? $context["head_title"] : null, " | ")));
echo "</title>\n <css-placeholder token=\"";
// line 39
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
echo "\">\n ";
// line 41
echo " ";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["base_font"]) ? $context["base_font"] : null));
echo "\n <js-placeholder token=\"";
// line 42
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
echo "\">\n </head>\n <body";
// line 44
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["body_classes"]) ? $context["body_classes"] : null), "method"), "html", null, true));
echo ">\n <a href=\"#main-content\" class=\"visually-hidden focusable skip-link\">\n ";
// line 46
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(t("Skip to main content")));
echo "\n </a>\n ";
// line 48
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["page_top"]) ? $context["page_top"] : null, "html", null, true));
echo "\n ";
// line 49
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["page"]) ? $context["page"] : null, "html", null, true));
echo "\n ";
// line 50
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["page_bottom"]) ? $context["page_bottom"] : null, "html", null, true));
echo "\n <js-bottom-placeholder token=\"";
// line 51
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
echo "\">\n </body>\n</html>\n";
}
开发者ID:mu5a5hi,项目名称:testmampdrupal,代码行数:60,代码来源:0b2df560a773824b67e785a1ccbac724648110006c1dd3a1ac55e5270b9223cb.php
示例11: 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;
}
示例12: buildRegions
/**
* #pre_render callback for building the regions.
*/
public function buildRegions(array $build)
{
$cacheability = CacheableMetadata::createFromRenderArray($build)->addCacheableDependency($this);
$contexts = $this->getContexts();
foreach ($this->getRegionAssignments() as $region => $blocks) {
if (!$blocks) {
continue;
}
$region_name = Html::getClass("block-region-{$region}");
$build[$region]['#prefix'] = '<div class="' . $region_name . '">';
$build[$region]['#suffix'] = '</div>';
/** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
$weight = 0;
foreach ($blocks as $block_id => $block) {
if ($block instanceof ContextAwarePluginInterface) {
$this->contextHandler()->applyContextMapping($block, $contexts);
}
$access = $block->access($this->account, TRUE);
$cacheability->addCacheableDependency($access);
if (!$access->isAllowed()) {
continue;
}
$block_build = ['#theme' => 'block', '#attributes' => [], '#weight' => $weight++, '#configuration' => $block->getConfiguration(), '#plugin_id' => $block->getPluginId(), '#base_plugin_id' => $block->getBaseId(), '#derivative_plugin_id' => $block->getDerivativeId(), '#block_plugin' => $block, '#pre_render' => [[$this, 'buildBlock']], '#cache' => ['keys' => ['page_manager_block_display', $this->id(), 'block', $block_id], 'tags' => Cache::mergeTags($this->getCacheTags(), $block->getCacheTags()), 'contexts' => $block->getCacheContexts(), 'max-age' => $block->getCacheMaxAge()]];
// Merge the cacheability metadata of blocks into the page. This helps
// to avoid cache redirects if the blocks have more cache contexts than
// the page, which the page must respect as well.
$cacheability->addCacheableDependency($block);
$build[$region][$block_id] = $block_build;
}
}
$build['#title'] = $this->renderPageTitle($this->configuration['page_title']);
$cacheability->applyTo($build);
return $build;
}
示例13: getLinks
/**
* Gets the list of links used by this field.
*
* @return array
* The links which are used by the render function.
*/
protected function getLinks()
{
$links = array();
foreach ($this->options['fields'] as $field) {
if (empty($this->view->field[$field]->last_render_text)) {
continue;
}
$title = $this->view->field[$field]->last_render_text;
$path = '';
$url = NULL;
if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $this->view->field[$field]->options['alter']['path'];
} elseif (!empty($this->view->field[$field]->options['alter']['url']) && $this->view->field[$field]->options['alter']['url'] instanceof UrlObject) {
$url = $this->view->field[$field]->options['alter']['url'];
}
// Make sure that tokens are replaced for this paths as well.
$tokens = $this->getRenderTokens(array());
$path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($path, $tokens)));
$links[$field] = array('url' => $path ? UrlObject::fromUri('internal:/' . $path) : $url, 'title' => $title);
if (!empty($this->options['destination'])) {
$links[$field]['query'] = \Drupal::destination()->getAsArray();
}
}
return $links;
}
示例14: at_core_submit_mobile_blocks
/**
* @file
* Save Breadcrumb CSS to file
*/
function at_core_submit_mobile_blocks($values, $theme, $generated_files_path) {
$mobile_blocks_css = array();
$theme_blocks = entity_load_multiple_by_properties('block', ['theme' => $theme]);
if (!empty($theme_blocks)) {
foreach ($theme_blocks as $block_key => $block_values) {
$block_id = $block_values->id();
if (isset($values['settings_mobile_block_show_' . $block_id]) && $values['settings_mobile_block_show_' . $block_id] == 1) {
$block_selector = '#' . Html::getUniqueId('block-' . $block_id);
$mobile_blocks_css[] = $block_selector . ' {display:none}' . "\n";
$mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:block}' . "\n";
}
if (isset($values['settings_mobile_block_hide_' . $block_id]) && $values['settings_mobile_block_hide_' . $block_id] == 1) {
$block_selector = '#' . Html::getUniqueId('block-' . $block_id);
$mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:none}' . "\n";
$mobile_blocks_css[] = $block_selector . ' {display:block}' . "\n";
}
}
}
if (!empty($mobile_blocks_css)) {
$file_name = 'mobile-blocks.css';
$filepath = $generated_files_path . '/' . $file_name;
file_unmanaged_save_data($mobile_blocks_css, $filepath, FILE_EXISTS_REPLACE);
}
}
示例15: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$tags = array("set" => 29, "if" => 37, "block" => 41);
$filters = array("clean_class" => 31);
$functions = array();
try {
$this->env->getExtension('sandbox')->checkSecurity(
array('set', 'if', 'block'),
array('clean_class'),
array()
);
} catch (Twig_Sandbox_SecurityError $e) {
$e->setTemplateFile($this->getTemplateName());
if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
$e->setTemplateLine($tags[$e->getTagName()]);
} elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
$e->setTemplateLine($filters[$e->getFilterName()]);
} elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
$e->setTemplateLine($functions[$e->getFunctionName()]);
}
throw $e;
}
// line 29
$context["classes"] = array(0 => "block", 1 => ("block-" . \Drupal\Component\Utility\Html::getClass($this->getAttribute( // line 31
(isset($context["configuration"]) ? $context["configuration"] : null), "provider", array()))), 2 => ("block-" . \Drupal\Component\Utility\Html::getClass( // line 32
(isset($context["plugin_id"]) ? $context["plugin_id"] : null))));
// line 35
echo "<div";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute((isset($context["attributes"]) ? $context["attributes"] : null), "addClass", array(0 => (isset($context["classes"]) ? $context["classes"] : null)), "method"), "html", null, true));
echo ">
";
// line 36
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_prefix"]) ? $context["title_prefix"] : null), "html", null, true));
echo "
";
// line 37
if ((isset($context["label"]) ? $context["label"] : null)) {
// line 38
echo " <h2";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_attributes"]) ? $context["title_attributes"] : null), "html", null, true));
echo ">";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["label"]) ? $context["label"] : null), "html", null, true));
echo "</h2>
";
}
// line 40
echo " ";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_suffix"]) ? $context["title_suffix"] : null), "html", null, true));
echo "
";
// line 41
$this->displayBlock('content', $context, $blocks);
// line 44
echo "</div>
";
}
开发者ID:juanmnl07,项目名称:drupal8-test,代码行数:60,代码来源:4ad9772a326dada1bc74824d07cd16717c591bd611fbb9664c72d075882d2415.php