protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 36, "block" => 38);
     $filters = array("clean_id" => 36, "without" => 37);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'block'), array('clean_id', 'without'), 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 36
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 37
     echo "<nav role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_without($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "removeClass", array(0 => "clearfix"), "method"), "role", "aria-labelledby"), "html", null, true));
     echo ">\n  ";
     // line 38
     $this->displayBlock('content', $context, $blocks);
     // line 41
     echo "</nav>\n";
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 10, "trans" => 17);
     $filters = array("clean_id" => 10);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'trans'), array('clean_id'), 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 10
     $context["show_anchor"] = "show-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 11
     $context["hide_anchor"] = "hide-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 1
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
示例#3
0
文件: Tabs.php 项目: frankcr/sftw8
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element, $rendering_object)
 {
     $element += array('#prefix' => '<div class=" ' . implode(' ', $this->getClasses()) . '">', '#suffix' => '</div>', '#tree' => TRUE, '#parents' => array($this->group->group_name), '#default_tab' => '');
     if ($this->getSetting('id')) {
         $element['#id'] = Html::getId($this->getSetting('id'));
     }
     // By default tabs don't have titles but you can override it in the theme.
     if ($this->getLabel()) {
         $element['#title'] = SafeMarkup::checkPlain($this->getLabel());
     }
     $form_state = new FormState();
     if ($this->getSetting('direction') == 'vertical') {
         $element += array('#type' => 'vertical_tabs', '#theme_wrappers' => array('vertical_tabs'));
         $complete_form = array();
         $element = VerticalTabs::processVerticalTabs($element, $form_state, $complete_form);
     } else {
         $element += array('#type' => 'horizontal_tabs', '#theme_wrappers' => array('horizontal_tabs'));
         $on_form = $this->context == 'form';
         $element = HorizontalTabs::processHorizontalTabs($element, $form_state, $on_form);
     }
     // Make sure the group has 1 child. This is needed to succeed at form_pre_render_vertical_tabs().
     // Skipping this would force us to move all child groups to this array, making it an un-nestable.
     $element['group']['#groups'][$this->group->group_name] = array(0 => array());
     $element['group']['#groups'][$this->group->group_name]['#group_exists'] = TRUE;
     // Search for a tab that was marked as open. First one wins.
     foreach (Element::children($element) as $tab_name) {
         if (!empty($element[$tab_name]['#open'])) {
             $element[$this->group->group_name . '__active_tab']['#default_value'] = $tab_name;
             break;
         }
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 38, "if" => 48, "block" => 58, "trans" => 63);
     $filters = array("clean_class" => 42, "clean_id" => 45, "without" => 46);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'if', 'block', 'trans'), array('clean_class', 'clean_id', 'without'), 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 38
     $context["classes"] = array(0 => "block", 1 => "block-menu", 2 => "navigation", 3 => "menu--" . \Drupal\Component\Utility\Html::getClass(isset($context["derivative_plugin_id"]) ? $context["derivative_plugin_id"] : null));
     // line 45
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 46
     echo "<nav role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_without($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "role", "aria-labelledby"), "html", null, true));
     echo ">\n  ";
     // line 48
     echo "  ";
     if (!$this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label_display", array())) {
         // line 49
         echo "    ";
         $context["title_attributes"] = $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "addClass", array(0 => "visually-hidden"), "method");
         // line 50
         echo "  ";
     }
     // line 51
     echo "  ";
     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 "\n  <h2";
     // line 52
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "setAttribute", array(0 => "id", 1 => isset($context["heading_id"]) ? $context["heading_id"] : null), "method"), "html", null, true));
     echo ">";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label", array()), "html", null, true));
     echo "</h2>\n  ";
     // line 53
     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 "\n\n  ";
     // line 56
     echo "  ";
     $context["show_anchor"] = "show-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 57
     echo "  ";
     $context["hide_anchor"] = "hide-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 58
     echo "  ";
     $this->displayBlock('content', $context, $blocks);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $__internal_d5fdbc60c80f6b72247ec473e59d80d9ff42128768881ee08f6810a8c73d62af = $this->env->getExtension("native_profiler");
     $__internal_d5fdbc60c80f6b72247ec473e59d80d9ff42128768881ee08f6810a8c73d62af->enter($__internal_d5fdbc60c80f6b72247ec473e59d80d9ff42128768881ee08f6810a8c73d62af_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "core/themes/classy/templates/block/block--system-menu-block.html.twig"));
     $tags = array("set" => 35, "if" => 45, "block" => 53);
     $filters = array("clean_class" => 39, "clean_id" => 42, "without" => 43);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'if', 'block'), array('clean_class', 'clean_id', 'without'), 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 35
     $context["classes"] = array(0 => "block", 1 => "block-menu", 2 => "navigation", 3 => "menu--" . \Drupal\Component\Utility\Html::getClass(isset($context["derivative_plugin_id"]) ? $context["derivative_plugin_id"] : null));
     // line 42
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 43
     echo "<nav role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_without($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "role", "aria-labelledby"), "html", null, true));
     echo ">\n  ";
     // line 45
     echo "  ";
     if (!$this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label_display", array())) {
         // line 46
         echo "    ";
         $context["title_attributes"] = $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "addClass", array(0 => "visually-hidden"), "method");
         // line 47
         echo "  ";
     }
     // line 48
     echo "  ";
     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 "\n  <h2";
     // line 49
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "setAttribute", array(0 => "id", 1 => isset($context["heading_id"]) ? $context["heading_id"] : null), "method"), "html", null, true));
     echo ">";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label", array()), "html", null, true));
     echo "</h2>\n  ";
     // line 50
     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 "\n\n  ";
     // line 53
     echo "  ";
     $this->displayBlock('content', $context, $blocks);
     // line 56
     echo "</nav>\n";
     $__internal_d5fdbc60c80f6b72247ec473e59d80d9ff42128768881ee08f6810a8c73d62af->leave($__internal_d5fdbc60c80f6b72247ec473e59d80d9ff42128768881ee08f6810a8c73d62af_prof);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 10
     $context["show_anchor"] = "show-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 11
     $context["hide_anchor"] = "hide-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 1
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 44, "if" => 56, "block" => 64);
     $filters = array("clean_class" => 47, "clean_id" => 51);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'if', 'block'), array('clean_class', 'clean_id'), 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 44
     $context["classes"] = array(0 => "block", 1 => "block-menu", 2 => "block-menu--" . \Drupal\Component\Utility\Html::getClass(isset($context["derivative_plugin_id"]) ? $context["derivative_plugin_id"] : null), 3 => isset($context["label"]) ? $context["label"] : null ? "has-title" : "");
     // line 51
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 52
     echo "<nav";
     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 " role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\">\n  <div class=\"block__inner block-menu__inner\">\n\n    ";
     // line 56
     echo "    ";
     if (!$this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label_display", array())) {
         // line 57
         echo "      ";
         $context["title_attributes"] = $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "addClass", array(0 => "visually-hidden"), "method");
         // line 58
         echo "    ";
     }
     // line 59
     echo "\n    ";
     // line 60
     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 "\n    <h2 id=\"";
     // line 61
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "addClass", array(0 => "block__title", 1 => "block-menu__title"), "method"), "html", null, true));
     echo "><span>";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label", array()), "html", null, true));
     echo "</span></h2>\n    ";
     // line 62
     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 "\n\n    ";
     // line 64
     $this->displayBlock('content', $context, $blocks);
     // line 69
     echo "\n  </div>\n</nav>\n";
 }
    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 44
        $context["classes"] = array(0 => "block", 1 => "block-menu", 2 => ("block-menu--" . \Drupal\Component\Utility\Html::getClass(        // line 47
(isset($context["derivative_plugin_id"]) ? $context["derivative_plugin_id"] : null))), 3 => ((        // line 48
(isset($context["label"]) ? $context["label"] : null)) ? ("has-title") : ("")));
        // line 51
        $context["heading_id"] = ($this->getAttribute((isset($context["attributes"]) ? $context["attributes"] : null), "id", array()) . \Drupal\Component\Utility\Html::getId("-menu"));
        // line 52
        echo "<nav";
        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 " role=\"navigation\" aria-labelledby=\"";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["heading_id"]) ? $context["heading_id"] : null), "html", null, true);
        echo "\">
  <div class=\"block__inner block-menu__inner\">

    ";
        // line 56
        echo "    ";
        if ( !$this->getAttribute((isset($context["configuration"]) ? $context["configuration"] : null), "label_display", array())) {
            // line 57
            echo "      ";
            $context["title_attributes"] = $this->getAttribute((isset($context["title_attributes"]) ? $context["title_attributes"] : null), "addClass", array(0 => "visually-hidden"), "method");
            // line 58
            echo "    ";
        }
        // line 59
        echo "
    ";
        // line 60
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_prefix"]) ? $context["title_prefix"] : null), "html", null, true);
        echo "
    <h2 id=\"";
        // line 61
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["heading_id"]) ? $context["heading_id"] : null), "html", null, true);
        echo "\"";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute((isset($context["title_attributes"]) ? $context["title_attributes"] : null), "addClass", array(0 => "block__title", 1 => "block-menu__title"), "method"), "html", null, true);
        echo "><span>";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute((isset($context["configuration"]) ? $context["configuration"] : null), "label", array()), "html", null, true);
        echo "</span></h2>
    ";
        // line 62
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_suffix"]) ? $context["title_suffix"] : null), "html", null, true);
        echo "

    ";
        // line 65
        echo "    ";
        $this->displayBlock('content', $context, $blocks);
        // line 70
        echo "
  </div>
