本文整理汇总了PHP中twig_template_get_attributes函数的典型用法代码示例。如果您正苦于以下问题:PHP twig_template_get_attributes函数的具体用法?PHP twig_template_get_attributes怎么用?PHP twig_template_get_attributes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了twig_template_get_attributes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: block_toolbar
public function block_toolbar($context, array $blocks = array())
{
$__internal_9adef72a65a3682859e4bc72838a13faeaf5430cd635e3d606afd366160a6e64 = $this->env->getExtension("native_profiler");
$__internal_9adef72a65a3682859e4bc72838a13faeaf5430cd635e3d606afd366160a6e64->enter($__internal_9adef72a65a3682859e4bc72838a13faeaf5430cd635e3d606afd366160a6e64_prof = new Twig_Profiler_Profile($this->getTemplateName(), "block", "toolbar"));
// line 4
echo " ";
ob_start();
// line 5
echo " <span>\n <svg width=\"13\" height=\"28\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" x=\"0px\" y=\"0px\" viewBox=\"0 0 13 28\" enable-background=\"new 0 0 13 28\" xml:space=\"preserve\"><g><rect x=\"3\" y=\"11\" fill=\"#BCBCBB\" width=\"7\" height=\"9\"/></g><g><path fill=\"#3F3F3F\" d=\"M11 6V21H2V6H0V22c0 0.6 0.4 1 1 1h11c0.6 0 1-0.4 1-1V6H11z\"/></g></svg>\n <span>";
// line 7
echo twig_escape_filter($this->env, sprintf("%.1f", twig_template_get_attributes($this, isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memory", array()) / 1024 / 1024), "html", null, true);
echo " MB</span>\n </span>\n ";
$context["icon"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
// line 10
echo " ";
ob_start();
// line 11
echo " <div class=\"sf-toolbar-info-piece\">\n <b>Memory usage</b>\n <span>";
// line 13
echo twig_escape_filter($this->env, sprintf("%.1f", twig_template_get_attributes($this, isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memory", array()) / 1024 / 1024), "html", null, true);
echo " / ";
echo twig_template_get_attributes($this, isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memoryLimit", array()) == -1 ? "∞" : twig_escape_filter($this->env, sprintf("%.1f", twig_template_get_attributes($this, isset($context["collector"]) ? $context["collector"] : $this->getContext($context, "collector"), "memoryLimit", array()) / 1024 / 1024));
echo " MB</span>\n </div>\n ";
$context["text"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
// line 16
echo " ";
$this->loadTemplate("@WebProfiler/Profiler/toolbar_item.html.twig", "@WebProfiler/Collector/memory.html.twig", 16)->display(array_merge($context, array("link" => false)));
$__internal_9adef72a65a3682859e4bc72838a13faeaf5430cd635e3d606afd366160a6e64->leave($__internal_9adef72a65a3682859e4bc72838a13faeaf5430cd635e3d606afd366160a6e64_prof);
}
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:29,代码来源:f7ece9035c583fa10d944eb58102e2430d174c1f53244e46b2e46f17ed5f.php
示例2: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_a0b93d3d955dec62c41cfd4dabe28b36b1a0f0c8ee46f247f4c1b40a626aeb27 = $this->env->getExtension("native_profiler");
$__internal_a0b93d3d955dec62c41cfd4dabe28b36b1a0f0c8ee46f247f4c1b40a626aeb27->enter($__internal_a0b93d3d955dec62c41cfd4dabe28b36b1a0f0c8ee46f247f4c1b40a626aeb27_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@Twig/Exception/trace.txt.twig"));
// line 1
if (twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "function", array())) {
// line 2
echo " at ";
echo twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "class", array()) . twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "type", array()) . twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "function", array());
echo "(";
echo $this->env->getExtension('code')->formatArgsAsText(twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "args", array()));
echo ")\n";
} else {
// line 4
echo " at n/a\n";
}
// line 6
if (twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : null, "file", array(), "any", true, true) && twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : null, "line", array(), "any", true, true)) {
// line 7
echo " in ";
echo twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "file", array());
echo " line ";
echo twig_template_get_attributes($this, isset($context["trace"]) ? $context["trace"] : $this->getContext($context, "trace"), "line", array());
echo "\n";
}
$__internal_a0b93d3d955dec62c41cfd4dabe28b36b1a0f0c8ee46f247f4c1b40a626aeb27->leave($__internal_a0b93d3d955dec62c41cfd4dabe28b36b1a0f0c8ee46f247f4c1b40a626aeb27_prof);
}
开发者ID:RuntyCybin,项目名称:CProject,代码行数:27,代码来源:bc4fbf6030e97c6273714f0776ea3f800aa0e5b22312c2d3bcf1b7bbf513fcdb.php
示例3: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$tags = array("if" => 22, "for" => 33);
$filters = array();
$functions = array();
try {
$this->env->getExtension('sandbox')->checkSecurity(array('if', 'for'), array(), 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 22
if (isset($context["multiple"]) ? $context["multiple"] : null) {
// line 23
echo " <div class=\"js-form-item form-item\">\n ";
// line 24
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["table"]) ? $context["table"] : null, "html", null, true));
echo "\n ";
// line 25
if (twig_template_get_attributes($this, isset($context["description"]) ? $context["description"] : null, "content", array())) {
// line 26
echo " <div";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_template_get_attributes($this, twig_template_get_attributes($this, isset($context["description"]) ? $context["description"] : null, "attributes", array()), "addClass", array(0 => "description"), "method"), "html", null, true));
echo " >";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_template_get_attributes($this, isset($context["description"]) ? $context["description"] : null, "content", array()), "html", null, true));
echo "</div>\n ";
}
// line 28
echo " ";
if (isset($context["button"]) ? $context["button"] : null) {
// line 29
echo " <div class=\"clearfix\">";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["button"]) ? $context["button"] : null, "html", null, true));
echo "</div>\n ";
}
// line 31
echo " </div>\n";
} else {
// line 33
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(isset($context["elements"]) ? $context["elements"] : null);
foreach ($context['_seq'] as $context["_key"] => $context["element"]) {
// line 34
echo " ";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $context["element"], "html", null, true));
echo "\n ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['element'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
}
}
开发者ID:mikekeilty,项目名称:seventen-marketing-website,代码行数:60,代码来源:5c7f654ba7ce67d3f9c62da123a43ac9f66f217fbcdaa36b063273589b63933b.php
示例4: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_be655af744011807162b8e2fc96b8dc6d010ebba262f563f899f196b51decc41 = $this->env->getExtension("native_profiler");
$__internal_be655af744011807162b8e2fc96b8dc6d010ebba262f563f899f196b51decc41->enter($__internal_be655af744011807162b8e2fc96b8dc6d010ebba262f563f899f196b51decc41_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "TwigBundle:Exception:traces_text.html.twig"));
// line 1
echo "<div class=\"block\">\n <h2>\n Stack Trace (Plain Text) \n ";
// line 4
ob_start();
// line 5
echo " <a href=\"#\" onclick=\"toggle('traces-text'); switchIcons('icon-traces-text-open', 'icon-traces-text-close'); return false;\">\n <img class=\"toggle\" id=\"icon-traces-text-close\" alt=\"-\" src=\"data:image/gif;base64,R0lGODlhEgASAMQSANft94TG57Hb8GS44ez1+mC24IvK6ePx+Wa44dXs92+942e54o3L6W2844/M6dnu+P/+/l614P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAASABIAQAVCoCQBTBOd6Kk4gJhGBCTPxysJb44K0qD/ER/wlxjmisZkMqBEBW5NHrMZmVKvv9hMVsO+hE0EoNAstEYGxG9heIhCADs=\" style=\"display: none\" />\n <img class=\"toggle\" id=\"icon-traces-text-open\" alt=\"+\" src=\"data:image/gif;base64,R0lGODlhEgASAMQTANft99/v+Ga44bHb8ITG52S44dXs9+z1+uPx+YvK6WC24G+944/M6W28443L6dnu+Ge54v/+/l614P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABMALAAAAAASABIAQAVS4DQBTiOd6LkwgJgeUSzHSDoNaZ4PU6FLgYBA5/vFID/DbylRGiNIZu74I0h1hNsVxbNuUV4d9SsZM2EzWe1qThVzwWFOAFCQFa1RQq6DJB4iIQA7\" style=\"display: inline\" />\n </a>\n ";
echo trim(preg_replace('/>\\s+</', '><', ob_get_clean()));
// line 10
echo " </h2>\n\n <div id=\"traces-text\" class=\"trace\" style=\"display: none;\">\n<pre>";
// line 13
$context['_parent'] = (array) $context;
$context['_seq'] = twig_ensure_traversable(twig_template_get_attributes($this, isset($context["exception"]) ? $context["exception"] : $this->getContext($context, "exception"), "toarray", array()));
foreach ($context['_seq'] as $context["i"] => $context["e"]) {
// line 14
echo "[";
echo twig_escape_filter($this->env, $context["i"] + 1, "html", null, true);
echo "] ";
echo twig_escape_filter($this->env, twig_template_get_attributes($this, $context["e"], "class", array()), "html", null, true);
echo ": ";
echo twig_escape_filter($this->env, twig_template_get_attributes($this, $context["e"], "message", array()), "html", null, true);
echo "\n";
// line 15
$this->loadTemplate("TwigBundle:Exception:traces.txt.twig", "TwigBundle:Exception:traces_text.html.twig", 15)->display(array("exception" => $context["e"]));
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['i'], $context['e'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 16
echo "</pre>\n </div>\n</div>\n";
$__internal_be655af744011807162b8e2fc96b8dc6d010ebba262f563f899f196b51decc41->leave($__internal_be655af744011807162b8e2fc96b8dc6d010ebba262f563f899f196b51decc41_prof);
}
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:35,代码来源:abf434acc326d49b1efca10416e15b6bba5f07ffde6a9b59836bbf100fbc.php
示例5: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_690c285c718fbd8c201e4150c92f9df0e5cb8c91ecddb6e3845a6c3f49e20558 = $this->env->getExtension("native_profiler");
$__internal_690c285c718fbd8c201e4150c92f9df0e5cb8c91ecddb6e3845a6c3f49e20558->enter($__internal_690c285c718fbd8c201e4150c92f9df0e5cb8c91ecddb6e3845a6c3f49e20558_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/base_js.html.twig"));
// line 1
echo "<script>/*<![CDATA[*/\n ";
// line 5
echo "\n Sfjs = (function() {\n \"use strict\";\n\n var classListIsSupported = 'classList' in document.documentElement;\n\n if (classListIsSupported) {\n var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };\n var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };\n var addClass = function(el, cssClass) { el.classList.add(cssClass); };\n var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };\n } else {\n var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\\\b' + cssClass + '\\\\b')); };\n var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\\\b' + cssClass + '\\\\b'), ' '); };\n var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += \" \" + cssClass; } };\n var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };\n }\n\n var noop = function() {},\n\n collectionToArray = function (collection) {\n var length = collection.length || 0,\n results = new Array(length);\n\n while (length--) {\n results[length] = collection[length];\n }\n\n return results;\n },\n\n profilerStorageKey = 'sf2/profiler/',\n\n request = function(url, onSuccess, onError, payload, options) {\n var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n options = options || {};\n options.maxTries = options.maxTries || 0;\n xhr.open(options.method || 'GET', url, true);\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n xhr.onreadystatechange = function(state) {\n if (4 !== xhr.readyState) {\n return null;\n }\n\n if (xhr.status == 404 && options.maxTries > 1) {\n setTimeout(function(){\n options.maxTries--;\n request(url, onSuccess, onError, payload, options);\n }, 500);\n\n return null;\n }\n\n if (200 === xhr.status) {\n (onSuccess || noop)(xhr);\n } else {\n (onError || noop)(xhr);\n }\n };\n xhr.send(payload || '');\n },\n\n getPreference = function(name) {\n if (!window.localStorage) {\n return null;\n }\n\n return localStorage.getItem(profilerStorageKey + name);\n },\n\n setPreference = function(name, value) {\n if (!window.localStorage) {\n return null;\n }\n\n localStorage.setItem(profilerStorageKey + name, value);\n },\n\n requestStack = [],\n\n renderAjaxRequests = function() {\n var requestCounter = document.querySelectorAll('.sf-toolbar-ajax-requests');\n if (!requestCounter.length) {\n return;\n }\n\n var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax');\n var tbodies = document.querySelectorAll('.sf-toolbar-ajax-request-list');\n var state = 'ok';\n if (tbodies.length) {\n var tbody = tbodies[0];\n\n var rows = document.createDocumentFragment();\n\n if (requestStack.length) {\n for (var i = 0; i < requestStack.length; i++) {\n var request = requestStack[i];\n\n var row = document.createElement('tr');\n rows.appendChild(row);\n\n var methodCell = document.createElement('td');\n if (request.error) {\n methodCell.className = 'sf-ajax-request-error';\n }\n methodCell.textContent = request.method;\n row.appendChild(methodCell);\n\n var pathCell = document.createElement('td');\n pathCell.className = 'sf-ajax-request-url';\n if ('GET' === request.method) {\n var pathLink = document.createElement('a');\n pathLink.setAttribute('href', request.url);\n pathLink.textContent = request.url;\n pathCell.appendChild(pathLink);\n } else {\n pathCell.textContent = request.url;\n }\n pathCell.setAttribute('title', request.url);\n row.appendChild(pathCell);\n\n var durationCell = document.createElement('td');\n durationCell.className = 'sf-ajax-request-duration';\n\n if (request.duration) {\n durationCell.textContent = request.duration + \"ms\";\n } else {\n durationCell.textContent = '-';\n }\n row.appendChild(durationCell);\n\n row.appendChild(document.createTextNode(' '));\n var profilerCell = document.createElement('td');\n\n if (request.profilerUrl) {\n var profilerLink = document.createElement('a');\n profilerLink.setAttribute('href', request.profilerUrl);\n profilerLink.textContent = request.profile;\n profilerCell.appendChild(profilerLink);\n } else {\n profilerCell.textContent = 'n/a';\n }\n\n row.appendChild(profilerCell);\n\n var requestState = 'ok';\n if (request.error) {\n requestState = 'error';\n if (state != \"loading\" && i > requestStack.length - 4) {\n state = 'error';\n }\n } else if (request.loading) {\n requestState = 'loading';\n state = 'loading';\n }\n row.className = 'sf-ajax-request sf-ajax-request-' + requestState;\n }\n\n var infoSpan = document.querySelectorAll(\".sf-toolbar-ajax-info\")[0];\n var children = collectionToArray(tbody.children);\n for (var i = 0; i < children.length; i++) {\n tbody.removeChild(children[i]);\n }\n tbody.appendChild(rows);\n\n if (infoSpan) {\n var text = requestStack.length + ' AJAX request' + (requestStack.length > 1 ? 's' : '');\n infoSpan.textContent = text;\n }\n\n ajaxToolbarPanel.style.display = 'block';\n } else {\n ajaxToolbarPanel.style.display = 'none';\n }\n }\n\n requestCounter[0].textContent = requestStack.length;\n\n var className = 'sf-toolbar-ajax-requests sf-toolbar-value';\n requestCounter[0].className = className;\n\n if (state == 'ok') {\n Sfjs.removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');\n Sfjs.removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');\n } else if (state == 'error') {\n Sfjs.addClass(ajaxToolbarPanel, 'sf-toolbar-status-red');\n } else {\n Sfjs.addClass(ajaxToolbarPanel, 'sf-ajax-request-loading');\n }\n };\n\n var addEventListener;\n\n var el = document.createElement('div');\n if (!'addEventListener' in el) {\n addEventListener = function (element, eventName, callback) {\n element.attachEvent('on' + eventName, callback);\n };\n } else {\n addEventListener = function (element, eventName, callback) {\n element.addEventListener(eventName, callback, false);\n };\n }\n\n ";
// line 209
if (array_key_exists("excluded_ajax_paths", $context)) {
// line 210
echo " if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {\n var proxied = XMLHttpRequest.prototype.open;\n\n XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {\n var self = this;\n\n /* prevent logging AJAX calls to static and inline files, like templates */\n var path = url;\n if (url.substr(0, 1) === '/') {\n if (0 === url.indexOf('";
// line 219
echo twig_escape_filter($this->env, twig_escape_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array()), "js"), "html", null, true);
echo "')) {\n path = url.substr(";
// line 220
echo twig_escape_filter($this->env, twig_length_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array())), "html", null, true);
echo ");\n }\n }\n else if (0 === url.indexOf('";
// line 223
echo twig_escape_filter($this->env, twig_escape_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "schemeAndHttpHost", array()) . twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array()), "js"), "html", null, true);
echo "')) {\n path = url.substr(";
// line 224
echo twig_escape_filter($this->env, twig_length_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "schemeAndHttpHost", array()) . twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array())), "html", null, true);
echo ");\n }\n\n if (path.substr(0, 1) === '/' && !path.match(new RegExp(";
// line 227
echo twig_jsonencode_filter(isset($context["excluded_ajax_paths"]) ? $context["excluded_ajax_paths"] : $this->getContext($context, "excluded_ajax_paths"));
echo "))) {\n var stackElement = {\n loading: true,\n error: false,\n url: url,\n method: method,\n start: new Date()\n };\n\n requestStack.push(stackElement);\n\n this.addEventListener('readystatechange', function() {\n if (self.readyState == 4) {\n stackElement.duration = new Date() - stackElement.start;\n stackElement.loading = false;\n stackElement.error = self.status < 200 || self.status >= 400;\n stackElement.profile = self.getResponseHeader(\"X-Debug-Token\");\n stackElement.profilerUrl = self.getResponseHeader(\"X-Debug-Token-Link\");\n\n Sfjs.renderAjaxRequests();\n }\n }, false);\n\n Sfjs.renderAjaxRequests();\n }\n\n proxied.apply(this, Array.prototype.slice.call(arguments));\n };\n }\n ";
}
// line 257
echo "\n return {\n hasClass: hasClass,\n\n removeClass: removeClass,\n\n addClass: addClass,\n\n toggleClass: toggleClass,\n\n getPreference: getPreference,\n\n setPreference: setPreference,\n\n addEventListener: addEventListener,\n\n request: request,\n\n renderAjaxRequests: renderAjaxRequests,\n\n load: function(selector, url, onSuccess, onError, options) {\n var el = document.getElementById(selector);\n\n if (el && el.getAttribute('data-sfurl') !== url) {\n request(\n url,\n function(xhr) {\n el.innerHTML = xhr.responseText;\n el.setAttribute('data-sfurl', url);\n removeClass(el, 'loading');\n (onSuccess || noop)(xhr, el);\n },\n function(xhr) { (onError || noop)(xhr, el); },\n '',\n options\n );\n }\n\n return this;\n },\n\n toggle: function(selector, elOn, elOff) {\n var tmp = elOn.style.display,\n el = document.getElementById(selector);\n\n elOn.style.display = elOff.style.display;\n elOff.style.display = tmp;\n\n if (el) {\n el.style.display = 'none' === tmp ? 'none' : 'block';\n }\n\n return this;\n },\n\n createTabs: function() {\n var tabGroups = document.querySelectorAll('.sf-tabs');\n\n /* create the tab navigation for each group of tabs */\n for (var i = 0; i < tabGroups.length; i++) {\n var tabs = tabGroups[i].querySelectorAll('.tab');\n var tabNavigation = document.createElement('ul');\n tabNavigation.className = 'tab-navigation';\n\n for (var j = 0; j < tabs.length; j++) {\n var tabId = 'tab-' + i + '-' + j;\n var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;\n\n var tabNavigationItem = document.createElement('li');\n tabNavigationItem.setAttribute('data-tab-id', tabId);\n if (j == 0) { Sfjs.addClass(tabNavigationItem, 'active'); }\n if (Sfjs.hasClass(tabs[j], 'disabled')) { Sfjs.addClass(tabNavigationItem, 'disabled'); }\n tabNavigationItem.innerHTML = tabTitle;\n tabNavigation.appendChild(tabNavigationItem);\n\n var tabContent = tabs[j].querySelector('.tab-content');\n tabContent.parentElement.setAttribute('id', tabId);\n }\n\n tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);\n }\n\n /* display the active tab and add the 'click' event listeners */\n for (i = 0; i < tabGroups.length; i++) {\n tabNavigation = tabGroups[i].querySelectorAll('.tab-navigation li');\n\n for (j = 0; j < tabNavigation.length; j++) {\n tabId = tabNavigation[j].getAttribute('data-tab-id');\n document.getElementById(tabId).querySelector('.tab-title').className = 'hidden';\n\n if (Sfjs.hasClass(tabNavigation[j], 'active')) {\n document.getElementById(tabId).className = 'block';\n } else {\n document.getElementById(tabId).className = 'hidden';\n }\n\n tabNavigation[j].addEventListener('click', function(e) {\n var activeTab = e.target || e.srcElement;\n\n /* needed because when the tab contains HTML contents, user can click */\n /* on any of those elements instead of their parent '<li>' element */\n while (activeTab.tagName.toLowerCase() !== 'li') {\n activeTab = activeTab.parentNode;\n }\n\n /* get the full list of tabs through the parent of the active tab element */\n var tabNavigation = activeTab.parentNode.children;\n for (var k = 0; k < tabNavigation.length; k++) {\n var tabId = tabNavigation[k].getAttribute('data-tab-id');\n document.getElementById(tabId).className = 'hidden';\n Sfjs.removeClass(tabNavigation[k], 'active');\n }\n\n Sfjs.addClass(activeTab, 'active');\n var activeTabId = activeTab.getAttribute('data-tab-id');\n document.getElementById(activeTabId).className = 'block';\n });\n }\n }\n },\n\n createToggles: function() {\n var toggles = document.querySelectorAll('.sf-toggle');\n\n for (var i = 0; i < toggles.length; i++) {\n var elementSelector = toggles[i].getAttribute('data-toggle-selector');\n var element = document.querySelector(elementSelector);\n\n Sfjs.addClass(element, 'sf-toggle-content');\n\n if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {\n Sfjs.addClass(element, 'sf-toggle-visible');\n } else {\n Sfjs.addClass(element, 'sf-toggle-hidden');\n }\n\n Sfjs.addEventListener(toggles[i], 'click', function(e) {\n e.preventDefault();\n\n var toggle = e.target || e.srcElement;\n\n /* needed because when the toggle contains HTML contents, user can click */\n /* on any of those elements instead of their parent '.sf-toggle' element */\n while (!Sfjs.hasClass(toggle, 'sf-toggle')) {\n toggle = toggle.parentNode;\n }\n\n var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));\n\n Sfjs.toggleClass(element, 'sf-toggle-hidden');\n Sfjs.toggleClass(element, 'sf-toggle-visible');\n\n /* the toggle doesn't change its contents when clicking on it */\n if (!toggle.hasAttribute('data-toggle-alt-content')) {\n return;\n }\n\n if (!toggle.hasAttribute('data-toggle-original-content')) {\n toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);\n }\n\n var currentContent = toggle.innerHTML;\n var originalContent = toggle.getAttribute('data-toggle-original-content');\n var altContent = toggle.getAttribute('data-toggle-alt-content');\n toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;\n });\n }\n }\n };\n })();\n\n Sfjs.addEventListener(window, 'load', function() {\n Sfjs.createTabs();\n Sfjs.createToggles();\n });\n\n/*]]>*/</script>\n";
$__internal_690c285c718fbd8c201e4150c92f9df0e5cb8c91ecddb6e3845a6c3f49e20558->leave($__internal_690c285c718fbd8c201e4150c92f9df0e5cb8c91ecddb6e3845a6c3f49e20558_prof);
}
开发者ID:RuntyCybin,项目名称:CProject,代码行数:32,代码来源:30ffb2e6fd10754d6f397530495e5ce78bcfa8c26062776a0af2070cb754fb31.php
示例6: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$__internal_95165891656848f19f1e47c126e1ce92274717466d04410c4af1a4eb86c990da = $this->env->getExtension("native_profiler");
$__internal_95165891656848f19f1e47c126e1ce92274717466d04410c4af1a4eb86c990da->enter($__internal_95165891656848f19f1e47c126e1ce92274717466d04410c4af1a4eb86c990da_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/base_js.html.twig"));
// line 1
echo "<script>/*<![CDATA[*/\n Sfjs = (function() {\n \"use strict\";\n\n var noop = function() {},\n\n collectionToArray = function (collection) {\n var length = collection.length || 0,\n results = new Array(length);\n\n while (length--) {\n results[length] = collection[length];\n }\n\n return results;\n },\n\n profilerStorageKey = 'sf2/profiler/',\n\n request = function(url, onSuccess, onError, payload, options) {\n var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n options = options || {};\n options.maxTries = options.maxTries || 0;\n xhr.open(options.method || 'GET', url, true);\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n xhr.onreadystatechange = function(state) {\n if (4 !== xhr.readyState) {\n return null;\n }\n\n if (xhr.status == 404 && options.maxTries > 1) {\n setTimeout(function(){\n options.maxTries--;\n request(url, onSuccess, onError, payload, options);\n }, 500);\n\n return null;\n }\n\n if (200 === xhr.status) {\n (onSuccess || noop)(xhr);\n } else {\n (onError || noop)(xhr);\n }\n };\n xhr.send(payload || '');\n },\n\n hasClass = function(el, klass) {\n return el.className && el.className.match(new RegExp('\\\\b' + klass + '\\\\b'));\n },\n\n removeClass = function(el, klass) {\n if (el.className) {\n el.className = el.className.replace(new RegExp('\\\\b' + klass + '\\\\b'), ' ');\n }\n },\n\n addClass = function(el, klass) {\n if (!hasClass(el, klass)) {\n el.className += \" \" + klass;\n }\n },\n\n getPreference = function(name) {\n if (!window.localStorage) {\n return null;\n }\n\n return localStorage.getItem(profilerStorageKey + name);\n },\n\n setPreference = function(name, value) {\n if (!window.localStorage) {\n return null;\n }\n\n localStorage.setItem(profilerStorageKey + name, value);\n },\n\n requestStack = [],\n\n renderAjaxRequests = function() {\n var requestCounter = document.querySelectorAll('.sf-toolbar-ajax-requests');\n if (!requestCounter.length) {\n return;\n }\n\n var tbodies = document.querySelectorAll('.sf-toolbar-ajax-request-list');\n var state = 'ok';\n if (tbodies.length) {\n var tbody = tbodies[0];\n\n var rows = document.createDocumentFragment();\n\n if (requestStack.length) {\n for (var i = 0; i < requestStack.length; i++) {\n var request = requestStack[i];\n\n var row = document.createElement('tr');\n rows.appendChild(row);\n\n var methodCell = document.createElement('td');\n if (request.error) {\n methodCell.className = 'sf-ajax-request-error';\n }\n methodCell.textContent = request.method;\n row.appendChild(methodCell);\n\n var pathCell = document.createElement('td');\n pathCell.className = 'sf-ajax-request-url';\n if ('GET' === request.method) {\n var pathLink = document.createElement('a');\n pathLink.setAttribute('href', request.url);\n pathLink.textContent = request.url;\n pathCell.appendChild(pathLink);\n } else {\n pathCell.textContent = request.url;\n }\n pathCell.setAttribute('title', request.url);\n row.appendChild(pathCell);\n\n var durationCell = document.createElement('td');\n durationCell.className = 'sf-ajax-request-duration';\n\n if (request.duration) {\n durationCell.textContent = request.duration + \"ms\";\n } else {\n durationCell.textContent = '-';\n }\n row.appendChild(durationCell);\n\n row.appendChild(document.createTextNode(' '));\n var profilerCell = document.createElement('td');\n\n if (request.profilerUrl) {\n var profilerLink = document.createElement('a');\n profilerLink.setAttribute('href', request.profilerUrl);\n profilerLink.textContent = request.profile;\n profilerCell.appendChild(profilerLink);\n } else {\n profilerCell.textContent = 'n/a';\n }\n\n row.appendChild(profilerCell);\n\n var requestState = 'ok';\n if (request.error) {\n requestState = 'error';\n if (state != \"loading\" && i > requestStack.length - 4) {\n state = 'error';\n }\n } else if (request.loading) {\n requestState = 'loading';\n state = 'loading';\n }\n row.className = 'sf-ajax-request sf-ajax-request-' + requestState;\n }\n\n var infoSpan = document.querySelectorAll(\".sf-toolbar-ajax-info\")[0];\n var children = collectionToArray(tbody.children);\n for (var i = 0; i < children.length; i++) {\n tbody.removeChild(children[i]);\n }\n tbody.appendChild(rows);\n\n if (infoSpan) {\n var text = requestStack.length + ' call' + (requestStack.length > 1 ? 's' : '');\n infoSpan.textContent = text;\n }\n } else {\n var cell = document.createElement('td');\n cell.setAttribute('colspan', '4');\n cell.textContent = \"No AJAX requests yet.\";\n var row = document.createElement('tr');\n row.appendChild(cell);\n tbody.appendChild(row);\n }\n }\n\n requestCounter[0].textContent = requestStack.length;\n\n var className = 'sf-toolbar-ajax-requests sf-toolbar-status';\n if (state == 'ok') {\n className += ' sf-toolbar-status-green';\n } else if (state == 'error') {\n className += ' sf-toolbar-status-red';\n } else {\n className += ' sf-ajax-request-loading';\n }\n\n requestCounter[0].className = className;\n };\n\n var addEventListener;\n\n var el = document.createElement('div');\n if (!'addEventListener' in el) {\n addEventListener = function (element, eventName, callback) {\n element.attachEvent('on' + eventName, callback);\n };\n } else {\n addEventListener = function (element, eventName, callback) {\n element.addEventListener(eventName, callback, false);\n };\n }\n\n ";
// line 208
if (array_key_exists("excluded_ajax_paths", $context)) {
// line 209
echo " if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {\n var proxied = XMLHttpRequest.prototype.open;\n\n XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {\n var self = this;\n\n /* prevent logging AJAX calls to static and inline files, like templates */\n var path = url;\n if (url.substr(0, 1) === '/') {\n if (0 === url.indexOf('";
// line 218
echo twig_escape_filter($this->env, twig_escape_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array()), "js"), "html", null, true);
echo "')) {\n path = url.substr(";
// line 219
echo twig_escape_filter($this->env, twig_length_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array())), "html", null, true);
echo ");\n }\n }\n else if (0 === url.indexOf('";
// line 222
echo twig_escape_filter($this->env, twig_escape_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "schemeAndHttpHost", array()) . twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array()), "js"), "html", null, true);
echo "')) {\n path = url.substr(";
// line 223
echo twig_escape_filter($this->env, twig_length_filter($this->env, twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "schemeAndHttpHost", array()) . twig_template_get_attributes($this, isset($context["request"]) ? $context["request"] : $this->getContext($context, "request"), "basePath", array())), "html", null, true);
echo ");\n }\n\n if (path.substr(0, 1) === '/' && !path.match(new RegExp(";
// line 226
echo twig_jsonencode_filter(isset($context["excluded_ajax_paths"]) ? $context["excluded_ajax_paths"] : $this->getContext($context, "excluded_ajax_paths"));
echo "))) {\n var stackElement = {\n loading: true,\n error: false,\n url: url,\n method: method,\n start: new Date()\n };\n\n requestStack.push(stackElement);\n\n this.addEventListener('readystatechange', function() {\n if (self.readyState == 4) {\n stackElement.duration = new Date() - stackElement.start;\n stackElement.loading = false;\n stackElement.error = self.status < 200 || self.status >= 400;\n stackElement.profile = self.getResponseHeader(\"X-Debug-Token\");\n stackElement.profilerUrl = self.getResponseHeader(\"X-Debug-Token-Link\");\n\n Sfjs.renderAjaxRequests();\n }\n }, false);\n\n Sfjs.renderAjaxRequests();\n }\n\n proxied.apply(this, Array.prototype.slice.call(arguments));\n };\n }\n ";
}
// line 256
echo "\n return {\n hasClass: hasClass,\n\n removeClass: removeClass,\n\n addClass: addClass,\n\n getPreference: getPreference,\n\n setPreference: setPreference,\n\n addEventListener: addEventListener,\n\n request: request,\n\n renderAjaxRequests: renderAjaxRequests,\n\n load: function(selector, url, onSuccess, onError, options) {\n var el = document.getElementById(selector);\n\n if (el && el.getAttribute('data-sfurl') !== url) {\n request(\n url,\n function(xhr) {\n el.innerHTML = xhr.responseText;\n el.setAttribute('data-sfurl', url);\n removeClass(el, 'loading');\n (onSuccess || noop)(xhr, el);\n },\n function(xhr) { (onError || noop)(xhr, el); },\n '',\n options\n );\n }\n\n return this;\n },\n\n toggle: function(selector, elOn, elOff) {\n var tmp = elOn.style.display,\n el = document.getElementById(selector);\n\n elOn.style.display = elOff.style.display;\n elOff.style.display = tmp;\n\n if (el) {\n el.style.display = 'none' === tmp ? 'none' : 'block';\n }\n\n return this;\n }\n }\n })();\n/*]]>*/</script>\n";
$__internal_95165891656848f19f1e47c126e1ce92274717466d04410c4af1a4eb86c990da->leave($__internal_95165891656848f19f1e47c126e1ce92274717466d04410c4af1a4eb86c990da_prof);
}
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:30,代码来源:6de05642dc9f833109162fb0b242270c510fd8d0c5b129de26b7f09c5aae.php
示例7: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$tags = array("set" => 14);
$filters = array("clean_class" => 15);
$functions = array();
try {
$this->env->getExtension('sandbox')->checkSecurity(array('set'), 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($fun
|
请发表评论