Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: juzna/nette
...
head fork: juzna/nette
  • 9 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
2  Nette/Config/Extensions/NetteExtension.php
@@ -325,7 +325,7 @@ private function setupDatabase(ContainerBuilder $container, array $config)
}
$connection = $container->addDefinition($this->prefix("database.$name"))
- ->setClass(isset($config['class']) ? $config['class'] : 'Nette\Database\Connection', array($info['dsn'], $info['user'], $info['password'], $info['options']))
+ ->setClass(isset($info['class']) ? $info['class'] : 'Nette\Database\Connection', array($info['dsn'], $info['user'], $info['password'], $info['options']))
->setAutowired($info['autowired'])
->addSetup('setCacheStorage')
->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array(
View
21 Nette/Database/Table/AbstractGroupedSelection.php
@@ -150,4 +150,25 @@ protected function getRefTable(& $refPath)
return $refObj;
}
+
+
+ /***************** manipulation - not supported *****************j*d*/
+
+
+
+ public function insert($data)
+ {
+ throw new \Nette\NotSupportedException('This method must be overloaded');
+ }
+
+ public function update($data)
+ {
+ throw new \Nette\NotSupportedException('This method must be overloaded');
+ }
+
+ public function delete()
+ {
+ throw new \Nette\NotSupportedException('This method must be overloaded');
+ }
+
}
View
6 Nette/Database/Table/GroupedSelection.php
@@ -136,7 +136,7 @@ public function insert($data)
$data[$this->column] = $this->active;
}
- return parent::insert($data);
+ return Selection::insert($data);
}
@@ -147,7 +147,7 @@ public function update($data)
$this->sqlBuilder = new SqlBuilder($this);
$this->where($this->column, $this->active);
- $return = parent::update($data);
+ $return = Selection::update($data);
$this->sqlBuilder = $builder;
return $return;
@@ -161,7 +161,7 @@ public function delete()
$this->sqlBuilder = new SqlBuilder($this);
$this->where($this->column, $this->active);
- $return = parent::delete();
+ $return = Selection::delete();
$this->sqlBuilder = $builder;
return $return;
View
16 Nette/Database/Table/Selection.php
@@ -890,4 +890,20 @@ public function fetchIndexed($key = NULL) {
return $this->fetchPairs($key ? : $this->primary);
}
+
+
+ /**
+ * Fetch single value
+ */
+ public function fetchSingle()
+ {
+ $row = reset($this->data);
+ if ($row) {
+ $tmp = $row->toArray();
+ return $tmp[0];
+ } else {
+ return null;
+ }
+ }
+
}
View
77 Nette/Diagnostics/Bar.php
@@ -63,35 +63,17 @@ public function getPanel($id)
* Renders debug bar.
* @return void
*/
- public function render()
+ public function render($contentOnly = FALSE)
{
- $obLevel = ob_get_level();
- $panels = array();
- foreach ($this->panels as $id => $panel) {
- try {
- $panels[] = array(
- 'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
- 'tab' => $tab = (string) $panel->getTab(),
- 'panel' => $tab ? (string) $panel->getPanel() : NULL,
- );
- } catch (\Exception $e) {
- $panels[] = array(
- 'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
- 'tab' => "Error in $id",
- 'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
- );
- while (ob_get_level() > $obLevel) { // restore ob-level if broken
- ob_end_clean();
- }
- }
+ if (preg_match('#^Location:#im', implode("\n", headers_list()))) {
+ $this->store();
+ return;
}
+ $panels = $this->renderPanels();
+
@session_start();
$session = & $_SESSION['__NF']['debuggerbar'];
- if (preg_match('#^Location:#im', implode("\n", headers_list()))) {
- $session[] = $panels;
- return;
- }
foreach (array_reverse((array) $session) as $reqId => $oldpanels) {
$panels[] = array(
@@ -111,11 +93,50 @@ public function render()
- public function __toString()
+ /**
+ * Store panels to session for later retrieval (used in redirects and ajax)
+ */
+ public function store()
+ {
+ @session_start();
+ $session = &$_SESSION['__NF']['debuggerbar'];
+ $session[] = $this->renderPanels();
+ }
+
+
+
+ /***************** internal *****************d*g*/
+
+
+
+ /**
+ * Render all panels into array
+ * @internal
+ * @return array
+ */
+ private function renderPanels()
{
- ob_start();
- $this->render();
- return ob_get_clean();
+ $obLevel = ob_get_level();
+ $panels = array();
+ foreach($this->panels as $id => $panel) {
+ try {
+ $panels[] = array(
+ 'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
+ 'tab' => $tab = (string)$panel->getTab(),
+ 'panel' => $tab ? (string)$panel->getPanel() : NULL,
+ );
+ } catch(\Exception $e) {
+ $panels[] = array(
+ 'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
+ 'tab' => "Error in $id",
+ 'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
+ );
+ while(ob_get_level() > $obLevel) { // restore ob-level if broken
+ ob_end_clean();
+ }
+ }
+ }
+ return $panels;
}
}
View
24 Nette/Diagnostics/Debugger.php
@@ -164,7 +164,7 @@ public static function _init()
if (self::$consoleMode) {
self::$source = empty($_SERVER['argv']) ? 'cli' : 'cli: ' . implode(' ', $_SERVER['argv']);
} else {
- self::$ajaxDetected = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
+ self::$ajaxDetected = !empty($_GET['ajax']) || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
if (isset($_SERVER['REQUEST_URI'])) {
self::$source = (isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://')
. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''))
@@ -206,6 +206,10 @@ public static function _init()
});
self::$bar = new Bar;
+ if (isset($_SERVER['HTTP_NETTE_DEBUGGER_VIEW'])) {
+ self::$bar->render(TRUE);
+ exit;
+ }
self::$bar->addPanel(new DefaultBarPanel('time'));
self::$bar->addPanel(new DefaultBarPanel('memory'));
self::$bar->addPanel(self::$errorPanel = new DefaultBarPanel('errors')); // filled by _errorHandler()
@@ -257,12 +261,12 @@ public static function enable($mode = NULL, $logDirectory = NULL, $email = NULL)
if (self::$logDirectory) {
ini_set('error_log', self::$logDirectory . '/php_error.log');
}
- if (isset($_SERVER['HTTP_NETTE_DEBUG_HELPER'])) {
+ if (!empty($_SERVER['HTTP_NETTE_DEBUGGER_STORE_AJAX'])) {
$dir = TEMP_DIR . '/_Nette.DebugHelper';
if (!file_exists($dir)) {
mkdir($dir);
}
- self::$intermediateDebugFile = tempnam($dir, $_SERVER['HTTP_NETTE_DEBUG_HELPER']);
+ self::$intermediateDebugFile = tempnam($dir, $_SERVER['HTTP_NETTE_DEBUGGER_STORE_AJAX']);
if (!headers_sent()) {
header("Nette-Debug-Nonce: " . basename(self::$intermediateDebugFile));
}
@@ -392,9 +396,8 @@ public static function _shutdownHandler()
if(self::isHtmlMode()) {
self::$bar->render();
- } elseif (self::$intermediateDebugFile) {
- file_put_contents(self::$intermediateDebugFile, self::$bar->__toString());
- @chmod(self::$intermediateDebugFile, 0666);
+ } elseif (self::$ajaxDetected && isset($_SERVER['HTTP_NETTE_DEBUGGER_STORE_AJAX'])) {
+ self::$bar->store();
}
}
}
@@ -494,6 +497,11 @@ public static function _errorHandler($severity, $message, $file, $line, $context
return NULL;
}
+ // juzna's hacks - omit some errors
+ if ($severity === E_NOTICE && strpos($message, 'Undefined variable:') === 0 && (strpos($file, 'templates/') || strpos($file, 'Template/'))) {
+ return; // we ain't give a shit about undefined variables in templates
+ }
+
if ($severity === E_RECOVERABLE_ERROR || $severity === E_USER_ERROR) {
if (Helpers::findTrace(/*5.2*PHP_VERSION_ID < 50205 ? debug_backtrace() : */debug_backtrace(FALSE), '*::__toString')) {
$previous = isset($context['e']) && $context['e'] instanceof \Exception ? $context['e'] : NULL;
@@ -505,7 +513,9 @@ public static function _errorHandler($severity, $message, $file, $line, $context
return FALSE; // calls normal error handler to fill-in error_get_last()
} elseif (!self::$productionMode && (is_bool(self::$strictMode) ? self::$strictMode : ((self::$strictMode & $severity) === $severity))) {
- self::_exceptionHandler(new Nette\FatalErrorException($message, 0, $severity, $file, $line, $context));
+ $e = new Nette\FatalErrorException($message, 0, $severity, $file, $line, $context);
+// self::_exceptionHandler($e);
+ self::log($e);
}
static $types = array(
View
5 Nette/Diagnostics/templates/bar.phtml
@@ -23,6 +23,7 @@ use Nette;
<!-- Nette Debug Bar -->
+<?php if (!$contentOnly): ?>
<?php ob_start() ?>
&nbsp;
@@ -346,7 +347,7 @@ use Nette;
<?php require __DIR__ . '/bar.js' ?>
/* ]]> */
</script>
-
+<?php endif; // !$contentOnly ?>
<?php foreach ($panels as $id => $panel): if (!$panel['panel']) continue; ?>
<div class="nette-panel" id="nette-debug-panel-<?php echo $panel['id'] ?>">
@@ -370,6 +371,7 @@ use Nette;
<li><a href="#" rel="close" title="close debug bar">&times;</a></li>
</ul>
</div>
+<?php if(!$contentOnly): ?>
<?php $output = ob_get_clean(); ?>
@@ -394,5 +396,6 @@ use Nette;
};
})(window.onload);
</script>
+<?php endif; // !$contentOnly ?>
<!-- /Nette Debug Bar -->

No commit comments for this range

Something went wrong with that request. Please try again.