</nav>
";
    }
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element, $rendering_object)
 {
     $element += array('#type' => 'field_group_accordion_item', '#collapsed' => $this->getSetting('formatter'), '#description' => $this->getSetting('description'), '#title' => Drupal::translation()->translate($this->getLabel()));
     if ($this->getSetting('id')) {
         $element['#id'] = Html::getId($this->getSetting('id'));
     }
     $classes = $this->getClasses();
     if (!empty($classes)) {
         $element += array('#attributes' => array('class' => $classes));
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 44, "block" => 62);
     $filters = array("clean_class" => 46, "clean_id" => 51);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'block'), array('clean_class', 'clean_id'), 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 44
     $context["classes"] = array(0 => "rm-block", 1 => "rm--menu--" . \Drupal\Component\Utility\Html::getClass(isset($context["derivative_plugin_id"]) ? $context["derivative_plugin_id"] : null), 2 => isset($context["label"]) ? $context["label"] : null ? "has-title" : "", 3 => "js-hide");
     // line 51
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 52
     echo "<nav";
     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 " role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\">\n  <div class=\"rm-block__inner\">\n    ";
     // line 54
     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 "\n    <div id=\"";
     // line 55
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "addClass", array(0 => "rm-toggle"), "method"), "html", null, true));
     echo ">\n      ";
     // line 56
     $context["rm_text_state"] = isset($context["label"]) ? $context["label"] : null ? "rm-toggle__label" : "visually-hidden";
     // line 57
     echo "      <button href=\"#rm-content\" class=\"rm-toggle__link un-button\" role='button' aria-controls=\"rm-content\" aria-expanded=\"false\">\n        <span class=\"";
     // line 58
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["rm_text_state"]) ? $context["rm_text_state"] : null, "html", null, true));
     echo "\">";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label", array()), "html", null, true));
     echo "</span>\n      </button>\n    </div>\n    ";
     // line 61
     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 "\n    ";
     // line 62
     $this->displayBlock('content', $context, $blocks);
     // line 67
     echo "  </div>\n</nav>\n";
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 34, "if" => 37, "block" => 45);
     $filters = array("clean_id" => 34, "without" => 35);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'if', 'block'), array('clean_id', 'without'), 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 34
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 35
     echo "<nav role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_without(isset($context["attributes"]) ? $context["attributes"] : null, "role", "aria-labelledby"), "html", null, true));
     echo ">\n  ";
     // line 37
     echo "  ";
     if (!$this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label_display", array())) {
         // line 38
         echo "    ";
         $context["title_attributes"] = $this->getAttribute(isset($context["title_attributes"]) ? $context["title_attributes"] : null, "addClass", array(0 => "visually-hidden"), "method");
         // line 39
         echo "  ";
     }
     // line 40
     echo "  ";
     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 "\n  <h2";
     // line 41
     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, $this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "label", array()), "html", null, true));
     echo "</h2>\n  ";
     // line 42
     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 "\n\n  ";
     // line 45
     echo "  ";
     $this->displayBlock('content', $context, $blocks);
     // line 48
     echo "</nav>\n";
 }
示例#12
0
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element)
 {
     $form_state = new FormState();
     $element += array('#type' => 'field_group_accordion', '#effect' => $this->getSetting('effect'));
     if ($this->getSetting('id')) {
         $element['#id'] = Html::getId($this->getSetting('id'));
     }
     $classes = $this->getClasses();
     if (!empty($classes)) {
         $element += array('#attributes' => array('class' => $classes));
     }
     \Drupal\field_group\Element\Accordion::processAccordion($element, $form_state);
 }
