本文整理汇总了PHP中Environment::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getContext方法的具体用法?PHP Environment::getContext怎么用?PHP Environment::getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processTemplateMacro
function processTemplateMacro($macro, $file, $optstr)
{
$template = new FileTemplate($file);
$template->registerFilter(Environment::getNette()->createLatte());
$template->registerHelperLoader('TemplateHelpers::loader');
$template->setCacheStorage(Environment::getContext()->nette->templateCacheStorage);
$template->page = $this->pageContext;
//TODO disable macros in getContent()
$template->opts = $opts = self::parseOptions($optstr);
//from Nette\Application\UI\Control
$template->baseUri = $template->baseUrl = rtrim($this->url->getBaseUrl(), '/');
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
//lang settings
$template->lang = $this->pageContext->lang;
$template->langs = $this->i18n->langs;
$template->setTranslator(new TranslationsModel($this->pageContext->lang));
try {
$template = $template->__toString(true);
} catch (Exception $e) {
if (Debugger::$productionMode) {
Debugger::log($e);
return "<span class='zprava'>Error: {$macro} not availible</span>";
} else {
return "<span class='zprava'>Error: " . $e->getMessage() . "</span>";
}
}
return $template;
}
示例2: paintBlueScreen
public static function paintBlueScreen(Exception $exception)
{
if (class_exists('Environment', FALSE)) {
$application = Environment::getContext()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getContext()->getService('Nette\\Application\\Application') : NULL;
}
if (!function_exists('_netteDebugPrintCode')) {
function _netteDebugPrintCode($file, $line, $count = 15)
{
if (function_exists('ini_set')) {
ini_set('highlight.comment', '#999; font-style: italic');
ini_set('highlight.default', '#000');
ini_set('highlight.html', '#06B');
ini_set('highlight.keyword', '#D24; font-weight: bold');
ini_set('highlight.string', '#080');
}
$start = max(1, $line - floor($count / 2));
$source = @file_get_contents($file);
if (!$source) {
return;
}
$source = explode("\n", highlight_string($source, TRUE));
$spans = 1;
echo $source[0];
$source = explode('<br />', $source[1]);
array_unshift($source, NULL);
$i = $start;
while (--$i >= 1) {
if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
if ($m[1] !== '</span>') {
$spans++;
echo $m[1];
}
break;
}
}
$source = array_slice($source, $start, $count, TRUE);
end($source);
$numWidth = strlen((string) key($source));
foreach ($source as $n => $s) {
$spans += substr_count($s, '<span') - substr_count($s, '</span');
$s = str_replace(array("\r", "\n"), array('', ''), $s);
if ($n === $line) {
printf("<span class='highlight'>Line %{$numWidth}s: %s\n</span>%s", $n, strip_tags($s), preg_replace('#[^>]*(<[^>]+>)[^<]*#', '$1', $s));
} else {
printf("<span class='line'>Line %{$numWidth}s:</span> %s\n", $n, $s);
}
}
echo str_repeat('</span>', $spans), '</code>';
}
function _netteDump($dump)
{
return '<pre class="nette-dump">' . preg_replace_callback('#^( *)((?>[^(]{1,200}))\\((\\d+)\\) <code>#m', create_function('$m', '
return "$m[1]<a href=\'#\' onclick=\'return !netteToggle(this)\'>$m[2]($m[3]) " . (trim($m[1]) || $m[3] < 7 ? \'<abbr>▼</abbr> </a><code>\' : \'<abbr>►</abbr> </a><code class="collapsed">\');
'), $dump) . '</pre>';
}
function _netteOpenPanel($name, $collapsed)
{
static $id;
$id++;
?>
<div class="panel">
<h2><a href="#" onclick="return !netteToggle(this, 'netteBsPnl<?php
echo $id;
?>
')"><?php
echo htmlSpecialChars($name);
?>
<abbr><?php
echo $collapsed ? '►' : '▼';
?>
</abbr></a></h2>
<div id="netteBsPnl<?php
echo $id;
?>
" class="<?php
echo $collapsed ? 'collapsed ' : '';
?>
inner">
<?php
}
function _netteClosePanel()
{
?>
</div>
</div>
<?php
}
}
static $errorTypes = array(E_ERROR => 'Fatal Error', E_USER_ERROR => 'User Error', E_RECOVERABLE_ERROR => 'Recoverable Error', E_CORE_ERROR => 'Core Error', E_COMPILE_ERROR => 'Compile Error', E_PARSE => 'Parse Error', E_WARNING => 'Warning', E_CORE_WARNING => 'Core Warning', E_COMPILE_WARNING => 'Compile Warning', E_USER_WARNING => 'User Warning', E_NOTICE => 'Notice', E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
$title = $exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()]) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
$expandPath = NETTE_DIR . DIRECTORY_SEPARATOR;
if (headers_sent()) {
echo '</pre></xmp></table>';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
//.........这里部分代码省略.........
示例3: render
public function render(Exception $exception)
{
if (class_exists('Environment', FALSE)) {
$application = Environment::getContext()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getContext()->getService('Nette\\Application\\Application') : NULL;
}
$panels = $this->panels;
static $errorTypes = array(E_ERROR => 'Fatal Error', E_USER_ERROR => 'User Error', E_RECOVERABLE_ERROR => 'Recoverable Error', E_CORE_ERROR => 'Core Error', E_COMPILE_ERROR => 'Compile Error', E_PARSE => 'Parse Error', E_WARNING => 'Warning', E_CORE_WARNING => 'Core Warning', E_COMPILE_WARNING => 'Compile Warning', E_USER_WARNING => 'User Warning', E_NOTICE => 'Notice', E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
$title = $exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()]) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
$expandPath = NETTE_DIR . DIRECTORY_SEPARATOR;
$counter = 0;
?>
<!-- "' --></script></style></pre></xmp></table>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex,noarchive">
<meta name="generator" content="Nette Framework">
<title><?php
echo htmlspecialchars($title);
?>
</title><!-- <?php
$ex = $exception;
echo $ex->getMessage(), $ex->getCode() ? ' #' . $ex->getCode() : '';
while (method_exists($ex, 'getPrevious') && ($ex = $ex->getPrevious()) || isset($ex->previous) && ($ex = $ex->previous)) {
echo '; caused by ', get_class($ex), ' ', $ex->getMessage(), $ex->getCode() ? ' #' . $ex->getCode() : '';
}
?>
-->
<style type="text/css" class="nette">html{overflow-y:scroll}body{margin:0 0 2em;padding:0}#netteBluescreen{font:9pt/1.5 Verdana,sans-serif;background:white;color:#333;position:absolute;left:0;top:0;width:100%;z-index:23178;text-align:left}#netteBluescreen *{font:inherit;color:inherit;background:transparent;border:none;margin:0;padding:0;text-align:inherit;text-indent:0}#netteBluescreen b{font-weight:bold}#netteBluescreen i{font-style:italic}#netteBluescreen a{text-decoration:none;color:#328ADC;padding:2px 4px;margin:-2px -4px}#netteBluescreen a:hover,#netteBluescreen a:active,#netteBluescreen a:focus{color:#085AA3}#netteBluescreen a abbr{font-family:sans-serif;color:#BBB}#netteBluescreenIcon{position:absolute;right:.5em;top:.5em;z-index:23179;text-decoration:none;background:#CD1818;padding:3px}#netteBluescreenError{background:#CD1818;color:white;font:13pt/1.5 Verdana,sans-serif!important;display:block}#netteBluescreenError #netteBsSearch{color:#CD1818;font-size:.7em}#netteBluescreenError:hover #netteBsSearch{color:#ED8383}#netteBluescreen h1{font-size:18pt;font-weight:normal;text-shadow:1px 1px 0 rgba(0,0,0,.4);margin:.7em 0}#netteBluescreen h2{font:14pt/1.5 sans-serif!important;color:#888;margin:.6em 0}#netteBluescreen h3{font:bold 10pt/1.5 Verdana,sans-serif!important;margin:1em 0;padding:0}#netteBluescreen p,#netteBluescreen pre{margin:.8em 0}#netteBluescreen pre,#netteBluescreen code,#netteBluescreen table{font:9pt/1.5 Consolas,monospace!important}#netteBluescreen pre,#netteBluescreen table{background:#FDF5CE;padding:.4em .7em;border:1px dotted silver;overflow:auto}#netteBluescreen table pre{padding:0;margin:0;border:none}#netteBluescreen pre.nette-dump span{color:#C22}#netteBluescreen pre.nette-dump a{color:#333}#netteBluescreen div.panel{padding:1px 25px}#netteBluescreen div.inner{background:#F4F3F1;padding:.1em 1em 1em;border-radius:8px;-moz-border-radius:8px;-webkit-border-radius:8px}#netteBluescreen table{border-collapse:collapse;width:100%}#netteBluescreen .outer{overflow:auto}#netteBluescreen td,#netteBluescreen th{vertical-align:top;text-align:left;padding:2px 6px;border:1px solid #e6dfbf}#netteBluescreen th{width:10%;font-weight:bold}#netteBluescreen tr:nth-child(2n),#netteBluescreen tr:nth-child(2n) pre{background-color:#F7F0CB}#netteBluescreen ol{margin:1em 0;padding-left:2.5em}#netteBluescreen ul{font:7pt/1.5 Verdana,sans-serif!important;padding:2em 4em;margin:1em 0 0;color:#777;background:#F6F5F3 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFEAAAAjCAMAAADbuxbOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRF/fz24d7Y7Onj5uLd9vPu3drUzMvG09LN39zW8e7o2NbQ3NnT29jS0M7J1tXQAAAApvmsFgAAABB0Uk5T////////////////////AOAjXRkAAAKlSURBVHja7FbbsqQgDAwENEgc//9vN+SCWDtbtXPmZR/Wc6o02mlC58LA9ckFAOszvMV8xNgyUjyXhojfMVKvRL0ZHavxXYy5JrmchMdzou8YlTClxajtK8ZGGpWRoBr1+gFjKfHkJPbizabLgzE3pH7Iu4K980xgFvlrVzMZoVBWhtvouCDdcTDmTgMCJdVxJ9MKO6XxnliM7hxi5lbj2ZVM4l8DqYyKoNLYcfqBB1/LpHYxEcfVG6ZpMDgyFUVWY/Q1sSYPpIdSAKWqLWL0XqWiMWc4hpH0OQOMOAgdycY4N9Sb7wWANQs3rsDSdLAYiuxi5siVfOhBWIrtH0G3kNaF/8Q4kCPE1kMucG/ZMUBUCOgiKJkPuWWTLGVgLGpwns1DraUayCtoBqERyaYtVsm85NActRooezvSLO/sKZP/nq8n4+xcyjNsRu8zW6KWpdb7wjiQd4WrtFZYFiKHENSmWp6xshh96c2RQ+c7Lt+qbijyEjHWUJ/pZsy8MGIUuzNiPySK2Gqoh6ZTRF6ko6q3nVTkaA//itIrDpW6l3SLo8juOmqMXkYknu5FdQxWbhCfKHEGDhxxyTVaXJF3ZjSl3jMksjSOOKmne9pI+mcG5QvaUJhI9HpkmRo2NpCrDJvsktRhRE2MM6F2n7dt4OaMUq8bCctk0+PoMRzL+1l5PZ2eyM/Owr86gf8z/tOM53lom5+nVcFuB+eJVzlXwAYy9TZ9s537tfqcsJWbEU4nBngZo6FfO9T9CdhfBtmk2dLiAy8uS4zwOpMx2HqYbTC+amNeAYTpsP4SIgvWfUBWXxn3CMHW3ffd7k3+YIkx7w0t/CVGvcPejoeOlzOWzeGbawOHqXQGUTMZRcfj4XPCgW9y/fuvVn8zD9P1QHzv80uAAQA0i3Jer7Jr7gAAAABJRU5ErkJggg==') 99% 10px no-repeat;border-top:1px solid #DDD}#netteBluescreen .highlight{background:#CD1818;color:white;font-weight:bold;font-style:normal;display:block;padding:0 .4em;margin:0 -.4em}#netteBluescreen .line{color:#9F9C7F;font-weight:normal;font-style:normal}#netteBluescreen a[href^=editor\:]{color:inherit;border-bottom:1px dotted #C1D2E1}</style>
</head>
<body>
<div id="netteBluescreen">
<a id="netteBluescreenIcon" href="#" rel="next"><abbr>▼</abbr></a
><div>
<div id="netteBluescreenError" class="panel">
<h1><?php
echo htmlspecialchars($title), $exception->getCode() ? ' #' . $exception->getCode() : '';
?>
</h1>
<p><?php
echo htmlspecialchars($exception->getMessage());
?>
<a href="http://www.google.cz/search?sourceid=nette&q=<?php
echo urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage()));
?>
" id="netteBsSearch">search►</a></p>
</div>
<?php
$ex = $exception;
$level = 0;
?>
<?php
do {
?>
<?php
if ($level++) {
?>
<div class="panel">
<h2><a href="#" rel="netteBsPnl<?php
echo ++$counter;
?>
">Caused by <abbr><?php
echo ($collapsed = $level > 2) ? '►' : '▼';
?>
</abbr></a></h2>
<div id="netteBsPnl<?php
echo $counter;
?>
" class="<?php
echo $collapsed ? 'nette-collapsed ' : '';
?>
inner">
<div class="panel">
<h1><?php
echo htmlspecialchars(get_class($ex)), $ex->getCode() ? ' #' . $ex->getCode() : '';
?>
</h1>
<p><b><?php
echo htmlspecialchars($ex->getMessage());
?>
</b></p>
</div>
<?php
}
?>
//.........这里部分代码省略.........
示例4: getControlHtml
public function getControlHtml($opts = null)
{
$preview = $this->previewLink("480x330");
//$link = $this->downloadLink();
$link = Environment::getHttpRequest()->getUrl()->getBasePath() . "data/files/{$this->id}.orig.{$this->suffix}";
// custom templating
$template = Environment::getContext()->params["themeDir"] . '/control-video.latte';
if (file_exists($template)) {
$tpl = Environment::getApplication()->presenter->createTemplate();
$tpl->setFile($template);
$tpl->file = $this;
$tpl->preview = $preview;
$tpl->link = $link;
$tpl->basePath = Environment::getHttpRequest()->getUrl()->getBasePath();
return (string) $tpl;
}
return "\n<video src='{$link}' width='480' height='330' poster='{$preview}' preload='none'>\n" . "Pokud vidíte tento text, váš prohlížeč zřejmě neumí přehrávat video.\n" . "<br>Video můžete alespoň <a href='{$link}'>stáhnout</a> a zkusit ho přehrát mimo prohlížeč.\n" . "</video>\n";
//TODO proč nefunguje downloadLink??
//TODO dát to do šablony
//TODO do disable textu přidat preview
}
示例5: getContainer
/**
*
* @return \SystemContainer
*/
protected function getContainer()
{
return Environment::getContext();
}