示例#13
0
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element)
 {
     $element += array('#type' => 'details', '#title' => SafeMarkup::checkPlain($this->t($this->getLabel())), '#open' => $this->getSetting('open'));
     if ($this->getSetting('id')) {
         $element['#id'] = Html::getId($this->getSetting('id'));
     }
     if ($this->getSetting('classes')) {
         $element += array('#attributes' => array('class' => explode(' ', $this->getSetting('classes'))));
     }
     if ($this->getSetting('description')) {
         $element += array('#description' => $this->getSetting('description'));
     }
 }
示例#14
0
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element, $rendering_object)
 {
     $element += array('#type' => 'details', '#title' => SafeMarkup::checkPlain($this->t($this->getLabel())), '#open' => $this->getSetting('open'));
     if ($this->getSetting('id')) {
         $element['#id'] = Html::getId($this->getSetting('id'));
     }
     $classes = $this->getClasses();
     if (!empty($classes)) {
         $element += array('#attributes' => array('class' => $classes));
     }
     if ($this->getSetting('description')) {
         $element += array('#description' => $this->getSetting('description'));
     }
 }
示例#15
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $menu_links_elements = $this->getMenuLinkElements($this->entity->getTargetMenu());
     $layout_options = $this->getLayoutOptions();
     $table_header = ['label' => $this->t('Label'), 'category' => $this->t('Category'), 'region' => $this->t('Region'), 'weight' => $this->t('Weight'), 'operations' => $this->t('Operations')];
     $form['links'] = ['#type' => 'container', '#title' => $this->t('Menu links'), '#tree' => TRUE];
     $blocks = $this->entity->getAllBlocksSortedByLink();
     foreach ($menu_links_elements as $link_element_id => $link_element) {
         // Replace any dots with a underscore since dots are not supported as
         // keys in the configuration data.
         $link_element_id = str_replace('.', '_', $link_element_id);
         $link_layout = $this->entity->getLinkLayout($link_element_id);
         $regions = $this->getLayoutRegions($link_layout);
         $link_id = Html::getId($link_element_id);
         $form['links'][$link_element_id] = ['#type' => 'fieldset', '#title' => $link_element->link->getTitle()];
         $form['links'][$link_element_id]['layout'] = ['#type' => 'select', '#title' => $this->t('Layout'), '#options' => $layout_options, '#default_value' => $link_layout, '#ajax' => ['callback' => '::onLayoutSelect', 'wrapper' => "mega-menu-link-{$link_id}-blocks-wrapper"], '#attributes' => ['data-link-element-id' => $link_element_id]];
         $form['links'][$link_element_id]['blocks'] = ['#prefix' => '<div id="mega-menu-link-' . $link_id . '-blocks-wrapper">', '#suffix' => '</div>', '#type' => 'table', '#header' => $table_header, '#empty' => $this->t('There are no regions for blocks.')];
         // Add regions.
         foreach ($regions as $region_key => $region_name) {
             // Tabledrag stuff.
             $form['links'][$link_element_id]['blocks']['#tabledrag'][] = ['action' => 'match', 'relationship' => 'sibling', 'group' => 'block-region-select', 'subgroup' => 'block-region-' . $region_key, 'hidden' => FALSE];
             $form['links'][$link_element_id]['blocks']['#tabledrag'][] = ['action' => 'order', 'relationship' => 'sibling', 'group' => 'block-weight', 'subgroup' => 'block-weight-' . $region_key];
             // Regions.
             $form['links'][$link_element_id]['blocks'][$region_key] = ['#attributes' => ['class' => ['region-title', 'region-title-' . $region_key], 'no_striping' => TRUE]];
             if ($region_key === MegaMenuInterface::NO_REGION) {
                 $form['links'][$link_element_id]['blocks'][$region_key]['title'] = ['#markup' => $region_name, '#wrapper_attributes' => ['colspan' => 5]];
             } else {
                 $form['links'][$link_element_id]['blocks'][$region_key]['title'] = ['#theme_wrappers' => ['container' => ['#attributes' => ['class' => ['region-title__action']]]], '#prefix' => $region_name, '#type' => 'link', '#title' => $this->t('Place block <span class="visually-hidden">in the %region region</span>', ['%region' => $region_name]), '#url' => Url::fromRoute('mega_menu.block_library', ['mega_menu' => $this->entity->id()], ['query' => ['link' => $link_element_id, 'region' => $region_key]]), '#wrapper_attributes' => ['colspan' => 5], '#attributes' => ['class' => ['use-ajax', 'button', 'button--small'], 'data-dialog-type' => 'modal', 'data-dialog-options' => Json::encode(['width' => 700])]];
             }
             $blocks_by_region = isset($blocks[$link_element_id]) ? $blocks[$link_element_id]->getAllByRegion() : [];
             $region_message_class = empty($blocks_by_region[$region_key]) ? 'region-empty' : 'region-populated';
             $form['links'][$link_element_id]['blocks'][$region_key . '-message'] = ['#attributes' => ['class' => ['region-message', 'region-' . $region_key . '-message', $region_message_class]]];
             $form['links'][$link_element_id]['blocks'][$region_key . '-message']['message'] = ['#markup' => '<em>' . $this->t('No blocks in this region') . '</em>', '#wrapper_attributes' => ['colspan' => 5]];
             if (!isset($blocks_by_region[$region_key])) {
                 continue;
             }
             /** @var BlockPluginInterface $block */
             foreach ($blocks_by_region[$region_key] as $block_id => $block) {
                 if (!isset($form['links'][$link_element_id])) {
                     continue;
                 }
                 $operations = ['edit' => ['title' => $this->t('Edit'), 'url' => Url::fromRoute('mega_menu.block_edit', ['mega_menu' => $this->entity->id(), 'block_id' => $block_id], ['query' => ['link' => $link_element_id, 'region' => $region_key]]), 'attributes' => ['class' => ['use-ajax', 'button', 'button--small'], 'data-dialog-type' => 'modal', 'data-dialog-options' => Json::encode(['width' => 700])]], 'delete' => ['title' => $this->t('Delete'), 'url' => Url::fromRoute('mega_menu.block_delete', ['mega_menu' => $this->entity->id(), 'block_id' => $block_id], ['query' => ['link' => $link_element_id]]), 'attributes' => ['class' => ['use-ajax', 'button', 'button--small'], 'data-dialog-type' => 'modal', 'data-dialog-options' => Json::encode(['width' => 700])]]];
                 $configuration = $block->getConfiguration();
                 $form['links'][$link_element_id]['blocks'][$block_id] = ['#attributes' => ['class' => ['draggable']], 'label' => ['#markup' => $block->label()], 'category' => ['#markup' => $block->getPluginDefinition()['category']], 'region' => ['#type' => 'select', '#title' => $this->t('Region for @block block', ['@block' => $block->label()]), '#title_display' => 'invisible', '#default_value' => $region_key, '#options' => $regions, '#attributes' => ['class' => ['block-region-select', 'block-region-' . $region_key]]], 'weight' => ['#type' => 'weight', '#default_value' => isset($configuration['weight']) ? $configuration['weight'] : 0, '#title' => $this->t('Weight for @block block', ['@block' => $block->label()]), '#title_display' => 'invisible', '#attributes' => ['class' => ['block-weight', 'block-weight-' . $configuration['region']]]], 'operations' => ['#type' => 'operations', '#links' => $operations]];
             }
         }
     }
     return $form;
 }
示例#16
0
 /**
  * {@inheritdoc}
  */
 public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 {
     /** @var \Drupal\link\LinkItemInterface $item */
     $item = $items[$delta];
     $html_id = Html::getId('leaflet-widget');
     $element['leaflet_map']['#markup'] = '<div class="leaflet-widget" id="' . $html_id . '"></div>';
     $element['#attached']['library'][] = 'bbox/leaflet';
     $element['#attached']['library'][] = 'bbox/field';
     $element['#attached']['drupalSettings']['bbox']['widgets'][] = $html_id;
     $element['northeast_lng'] = array('#title' => $this->t('northeast lng'), '#default_value' => $item->northeast_lng, '#type' => 'textfield', '#attributes' => array('class' => array('northeast-lng')));
     $element['northeast_lat'] = array('#title' => $this->t('northeast lat'), '#default_value' => $item->northeast_lat, '#type' => 'textfield', '#attributes' => array('class' => array('northeast-lat')));
     $element['southwest_lng'] = array('#title' => $this->t('southwest lng'), '#default_value' => $item->southwest_lng, '#type' => 'textfield', '#attributes' => array('class' => array('southwest-lng')));
     $element['southwest_lat'] = array('#title' => $this->t('southwest lat'), '#default_value' => $item->southwest_lat, '#type' => 'textfield', '#attributes' => array('class' => array('southwest-lat')));
     return $element;
 }
    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 36
        $context["classes"] = array(0 => "block", 1 => "block-menu", 2 => "navigation", 3 => ("menu--" . \Drupal\Component\Utility\Html::getClass(        // line 40
(isset($context["derivative_plugin_id"]) ? $context["derivative_plugin_id"] : null))));
        // line 43
        $context["heading_id"] = ($this->getAttribute((isset($context["attributes"]) ? $context["attributes"] : null), "id", array()) . \Drupal\Component\Utility\Html::getId("-menu"));
        // line 44
        echo "<nav role=\"navigation\" aria-labelledby=\"";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["heading_id"]) ? $context["heading_id"] : null), "html", null, true);
        echo "\"";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_without($this->getAttribute((isset($context["attributes"]) ? $context["attributes"] : null), "addClass", array(0 => (isset($context["classes"]) ? $context["classes"] : null)), "method"), "role", "aria-labelledby"), "html", null, true);
        echo ">
  ";
        // line 46
        echo "  ";
        if ( !$this->getAttribute((isset($context["configuration"]) ? $context["configuration"] : null), "label_display", array())) {
            // line 47
            echo "    ";
            $context["title_attributes"] = $this->getAttribute((isset($context["title_attributes"]) ? $context["title_attributes"] : null), "addClass", array(0 => "visually-hidden"), "method");
            // line 48
            echo "  ";
        }
        // line 49
        echo "  ";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_prefix"]) ? $context["title_prefix"] : null), "html", null, true);
        echo "
  <h2";
        // line 50
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute((isset($context["title_attributes"]) ? $context["title_attributes"] : null), "setAttribute", array(0 => "id", 1 => (isset($context["heading_id"]) ? $context["heading_id"] : null)), "method"), "html", null, true);
        echo ">";
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute((isset($context["configuration"]) ? $context["configuration"] : null), "label", array()), "html", null, true);
        echo "</h2>
  ";
        // line 51
        echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_suffix"]) ? $context["title_suffix"] : null), "html", null, true);
        echo "

  ";
        // line 54
        echo "  ";
        $this->displayBlock('content', $context, $blocks);
        // line 57
        echo "</nav>
";
    }
示例#18
0
 /**
  * Tests the exposed form with a non-standard identifier.
  */
 public function testExposedIdentifier()
 {
     // Alter the identifier of the filter to a random string.
     $view = Views::getView('test_exposed_form_buttons');
     $view->setDisplay();
     $identifier = 'new_identifier';
     $view->displayHandlers->get('default')->overrideOption('filters', array('type' => ['exposed' => TRUE, 'field' => 'type', 'id' => 'type', 'table' => 'node_field_data', 'plugin_id' => 'in_operator', 'entity_type' => 'node', 'entity_field' => 'type', 'expose' => ['identifier' => $identifier, 'label' => 'Content: Type', 'operator_id' => 'type_op', 'reduce' => FALSE, 'description' => 'Exposed overridden description']]));
     $view->save();
     $this->drupalGet('test_exposed_form_buttons', array('query' => array($identifier => 'article')));
     $this->assertFieldById(Html::getId('edit-' . $identifier), 'article', "Article type filter set with new identifier.");
     // Alter the identifier of the filter to a random string containing
     // restricted characters.
     $view = Views::getView('test_exposed_form_buttons');
     $view->setDisplay();
     $identifier = 'bad identifier';
     $view->displayHandlers->get('default')->overrideOption('filters', array('type' => ['exposed' => TRUE, 'field' => 'type', 'id' => 'type', 'table' => 'node_field_data', 'plugin_id' => 'in_operator', 'entity_type' => 'node', 'entity_field' => 'type', 'expose' => ['identifier' => $identifier, 'label' => 'Content: Type', 'operator_id' => 'type_op', 'reduce' => FALSE, 'description' => 'Exposed overridden description']]));
     $this->executeView($view);
     $errors = $view->validate();
     $expected = ['default' => ['This identifier has illegal characters.'], 'page_1' => ['This identifier has illegal characters.']];
     $this->assertEqual($errors, $expected);
 }
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element, $rendering_object)
 {
     $element_attributes = new Attribute();
     if ($this->getSetting('attributes')) {
         // This regex split the attributes string so that we can pass that
         // later to drupal_attributes().
         preg_match_all('/([^\\s=]+)="([^"]+)"/', $this->getSetting('attributes'), $matches);
         // Put the attribute and the value together.
         foreach ($matches[1] as $key => $attribute) {
             $element_attributes[$attribute] = $matches[2][$key];
         }
     }
     // Add the id to the attributes array.
     if ($this->getSetting('id')) {
         $element_attributes['id'] = Html::getId($this->getSetting('id'));
     }
     // Add the classes to the attributes array.
     $classes = $this->getClasses();
     if (!empty($classes)) {
         if (!isset($element_attributes['class'])) {
             $element_attributes['class'] = array();
         } else {
             $element_attributes['class'] = array($element_attributes['class']);
         }
         $element_attributes['class'] = array_merge($classes, $element_attributes['class']->value());
     }
     $element['#effect'] = $this->getSetting('effect');
     $element['#speed'] = $this->getSetting('speed');
     $element['#type'] = 'field_group_html_element';
     $element['#wrapper_element'] = $this->getSetting('element');
     $element['#attributes'] = $element_attributes;
     if ($this->getSetting('show_label')) {
         $element['#title_element'] = $this->getSetting('label_element');
         $element['#title'] = SafeMarkup::checkPlain($this->t($this->getLabel()));
     }
     $form_state = new FormState();
     \Drupal\field_group\Element\HtmlElement::processHtmlElement($element, $form_state);
 }
示例#20
0
 /**
  * {@inheritdoc}
  */
 public function preRender(&$element)
 {
     $add = array('#type' => 'details', '#title' => SafeMarkup::checkPlain($this->t($this->getLabel())), '#description' => $this->getSetting('description'));
     if ($this->getSetting('id')) {
         $add['#id'] = Html::getId($this->getSetting('id'));
     } else {
         $add['#id'] = Html::getId('edit-' . $this->group->group_name);
     }
     $classes = $this->getClasses();
     if (!empty($classes)) {
         $element += array('#attributes' => array('class' => $classes));
     }
     if ($this->getSetting('formatter') == 'open') {
         $element['#open'] = TRUE;
     }
     // Front-end and back-end on configuration will lead
     // to vertical tabs nested in a separate vertical group.
     if (!empty($this->group->parent_name)) {
         $add['#group'] = $this->group->parent_name;
         $add['#parents'] = array($add['#group']);
     }
     $element += $add;
 }
 /**
  * @covers ::buildOneAvailablePlugin
  */
 public function testBuildOneAvailablePlugin()
 {
     $plugin_id = $this->randomMachineName();
     $plugin_form = array('#type' => $this->randomMachineName());
     $plugin = $this->getMockForAbstractClass(AdvancedPluginSelectorBaseUnitTestPluginFormPluginInterface::class);
     $plugin->expects($this->atLeastOnce())->method('getPluginId')->willReturn($plugin_id);
     $plugin->expects($this->once())->method('buildConfigurationForm')->willReturn($plugin_form);
     $element = array('#available_plugins' => array($plugin));
     $form_state = $this->getMock(FormStateInterface::class);
     $form = [];
     $label = $this->randomMachineName();
     $this->sut->setLabel($label);
     $expected_build = array('#available_plugins' => array($plugin), 'select' => array('message' => ['#title' => $label, '#type' => 'item'], 'container' => array('#type' => 'container', 'plugin_id' => array('#type' => 'value', '#value' => $plugin_id))), 'plugin_form' => array('#attributes' => array('class' => array('plugin-selector-' . Html::getId($this->pluginId) . '-plugin-form')), '#type' => 'container') + $plugin_form);
     $build = $this->sut->buildOneAvailablePlugin($element, $form_state, $form);
     unset($build['plugin_form']['#id']);
     $this->assertSame($expected_build, $build);
 }
示例#22
0
 /**
  * Creates a BigPipe no-JS placeholder.
  *
  * @param string $original_placeholder
  *   The original placeholder.
  * @param array $placeholder_render_array
  *   The render array for a placeholder.
  *
  * @return array
  *   The resulting BigPipe no-JS placeholder render array.
  *
  * @todo Figure out how to simplify this. Perhaps no new placeholder is in fact necessary?
  * @todo Related, perhaps distinguish between "HTML" and "non-HTML (attr value)" use cases? Because right now, this *breaks* HTML and therefore breaks response filters: this indiscriminately uses a <div> as a placeholder, which is invalid inside a HTML attribute, and thus breaks DOM parsing.
  */
 protected static function createBigPipeNoJsPlaceholder($original_placeholder, array $placeholder_render_array)
 {
     $html_placeholder = Html::getId($original_placeholder);
     return ['#markup' => '<div data-big-pipe-selector-nojs="' . $html_placeholder . '"></div>', '#cache' => ['max-age' => 0, 'contexts' => ['session.exists']], '#attached' => ['big_pipe_nojs_placeholders' => [$html_placeholder => $placeholder_render_array]]];
 }
示例#23
0
 /**
  * {@inheritdoc}
  */
 public function doBuildForm($form_id, &$element, FormStateInterface &$form_state)
 {
     // Initialize as unprocessed.
     $element['#processed'] = FALSE;
     // Use element defaults.
     if (isset($element['#type']) && empty($element['#defaults_loaded']) && ($info = $this->elementInfo->getInfo($element['#type']))) {
         // Overlay $info onto $element, retaining preexisting keys in $element.
         $element += $info;
         $element['#defaults_loaded'] = TRUE;
     }
     // Assign basic defaults common for all form elements.
     $element += array('#required' => FALSE, '#attributes' => array(), '#title_display' => 'before', '#description_display' => 'after', '#errors' => NULL);
     // Special handling if we're on the top level form element.
     if (isset($element['#type']) && $element['#type'] == 'form') {
         if (!empty($element['#https']) && !UrlHelper::isExternal($element['#action'])) {
             global $base_root;
             // Not an external URL so ensure that it is secure.
             $element['#action'] = str_replace('http://', 'https://', $base_root) . $element['#action'];
         }
         // Store a reference to the complete form in $form_state prior to building
         // the form. This allows advanced #process and #after_build callbacks to
         // perform changes elsewhere in the form.
         $form_state->setCompleteForm($element);
         // Set a flag if we have a correct form submission. This is always TRUE
         // for programmed forms coming from self::submitForm(), or if the form_id
         // coming from the POST data is set and matches the current form_id.
         $input = $form_state->getUserInput();
         if ($form_state->isProgrammed() || !empty($input) && (isset($input['form_id']) && $input['form_id'] == $form_id)) {
             $form_state->setProcessInput();
             if (isset($element['#token'])) {
                 $input = $form_state->getUserInput();
                 if (empty($input['form_token']) || !$this->csrfToken->validate($input['form_token'], $element['#token'])) {
                     // Set an early form error to block certain input processing since
                     // that opens the door for CSRF vulnerabilities.
                     $this->setInvalidTokenError($form_state);
                     // This value is checked in self::handleInputElement().
                     $form_state->setInvalidToken(TRUE);
                     // Make sure file uploads do not get processed.
                     $this->requestStack->getCurrentRequest()->files = new FileBag();
                 }
             }
         } else {
             $form_state->setProcessInput(FALSE);
         }
         // All form elements should have an #array_parents property.
         $element['#array_parents'] = array();
     }
     if (!isset($element['#id'])) {
         $unprocessed_id = 'edit-' . implode('-', $element['#parents']);
         $element['#id'] = Html::getUniqueId($unprocessed_id);
         // Provide a selector usable by JavaScript. As the ID is unique, its not
         // possible to rely on it in JavaScript.
         $element['#attributes']['data-drupal-selector'] = Html::getId($unprocessed_id);
     } else {
         // Provide a selector usable by JavaScript. As the ID is unique, its not
         // possible to rely on it in JavaScript.
         $element['#attributes']['data-drupal-selector'] = Html::getId($element['#id']);
     }
     // Add the aria-describedby attribute to associate the form control with its
     // description.
     if (!empty($element['#description'])) {
         $element['#attributes']['aria-describedby'] = $element['#id'] . '--description';
     }
     // Handle input elements.
     if (!empty($element['#input'])) {
         $this->handleInputElement($form_id, $element, $form_state);
     }
     // Allow for elements to expand to multiple elements, e.g., radios,
     // checkboxes and files.
     if (isset($element['#process']) && !$element['#processed']) {
         foreach ($element['#process'] as $callback) {
             $complete_form =& $form_state->getCompleteForm();
             $element = call_user_func_array($form_state->prepareCallback($callback), array(&$element, &$form_state, &$complete_form));
         }
         $element['#processed'] = TRUE;
     }
     // We start off assuming all form elements are in the correct order.
     $element['#sorted'] = TRUE;
     // Recurse through all child elements.
     $count = 0;
     if (isset($element['#access'])) {
         $access = $element['#access'];
         $inherited_access = NULL;
         if ($access instanceof AccessResultInterface && !$access->isAllowed() || $access === FALSE) {
             $inherited_access = $access;
         }
     }
     foreach (Element::children($element) as $key) {
         // Prior to checking properties of child elements, their default
         // properties need to be loaded.
         if (isset($element[$key]['#type']) && empty($element[$key]['#defaults_loaded']) && ($info = $this->elementInfo->getInfo($element[$key]['#type']))) {
             $element[$key] += $info;
             $element[$key]['#defaults_loaded'] = TRUE;
         }
         // Don't squash an existing tree value.
         if (!isset($element[$key]['#tree'])) {
             $element[$key]['#tree'] = $element['#tree'];
         }
         // Children inherit #access from parent.
         if (isset($inherited_access)) {
             $element[$key]['#access'] = $inherited_access;
         }
         // Make child elements inherit their parent's #disabled and #allow_focus
         // values unless they specify their own.
         foreach (array('#disabled', '#allow_focus') as $property) {
             if (isset($element[$property]) && !isset($element[$key][$property])) {
                 $element[$key][$property] = $element[$property];
             }
         }
         // Don't squash existing parents value.
         if (!isset($element[$key]['#parents'])) {
             // Check to see if a tree of child elements is present. If so,
             // continue down the tree if required.
             $element[$key]['#parents'] = $element[$key]['#tree'] && $element['#tree'] ? array_merge($element['#parents'], array($key)) : array($key);
         }
         // Ensure #array_parents follows the actual form structure.
         $array_parents = $element['#array_parents'];
         $array_parents[] = $key;
         $element[$key]['#array_parents'] = $array_parents;
         // Assign a decimal placeholder weight to preserve original array order.
         if (!isset($element[$key]['#weight'])) {
             $element[$key]['#weight'] = $count / 1000;
         } else {
             // If one of the child elements has a weight then we will need to sort
             // later.
             unset($element['#sorted']);
         }
         $element[$key] = $this->doBuildForm($form_id, $element[$key], $form_state);
         $count++;
     }
     // The #after_build flag allows any piece of a form to be altered
     // after normal input parsing has been completed.
     if (isset($element['#after_build']) && !isset($element['#after_build_done'])) {
         foreach ($element['#after_build'] as $callback) {
             $element = call_user_func_array($form_state->prepareCallback($callback), array($element, &$form_state));
         }
         $element['#after_build_done'] = TRUE;
     }
     // If there is a file element, we need to flip a flag so later the
     // form encoding can be set.
     if (isset($element['#type']) && $element['#type'] == 'file') {
         $form_state->setHasFileElement();
     }
     // Final tasks for the form element after self::doBuildForm() has run for
     // all other elements.
     if (isset($element['#type']) && $element['#type'] == 'form') {
         // If there is a file element, we set the form encoding.
         if ($form_state->hasFileElement()) {
             $element['#attributes']['enctype'] = 'multipart/form-data';
         }
         // Allow Ajax submissions to the form action to bypass verification. This
         // is especially useful for multipart forms, which cannot be verified via
         // a response header.
         $element['#attached']['drupalSettings']['ajaxTrustedUrl'][$element['#action']] = TRUE;
         // If a form contains a single textfield, and the ENTER key is pressed
         // within it, Internet Explorer submits the form with no POST data
         // identifying any submit button. Other browsers submit POST data as
         // though the user clicked the first button. Therefore, to be as
         // consistent as we can be across browsers, if no 'triggering_element' has
         // been identified yet, default it to the first button.
         $buttons = $form_state->getButtons();
         if (!$form_state->isProgrammed() && !$form_state->getTriggeringElement() && !empty($buttons)) {
             $form_state->setTriggeringElement($buttons[0]);
         }
         $triggering_element = $form_state->getTriggeringElement();
         // If the triggering element specifies "button-level" validation and
         // submit handlers to run instead of the default form-level ones, then add
         // those to the form state.
         if (isset($triggering_element['#validate'])) {
             $form_state->setValidateHandlers($triggering_element['#validate']);
         }
         if (isset($triggering_element['#submit'])) {
             $form_state->setSubmitHandlers($triggering_element['#submit']);
         }
         // If the triggering element executes submit handlers, then set the form
         // state key that's needed for those handlers to run.
         if (!empty($triggering_element['#executes_submit_callback'])) {
             $form_state->setSubmitted();
         }
         // Special processing if the triggering element is a button.
         if (!empty($triggering_element['#is_button'])) {
             // Because there are several ways in which the triggering element could
             // have been determined (including from input variables set by
             // JavaScript or fallback behavior implemented for IE), and because
             // buttons often have their #name property not derived from their
             // #parents property, we can't assume that input processing that's
             // happened up until here has resulted in
             // $form_state->getValue(BUTTON_NAME) being set. But it's common for
             // forms to have several buttons named 'op' and switch on
             // $form_state->getValue('op') during submit handler execution.
             $form_state->setValue($triggering_element['#name'], $triggering_element['#value']);
         }
     }
     return $element;
 }
示例#24
0
 /**
  * Tests the Html::getUniqueId() method.
  *
  * @param string $expected
  *   The expected result.
  * @param string $source
  *   The string being transformed to an ID.
  *
  * @dataProvider providerTestHtmlGetId
  *
  * @covers ::getId
  */
 public function testHtmlGetId($expected, $source)
 {
     Html::setIsAjax(FALSE);
     $this->assertSame($expected, Html::getId($source));
 }
示例#25
0
  /**
   * Returns the form for the second page.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return array
   *   The form structure.
   */
  protected function buildFormPageTwo(array $form, FormStateInterface $form_state) {
    $form['#title'] = $this->t('Content types');
    $form['description'] = array(
      '#type' => 'item',
      '#title' => $this->t('Choose fields to start with.'),
    );

    $rdf_type = $form_state->get(['page_values', 1, 'rdf-type']);
    $properties = $this->converter->getTypeProperties($rdf_type);
    $field_types = \Drupal::service('plugin.manager.field.field_type')
      ->getUiDefinitions();

    $field_type_options = array();
    foreach ($field_types as $name => $field_type) {
      // Skip field types which should not be added via user interface.
      if (empty($field_type['no_ui'])) {
        $field_type_options[$name] = $field_type['label'];
      }
    }
    asort($field_type_options);

    $table = array(
      '#type' => 'table',
      '#tree' => TRUE,
      '#header' => array(
        $this->t('Enable'),
        $this->t('Property'),
        $this->t('Data Type'),
      ),
      '#regions' => array(),
      '#attributes' => array(
        'class' => array('rdfui-field-mappings'),
        'id' => Html::getId('rdf-builder'),
      ),
    );

    foreach ($properties as $key => $value) {
      $table[$key] = array(
        '#attributes' => array(
          'id' => Html::getClass($key),
        ),
        'enable' => array(
          '#type' => 'checkbox',
          '#title' => $this->t('Enable'),
          '#title_display' => 'invisible',
        ),
        'property' => array(
          '#markup' => SafeMarkup::checkPlain($value),
        ),
        'type' => array(
          '#type' => 'select',
          '#title' => $this->t('Data Type'),
          '#title_display' => 'invisible',
          '#options' => $field_type_options,
          '#default_value' => $this->getDefaultFieldType($key),
          '#empty_option' => $this->t('- Select a field type -'),
          '#attributes' => array('class' => array('field-type-select')),
          '#cell_attributes' => array('colspan' => 2),
        ),
      );
    }
    // Fields.
    $table['#regions']['content']['rows_order'] = array();
    foreach (Element::children($table) as $name) {
      $table['#regions']['content']['rows_order'][] = $name;
    }

    $form['fields'] = $table;

    $form['actions'] = array('#type' => 'actions');
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#button_type' => 'primary',
      '#value' => $this->t('Save'),
    );

    $form['actions']['previous'] = array(
      '#type' => 'submit',
      '#value' => $this->t('< Back'),
      '#submit' => array(array($this, 'pageTwoBackSubmit')),
      '#limit_validation_errors' => array(),
      '#validate' => array(array($this, 'pageTwoBackValidate')),
      '#weight' => -1,
    );
    return $form;
  }
 /**
  * Generates a BigPipe placeholder ID.
  *
  * @param string $original_placeholder
  *   The original placeholder.
  * @param array $placeholder_render_array
  *   The render array for a placeholder.
  *
  * @return string
  *   The generated BigPipe placeholder ID.
  */
 protected static function generateBigPipePlaceholderId($original_placeholder, array $placeholder_render_array)
 {
     // Generate a BigPipe placeholder ID (to be used by BigPipe's JavaScript).
     // @see \Drupal\Core\Render\PlaceholderGenerator::createPlaceholder()
     if (isset($placeholder_render_array['#lazy_builder'])) {
         $callback = $placeholder_render_array['#lazy_builder'][0];
         $arguments = $placeholder_render_array['#lazy_builder'][1];
         $token = hash('crc32b', serialize($placeholder_render_array));
         return UrlHelper::buildQuery(['callback' => $callback, 'args' => $arguments, 'token' => $token]);
     } else {
         return Html::getId($original_placeholder);
     }
 }
示例#27
0
  /**
   * Builds the form fields for a set of fields.
   *
   * @param \Drupal\search_api\Item\FieldInterface[] $fields
   *   List of fields to display.
   * @param \Drupal\search_api\Item\AdditionalFieldInterface[] $additional
   *   List of additional fields that can be added.
   *
   * @return array
   *   The build structure.
   */
  protected function buildFields(array $fields, array $additional) {
    $data_type_plugin_manager = $this->getDataTypePluginManager();
    $types = $data_type_plugin_manager->getInstancesOptions();

    $fulltext_types = array('text');
    // Add all data types with fallback "text" to fulltext types as well.
    foreach ($data_type_plugin_manager->getInstances() as $id => $type) {
      if ($type->getFallbackType() == 'text') {
        $fulltext_types[] = $id;
      }
    }

    $boost_values = array('0.1', '0.2', '0.3', '0.5', '0.8', '1.0', '2.0', '3.0', '5.0', '8.0', '13.0', '21.0');
    $boosts = array_combine($boost_values, $boost_values);

    $build = array(
      '#type' => 'details',
      '#open' => TRUE,
      '#theme' => 'search_api_admin_fields_table',
      '#parents' => array(),
    );

    foreach ($fields as $key => $field) {
      $build['fields'][$key]['title']['#plain_text'] = $field->getLabel();
      $build['fields'][$key]['id']['#plain_text'] = $key;
      if ($field->getDescription()) {
        $build['fields'][$key]['description'] = array(
          '#type' => 'value',
          '#value' => $field->getDescription(),
        );
      }
      $build['fields'][$key]['indexed'] = array(
        '#type' => 'checkbox',
        '#default_value' => $field->isIndexed(),
        '#disabled' => $field->isIndexedLocked(),
      );
      $css_key = '#edit-fields-' . Html::getId($key);
      $build['fields'][$key]['type'] = array(
        '#type' => 'select',
        '#options' => $types,
        '#default_value' => $field->getType(),
        '#states' => array(
          'visible' => array(
            $css_key . '-indexed' => array('checked' => TRUE),
          ),
        ),
        '#disabled' => $field->isTypeLocked(),
      );
      $build['fields'][$key]['boost'] = array(
        '#type' => 'select',
        '#options' => $boosts,
        '#default_value' => sprintf('%.1f', $field->getBoost()),
        '#states' => array(
          'visible' => array(
            $css_key . '-indexed' => array('checked' => TRUE),
          ),
        ),
      );
      foreach ($fulltext_types as $type) {
        $build['fields'][$key]['boost']['#states']['visible'][$css_key . '-type'][] = array('value' => $type);
      }
      $build['fields'][$key]['#access'] = !$field->isHidden();
    }

    if ($additional) {
      // Build our options.
      $build['additional'] = array(
        '#type' => 'details',
        '#title' => $this->t('Related fields'),
        '#description' => $this->t(
            'There are entities related to entities of this type. ' .
            'You can add their fields to the list above so they can be indexed too.'
          ) . '<br />',
        '#open' => TRUE,
        '#tree' => TRUE,
      );
      foreach ($additional as $key => $additional_field) {
        // We need to loop through each option because we need to disable the
        // checkbox if it's a dependency for another option.
        $build['additional']['field'][$key] = array(
          '#type' => 'checkbox',
          '#title' => $additional_field->getLabel(),
          '#default_value' => $additional_field->isEnabled(),
          '#disabled' => $additional_field->isLocked(),
          '#access' => !$additional_field->isHidden(),
        );
      }
      $build['additional']['actions']['#type'] = 'actions';
      $build['additional']['actions']['add'] = array(
        '#type' => 'submit',
        '#value' => $this->t('Update'),
      );
    }

    return $build;
  }
示例#28
0
 /**
  * Tests the Html::getUniqueId() method.
  *
  * @param string $expected
  *   The expected result.
  * @param string $source
  *   The string being transformed to an ID.
  *
  * @dataProvider providerTestHtmlGetId
  *
  * @covers ::getId
  */
 public function testHtmlGetId($expected, $source)
 {
     $this->assertSame($expected, Html::getId($source));
 }
示例#29
0
 /**
  * Provide a simple textfield for equality
  */
 protected function valueForm(&$form, FormStateInterface $form_state)
 {
     // We have to make some choices when creating this as an exposed
     // filter form. For example, if the operator is locked and thus
     // not rendered, we can't render dependencies; instead we only
     // render the form items we need.
     $which = 'all';
     if (!empty($form['operator'])) {
         $source = ':input[name="options[operator]"]';
     }
     if ($exposed = $form_state->get('exposed')) {
         $identifier = $this->options['expose']['identifier'];
         if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
             // exposed and locked.
             $which = 'value';
         } else {
             $source = ':input[name="' . $this->options['expose']['operator_id'] . '"]';
         }
     }
     if ($which == 'all' || $which == 'value') {
         $html_id = Html::getId('leaflet-widget');
         $form['wrapper'] = array('#type' => 'fieldset', '#title' => $this->exposedInfo()['label'], '#attributes' => array('class' => array('fieldgroup')));
         $form['wrapper']['leaflet_map']['#markup'] = '<div class="leaflet-widget" id="' . $html_id . '"></div>';
         $form['#attached']['library'][] = 'bbox/leaflet';
         $form['#attached']['library'][] = 'bbox/views';
         $form['#attached']['drupalSettings']['bbox']['widgets'][] = $html_id;
         $form['wrapper'][$identifier] = array('#type' => 'textfield', '#size' => 30, '#attributes' => array('class' => array('bbox-value')), '#default_value' => $this->value);
         $user_input = $form_state->getUserInput();
         if ($exposed && !isset($user_input[$identifier])) {
             $user_input[$identifier] = $this->value;
             $form_state->setUserInput($user_input);
         }
         if ($which == 'all') {
             // Setup #states for all operators with one value.
             foreach ($this->operatorValues(1) as $operator) {
                 $form['value']['#states']['visible'][] = array($source => array('value' => $operator));
             }
         }
     }
     if (!isset($form['value'])) {
         // Ensure there is something in the 'value'.
         $form['value'] = array('#type' => 'value', '#value' => NULL);
     }
 }
示例#30
-1
 /**
  * Builds the Toolbar as a structured array ready for drupal_render().
  *
  * Since building the toolbar takes some time, it is done just prior to
  * rendering to ensure that it is built only if it will be displayed.
  *
  * @param array $element
  *   A renderable array.
  *
  * @return array
  *  A renderable array.
  *
  * @see toolbar_page_top().
  */
 public static function preRenderToolbar($element)
 {
     // Get the configured breakpoints to switch from vertical to horizontal
     // toolbar presentation.
     $breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar');
     if (!empty($breakpoints)) {
         $media_queries = array();
         foreach ($breakpoints as $id => $breakpoint) {
             $media_queries[$id] = $breakpoint->getMediaQuery();
         }
         $element['#attached']['drupalSettings']['toolbar']['breakpoints'] = $media_queries;
     }
     $module_handler = static::moduleHandler();
     // Get toolbar items from all modules that implement hook_toolbar().
     $items = $module_handler->invokeAll('toolbar');
     // Allow for altering of hook_toolbar().
     $module_handler->alter('toolbar', $items);
     // Sort the children.
     uasort($items, array('\\Drupal\\Component\\Utility\\SortArray', 'sortByWeightProperty'));
     // Merge in the original toolbar values.
     $element = array_merge($element, $items);
     // Assign each item a unique ID, based on its key.
     foreach (Element::children($element) as $key) {
         $element[$key]['#id'] = Html::getId('toolbar-item-' . $key);
     }
     return $element;
 }