Nette-2.4-20160731/0000755000000000000000000000000012747434646012056 5ustar rootrootNette-2.4-20160731/version.txt0000644000000000000000000000243712747434606014306 0ustar rootrootNette 2.4-20160731 latte/latte v2.4.1 Latte: the amazing template engine for PHP nette/application v2.4.1 Nette Application MVC Component nette/bootstrap v2.4.1 Nette Bootstrap nette/caching v2.5.1 Nette Caching Component nette/component-model v2.3.0 Nette Component Model nette/database v2.4.0 Nette Database Component nette/deprecated v2.4.0 APIs and features removed from Nette Framework nette/di v2.4.2 Nette Dependency Injection Component nette/finder v2.4.0 Nette Finder: Files Searching nette/forms v2.4.1 Nette Forms: greatly facilitates web forms nette/http v2.4.0 Nette HTTP Component nette/mail v2.4.1 Nette Mail: Sending E-mails nette/neon v2.4.0 Nette NEON: parser & generator for Nette Object Notation nette/php-generator v2.4.1 Nette PHP Generator nette/reflection v2.4.0 Nette PHP Reflection Component nette/robot-loader v2.4.0 Nette RobotLoader: comfortable autoloading nette/safe-stream v2.3.2 Nette SafeStream: Atomic Operations nette/security v2.4.0 Nette Security: Access Control Component nette/tokenizer v2.2.3 Nette Tokenizer nette/utils v2.4.0 Nette Utility Classes tracy/tracy v2.4.2 Tracy: useful PHP debugger Nette-2.4-20160731/tools/0000755000000000000000000000000012747434604013210 5ustar rootrootNette-2.4-20160731/tools/open-in-editor/0000755000000000000000000000000012747434604016041 5ustar rootrootNette-2.4-20160731/tools/open-in-editor/open-editor.js0000644000000000000000000000272412747434604020631 0ustar rootroot// NetBeans // var editor = '"C:\\Program Files\\NetBeans 8.1\\bin\\netbeans.exe" "%file%:%line%" --console suppress'; // PhpStorm // var editor = '"C:\\Program Files (x86)\\JetBrains\\PhpStorm 10.0\\bin\\PhpStorm.exe" --line %line% "%file%"'; // Nusphere PHPEd // var editor = '"C:\\Program Files\\NuSphere\\PhpED\\phped.exe" "%file%" --line=%line%'; // SciTE // var editor = '"C:\\Program Files\\SciTE\\scite.exe" "-open:%file%" -goto:%line%'; // EmEditor // var editor = '"C:\\Program Files\\EmEditor\\EmEditor.exe" "%file%" /l %line%'; // PSPad Editor // var editor = '"C:\\Program Files\\PSPad editor\\PSPad.exe" -%line% "%file%"'; // gVim // var editor = '"C:\\Program Files\\Vim\\vim73\\gvim.exe" "%file%" +%line%'; // Sublime Text 2 // var editor = '"C:\\Program Files\\Sublime Text 2\\sublime_text.exe" "%file%:%line%"'; var mappings = { // '/remotepath': '/localpath' }; if (typeof editor === 'undefined') { WScript.Echo('Create variable "editor" in ' + WScript.ScriptFullName); WScript.Quit(); } var url = WScript.Arguments(0); var match = /^editor:\/\/open\/\?file=(.+)&line=(\d+)/.exec(url); if (match) { var file = decodeURIComponent(match[1]).replace(/\+/g, ' '); for (var id in mappings) { if (file.indexOf(id) === 0) { file = mappings[id] + file.substr(id.length); break; } } var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file); var shell = new ActiveXObject("WScript.Shell"); shell.Exec(command.replace(/\\/g, '\\\\')); } Nette-2.4-20160731/tools/open-in-editor/install.cmd0000644000000000000000000000060112747434604020171 0ustar rootroot@echo off :: This Windows batch file sets open-editor.js as handler for editor:// protocol if defined PROCESSOR_ARCHITEW6432 (set reg="%systemroot%\sysnative\reg.exe") else (set reg=reg) %reg% ADD HKCR\editor /ve /d "URL:editor Protocol" /f %reg% ADD HKCR\editor /v "URL Protocol" /d "" /f %reg% ADD HKCR\editor\shell\open\command /ve /d "wscript \"%~dp0open-editor.js\" \"%%1\"" /f Nette-2.4-20160731/readme.txt0000644000000000000000000000506712747434552014060 0ustar rootroot[Nette Framework](https://nette.org) =================================== [![Downloads this Month](https://img.shields.io/packagist/dm/nette/nette.svg)](https://packagist.org/packages/nette/nette) [![Latest Stable Version](https://poser.pugx.org/nette/nette/v/stable)](https://github.com/nette/nette/releases) [![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/nette/blob/master/license.md) [![Join the chat at Gitter](https://img.shields.io/badge/Gitter-join%20chat-green.svg)](https://gitter.im/nette/nette) Nette Framework is a popular tool for PHP web development. It is designed to be as usable and as friendly as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks. Nette Framework speaks your language and helps you to easily build better websites. It contains these packages: - [Application](https://github.com/nette/application) - [Bootstrap](https://github.com/nette/bootstrap) - [Caching](https://github.com/nette/caching) - [Component Model](https://github.com/nette/component-model) - [Database](https://github.com/nette/database) - [DI](https://github.com/nette/di) - [Finder](https://github.com/nette/finder) - [Forms](https://github.com/nette/forms) - [Http](https://github.com/nette/http) - [Mail](https://github.com/nette/mail) - [Neon](https://github.com/nette/neon) - [Php Generator](https://github.com/nette/php-generator) - [Reflection](https://github.com/nette/reflection) - [Robot Loader](https://github.com/nette/robot-loader) - [Safe Stream](https://github.com/nette/safe-stream) - [Security](https://github.com/nette/security) - [Tokenizer](https://github.com/nette/tokenizer) - [Utils](https://github.com/nette/utils) - [Latte](https://latte.nette.org) - [Tracy](https://tracy.nette.org) - [deprecated](https://github.com/nette/deprecated) - and [Tester](https://tester.nette.org) Installation ------------ The best way to install Nette Framework is to download the latest package from https://nette.org/download or use [Composer](https://doc.nette.org/composer). All Nette components are 100% compatible with PHP 7. Minimal required version of PHP is 5.6.0 for Nette Framework 2.4-dev and PHP 5.3.1 for stable Nette Framework 2.3. Please run [Requirements Checker](https://doc.nette.org/requirements) to obtain more detailed information. Getting started --------------- The [Quick Start tutorial](https://doc.nette.org/quickstart) gives you a first introduction to the framework by creating a simple database driven application. Nette-2.4-20160731/Nette/0000755000000000000000000000000012747434622013127 5ustar rootrootNette-2.4-20160731/Nette/Utils/0000755000000000000000000000000012747434604014227 5ustar rootrootNette-2.4-20160731/Nette/Utils/Validators.php0000644000000000000000000001657212747434604017063 0ustar rootroot 'is_bool', 'boolean' => 'is_bool', 'int' => 'is_int', 'integer' => 'is_int', 'float' => 'is_float', 'number' => NULL, // is_int || is_float, 'numeric' => [__CLASS__, 'isNumeric'], 'numericint' => [__CLASS__, 'isNumericInt'], 'string' => 'is_string', 'unicode' => [__CLASS__, 'isUnicode'], 'array' => 'is_array', 'list' => [Arrays::class, 'isList'], 'object' => 'is_object', 'resource' => 'is_resource', 'scalar' => 'is_scalar', 'callable' => [__CLASS__, 'isCallable'], 'null' => 'is_null', 'email' => [__CLASS__, 'isEmail'], 'url' => [__CLASS__, 'isUrl'], 'uri' => [__CLASS__, 'isUri'], 'none' => [__CLASS__, 'isNone'], 'type' => [__CLASS__, 'isType'], 'identifier' => [__CLASS__, 'isPhpIdentifier'], 'pattern' => NULL, 'alnum' => 'ctype_alnum', 'alpha' => 'ctype_alpha', 'digit' => 'ctype_digit', 'lower' => 'ctype_lower', 'upper' => 'ctype_upper', 'space' => 'ctype_space', 'xdigit' => 'ctype_xdigit', ]; protected static $counters = [ 'string' => 'strlen', 'unicode' => [Strings::class, 'length'], 'array' => 'count', 'list' => 'count', 'alnum' => 'strlen', 'alpha' => 'strlen', 'digit' => 'strlen', 'lower' => 'strlen', 'space' => 'strlen', 'upper' => 'strlen', 'xdigit' => 'strlen', ]; /** * Throws exception if a variable is of unexpected type. * @param mixed * @param string expected types separated by pipe * @param string label * @return void */ public static function assert($value, $expected, $label = 'variable') { if (!static::is($value, $expected)) { $expected = str_replace(['|', ':'], [' or ', ' in range '], $expected); if (is_array($value)) { $type = 'array(' . count($value) . ')'; } elseif (is_object($value)) { $type = 'object ' . get_class($value); } elseif (is_string($value) && strlen($value) < 40) { $type = "string '$value'"; } else { $type = gettype($value); } throw new AssertionException("The $label expects to be $expected, $type given."); } } /** * Throws exception if an array field is missing or of unexpected type. * @param array * @param string item * @param string expected types separated by pipe * @param string * @return void */ public static function assertField($arr, $field, $expected = NULL, $label = "item '%' in array") { self::assert($arr, 'array', 'first argument'); if (!array_key_exists($field, $arr)) { throw new AssertionException('Missing ' . str_replace('%', $field, $label) . '.'); } elseif ($expected) { static::assert($arr[$field], $expected, str_replace('%', $field, $label)); } } /** * Finds whether a variable is of expected type. * @param mixed * @param string expected types separated by pipe with optional ranges * @return bool */ public static function is($value, $expected) { foreach (explode('|', $expected) as $item) { list($type) = $item = explode(':', $item, 2); if (isset(static::$validators[$type])) { if (!call_user_func(static::$validators[$type], $value)) { continue; } } elseif ($type === 'number') { if (!is_int($value) && !is_float($value)) { continue; } } elseif ($type === 'pattern') { if (preg_match('|^' . (isset($item[1]) ? $item[1] : '') . '\z|', $value)) { return TRUE; } continue; } elseif (!$value instanceof $type) { continue; } if (isset($item[1])) { $length = $value; if (isset(static::$counters[$type])) { $length = call_user_func(static::$counters[$type], $value); } $range = explode('..', $item[1]); if (!isset($range[1])) { $range[1] = $range[0]; } if (($range[0] !== '' && $length < $range[0]) || ($range[1] !== '' && $length > $range[1])) { continue; } } return TRUE; } return FALSE; } /** * Finds whether a value is an integer. * @return bool */ public static function isNumericInt($value) { return is_int($value) || is_string($value) && preg_match('#^-?[0-9]+\z#', $value); } /** * Finds whether a string is a floating point number in decimal base. * @return bool */ public static function isNumeric($value) { return is_float($value) || is_int($value) || is_string($value) && preg_match('#^-?[0-9]*[.]?[0-9]+\z#', $value); } /** * Finds whether a value is a syntactically correct callback. * @return bool */ public static function isCallable($value) { return $value && is_callable($value, TRUE); } /** * Finds whether a value is an UTF-8 encoded string. * @param string * @return bool */ public static function isUnicode($value) { return is_string($value) && preg_match('##u', $value); } /** * Finds whether a value is "falsy". * @return bool */ public static function isNone($value) { return $value == NULL; // intentionally == } /** * Finds whether a variable is a zero-based integer indexed array. * @param array * @return bool */ public static function isList($value) { return Arrays::isList($value); } /** * Is a value in specified range? * @param mixed * @param array min and max value pair * @return bool */ public static function isInRange($value, $range) { return (!isset($range[0]) || $range[0] === '' || $value >= $range[0]) && (!isset($range[1]) || $range[1] === '' || $value <= $range[1]); } /** * Finds whether a string is a valid email address. * @param string * @return bool */ public static function isEmail($value) { $atom = "[-a-z0-9!#$%&'*+/=?^_`{|}~]"; // RFC 5322 unquoted characters in local-part $alpha = "a-z\x80-\xFF"; // superset of IDN return (bool) preg_match("(^ (\"([ !#-[\\]-~]*|\\\\[ -~])+\"|$atom+(\\.$atom+)*) # quoted or unquoted @ ([0-9$alpha]([-0-9$alpha]{0,61}[0-9$alpha])?\\.)+ # domain - RFC 1034 [$alpha]([-0-9$alpha]{0,17}[$alpha])? # top domain \\z)ix", $value); } /** * Finds whether a string is a valid http(s) URL. * @param string * @return bool */ public static function isUrl($value) { $alpha = "a-z\x80-\xFF"; return (bool) preg_match("(^ https?://( (([-_0-9$alpha]+\\.)* # subdomain [0-9$alpha]([-0-9$alpha]{0,61}[0-9$alpha])?\\.)? # domain [$alpha]([-0-9$alpha]{0,17}[$alpha])? # top domain |\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3} # IPv4 |\[[0-9a-f:]{3,39}\] # IPv6 )(:\\d{1,5})? # port (/\\S*)? # path \\z)ix", $value); } /** * Finds whether a string is a valid URI according to RFC 1738. * @param string * @return bool */ public static function isUri($value) { return (bool) preg_match('#^[a-z\d+\.-]+:\S+\z#i', $value); } /** * Checks whether the input is a class, interface or trait. * @param string * @return bool */ public static function isType($type) { return class_exists($type) || interface_exists($type) || trait_exists($type); } /** * Checks whether the input is a valid PHP identifier. * @return bool */ public static function isPhpIdentifier($value) { return is_string($value) && preg_match('#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\z#', $value); } } Nette-2.4-20160731/Nette/Utils/Strings.php0000644000000000000000000003675112747434604016405 0ustar rootroot= 0xD800 && $code <= 0xDFFF) || $code > 0x10FFFF) { throw new Nette\InvalidArgumentException('Code point must be in range 0x0 to 0xD7FF or 0xE000 to 0x10FFFF.'); } return iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code)); } /** * Starts the $haystack string with the prefix $needle? * @param string * @param string * @return bool */ public static function startsWith($haystack, $needle) { return strncmp($haystack, $needle, strlen($needle)) === 0; } /** * Ends the $haystack string with the suffix $needle? * @param string * @param string * @return bool */ public static function endsWith($haystack, $needle) { return strlen($needle) === 0 || substr($haystack, -strlen($needle)) === $needle; } /** * Does $haystack contain $needle? * @param string * @param string * @return bool */ public static function contains($haystack, $needle) { return strpos($haystack, $needle) !== FALSE; } /** * Returns a part of UTF-8 string. * @param string * @param int in characters (code points) * @param int in characters (code points) * @return string */ public static function substring($s, $start, $length = NULL) { if (function_exists('mb_substr')) { return mb_substr($s, $start, $length, 'UTF-8'); // MB is much faster } elseif ($length === NULL) { $length = self::length($s); } elseif ($start < 0 && $length < 0) { $start += self::length($s); // unifies iconv_substr behavior with mb_substr } return iconv_substr($s, $start, $length, 'UTF-8'); } /** * Removes special controls characters and normalizes line endings and spaces. * @param string UTF-8 encoding * @return string */ public static function normalize($s) { $s = self::normalizeNewLines($s); // remove control characters; leave \t + \n $s = preg_replace('#[\x00-\x08\x0B-\x1F\x7F-\x9F]+#u', '', $s); // right trim $s = preg_replace('#[\t ]+$#m', '', $s); // leading and trailing blank lines $s = trim($s, "\n"); return $s; } /** * Standardize line endings to unix-like. * @param string UTF-8 encoding or 8-bit * @return string */ public static function normalizeNewLines($s) { return str_replace(["\r\n", "\r"], "\n", $s); } /** * Converts to ASCII. * @param string UTF-8 encoding * @return string ASCII */ public static function toAscii($s) { static $transliterator = NULL; if ($transliterator === NULL && class_exists('Transliterator', FALSE)) { $transliterator = \Transliterator::create('Any-Latin; Latin-ASCII'); } $s = preg_replace('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]#u', '', $s); $s = strtr($s, '`\'"^~?', "\x01\x02\x03\x04\x05\x06"); $s = str_replace( ["\xE2\x80\x9E", "\xE2\x80\x9C", "\xE2\x80\x9D", "\xE2\x80\x9A", "\xE2\x80\x98", "\xE2\x80\x99", "\xC2\xB0"], ["\x03", "\x03", "\x03", "\x02", "\x02", "\x02", "\x04"], $s ); if ($transliterator !== NULL) { $s = $transliterator->transliterate($s); } if (ICONV_IMPL === 'glibc') { $s = str_replace( ["\xC2\xBB", "\xC2\xAB", "\xE2\x80\xA6", "\xE2\x84\xA2", "\xC2\xA9", "\xC2\xAE"], ['>>', '<<', '...', 'TM', '(c)', '(R)'], $s ); $s = iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); $s = strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e" . "\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" . "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8" . "\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe" . "\x96\xa0\x8b\x97\x9b\xa6\xad\xb7", 'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.'); $s = preg_replace('#[^\x00-\x7F]++#', '', $s); } else { $s = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); } $s = str_replace(['`', "'", '"', '^', '~', '?'], '', $s); return strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?'); } /** * Converts to web safe characters [a-z0-9-] text. * @param string UTF-8 encoding * @param string allowed characters * @param bool * @return string */ public static function webalize($s, $charlist = NULL, $lower = TRUE) { $s = self::toAscii($s); if ($lower) { $s = strtolower($s); } $s = preg_replace('#[^a-z0-9' . ($charlist !== NULL ? preg_quote($charlist, '#') : '') . ']+#i', '-', $s); $s = trim($s, '-'); return $s; } /** * Truncates string to maximal length. * @param string UTF-8 encoding * @param int * @param string UTF-8 encoding * @return string */ public static function truncate($s, $maxLen, $append = "\xE2\x80\xA6") { if (self::length($s) > $maxLen) { $maxLen = $maxLen - self::length($append); if ($maxLen < 1) { return $append; } elseif ($matches = self::match($s, '#^.{1,'.$maxLen.'}(?=[\s\x00-/:-@\[-`{-~])#us')) { return $matches[0] . $append; } else { return self::substring($s, 0, $maxLen) . $append; } } return $s; } /** * Indents the content from the left. * @param string UTF-8 encoding or 8-bit * @param int * @param string * @return string */ public static function indent($s, $level = 1, $chars = "\t") { if ($level > 0) { $s = self::replace($s, '#(?:^|[\r\n]+)(?=[^\r\n])#', '$0' . str_repeat($chars, $level)); } return $s; } /** * Convert to lower case. * @param string UTF-8 encoding * @return string */ public static function lower($s) { return mb_strtolower($s, 'UTF-8'); } /** * Convert first character to lower case. * @param string UTF-8 encoding * @return string */ public static function firstLower($s) { return self::lower(self::substring($s, 0, 1)) . self::substring($s, 1); } /** * Convert to upper case. * @param string UTF-8 encoding * @return string */ public static function upper($s) { return mb_strtoupper($s, 'UTF-8'); } /** * Convert first character to upper case. * @param string UTF-8 encoding * @return string */ public static function firstUpper($s) { return self::upper(self::substring($s, 0, 1)) . self::substring($s, 1); } /** * Capitalize string. * @param string UTF-8 encoding * @return string */ public static function capitalize($s) { return mb_convert_case($s, MB_CASE_TITLE, 'UTF-8'); } /** * Case-insensitive compares UTF-8 strings. * @param string * @param string * @param int * @return bool */ public static function compare($left, $right, $len = NULL) { if ($len < 0) { $left = self::substring($left, $len, -$len); $right = self::substring($right, $len, -$len); } elseif ($len !== NULL) { $left = self::substring($left, 0, $len); $right = self::substring($right, 0, $len); } return self::lower($left) === self::lower($right); } /** * Finds the length of common prefix of strings. * @param string|array * @return string */ public static function findPrefix(...$strings) { if (is_array($strings[0])) { $strings = $strings[0]; } $first = array_shift($strings); for ($i = 0; $i < strlen($first); $i++) { foreach ($strings as $s) { if (!isset($s[$i]) || $first[$i] !== $s[$i]) { while ($i && $first[$i - 1] >= "\x80" && $first[$i] >= "\x80" && $first[$i] < "\xC0") { $i--; } return substr($first, 0, $i); } } } return $first; } /** * Returns number of characters (not bytes) in UTF-8 string. * That is the number of Unicode code points which may differ from the number of graphemes. * @param string * @return int */ public static function length($s) { return function_exists('mb_strlen') ? mb_strlen($s, 'UTF-8') : strlen(utf8_decode($s)); } /** * Strips whitespace. * @param string UTF-8 encoding * @param string * @return string */ public static function trim($s, $charlist = self::TRIM_CHARACTERS) { $charlist = preg_quote($charlist, '#'); return self::replace($s, '#^['.$charlist.']+|['.$charlist.']+\z#u', ''); } /** * Pad a string to a certain length with another string. * @param string UTF-8 encoding * @param int * @param string * @return string */ public static function padLeft($s, $length, $pad = ' ') { $length = max(0, $length - self::length($s)); $padLen = self::length($pad); return str_repeat($pad, (int) ($length / $padLen)) . self::substring($pad, 0, $length % $padLen) . $s; } /** * Pad a string to a certain length with another string. * @param string UTF-8 encoding * @param int * @param string * @return string */ public static function padRight($s, $length, $pad = ' ') { $length = max(0, $length - self::length($s)); $padLen = self::length($pad); return $s . str_repeat($pad, (int) ($length / $padLen)) . self::substring($pad, 0, $length % $padLen); } /** * Reverse string. * @param string UTF-8 encoding * @return string */ public static function reverse($s) { return iconv('UTF-32LE', 'UTF-8', strrev(iconv('UTF-8', 'UTF-32BE', $s))); } /** * Use Nette\Utils\Random::generate * @deprecated */ public static function random($length = 10, $charlist = '0-9a-z') { trigger_error(__METHOD__ . '() is deprecated, use Nette\Utils\Random::generate()', E_USER_DEPRECATED); return Random::generate($length, $charlist); } /** * Returns part of $haystack before $nth occurence of $needle. * @param string * @param string * @param int negative value means searching from the end * @return string|FALSE returns FALSE if the needle was not found */ public static function before($haystack, $needle, $nth = 1) { $pos = self::pos($haystack, $needle, $nth); return $pos === FALSE ? FALSE : substr($haystack, 0, $pos); } /** * Returns part of $haystack after $nth occurence of $needle. * @param string * @param string * @param int negative value means searching from the end * @return string|FALSE returns FALSE if the needle was not found */ public static function after($haystack, $needle, $nth = 1) { $pos = self::pos($haystack, $needle, $nth); return $pos === FALSE ? FALSE : (string) substr($haystack, $pos + strlen($needle)); } /** * Returns position of $nth occurence of $needle in $haystack. * @param string * @param string * @param int negative value means searching from the end * @return int|FALSE offset in characters or FALSE if the needle was not found */ public static function indexOf($haystack, $needle, $nth = 1) { $pos = self::pos($haystack, $needle, $nth); return $pos === FALSE ? FALSE : self::length(substr($haystack, 0, $pos)); } /** * Returns position of $nth occurence of $needle in $haystack. * @return int|FALSE offset in bytes or FALSE if the needle was not found */ private static function pos($haystack, $needle, $nth = 1) { if (!$nth) { return FALSE; } elseif ($nth > 0) { if (strlen($needle) === 0) { return 0; } $pos = 0; while (FALSE !== ($pos = strpos($haystack, $needle, $pos)) && --$nth) { $pos++; } } else { $len = strlen($haystack); if (strlen($needle) === 0) { return $len; } $pos = $len - 1; while (FALSE !== ($pos = strrpos($haystack, $needle, $pos - $len)) && ++$nth) { $pos--; } } return $pos; } /** * Splits string by a regular expression. * @param string * @param string * @param int * @return array */ public static function split($subject, $pattern, $flags = 0) { return self::pcre('preg_split', [$pattern, $subject, -1, $flags | PREG_SPLIT_DELIM_CAPTURE]); } /** * Performs a regular expression match. * @param string * @param string * @param int can be PREG_OFFSET_CAPTURE (returned in bytes) * @param int offset in bytes * @return mixed */ public static function match($subject, $pattern, $flags = 0, $offset = 0) { if ($offset > strlen($subject)) { return NULL; } return self::pcre('preg_match', [$pattern, $subject, & $m, $flags, $offset]) ? $m : NULL; } /** * Performs a global regular expression match. * @param string * @param string * @param int can be PREG_OFFSET_CAPTURE (returned in bytes); PREG_SET_ORDER is default * @param int offset in bytes * @return array */ public static function matchAll($subject, $pattern, $flags = 0, $offset = 0) { if ($offset > strlen($subject)) { return []; } self::pcre('preg_match_all', [ $pattern, $subject, & $m, ($flags & PREG_PATTERN_ORDER) ? $flags : ($flags | PREG_SET_ORDER), $offset, ]); return $m; } /** * Perform a regular expression search and replace. * @param string * @param string|array * @param string|callable * @param int * @return string */ public static function replace($subject, $pattern, $replacement = NULL, $limit = -1) { if (is_object($replacement) || is_array($replacement)) { if ($replacement instanceof Nette\Callback) { trigger_error('Nette\Callback is deprecated, use PHP callback.', E_USER_DEPRECATED); $replacement = $replacement->getNative(); } if (!is_callable($replacement, FALSE, $textual)) { throw new Nette\InvalidStateException("Callback '$textual' is not callable."); } return self::pcre('preg_replace_callback', [$pattern, $replacement, $subject, $limit]); } elseif ($replacement === NULL && is_array($pattern)) { $replacement = array_values($pattern); $pattern = array_keys($pattern); } return self::pcre('preg_replace', [$pattern, $replacement, $subject, $limit]); } /** @internal */ public static function pcre($func, $args) { static $messages = [ PREG_INTERNAL_ERROR => 'Internal error', PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted', PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted', PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data', PREG_BAD_UTF8_OFFSET_ERROR => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point', 6 => 'Failed due to limited JIT stack space', // PREG_JIT_STACKLIMIT_ERROR ]; $res = Callback::invokeSafe($func, $args, function ($message) use ($args) { // compile-time error, not detectable by preg_last_error throw new RegexpException($message . ' in pattern: ' . implode(' or ', (array) $args[0])); }); if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars && ($res === NULL || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'])) ) { throw new RegexpException((isset($messages[$code]) ? $messages[$code] : 'Unknown error') . ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code); } return $res; } } Nette-2.4-20160731/Nette/Utils/StaticClass.php0000644000000000000000000000112312747434604017152 0ustar rootroot$name) || $this->$name instanceof \Traversable) { foreach ($this->$name as $handler) { Callback::invokeArgs($handler, $args); } } elseif ($this->$name !== NULL) { throw new UnexpectedValueException("Property $class::$$name must be array or NULL, " . gettype($this->$name) . ' given.'); } } elseif ($isProp && $this->$name instanceof \Closure) { // closure in property trigger_error("Invoking closure in property via \$obj->$name() is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); return call_user_func_array($this->$name, $args); } elseif (($methods = & ObjectMixin::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods trigger_error("Magic methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); list($op, $rp, $type) = $methods[$name]; if (count($args) !== ($op === 'get' ? 0 : 1)) { throw new InvalidArgumentException("$class::$name() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.'); } elseif ($type && $args && !ObjectMixin::checkType($args[0], $type)) { throw new InvalidArgumentException("Argument passed to $class::$name() must be $type, " . gettype($args[0]) . ' given.'); } if ($op === 'get') { return $rp->getValue($this); } elseif ($op === 'set') { $rp->setValue($this, $args[0]); } elseif ($op === 'add') { $val = $rp->getValue($this); $val[] = $args[0]; $rp->setValue($this, $val); } return $this; } elseif ($cb = ObjectMixin::getExtensionMethod($class, $name)) { // extension methods trigger_error("Extension methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); return Callback::invoke($cb, $this, ...$args); } else { ObjectMixin::strictCall($class, $name); } } /** * @return void * @throws MemberAccessException */ public static function __callStatic($name, $args) { ObjectMixin::strictStaticCall(get_called_class(), $name); } /** * @return mixed property value * @throws MemberAccessException if the property is not defined. */ public function & __get($name) { $class = get_class($this); $uname = ucfirst($name); if ($prop = ObjectMixin::getMagicProperty($class, $name)) { // property getter if (!($prop & 0b0001)) { throw new MemberAccessException("Cannot read a write-only property $class::\$$name."); } $m = ($prop & 0b0010 ? 'get' : 'is') . $uname; if ($prop & 0b0100) { // return by reference return $this->$m(); } else { $val = $this->$m(); return $val; } } elseif ($name === '') { throw new MemberAccessException("Cannot read a class '$class' property without name."); } elseif (($methods = & ObjectMixin::getMethods($class)) && isset($methods[$m = 'get' . $uname]) || isset($methods[$m = 'is' . $uname])) { // old property getter trigger_error("Missing annotation @property for $class::\$$name used" . ObjectMixin::getSource(), E_USER_DEPRECATED); if ($methods[$m] === 0) { $methods[$m] = (new \ReflectionMethod($class, $m))->returnsReference(); } if ($methods[$m] === TRUE) { return $this->$m(); } else { $val = $this->$m(); return $val; } } elseif (isset($methods[$name])) { // public method as closure getter trigger_error("Accessing methods as properties via \$obj->$name is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); $val = Callback::closure($this, $name); return $val; } elseif (isset($methods['set' . $uname])) { // property getter throw new MemberAccessException("Cannot read a write-only property $class::\$$name."); } else { ObjectMixin::strictGet($class, $name); } } /** * @return void * @throws MemberAccessException if the property is not defined or is read-only */ public function __set($name, $value) { $class = get_class($this); $uname = ucfirst($name); if (ObjectMixin::hasProperty($class, $name)) { // unsetted property $this->$name = $value; } elseif ($prop = ObjectMixin::getMagicProperty($class, $name)) { // property setter if (!($prop & 0b1000)) { throw new MemberAccessException("Cannot write to a read-only property $class::\$$name."); } $this->{'set' . $name}($value); } elseif ($name === '') { throw new MemberAccessException("Cannot write to a class '$class' property without name."); } elseif (($methods = & ObjectMixin::getMethods($class)) && isset($methods[$m = 'set' . $uname])) { // old property setter trigger_error("Missing annotation @property for $class::\$$name used" . ObjectMixin::getSource(), E_USER_DEPRECATED); $this->$m($value); } elseif (isset($methods['get' . $uname]) || isset($methods['is' . $uname])) { // property setter throw new MemberAccessException("Cannot write to a read-only property $class::\$$name."); } else { ObjectMixin::strictSet($class, $name); } } /** * @return void * @throws MemberAccessException */ public function __unset($name) { $class = get_class($this); if (!ObjectMixin::hasProperty($class, $name)) { throw new MemberAccessException("Cannot unset the property $class::\$$name."); } } /** * @return bool */ public function __isset($name) { $uname = ucfirst($name); return ObjectMixin::getMagicProperty(get_class($this), $name) || ($name !== '' && ($methods = ObjectMixin::getMethods(get_class($this))) && (isset($methods['get' . $uname]) || isset($methods['is' . $uname]))); } /** * @return Reflection\ClassType|\ReflectionClass * @deprecated */ public static function getReflection() { trigger_error(get_called_class() . '::getReflection() is deprecated' . ObjectMixin::getSource(), E_USER_DEPRECATED); $class = class_exists(Reflection\ClassType::class) ? Reflection\ClassType::class : \ReflectionClass::class; return new $class(get_called_class()); } /** * @return mixed * @deprecated use Nette\Utils\ObjectMixin::setExtensionMethod() */ public static function extensionMethod($name, $callback = NULL) { if (strpos($name, '::') === FALSE) { $class = get_called_class(); } else { list($class, $name) = explode('::', $name); $class = (new \ReflectionClass($class))->getName(); } trigger_error("Extension methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); if ($callback === NULL) { return ObjectMixin::getExtensionMethod($class, $name); } else { ObjectMixin::setExtensionMethod($class, $name, $callback); } } } Nette-2.4-20160731/Nette/Utils/Random.php0000644000000000000000000000401612747434604016161 0ustar rootroot= 70000) { for ($i = 0; $i < $length; $i++) { $res .= $charlist[random_int(0, $chLen - 1)]; } return $res; } $bytes = ''; if (function_exists('openssl_random_pseudo_bytes')) { $bytes = (string) openssl_random_pseudo_bytes($length, $secure); if (!$secure) { $bytes = ''; } } if (strlen($bytes) < $length && function_exists('mcrypt_create_iv')) { $bytes = (string) mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); } if (strlen($bytes) < $length && !defined('PHP_WINDOWS_VERSION_BUILD') && is_readable('/dev/urandom')) { $bytes = (string) file_get_contents('/dev/urandom', FALSE, NULL, -1, $length); } if (strlen($bytes) < $length) { $rand3 = md5(serialize($_SERVER), TRUE); $charlist = str_shuffle($charlist); for ($i = 0; $i < $length; $i++) { if ($i % 5 === 0) { list($rand1, $rand2) = explode(' ', microtime()); $rand1 += lcg_value(); } $rand1 *= $chLen; $res .= $charlist[($rand1 + $rand2 + ord($rand3[$i % strlen($rand3)])) % $chLen]; $rand1 -= (int) $rand1; } return $res; } for ($i = 0; $i < $length; $i++) { $res .= $charlist[($i + ord($bytes[$i])) % $chLen]; } return $res; } } Nette-2.4-20160731/Nette/Utils/Paginator.php0000644000000000000000000000767212747434604016700 0ustar rootrootpage = (int) $page; return $this; } /** * Returns current page number. * @return int */ public function getPage() { return $this->base + $this->getPageIndex(); } /** * Returns first page number. * @return int */ public function getFirstPage() { return $this->base; } /** * Returns last page number. * @return int|NULL */ public function getLastPage() { return $this->itemCount === NULL ? NULL : $this->base + max(0, $this->getPageCount() - 1); } /** * Sets first page (base) number. * @param int * @return self */ public function setBase($base) { $this->base = (int) $base; return $this; } /** * Returns first page (base) number. * @return int */ public function getBase() { return $this->base; } /** * Returns zero-based page number. * @return int */ protected function getPageIndex() { $index = max(0, $this->page - $this->base); return $this->itemCount === NULL ? $index : min($index, max(0, $this->getPageCount() - 1)); } /** * Is the current page the first one? * @return bool */ public function isFirst() { return $this->getPageIndex() === 0; } /** * Is the current page the last one? * @return bool */ public function isLast() { return $this->itemCount === NULL ? FALSE : $this->getPageIndex() >= $this->getPageCount() - 1; } /** * Returns the total number of pages. * @return int|NULL */ public function getPageCount() { return $this->itemCount === NULL ? NULL : (int) ceil($this->itemCount / $this->itemsPerPage); } /** * Sets the number of items to display on a single page. * @param int * @return self */ public function setItemsPerPage($itemsPerPage) { $this->itemsPerPage = max(1, (int) $itemsPerPage); return $this; } /** * Returns the number of items to display on a single page. * @return int */ public function getItemsPerPage() { return $this->itemsPerPage; } /** * Sets the total number of items. * @param int (or NULL as infinity) * @return self */ public function setItemCount($itemCount) { $this->itemCount = ($itemCount === FALSE || $itemCount === NULL) ? NULL : max(0, (int) $itemCount); return $this; } /** * Returns the total number of items. * @return int|NULL */ public function getItemCount() { return $this->itemCount; } /** * Returns the absolute index of the first item on current page. * @return int */ public function getOffset() { return $this->getPageIndex() * $this->itemsPerPage; } /** * Returns the absolute index of the first item on current page in countdown paging. * @return int|NULL */ public function getCountdownOffset() { return $this->itemCount === NULL ? NULL : max(0, $this->itemCount - ($this->getPageIndex() + 1) * $this->itemsPerPage); } /** * Returns the number of items on current page. * @return int|NULL */ public function getLength() { return $this->itemCount === NULL ? $this->itemsPerPage : min($this->itemsPerPage, $this->itemCount - $this->getPageIndex() * $this->itemsPerPage); } } Nette-2.4-20160731/Nette/Utils/ObjectMixin.php0000644000000000000000000003637712747434604017173 0ustar rootroot [type => callback]] used by extension methods */ private static $extMethods = []; /********************* strictness ****************d*g**/ /** * @throws MemberAccessException */ public static function strictGet($class, $name) { $rc = new \ReflectionClass($class); $hint = self::getSuggestion(array_merge( array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), function ($p) { return !$p->isStatic(); }), self::parseFullDoc($rc, '~^[ \t*]*@property(?:-read)?[ \t]+(?:\S+[ \t]+)??\$(\w+)~m') ), $name); throw new MemberAccessException("Cannot read an undeclared property $class::\$$name" . ($hint ? ", did you mean \$$hint?" : '.')); } /** * @throws MemberAccessException */ public static function strictSet($class, $name) { $rc = new \ReflectionClass($class); $hint = self::getSuggestion(array_merge( array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), function ($p) { return !$p->isStatic(); }), self::parseFullDoc($rc, '~^[ \t*]*@property(?:-write)?[ \t]+(?:\S+[ \t]+)??\$(\w+)~m') ), $name); throw new MemberAccessException("Cannot write to an undeclared property $class::\$$name" . ($hint ? ", did you mean \$$hint?" : '.')); } /** * @throws MemberAccessException */ public static function strictCall($class, $method, $additionalMethods = []) { $hint = self::getSuggestion(array_merge( get_class_methods($class), self::parseFullDoc(new \ReflectionClass($class), '~^[ \t*]*@method[ \t]+(?:\S+[ \t]+)??(\w+)\(~m'), $additionalMethods ), $method); if (method_exists($class, $method)) { // called parent::$method() $class = 'parent'; } throw new MemberAccessException("Call to undefined method $class::$method()" . ($hint ? ", did you mean $hint()?" : '.')); } /** * @throws MemberAccessException */ public static function strictStaticCall($class, $method) { $hint = self::getSuggestion( array_filter((new \ReflectionClass($class))->getMethods(\ReflectionMethod::IS_PUBLIC), function ($m) { return $m->isStatic(); }), $method ); throw new MemberAccessException("Call to undefined static method $class::$method()" . ($hint ? ", did you mean $hint()?" : '.')); } /********************* Nette\Object ****************d*g**/ /** * __call() implementation. * @param object * @param string * @param array * @return mixed * @throws MemberAccessException */ public static function call($_this, $name, $args) { $class = get_class($_this); $isProp = self::hasProperty($class, $name); if ($name === '') { throw new MemberAccessException("Call to class '$class' method without name."); } elseif ($isProp === 'event') { // calling event handlers if (is_array($_this->$name) || $_this->$name instanceof \Traversable) { foreach ($_this->$name as $handler) { Callback::invokeArgs($handler, $args); } } elseif ($_this->$name !== NULL) { throw new Nette\UnexpectedValueException("Property $class::$$name must be array or NULL, " . gettype($_this->$name) . ' given.'); } } elseif ($isProp && $_this->$name instanceof \Closure) { // closure in property return call_user_func_array($_this->$name, $args); } elseif (($methods = & self::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods list($op, $rp, $type) = $methods[$name]; if (count($args) !== ($op === 'get' ? 0 : 1)) { throw new Nette\InvalidArgumentException("$class::$name() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.'); } elseif ($type && $args && !self::checkType($args[0], $type)) { throw new Nette\InvalidArgumentException("Argument passed to $class::$name() must be $type, " . gettype($args[0]) . ' given.'); } if ($op === 'get') { return $rp->getValue($_this); } elseif ($op === 'set') { $rp->setValue($_this, $args[0]); } elseif ($op === 'add') { $val = $rp->getValue($_this); $val[] = $args[0]; $rp->setValue($_this, $val); } return $_this; } elseif ($cb = self::getExtensionMethod($class, $name)) { // extension methods return Callback::invoke($cb, $_this, ...$args); } else { self::strictCall($class, $name, array_keys(self::getExtensionMethods($class))); } } /** * __callStatic() implementation. * @param string * @param string * @param array * @return void * @throws MemberAccessException */ public static function callStatic($class, $method, $args) { self::strictStaticCall($class, $method); } /** * __get() implementation. * @param object * @param string property name * @return mixed property value * @throws MemberAccessException if the property is not defined. */ public static function & get($_this, $name) { $class = get_class($_this); $uname = ucfirst($name); $methods = & self::getMethods($class); if ($name === '') { throw new MemberAccessException("Cannot read a class '$class' property without name."); } elseif (isset($methods[$m = 'get' . $uname]) || isset($methods[$m = 'is' . $uname])) { // property getter if ($methods[$m] === 0) { $methods[$m] = (new \ReflectionMethod($class, $m))->returnsReference(); } if ($methods[$m] === TRUE) { return $_this->$m(); } else { $val = $_this->$m(); return $val; } } elseif (isset($methods[$name])) { // public method as closure getter if (preg_match('#^(is|get|has)([A-Z]|$)#', $name) && !(new \ReflectionMethod($class, $name))->getNumberOfRequiredParameters()) { trigger_error("Did you forget parentheses after $name" . self::getSource() . '?', E_USER_WARNING); } $val = Callback::closure($_this, $name); return $val; } elseif (isset($methods['set' . $uname])) { // property getter throw new MemberAccessException("Cannot read a write-only property $class::\$$name."); } else { self::strictGet($class, $name); } } /** * __set() implementation. * @param object * @param string property name * @param mixed property value * @return void * @throws MemberAccessException if the property is not defined or is read-only */ public static function set($_this, $name, $value) { $class = get_class($_this); $uname = ucfirst($name); $methods = & self::getMethods($class); if ($name === '') { throw new MemberAccessException("Cannot write to a class '$class' property without name."); } elseif (self::hasProperty($class, $name)) { // unsetted property $_this->$name = $value; } elseif (isset($methods[$m = 'set' . $uname])) { // property setter $_this->$m($value); } elseif (isset($methods['get' . $uname]) || isset($methods['is' . $uname])) { // property setter throw new MemberAccessException("Cannot write to a read-only property $class::\$$name."); } else { self::strictSet($class, $name); } } /** * __unset() implementation. * @param object * @param string property name * @return void * @throws MemberAccessException */ public static function remove($_this, $name) { $class = get_class($_this); if (!self::hasProperty($class, $name)) { throw new MemberAccessException("Cannot unset the property $class::\$$name."); } } /** * __isset() implementation. * @param object * @param string property name * @return bool */ public static function has($_this, $name) { $name = ucfirst($name); $methods = & self::getMethods(get_class($_this)); return $name !== '' && (isset($methods['get' . $name]) || isset($methods['is' . $name])); } /********************* magic @properties ****************d*g**/ /** * Returns array of magic properties defined by annotation @property. * @return array of [name => bit mask] */ public static function getMagicProperties($class) { static $cache; $props = & $cache[$class]; if ($props !== NULL) { return $props; } $rc = new \ReflectionClass($class); preg_match_all( '~^ [ \t*]* @property(|-read|-write) [ \t]+ [^\s$]+ [ \t]+ \$ (\w+) ()~mx', (string) $rc->getDocComment(), $matches, PREG_SET_ORDER ); $props = []; foreach ($matches as list(, $type, $name)) { $uname = ucfirst($name); $write = $type !== '-read' && $rc->hasMethod($nm = 'set' . $uname) && ($rm = $rc->getMethod($nm)) && $rm->getName() === $nm && !$rm->isPrivate() && !$rm->isStatic(); $read = $type !== '-write' && ($rc->hasMethod($nm = 'get' . $uname) || $rc->hasMethod($nm = 'is' . $uname)) && ($rm = $rc->getMethod($nm)) && $rm->getName() === $nm && !$rm->isPrivate() && !$rm->isStatic(); if ($read || $write) { $props[$name] = $read << 0 | ($nm[0] === 'g') << 1 | $rm->returnsReference() << 2 | $write << 3; } } if ($parent = get_parent_class($class)) { $props += self::getMagicProperties($parent); } return $props; } /** @internal */ public static function getMagicProperty($class, $name) { $props = self::getMagicProperties($class); return isset($props[$name]) ? $props[$name] : NULL; } /********************* magic @methods ****************d*g**/ /** * Returns array of magic methods defined by annotation @method. * @return array */ public static function getMagicMethods($class) { $rc = new \ReflectionClass($class); preg_match_all('~^ [ \t*]* @method [ \t]+ (?: [^\s(]+ [ \t]+ )? (set|get|is|add) ([A-Z]\w*) (?: ([ \t]* \() [ \t]* ([^)$\s]*) )? ()~mx', (string) $rc->getDocComment(), $matches, PREG_SET_ORDER); $methods = []; foreach ($matches as list(, $op, $prop, $bracket, $type)) { if ($bracket !== '(') { trigger_error("Bracket must be immediately after @method $op$prop() in class $class.", E_USER_WARNING); } $name = $op . $prop; $prop = strtolower($prop[0]) . substr($prop, 1) . ($op === 'add' ? 's' : ''); if ($rc->hasProperty($prop) && ($rp = $rc->getProperty($prop)) && !$rp->isStatic()) { $rp->setAccessible(TRUE); if ($op === 'get' || $op === 'is') { $type = NULL; $op = 'get'; } elseif (!$type && preg_match('#@var[ \t]+(\S+)' . ($op === 'add' ? '\[\]#' : '#'), (string) $rp->getDocComment(), $m)) { $type = $m[1]; } if ($rc->inNamespace() && preg_match('#^[A-Z]\w+(\[|\||\z)#', (string) $type)) { $type = $rc->getNamespaceName() . '\\' . $type; } $methods[$name] = [$op, $rp, $type]; } } return $methods; } /** * Finds whether a variable is of expected type and do non-data-loss conversion. * @return bool * @internal */ public static function checkType(& $val, $type) { if (strpos($type, '|') !== FALSE) { $found = NULL; foreach (explode('|', $type) as $type) { $tmp = $val; if (self::checkType($tmp, $type)) { if ($val === $tmp) { return TRUE; } $found[] = $tmp; } } if ($found) { $val = $found[0]; return TRUE; } return FALSE; } elseif (substr($type, -2) === '[]') { if (!is_array($val)) { return FALSE; } $type = substr($type, 0, -2); $res = []; foreach ($val as $k => $v) { if (!self::checkType($v, $type)) { return FALSE; } $res[$k] = $v; } $val = $res; return TRUE; } switch (strtolower($type)) { case NULL: case 'mixed': return TRUE; case 'bool': case 'boolean': return ($val === NULL || is_scalar($val)) && settype($val, 'bool'); case 'string': return ($val === NULL || is_scalar($val) || (is_object($val) && method_exists($val, '__toString'))) && settype($val, 'string'); case 'int': case 'integer': return ($val === NULL || is_bool($val) || is_numeric($val)) && ((float) (int) $val === (float) $val) && settype($val, 'int'); case 'float': return ($val === NULL || is_bool($val) || is_numeric($val)) && settype($val, 'float'); case 'scalar': case 'array': case 'object': case 'callable': case 'resource': case 'null': return call_user_func("is_$type", $val); default: return $val instanceof $type; } } /********************* extension methods ****************d*g**/ /** * Adds a method to class. * @param string * @param string * @param mixed callable * @return void */ public static function setExtensionMethod($class, $name, $callback) { $name = strtolower($name); self::$extMethods[$name][$class] = Callback::check($callback); self::$extMethods[$name][''] = NULL; } /** * Returns extension method. * @param string * @param string * @return mixed */ public static function getExtensionMethod($class, $name) { $list = & self::$extMethods[strtolower($name)]; $cache = & $list[''][$class]; if (isset($cache)) { return $cache; } foreach ([$class] + class_parents($class) + class_implements($class) as $cl) { if (isset($list[$cl])) { return $cache = $list[$cl]; } } return $cache = FALSE; } /** * Returns extension methods. * @param string * @return array */ public static function getExtensionMethods($class) { $res = []; foreach (array_keys(self::$extMethods) as $name) { if ($cb = self::getExtensionMethod($class, $name)) { $res[$name] = $cb; } } return $res; } /********************* utilities ****************d*g**/ /** * Finds the best suggestion (for 8-bit encoding). * @return string|NULL * @internal */ public static function getSuggestion(array $possibilities, $value) { $norm = preg_replace($re = '#^(get|set|has|is|add)(?=[A-Z])#', '', $value); $best = NULL; $min = (strlen($value) / 4 + 1) * 10 + .1; foreach (array_unique($possibilities, SORT_REGULAR) as $item) { $item = $item instanceof \Reflector ? $item->getName() : $item; if ($item !== $value && ( ($len = levenshtein($item, $value, 10, 11, 10)) < $min || ($len = levenshtein(preg_replace($re, '', $item), $norm, 10, 11, 10) + 20) < $min )) { $min = $len; $best = $item; } } return $best; } private static function parseFullDoc(\ReflectionClass $rc, $pattern) { do { $doc[] = $rc->getDocComment(); } while ($rc = $rc->getParentClass()); return preg_match_all($pattern, implode($doc), $m) ? $m[1] : []; } /** * Checks if the public non-static property exists. * @return bool|'event' * @internal */ public static function hasProperty($class, $name) { static $cache; $prop = & $cache[$class][$name]; if ($prop === NULL) { $prop = FALSE; try { $rp = new \ReflectionProperty($class, $name); if ($rp->isPublic() && !$rp->isStatic()) { $prop = $name >= 'onA' && $name < 'on_' ? 'event' : TRUE; } } catch (\ReflectionException $e) { } } return $prop; } /** * Returns array of public (static, non-static and magic) methods. * @return array * @internal */ public static function & getMethods($class) { static $cache; if (!isset($cache[$class])) { $cache[$class] = array_fill_keys(get_class_methods($class), 0) + self::getMagicMethods($class); if ($parent = get_parent_class($class)) { $cache[$class] += self::getMethods($parent); } } return $cache[$class]; } /** @internal */ public static function getSource() { foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) { if (isset($item['file']) && dirname($item['file']) !== __DIR__) { return " in $item[file]:$item[line]"; } } } } Nette-2.4-20160731/Nette/Utils/Object.php0000644000000000000000000001026112747434604016146 0ustar rootroot * $val = $obj->label; // equivalent to $val = $obj->getLabel(); * $obj->label = 'Nette'; // equivalent to $obj->setLabel('Nette'); * * Property names are case-sensitive, and they are written in the camelCaps * or PascalCaps. * * Event functionality is provided by declaration of property named 'on{Something}' * Multiple handlers are allowed. * * public $onClick; // declaration in class * $this->onClick[] = 'callback'; // attaching event handler * if (!empty($this->onClick)) ... // are there any handlers? * $this->onClick($sender, $arg); // raises the event with arguments * * * Adding method to class (i.e. to all instances) works similar to JavaScript * prototype property. The syntax for adding a new method is: * * MyClass::extensionMethod('newMethod', function (MyClass $obj, $arg, ...) { ... }); * $obj = new MyClass; * $obj->newMethod($x); * * * @property-read Nette\Reflection\ClassType|\ReflectionClass $reflection */ abstract class Object { /** * Access to reflection. * @return Nette\Reflection\ClassType|\ReflectionClass */ public static function getReflection() { $class = class_exists(Nette\Reflection\ClassType::class) ? Nette\Reflection\ClassType::class : 'ReflectionClass'; return new $class(get_called_class()); } /** * Call to undefined method. * @param string method name * @param array arguments * @return mixed * @throws MemberAccessException */ public function __call($name, $args) { return Nette\Utils\ObjectMixin::call($this, $name, $args); } /** * Call to undefined static method. * @param string method name (in lower case!) * @param array arguments * @return mixed * @throws MemberAccessException */ public static function __callStatic($name, $args) { return Nette\Utils\ObjectMixin::callStatic(get_called_class(), $name, $args); } /** * Adding method to class. * @param string method name * @param callable * @return mixed */ public static function extensionMethod($name, $callback = NULL) { if (strpos($name, '::') === FALSE) { $class = get_called_class(); } else { list($class, $name) = explode('::', $name); $class = (new \ReflectionClass($class))->getName(); } if ($callback === NULL) { return Nette\Utils\ObjectMixin::getExtensionMethod($class, $name); } else { Nette\Utils\ObjectMixin::setExtensionMethod($class, $name, $callback); } } /** * Returns property value. Do not call directly. * @param string property name * @return mixed property value * @throws MemberAccessException if the property is not defined. */ public function &__get($name) { return Nette\Utils\ObjectMixin::get($this, $name); } /** * Sets value of a property. Do not call directly. * @param string property name * @param mixed property value * @return void * @throws MemberAccessException if the property is not defined or is read-only */ public function __set($name, $value) { Nette\Utils\ObjectMixin::set($this, $name, $value); } /** * Is property defined? * @param string property name * @return bool */ public function __isset($name) { return Nette\Utils\ObjectMixin::has($this, $name); } /** * Access to undeclared property. * @param string property name * @return void * @throws MemberAccessException */ public function __unset($name) { Nette\Utils\ObjectMixin::remove($this, $name); } } Nette-2.4-20160731/Nette/Utils/Json.php0000644000000000000000000000377112747434604015661 0ustar rootroot * $image = Image::fromFile('nette.jpg'); * $image->resize(150, 100); * $image->sharpen(); * $image->send(); * * * @method void alphaBlending(bool $on) * @method void antialias(bool $on) * @method void arc($x, $y, $w, $h, $start, $end, $color) * @method void char(int $font, $x, $y, string $char, $color) * @method void charUp(int $font, $x, $y, string $char, $color) * @method int colorAllocate($red, $green, $blue) * @method int colorAllocateAlpha($red, $green, $blue, $alpha) * @method int colorAt($x, $y) * @method int colorClosest($red, $green, $blue) * @method int colorClosestAlpha($red, $green, $blue, $alpha) * @method int colorClosestHWB($red, $green, $blue) * @method void colorDeallocate($color) * @method int colorExact($red, $green, $blue) * @method int colorExactAlpha($red, $green, $blue, $alpha) * @method void colorMatch(Image $image2) * @method int colorResolve($red, $green, $blue) * @method int colorResolveAlpha($red, $green, $blue, $alpha) * @method void colorSet($index, $red, $green, $blue) * @method array colorsForIndex($index) * @method int colorsTotal() * @method int colorTransparent($color = NULL) * @method void convolution(array $matrix, float $div, float $offset) * @method void copy(Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH) * @method void copyMerge(Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH, $opacity) * @method void copyMergeGray(Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH, $opacity) * @method void copyResampled(Image $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH) * @method void copyResized(Image $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH) * @method Image cropAuto(int $mode = -1, float $threshold = .5, int $color = -1) * @method void dashedLine($x1, $y1, $x2, $y2, $color) * @method void ellipse($cx, $cy, $w, $h, $color) * @method void fill($x, $y, $color) * @method void filledArc($cx, $cy, $w, $h, $s, $e, $color, $style) * @method void filledEllipse($cx, $cy, $w, $h, $color) * @method void filledPolygon(array $points, $numPoints, $color) * @method void filledRectangle($x1, $y1, $x2, $y2, $color) * @method void fillToBorder($x, $y, $border, $color) * @method void filter($filtertype) * @method void flip(int $mode) * @method array ftText($size, $angle, $x, $y, $col, string $fontFile, string $text, array $extrainfo = NULL) * @method void gammaCorrect(float $inputgamma, float $outputgamma) * @method int interlace($interlace = NULL) * @method bool isTrueColor() * @method void layerEffect($effect) * @method void line($x1, $y1, $x2, $y2, $color) * @method void paletteCopy(Image $source) * @method void paletteToTrueColor() * @method void polygon(array $points, $numPoints, $color) * @method array psText(string $text, $font, $size, $color, $backgroundColor, $x, $y, $space = NULL, $tightness = NULL, float $angle = NULL, $antialiasSteps = NULL) * @method void rectangle($x1, $y1, $x2, $y2, $col) * @method Image rotate(float $angle, $backgroundColor) * @method void saveAlpha(bool $saveflag) * @method Image scale(int $newWidth, int $newHeight = -1, int $mode = IMG_BILINEAR_FIXED) * @method void setBrush(Image $brush) * @method void setPixel($x, $y, $color) * @method void setStyle(array $style) * @method void setThickness($thickness) * @method void setTile(Image $tile) * @method void string($font, $x, $y, string $s, $col) * @method void stringUp($font, $x, $y, string $s, $col) * @method void trueColorToPalette(bool $dither, $ncolors) * @method array ttfText($size, $angle, $x, $y, $color, string $fontfile, string $text) * @property-read int $width * @property-read int $height * @property-read resource $imageResource */ class Image { use Nette\SmartObject; /** {@link resize()} only shrinks images */ const SHRINK_ONLY = 0b0001; /** {@link resize()} will ignore aspect ratio */ const STRETCH = 0b0010; /** {@link resize()} fits in given area so its dimensions are less than or equal to the required dimensions */ const FIT = 0b0000; /** {@link resize()} fills given area so its dimensions are greater than or equal to the required dimensions */ const FILL = 0b0100; /** {@link resize()} fills given area exactly */ const EXACT = 0b1000; /** image types */ const JPEG = IMAGETYPE_JPEG, PNG = IMAGETYPE_PNG, GIF = IMAGETYPE_GIF; const EMPTY_GIF = "GIF89a\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;"; /** @deprecated */ const ENLARGE = 0; /** @var resource */ private $image; /** * Returns RGB color. * @param int red 0..255 * @param int green 0..255 * @param int blue 0..255 * @param int transparency 0..127 * @return array */ public static function rgb($red, $green, $blue, $transparency = 0) { return [ 'red' => max(0, min(255, (int) $red)), 'green' => max(0, min(255, (int) $green)), 'blue' => max(0, min(255, (int) $blue)), 'alpha' => max(0, min(127, (int) $transparency)), ]; } /** * Opens image from file. * @param string * @param mixed detected image format * @throws Nette\NotSupportedException if gd extension is not loaded * @throws UnknownImageFileException if file not found or file type is not known * @return self */ public static function fromFile($file, & $format = NULL) { if (!extension_loaded('gd')) { throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } static $funcs = [ self::JPEG => 'imagecreatefromjpeg', self::PNG => 'imagecreatefrompng', self::GIF => 'imagecreatefromgif', ]; $format = @getimagesize($file)[2]; // @ - files smaller than 12 bytes causes read error if (!isset($funcs[$format])) { throw new UnknownImageFileException(is_file($file) ? "Unknown type of file '$file'." : "File '$file' not found."); } return new static(Callback::invokeSafe($funcs[$format], [$file], function ($message) { throw new ImageException($message); })); } /** * Create a new image from the image stream in the string. * @param string * @param mixed detected image format * @return self * @throws ImageException */ public static function fromString($s, & $format = NULL) { if (!extension_loaded('gd')) { throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } if (func_num_args() > 1) { $tmp = @getimagesizefromstring($s)[2]; // @ - strings smaller than 12 bytes causes read error $format = in_array($tmp, [self::JPEG, self::PNG, self::GIF], TRUE) ? $tmp : NULL; } return new static(Callback::invokeSafe('imagecreatefromstring', [$s], function ($message) { throw new ImageException($message); })); } /** * Creates blank image. * @param int * @param int * @param array * @return self */ public static function fromBlank($width, $height, $color = NULL) { if (!extension_loaded('gd')) { throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } $width = (int) $width; $height = (int) $height; if ($width < 1 || $height < 1) { throw new Nette\InvalidArgumentException('Image width and height must be greater than zero.'); } $image = imagecreatetruecolor($width, $height); if (is_array($color)) { $color += ['alpha' => 0]; $color = imagecolorresolvealpha($image, $color['red'], $color['green'], $color['blue'], $color['alpha']); imagealphablending($image, FALSE); imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $color); imagealphablending($image, TRUE); } return new static($image); } /** * Wraps GD image. * @param resource */ public function __construct($image) { $this->setImageResource($image); imagesavealpha($image, TRUE); } /** * Returns image width. * @return int */ public function getWidth() { return imagesx($this->image); } /** * Returns image height. * @return int */ public function getHeight() { return imagesy($this->image); } /** * Sets image resource. * @param resource * @return self */ protected function setImageResource($image) { if (!is_resource($image) || get_resource_type($image) !== 'gd') { throw new Nette\InvalidArgumentException('Image is not valid.'); } $this->image = $image; return $this; } /** * Returns image GD resource. * @return resource */ public function getImageResource() { return $this->image; } /** * Resizes image. * @param mixed width in pixels or percent * @param mixed height in pixels or percent * @param int flags * @return self */ public function resize($width, $height, $flags = self::FIT) { if ($flags & self::EXACT) { return $this->resize($width, $height, self::FILL)->crop('50%', '50%', $width, $height); } list($newWidth, $newHeight) = static::calculateSize($this->getWidth(), $this->getHeight(), $width, $height, $flags); if ($newWidth !== $this->getWidth() || $newHeight !== $this->getHeight()) { // resize $newImage = static::fromBlank($newWidth, $newHeight, self::RGB(0, 0, 0, 127))->getImageResource(); imagecopyresampled( $newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->getWidth(), $this->getHeight() ); $this->image = $newImage; } if ($width < 0 || $height < 0) { imageflip($this->image, $width < 0 ? ($height < 0 ? IMG_FLIP_BOTH : IMG_FLIP_HORIZONTAL) : IMG_FLIP_VERTICAL); } return $this; } /** * Calculates dimensions of resized image. * @param mixed source width * @param mixed source height * @param mixed width in pixels or percent * @param mixed height in pixels or percent * @param int flags * @return array */ public static function calculateSize($srcWidth, $srcHeight, $newWidth, $newHeight, $flags = self::FIT) { if (is_string($newWidth) && substr($newWidth, -1) === '%') { $newWidth = (int) round($srcWidth / 100 * abs($newWidth)); $percents = TRUE; } else { $newWidth = (int) abs($newWidth); } if (is_string($newHeight) && substr($newHeight, -1) === '%') { $newHeight = (int) round($srcHeight / 100 * abs($newHeight)); $flags |= empty($percents) ? 0 : self::STRETCH; } else { $newHeight = (int) abs($newHeight); } if ($flags & self::STRETCH) { // non-proportional if (empty($newWidth) || empty($newHeight)) { throw new Nette\InvalidArgumentException('For stretching must be both width and height specified.'); } if ($flags & self::SHRINK_ONLY) { $newWidth = (int) round($srcWidth * min(1, $newWidth / $srcWidth)); $newHeight = (int) round($srcHeight * min(1, $newHeight / $srcHeight)); } } else { // proportional if (empty($newWidth) && empty($newHeight)) { throw new Nette\InvalidArgumentException('At least width or height must be specified.'); } $scale = []; if ($newWidth > 0) { // fit width $scale[] = $newWidth / $srcWidth; } if ($newHeight > 0) { // fit height $scale[] = $newHeight / $srcHeight; } if ($flags & self::FILL) { $scale = [max($scale)]; } if ($flags & self::SHRINK_ONLY) { $scale[] = 1; } $scale = min($scale); $newWidth = (int) round($srcWidth * $scale); $newHeight = (int) round($srcHeight * $scale); } return [max($newWidth, 1), max($newHeight, 1)]; } /** * Crops image. * @param mixed x-offset in pixels or percent * @param mixed y-offset in pixels or percent * @param mixed width in pixels or percent * @param mixed height in pixels or percent * @return self */ public function crop($left, $top, $width, $height) { list($r['x'], $r['y'], $r['width'], $r['height']) = static::calculateCutout($this->getWidth(), $this->getHeight(), $left, $top, $width, $height); if (PHP_VERSION_ID > 50611) { // PHP bug #67447 $this->image = imagecrop($this->image, $r); } else { $newImage = static::fromBlank($r['width'], $r['height'], self::RGB(0, 0, 0, 127))->getImageResource(); imagecopy($newImage, $this->image, 0, 0, $r['x'], $r['y'], $r['width'], $r['height']); $this->image = $newImage; } return $this; } /** * Calculates dimensions of cutout in image. * @param mixed source width * @param mixed source height * @param mixed x-offset in pixels or percent * @param mixed y-offset in pixels or percent * @param mixed width in pixels or percent * @param mixed height in pixels or percent * @return array */ public static function calculateCutout($srcWidth, $srcHeight, $left, $top, $newWidth, $newHeight) { if (is_string($newWidth) && substr($newWidth, -1) === '%') { $newWidth = (int) round($srcWidth / 100 * $newWidth); } if (is_string($newHeight) && substr($newHeight, -1) === '%') { $newHeight = (int) round($srcHeight / 100 * $newHeight); } if (is_string($left) && substr($left, -1) === '%') { $left = (int) round(($srcWidth - $newWidth) / 100 * $left); } if (is_string($top) && substr($top, -1) === '%') { $top = (int) round(($srcHeight - $newHeight) / 100 * $top); } if ($left < 0) { $newWidth += $left; $left = 0; } if ($top < 0) { $newHeight += $top; $top = 0; } $newWidth = min($newWidth, $srcWidth - $left); $newHeight = min($newHeight, $srcHeight - $top); return [$left, $top, $newWidth, $newHeight]; } /** * Sharpen image. * @return self */ public function sharpen() { imageconvolution($this->image, [ // my magic numbers ;) [-1, -1, -1], [-1, 24, -1], [-1, -1, -1], ], 16, 0); return $this; } /** * Puts another image into this image. * @param Image * @param mixed x-coordinate in pixels or percent * @param mixed y-coordinate in pixels or percent * @param int opacity 0..100 * @return self */ public function place(Image $image, $left = 0, $top = 0, $opacity = 100) { $opacity = max(0, min(100, (int) $opacity)); if ($opacity === 0) { return $this; } $width = $image->getWidth(); $height = $image->getHeight(); if (is_string($left) && substr($left, -1) === '%') { $left = (int) round(($this->getWidth() - $width) / 100 * $left); } if (is_string($top) && substr($top, -1) === '%') { $top = (int) round(($this->getHeight() - $height) / 100 * $top); } $output = $input = $image->image; if ($opacity < 100) { for ($i = 0; $i < 128; $i++) { $tbl[$i] = round(127 - (127 - $i) * $opacity / 100); } $output = imagecreatetruecolor($width, $height); imagealphablending($output, FALSE); if (!$image->isTrueColor()) { $input = $output; imagefilledrectangle($output, 0, 0, $width, $height, imagecolorallocatealpha($output, 0, 0, 0, 127)); imagecopy($output, $image->image, 0, 0, 0, 0, $width, $height); } for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { $c = \imagecolorat($input, $x, $y); $c = ($c & 0xFFFFFF) + ($tbl[$c >> 24] << 24); \imagesetpixel($output, $x, $y, $c); } } imagealphablending($output, TRUE); } imagecopy( $this->image, $output, $left, $top, 0, 0, $width, $height ); return $this; } /** * Saves image to the file. * @param string filename * @param int quality 0..100 (for JPEG and PNG) * @param int optional image type * @return bool TRUE on success or FALSE on failure. */ public function save($file = NULL, $quality = NULL, $type = NULL) { if ($type === NULL) { switch (strtolower($ext = pathinfo($file, PATHINFO_EXTENSION))) { case 'jpg': case 'jpeg': $type = self::JPEG; break; case 'png': $type = self::PNG; break; case 'gif': $type = self::GIF; break; default: throw new Nette\InvalidArgumentException("Unsupported file extension '$ext'."); } } switch ($type) { case self::JPEG: $quality = $quality === NULL ? 85 : max(0, min(100, (int) $quality)); return imagejpeg($this->image, $file, $quality); case self::PNG: $quality = $quality === NULL ? 9 : max(0, min(9, (int) $quality)); return imagepng($this->image, $file, $quality); case self::GIF: return imagegif($this->image, $file); default: throw new Nette\InvalidArgumentException("Unsupported image type '$type'."); } } /** * Outputs image to string. * @param int image type * @param int quality 0..100 (for JPEG and PNG) * @return string */ public function toString($type = self::JPEG, $quality = NULL) { ob_start(function () {}); $this->save(NULL, $quality, $type); return ob_get_clean(); } /** * Outputs image to string. * @return string */ public function __toString() { try { return $this->toString(); } catch (\Throwable $e) { } catch (\Exception $e) { } if (isset($e)) { if (func_num_args()) { throw $e; } trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR); } } /** * Outputs image to browser. * @param int image type * @param int quality 0..100 (for JPEG and PNG) * @return bool TRUE on success or FALSE on failure. */ public function send($type = self::JPEG, $quality = NULL) { if (!in_array($type, [self::JPEG, self::PNG, self::GIF], TRUE)) { throw new Nette\InvalidArgumentException("Unsupported image type '$type'."); } header('Content-Type: ' . image_type_to_mime_type($type)); return $this->save(NULL, $quality, $type); } /** * Call to undefined method. * * @param string method name * @param array arguments * @return mixed * @throws Nette\MemberAccessException */ public function __call($name, $args) { $function = 'image' . $name; if (!function_exists($function)) { ObjectMixin::strictCall(get_class($this), $name); } foreach ($args as $key => $value) { if ($value instanceof self) { $args[$key] = $value->getImageResource(); } elseif (is_array($value) && isset($value['red'])) { // rgb $args[$key] = imagecolorallocatealpha( $this->image, $value['red'], $value['green'], $value['blue'], $value['alpha'] ) ?: imagecolorresolvealpha( $this->image, $value['red'], $value['green'], $value['blue'], $value['alpha'] ); } } $res = $function($this->image, ...$args); return is_resource($res) && get_resource_type($res) === 'gd' ? $this->setImageResource($res) : $res; } public function __clone() { ob_start(function () {}); imagegd2($this->image); $this->setImageResource(imagecreatefromstring(ob_get_clean())); } } Nette-2.4-20160731/Nette/Utils/IHtmlString.php0000644000000000000000000000040412747434604017142 0ustar rootroot * $el = Html::el('a')->href($link)->setText('Nette'); * $el->class = 'myclass'; * echo $el; * * echo $el->startTag(), $el->endTag(); * */ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, IHtmlString { use Nette\SmartObject; /** @var string element's name */ private $name; /** @var bool is element empty? */ private $isEmpty; /** @var array element's attributes */ public $attrs = []; /** @var array of Html | string nodes */ protected $children = []; /** @var bool use XHTML syntax? */ public static $xhtml = FALSE; /** @var array empty (void) elements */ public static $emptyElements = [ 'img' => 1, 'hr' => 1, 'br' => 1, 'input' => 1, 'meta' => 1, 'area' => 1, 'embed' => 1, 'keygen' => 1, 'source' => 1, 'base' => 1, 'col' => 1, 'link' => 1, 'param' => 1, 'basefont' => 1, 'frame' => 1, 'isindex' => 1, 'wbr' => 1, 'command' => 1, 'track' => 1, ]; /** * Static factory. * @param string element name (or NULL) * @param array|string element's attributes or plain text content * @return self */ public static function el($name = NULL, $attrs = NULL) { $el = new static; $parts = explode(' ', (string) $name, 2); $el->setName($parts[0]); if (is_array($attrs)) { $el->attrs = $attrs; } elseif ($attrs !== NULL) { $el->setText($attrs); } if (isset($parts[1])) { foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i') as $m) { $el->attrs[$m[1]] = isset($m[3]) ? $m[3] : TRUE; } } return $el; } /** * Changes element's name. * @param string * @param bool Is element empty? * @return self * @throws Nette\InvalidArgumentException */ public function setName($name, $isEmpty = NULL) { if ($name !== NULL && !is_string($name)) { throw new Nette\InvalidArgumentException(sprintf('Name must be string or NULL, %s given.', gettype($name))); } $this->name = $name; $this->isEmpty = $isEmpty === NULL ? isset(static::$emptyElements[$name]) : (bool) $isEmpty; return $this; } /** * Returns element's name. * @return string */ public function getName() { return $this->name; } /** * Is element empty? * @return bool */ public function isEmpty() { return $this->isEmpty; } /** * Sets multiple attributes. * @param array * @return self */ public function addAttributes(array $attrs) { $this->attrs = array_merge($this->attrs, $attrs); return $this; } /** * Appends value to element's attribute. * @param string * @param string|array value to append * @param string|bool value option * @return self */ public function appendAttribute($name, $value, $option = TRUE) { if (is_array($value)) { $prev = isset($this->attrs[$name]) ? (array) $this->attrs[$name] : []; $this->attrs[$name] = $value + $prev; } elseif ((string) $value === '') { $tmp = & $this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists } elseif (!isset($this->attrs[$name]) || is_array($this->attrs[$name])) { // needs array $this->attrs[$name][$value] = $option; } else { $this->attrs[$name] = [$this->attrs[$name] => TRUE, $value => $option]; } return $this; } /** * Sets element's attribute. * @param string * @param mixed * @return self */ public function setAttribute($name, $value) { $this->attrs[$name] = $value; return $this; } /** * Returns element's attribute. * @param string * @return mixed */ public function getAttribute($name) { return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL; } /** * Unsets element's attribute. * @param string * @return self */ public function removeAttribute($name) { unset($this->attrs[$name]); return $this; } /** * Overloaded setter for element's attribute. * @param string HTML attribute name * @param mixed HTML attribute value * @return void */ public function __set($name, $value) { $this->attrs[$name] = $value; } /** * Overloaded getter for element's attribute. * @param string HTML attribute name * @return mixed HTML attribute value */ public function &__get($name) { return $this->attrs[$name]; } /** * Overloaded tester for element's attribute. * @param string HTML attribute name * @return bool */ public function __isset($name) { return isset($this->attrs[$name]); } /** * Overloaded unsetter for element's attribute. * @param string HTML attribute name * @return void */ public function __unset($name) { unset($this->attrs[$name]); } /** * Overloaded setter for element's attribute. * @param string HTML attribute name * @param array (string) HTML attribute value or pair? * @return mixed */ public function __call($m, $args) { $p = substr($m, 0, 3); if ($p === 'get' || $p === 'set' || $p === 'add') { $m = substr($m, 3); $m[0] = $m[0] | "\x20"; if ($p === 'get') { return isset($this->attrs[$m]) ? $this->attrs[$m] : NULL; } elseif ($p === 'add') { $args[] = TRUE; } } if (count($args) === 0) { // invalid } elseif (count($args) === 1) { // set $this->attrs[$m] = $args[0]; } else { // add $this->appendAttribute($m, $args[0], $args[1]); } return $this; } /** * Special setter for element's attribute. * @param string path * @param array query * @return self */ public function href($path, $query = NULL) { if ($query) { $query = http_build_query($query, '', '&'); if ($query !== '') { $path .= '?' . $query; } } $this->attrs['href'] = $path; return $this; } /** * Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'. * @return self */ public function data($name, $value = NULL) { if (func_num_args() === 1) { $this->attrs['data'] = $name; } else { $this->attrs["data-$name"] = is_bool($value) ? json_encode($value) : $value; } return $this; } /** * Sets element's HTML content. * @param string raw HTML string * @return self * @throws Nette\InvalidArgumentException */ public function setHtml($html) { if (is_array($html)) { throw new Nette\InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html))); } $this->removeChildren(); $this->children[] = (string) $html; return $this; } /** * Returns element's HTML content. * @return string */ public function getHtml() { $s = ''; foreach ($this->children as $child) { if (is_object($child)) { $s .= $child->render(); } else { $s .= $child; } } return $s; } /** * Sets element's textual content. * @param string * @return self * @throws Nette\InvalidArgumentException */ public function setText($text) { if (!is_array($text) && !$text instanceof self) { $text = htmlspecialchars((string) $text, ENT_NOQUOTES, 'UTF-8'); } return $this->setHtml($text); } /** * Returns element's textual content. * @return string */ public function getText() { return html_entity_decode(strip_tags($this->getHtml()), ENT_QUOTES, 'UTF-8'); } /** * @deprecated */ public function add($child) { trigger_error(__METHOD__ . '() is deprecated, use addHtml() or addText() instead.', E_USER_DEPRECATED); return $this->addHtml($child); } /** * Adds new element's child. * @param Html|string Html node or raw HTML string * @return self */ public function addHtml($child) { return $this->insert(NULL, $child); } /** * Appends plain-text string to element content. * @param string plain-text string * @return self */ public function addText($text) { $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); return $this->insert(NULL, $text); } /** * Creates and adds a new Html child. * @param string elements's name * @param array|string element's attributes or raw HTML string * @return self created element */ public function create($name, $attrs = NULL) { $this->insert(NULL, $child = static::el($name, $attrs)); return $child; } /** * Inserts child node. * @param int|NULL position or NULL for appending * @param Html|string Html node or raw HTML string * @param bool * @return self * @throws Nette\InvalidArgumentException */ public function insert($index, $child, $replace = FALSE) { if ($child instanceof self || is_scalar($child)) { if ($index === NULL) { // append $this->children[] = $child; } else { // insert or replace array_splice($this->children, (int) $index, $replace ? 1 : 0, [$child]); } } else { throw new Nette\InvalidArgumentException(sprintf('Child node must be scalar or Html object, %s given.', is_object($child) ? get_class($child) : gettype($child))); } return $this; } /** * Inserts (replaces) child node (\ArrayAccess implementation). * @param int|NULL position or NULL for appending * @param Html|string Html node or raw HTML string * @return void */ public function offsetSet($index, $child) { $this->insert($index, $child, TRUE); } /** * Returns child node (\ArrayAccess implementation). * @param int * @return self|string */ public function offsetGet($index) { return $this->children[$index]; } /** * Exists child node? (\ArrayAccess implementation). * @param int * @return bool */ public function offsetExists($index) { return isset($this->children[$index]); } /** * Removes child node (\ArrayAccess implementation). * @param int * @return void */ public function offsetUnset($index) { if (isset($this->children[$index])) { array_splice($this->children, (int) $index, 1); } } /** * Returns children count. * @return int */ public function count() { return count($this->children); } /** * Removes all children. * @return void */ public function removeChildren() { $this->children = []; } /** * Iterates over elements. * @return \ArrayIterator */ public function getIterator() { return new \ArrayIterator($this->children); } /** * Returns all children. * @return array */ public function getChildren() { return $this->children; } /** * Renders element's start tag, content and end tag. * @param int * @return string */ public function render($indent = NULL) { $s = $this->startTag(); if (!$this->isEmpty) { // add content if ($indent !== NULL) { $indent++; } foreach ($this->children as $child) { if (is_object($child)) { $s .= $child->render($indent); } else { $s .= $child; } } // add end tag $s .= $this->endTag(); } if ($indent !== NULL) { return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2)); } return $s; } public function __toString() { try { return $this->render(); } catch (\Throwable $e) { } catch (\Exception $e) { } trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR); } /** * Returns element's start tag. * @return string */ public function startTag() { if ($this->name) { return '<' . $this->name . $this->attributes() . (static::$xhtml && $this->isEmpty ? ' />' : '>'); } else { return ''; } } /** * Returns element's end tag. * @return string */ public function endTag() { return $this->name && !$this->isEmpty ? 'name . '>' : ''; } /** * Returns element's attributes. * @return string * @internal */ public function attributes() { if (!is_array($this->attrs)) { return ''; } $s = ''; $attrs = $this->attrs; if (isset($attrs['data']) && is_array($attrs['data'])) { // deprecated trigger_error('Expanded attribute "data" is deprecated.', E_USER_DEPRECATED); foreach ($attrs['data'] as $key => $value) { $attrs['data-' . $key] = $value; } unset($attrs['data']); } foreach ($attrs as $key => $value) { if ($value === NULL || $value === FALSE) { continue; } elseif ($value === TRUE) { if (static::$xhtml) { $s .= ' ' . $key . '="' . $key . '"'; } else { $s .= ' ' . $key; } continue; } elseif (is_array($value)) { if (strncmp($key, 'data-', 5) === 0) { $value = Json::encode($value); } else { $tmp = NULL; foreach ($value as $k => $v) { if ($v != NULL) { // intentionally ==, skip NULLs & empty string // composite 'style' vs. 'others' $tmp[] = $v === TRUE ? $k : (is_string($k) ? $k . ':' . $v : $v); } } if ($tmp === NULL) { continue; } $value = implode($key === 'style' || !strncmp($key, 'on', 2) ? ';' : ' ', $tmp); } } elseif (is_float($value)) { $value = rtrim(rtrim(number_format($value, 10, '.', ''), '0'), '.'); } else { $value = (string) $value; } $q = strpos($value, '"') === FALSE ? '"' : "'"; $s .= ' ' . $key . '=' . $q . str_replace( ['&', $q, '<'], ['&', $q === '"' ? '"' : ''', self::$xhtml ? '<' : '<'], $value ) . (strpos($value, '`') !== FALSE && strpbrk($value, ' <>"\'') === FALSE ? ' ' : '') . $q; } $s = str_replace('@', '@', $s); return $s; } /** * Clones all children too. */ public function __clone() { foreach ($this->children as $key => $value) { if (is_object($value)) { $this->children[$key] = clone $value; } } } } Nette-2.4-20160731/Nette/Utils/FileSystem.php0000644000000000000000000001011512747434604017022 0ustar rootrootgetPathname()); } foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) { if ($item->isDir()) { static::createDir($dest . '/' . $iterator->getSubPathName()); } else { static::copy($item->getPathname(), $dest . '/' . $iterator->getSubPathName()); } } } else { static::createDir(dirname($dest)); if (@stream_copy_to_stream(fopen($source, 'r'), fopen($dest, 'w')) === FALSE) { // @ is escalated to exception throw new Nette\IOException("Unable to copy file '$source' to '$dest'."); } } } /** * Deletes a file or directory. * @return void * @throws Nette\IOException */ public static function delete($path) { if (is_file($path) || is_link($path)) { $func = DIRECTORY_SEPARATOR === '\\' && is_dir($path) ? 'rmdir' : 'unlink'; if (!@$func($path)) { // @ is escalated to exception throw new Nette\IOException("Unable to delete '$path'."); } } elseif (is_dir($path)) { foreach (new \FilesystemIterator($path) as $item) { static::delete($item->getPathname()); } if (!@rmdir($path)) { // @ is escalated to exception throw new Nette\IOException("Unable to delete directory '$path'."); } } } /** * Renames a file or directory. * @return void * @throws Nette\IOException * @throws Nette\InvalidStateException if the target file or directory already exist */ public static function rename($name, $newName, $overwrite = TRUE) { if (!$overwrite && file_exists($newName)) { throw new Nette\InvalidStateException("File or directory '$newName' already exists."); } elseif (!file_exists($name)) { throw new Nette\IOException("File or directory '$name' not found."); } else { static::createDir(dirname($newName)); static::delete($newName); if (!@rename($name, $newName)) { // @ is escalated to exception throw new Nette\IOException("Unable to rename file or directory '$name' to '$newName'."); } } } /** * Reads file content. * @return string * @throws Nette\IOException */ public static function read($file) { $content = @file_get_contents($file); // @ is escalated to exception if ($content === FALSE) { throw new Nette\IOException("Unable to read file '$file'."); } return $content; } /** * Writes a string to a file. * @return void * @throws Nette\IOException */ public static function write($file, $content, $mode = 0666) { static::createDir(dirname($file)); if (@file_put_contents($file, $content) === FALSE) { // @ is escalated to exception throw new Nette\IOException("Unable to write file '$file'."); } if ($mode !== NULL && !@chmod($file, $mode)) { // @ is escalated to exception throw new Nette\IOException("Unable to chmod file '$file'."); } } /** * Is path absolute? * @return bool */ public static function isAbsolute($path) { return (bool) preg_match('#([a-z]:)?[/\\\\]|[a-z][a-z0-9+.-]*://#Ai', $path); } } Nette-2.4-20160731/Nette/Utils/exceptions.php0000644000000000000000000000563612747434604017133 0ustar rootrootformat('Y-m-d H:i:s'), $time->getTimezone()); } elseif (is_numeric($time)) { if ($time <= self::YEAR) { $time += time(); } return (new static('@' . $time))->setTimeZone(new \DateTimeZone(date_default_timezone_get())); } else { // textual or NULL return new static($time); } } /** * @return string */ public function __toString() { return $this->format('Y-m-d H:i:s'); } /** * @param string * @return self */ public function modifyClone($modify = '') { $dolly = clone $this; return $modify ? $dolly->modify($modify) : $dolly; } /** * @param int * @return self */ public function setTimestamp($timestamp) { $zone = $this->getTimezone(); $this->__construct('@' . $timestamp); return $this->setTimeZone($zone); } /** * @return int|string */ public function getTimestamp() { $ts = $this->format('U'); return is_float($tmp = $ts * 1) ? $ts : $tmp; } /** * Returns new DateTime object formatted according to the specified format. * @param string The format the $time parameter should be in * @param string String representing the time * @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed) * @return self|FALSE */ public static function createFromFormat($format, $time, $timezone = NULL) { if ($timezone === NULL) { $timezone = new \DateTimeZone(date_default_timezone_get()); } elseif (is_string($timezone)) { $timezone = new \DateTimeZone($timezone); } elseif (!$timezone instanceof \DateTimeZone) { throw new Nette\InvalidArgumentException('Invalid timezone given'); } $date = parent::createFromFormat($format, $time, $timezone); return $date ? static::from($date) : FALSE; } /** * Returns JSON representation in ISO 8601 (used by JavaScript). * @return string */ public function jsonSerialize() { return $this->format('c'); } } Nette-2.4-20160731/Nette/Utils/Callback.php0000644000000000000000000001137112747434604016437 0ustar rootrootgetClosure(); } elseif (is_array($callable) && method_exists($callable[0], $callable[1])) { return (new \ReflectionMethod($callable[0], $callable[1]))->getClosure($callable[0]); } self::check($callable); $_callable_ = $callable; return function (...$args) use ($_callable_) { return $_callable_(...$args); }; } /** * Invokes callback. * @return mixed */ public static function invoke($callable, ...$args) { self::check($callable); return call_user_func_array($callable, $args); } /** * Invokes callback with an array of parameters. * @return mixed */ public static function invokeArgs($callable, array $args = []) { self::check($callable); return call_user_func_array($callable, $args); } /** * Invokes internal PHP function with own error handler. * @param string * @return mixed */ public static function invokeSafe($function, array $args, $onError) { $prev = set_error_handler(function ($severity, $message, $file) use ($onError, & $prev, $function) { if ($file === '' && defined('HHVM_VERSION')) { // https://github.com/facebook/hhvm/issues/4625 $file = func_get_arg(5)[1]['file']; } if ($file === __FILE__) { $msg = preg_replace("#^$function\(.*?\): #", '', $message); if ($onError($msg, $severity) !== FALSE) { return; } } return $prev ? $prev(...func_get_args()) : FALSE; }); try { $res = $function(...$args); restore_error_handler(); return $res; } catch (\Throwable $e) { restore_error_handler(); throw $e; } catch (\Exception $e) { restore_error_handler(); throw $e; } } /** * @return callable */ public static function check($callable, $syntax = FALSE) { if (!is_callable($callable, $syntax)) { throw new Nette\InvalidArgumentException($syntax ? 'Given value is not a callable type.' : sprintf("Callback '%s' is not callable.", self::toString($callable)) ); } return $callable; } /** * @return string */ public static function toString($callable) { if ($callable instanceof \Closure) { $inner = self::unwrap($callable); return '{closure' . ($inner instanceof \Closure ? '}' : ' ' . self::toString($inner) . '}'); } elseif (is_string($callable) && $callable[0] === "\0") { return '{lambda}'; } else { is_callable($callable, TRUE, $textual); return $textual; } } /** * @return \ReflectionMethod|\ReflectionFunction */ public static function toReflection($callable) { if ($callable instanceof \Closure) { $callable = self::unwrap($callable); } elseif ($callable instanceof Nette\Callback) { trigger_error('Nette\Callback is deprecated.', E_USER_DEPRECATED); $callable = $callable->getNative(); } $class = class_exists(Nette\Reflection\Method::class) ? Nette\Reflection\Method::class : 'ReflectionMethod'; if (is_string($callable) && strpos($callable, '::')) { return new $class($callable); } elseif (is_array($callable)) { return new $class($callable[0], $callable[1]); } elseif (is_object($callable) && !$callable instanceof \Closure) { return new $class($callable, '__invoke'); } else { $class = class_exists(Nette\Reflection\GlobalFunction::class) ? Nette\Reflection\GlobalFunction::class : 'ReflectionFunction'; return new $class($callable); } } /** * @return bool */ public static function isStatic($callable) { return is_array($callable) ? is_string($callable[0]) : is_string($callable); } /** * Unwraps closure created by self::closure() * @internal * @return callable */ public static function unwrap(\Closure $closure) { $r = new \ReflectionFunction($closure); if (substr($r->getName(), -1) === '}') { $vars = $r->getStaticVariables(); return isset($vars['_callable_']) ? $vars['_callable_'] : $closure; } elseif ($obj = $r->getClosureThis()) { return [$obj, $r->getName()]; } elseif ($class = $r->getClosureScopeClass()) { return [$class->getName(), $r->getName()]; } else { return $r->getName(); } } } Nette-2.4-20160731/Nette/Utils/Arrays.php0000644000000000000000000001325412747434604016206 0ustar rootroot $v) { if (is_array($v) && is_array($arr2[$k])) { $res[$k] = self::mergeTree($v, $arr2[$k]); } } return $res; } /** * Searches the array for a given key and returns the offset if successful. * @return int|FALSE offset if it is found, FALSE otherwise */ public static function searchKey(array $arr, $key) { $foo = [$key => NULL]; return array_search(key($foo), array_keys($arr), TRUE); } /** * Inserts new array before item specified by key. * @return void */ public static function insertBefore(array & $arr, $key, array $inserted) { $offset = (int) self::searchKey($arr, $key); $arr = array_slice($arr, 0, $offset, TRUE) + $inserted + array_slice($arr, $offset, count($arr), TRUE); } /** * Inserts new array after item specified by key. * @return void */ public static function insertAfter(array & $arr, $key, array $inserted) { $offset = self::searchKey($arr, $key); $offset = $offset === FALSE ? count($arr) : $offset + 1; $arr = array_slice($arr, 0, $offset, TRUE) + $inserted + array_slice($arr, $offset, count($arr), TRUE); } /** * Renames key in array. * @return void */ public static function renameKey(array & $arr, $oldKey, $newKey) { $offset = self::searchKey($arr, $oldKey); if ($offset !== FALSE) { $keys = array_keys($arr); $keys[$offset] = $newKey; $arr = array_combine($keys, $arr); } } /** * Returns array entries that match the pattern. * @return array */ public static function grep(array $arr, $pattern, $flags = 0) { return Strings::pcre('preg_grep', [$pattern, $arr, $flags]); } /** * Returns flattened array. * @return array */ public static function flatten(array $arr, $preserveKeys = FALSE) { $res = []; $cb = $preserveKeys ? function ($v, $k) use (& $res) { $res[$k] = $v; } : function ($v) use (& $res) { $res[] = $v; }; array_walk_recursive($arr, $cb); return $res; } /** * Finds whether a variable is a zero-based integer indexed array. * @return bool */ public static function isList($value) { return is_array($value) && (!$value || array_keys($value) === range(0, count($value) - 1)); } /** * Reformats table to associative tree. Path looks like 'field|field[]field->field=field'. * @return array|\stdClass */ public static function associate(array $arr, $path) { $parts = is_array($path) ? $path : preg_split('#(\[\]|->|=|\|)#', $path, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (!$parts || $parts[0] === '=' || $parts[0] === '|' || $parts === ['->']) { throw new Nette\InvalidArgumentException("Invalid path '$path'."); } $res = $parts[0] === '->' ? new \stdClass : []; foreach ($arr as $rowOrig) { $row = (array) $rowOrig; $x = & $res; for ($i = 0; $i < count($parts); $i++) { $part = $parts[$i]; if ($part === '[]') { $x = & $x[]; } elseif ($part === '=') { if (isset($parts[++$i])) { $x = $row[$parts[$i]]; $row = NULL; } } elseif ($part === '->') { if (isset($parts[++$i])) { $x = & $x->{$row[$parts[$i]]}; } else { $row = is_object($rowOrig) ? $rowOrig : (object) $row; } } elseif ($part !== '|') { $x = & $x[(string) $row[$part]]; } } if ($x === NULL) { $x = $row; } } return $res; } /** * Normalizes to associative array. * @return array */ public static function normalize(array $arr, $filling = NULL) { $res = []; foreach ($arr as $k => $v) { $res[is_int($k) ? $v : $k] = is_int($k) ? $filling : $v; } return $res; } /** * Picks element from the array by key and return its value. * @param array * @param string|int array key * @param mixed * @return mixed * @throws Nette\InvalidArgumentException if item does not exist and default value is not provided */ public static function pick(array & $arr, $key, $default = NULL) { if (array_key_exists($key, $arr)) { $value = $arr[$key]; unset($arr[$key]); return $value; } elseif (func_num_args() < 3) { throw new Nette\InvalidArgumentException("Missing item '$key'."); } else { return $default; } } } Nette-2.4-20160731/Nette/Utils/ArrayList.php0000644000000000000000000000416612747434604016661 0ustar rootrootlist); } /** * Returns items count. * @return int */ public function count() { return count($this->list); } /** * Replaces or appends a item. * @param int|NULL * @param mixed * @return void * @throws Nette\OutOfRangeException */ public function offsetSet($index, $value) { if ($index === NULL) { $this->list[] = $value; } elseif ($index < 0 || $index >= count($this->list)) { throw new Nette\OutOfRangeException('Offset invalid or out of range'); } else { $this->list[(int) $index] = $value; } } /** * Returns a item. * @param int * @return mixed * @throws Nette\OutOfRangeException */ public function offsetGet($index) { if ($index < 0 || $index >= count($this->list)) { throw new Nette\OutOfRangeException('Offset invalid or out of range'); } return $this->list[(int) $index]; } /** * Determines whether a item exists. * @param int * @return bool */ public function offsetExists($index) { return $index >= 0 && $index < count($this->list); } /** * Removes the element at the specified position in this list. * @param int * @return void * @throws Nette\OutOfRangeException */ public function offsetUnset($index) { if ($index < 0 || $index >= count($this->list)) { throw new Nette\OutOfRangeException('Offset invalid or out of range'); } array_splice($this->list, (int) $index, 1); } /** * Prepends a item. * @param mixed * @return void */ public function prepend($value) { $first = array_slice($this->list, 0, 1); $this->offsetSet(0, $value); array_splice($this->list, 1, 0, $first); } } Nette-2.4-20160731/Nette/Utils/ArrayHash.php0000644000000000000000000000313712747434604016626 0ustar rootroot $value) { if ($recursive && is_array($value)) { $obj->$key = static::from($value, TRUE); } else { $obj->$key = $value; } } return $obj; } /** * Returns an iterator over all items. * @return \RecursiveArrayIterator */ public function getIterator() { return new \RecursiveArrayIterator((array) $this); } /** * Returns items count. * @return int */ public function count() { return count((array) $this); } /** * Replaces or appends a item. * @return void */ public function offsetSet($key, $value) { if (!is_scalar($key)) { // prevents NULL throw new Nette\InvalidArgumentException(sprintf('Key must be either a string or an integer, %s given.', gettype($key))); } $this->$key = $value; } /** * Returns a item. * @return mixed */ public function offsetGet($key) { return $this->$key; } /** * Determines whether a item exists. * @return bool */ public function offsetExists($key) { return isset($this->$key); } /** * Removes the element from this list. * @return void */ public function offsetUnset($key) { unset($this->$key); } } Nette-2.4-20160731/Nette/Tracy/0000755000000000000000000000000012747434604014211 5ustar rootrootNette-2.4-20160731/Nette/Tracy/OutputDebugger.php0000644000000000000000000000351512747434604017673 0ustar rootrootstart(); } public function start() { foreach (get_included_files() as $file) { if (fread(fopen($file, 'r'), 3) === self::BOM) { $this->list[] = [$file, 1, self::BOM]; } } ob_start([$this, 'handler'], 1); } /** @internal */ public function handler($s, $phase) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); if (isset($trace[0]['file'], $trace[0]['line'])) { $stack = $trace; unset($stack[0]['line'], $stack[0]['args']); $i = count($this->list); if ($i && $this->list[$i - 1][3] === $stack) { $this->list[$i - 1][2] .= $s; } else { $this->list[] = [$trace[0]['file'], $trace[0]['line'], $s, $stack]; } } if ($phase === PHP_OUTPUT_HANDLER_FINAL) { return $this->renderHtml(); } } private function renderHtml() { $res = ''; foreach ($this->list as $item) { $stack = []; foreach (array_slice($item[3], 1) as $t) { $t += ['class' => '', 'type' => '', 'function' => '']; $stack[] = "$t[class]$t[type]$t[function]()" . (isset($t['file'], $t['line']) ? ' in ' . basename($t['file']) . ":$t[line]" : ''); } $res .= '' . Helpers::editorLink($item[0], $item[1]) . ' ' . str_replace(self::BOM, 'BOM', Dumper::toHtml($item[2])) . "
\n"; } return $res . '
'; } } Nette-2.4-20160731/Nette/Tracy/Logger.php0000644000000000000000000001264512747434604016151 0ustar rootrootdirectory = $directory; $this->email = $email; $this->blueScreen = $blueScreen; $this->mailer = [$this, 'defaultMailer']; } /** * Logs message or exception to file and sends email notification. * @param string|\Exception|\Throwable * @param int one of constant ILogger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email) * @return string logged error filename */ public function log($message, $priority = self::INFO) { if (!$this->directory) { throw new \LogicException('Directory is not specified.'); } elseif (!is_dir($this->directory)) { throw new \RuntimeException("Directory '$this->directory' is not found or is not directory."); } $exceptionFile = $message instanceof \Exception || $message instanceof \Throwable ? $this->getExceptionFile($message) : NULL; $line = $this->formatLogLine($message, $exceptionFile); $file = $this->directory . '/' . strtolower($priority ?: self::INFO) . '.log'; if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception throw new \RuntimeException("Unable to write to log file '$file'. Is directory writable?"); } if ($exceptionFile) { $this->logException($message, $exceptionFile); } if (in_array($priority, [self::ERROR, self::EXCEPTION, self::CRITICAL], TRUE)) { $this->sendEmail($message); } return $exceptionFile; } /** * @param string|\Exception|\Throwable * @return string */ protected function formatMessage($message) { if ($message instanceof \Exception || $message instanceof \Throwable) { while ($message) { $tmp[] = ($message instanceof \ErrorException ? Helpers::errorTypeToString($message->getSeverity()) . ': ' . $message->getMessage() : Helpers::getClass($message) . ': ' . $message->getMessage() ) . ' in ' . $message->getFile() . ':' . $message->getLine(); $message = $message->getPrevious(); } $message = implode($tmp, "\ncaused by "); } elseif (!is_string($message)) { $message = Dumper::toText($message); } return trim($message); } /** * @param string|\Exception|\Throwable * @return string */ protected function formatLogLine($message, $exceptionFile = NULL) { return implode(' ', [ @date('[Y-m-d H-i-s]'), // @ timezone may not be set preg_replace('#\s*\r?\n\s*#', ' ', $this->formatMessage($message)), ' @ ' . Helpers::getSource(), $exceptionFile ? ' @@ ' . basename($exceptionFile) : NULL, ]); } /** * @param \Exception|\Throwable * @return string */ public function getExceptionFile($exception) { $dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR); $hash = substr(md5(preg_replace('~(Resource id #)\d+~', '$1', $exception)), 0, 10); foreach (new \DirectoryIterator($this->directory) as $file) { if (strpos($file, $hash)) { return $dir . $file; } } return $dir . 'exception--' . @date('Y-m-d--H-i') . "--$hash.html"; // @ timezone may not be set } /** * Logs exception to the file if file doesn't exist. * @param \Exception|\Throwable * @return string logged error filename */ protected function logException($exception, $file = NULL) { $file = $file ?: $this->getExceptionFile($exception); $bs = $this->blueScreen ?: new BlueScreen; $bs->renderToFile($exception, $file); return $file; } /** * @param string|\Exception|\Throwable * @return void */ protected function sendEmail($message) { $snooze = is_numeric($this->emailSnooze) ? $this->emailSnooze : @strtotime($this->emailSnooze) - time(); // @ timezone may not be set if ($this->email && $this->mailer && @filemtime($this->directory . '/email-sent') + $snooze < time() // @ file may not exist && @file_put_contents($this->directory . '/email-sent', 'sent') // @ file may not be writable ) { call_user_func($this->mailer, $message, implode(', ', (array) $this->email)); } } /** * Default mailer. * @param string|\Exception|\Throwable * @param string * @return void * @internal */ public function defaultMailer($message, $email) { $host = preg_replace('#[^\w.-]+#', '', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n')); $parts = str_replace( ["\r\n", "\n"], ["\n", PHP_EOL], [ 'headers' => implode("\n", [ 'From: ' . ($this->fromEmail ?: "noreply@$host"), 'X-Mailer: Tracy', 'Content-Type: text/plain; charset=UTF-8', 'Content-Transfer-Encoding: 8bit', ]) . "\n", 'subject' => "PHP: An error occurred on the server $host", 'body' => $this->formatMessage($message) . "\n\nsource: " . Helpers::getSource(), ] ); mail($email, $parts['subject'], $parts['body'], $parts['headers']); } } Nette-2.4-20160731/Nette/Tracy/ILogger.php0000644000000000000000000000057512747434604016261 0ustar rootroot strlen($m[0])) { $file = '...' . $m[0]; } $file = strtr($file, '/', DIRECTORY_SEPARATOR); return self::formatHtml('%%%', $editor, $file . ($line ? ":$line" : ''), rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, basename($file), $line ? ":$line" : '' ); } else { return self::formatHtml('%', $file . ($line ? ":$line" : '')); } } /** * Returns link to editor. * @return string */ public static function editorUri($file, $line = NULL) { if (Debugger::$editor && $file && is_file($file)) { $file = strtr($file, Debugger::$editorMapping); return strtr(Debugger::$editor, ['%file' => rawurlencode($file), '%line' => $line ? (int) $line : 1]); } } public static function formatHtml($mask) { $args = func_get_args(); return preg_replace_callback('#%#', function () use (& $args, & $count) { return Helpers::escapeHtml($args[++$count]); }, $mask); } public static function escapeHtml($s) { return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } public static function findTrace(array $trace, $method, & $index = NULL) { $m = explode('::', $method); foreach ($trace as $i => $item) { if (isset($item['function']) && $item['function'] === end($m) && isset($item['class']) === isset($m[1]) && (!isset($item['class']) || $m[0] === '*' || is_a($item['class'], $m[0], TRUE)) ) { $index = $i; return $item; } } } /** * @return string */ public static function getClass($obj) { return explode("\x00", get_class($obj))[0]; } /** @internal */ public static function fixStack($exception) { if (function_exists('xdebug_get_function_stack')) { $stack = []; foreach (array_slice(array_reverse(xdebug_get_function_stack()), 2, -1) as $row) { $frame = [ 'file' => $row['file'], 'line' => $row['line'], 'function' => isset($row['function']) ? $row['function'] : '*unknown*', 'args' => [], ]; if (!empty($row['class'])) { $frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::'; $frame['class'] = $row['class']; } $stack[] = $frame; } $ref = new \ReflectionProperty('Exception', 'trace'); $ref->setAccessible(TRUE); $ref->setValue($exception, $stack); } return $exception; } /** @internal */ public static function fixEncoding($s) { return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES); } /** @internal */ public static function errorTypeToString($type) { $types = [ 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 standards', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated', ]; return isset($types[$type]) ? $types[$type] : 'Unknown error'; } /** @internal */ public static function getSource() { if (isset($_SERVER['REQUEST_URI'])) { return (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . $_SERVER['REQUEST_URI']; } else { return 'CLI (PID: ' . getmypid() . ')' . (empty($_SERVER['argv']) ? '' : ': ' . implode(' ', $_SERVER['argv'])); } } /** @internal */ public static function improveException($e) { $message = $e->getMessage(); if (!$e instanceof \Error && !$e instanceof \ErrorException) { // do nothing } elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) { $funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']); $hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2]); $message .= ", did you mean $hint()?"; } elseif (preg_match('#^Call to undefined method (\S+)::(\w+)#', $message, $m)) { $hint = self::getSuggestion(get_class_methods($m[1]), $m[2]); $message .= ", did you mean $hint()?"; } elseif (preg_match('#^Undefined variable: (\w+)#', $message, $m) && !empty($e->context)) { $hint = self::getSuggestion(array_keys($e->context), $m[1]); $message = "Undefined variable $$m[1], did you mean $$hint?"; } elseif (preg_match('#^Undefined property: (\S+)::\$(\w+)#', $message, $m)) { $rc = new \ReflectionClass($m[1]); $items = array_diff($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC)); $hint = self::getSuggestion($items, $m[2]); $message .= ", did you mean $$hint?"; } elseif (preg_match('#^Access to undeclared static property: (\S+)::\$(\w+)#', $message, $m)) { $rc = new \ReflectionClass($m[1]); $items = array_intersect($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC)); $hint = self::getSuggestion($items, $m[2]); $message .= ", did you mean $$hint?"; } if (isset($hint)) { $ref = new \ReflectionProperty($e, 'message'); $ref->setAccessible(TRUE); $ref->setValue($e, $message); } } /** * Finds the best suggestion. * @return string|NULL * @internal */ public static function getSuggestion(array $items, $value) { $best = NULL; $min = (strlen($value) / 4 + 1) * 10 + .1; foreach (array_unique($items, SORT_REGULAR) as $item) { $item = is_object($item) ? $item->getName() : $item; if (($len = levenshtein($item, $value, 10, 11, 10)) > 0 && $len < $min) { $min = $len; $best = $item; } } return $best; } /** @internal */ public static function isHtmlMode() { return empty($_SERVER['HTTP_X_REQUESTED_WITH']) && empty($_SERVER['HTTP_X_TRACY_AJAX']) && PHP_SAPI !== 'cli' && !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list())); } /** @internal */ public static function isAjax() { return isset($_SERVER['HTTP_X_TRACY_AJAX']) && preg_match('#^\w{10}\z#', $_SERVER['HTTP_X_TRACY_AJAX']); } } Nette-2.4-20160731/Nette/Tracy/FireLogger.php0000644000000000000000000001110612747434604016746 0ustar rootroot []]; /** * Sends message to FireLogger console. * @param mixed * @return bool was successful? */ public function log($message, $priority = self::DEBUG) { if (!isset($_SERVER['HTTP_X_FIRELOGGER']) || headers_sent()) { return FALSE; } $item = [ 'name' => 'PHP', 'level' => $priority, 'order' => count($this->payload['logs']), 'time' => str_pad(number_format((microtime(TRUE) - Debugger::$time) * 1000, 1, '.', ' '), 8, '0', STR_PAD_LEFT) . ' ms', 'template' => '', 'message' => '', 'style' => 'background:#767ab6', ]; $args = func_get_args(); if (isset($args[0]) && is_string($args[0])) { $item['template'] = array_shift($args); } if (isset($args[0]) && ($args[0] instanceof \Exception || $args[0] instanceof \Throwable)) { $e = array_shift($args); $trace = $e->getTrace(); if (isset($trace[0]['class']) && $trace[0]['class'] === 'Tracy\Debugger' && ($trace[0]['function'] === 'shutdownHandler' || $trace[0]['function'] === 'errorHandler') ) { unset($trace[0]); } $file = str_replace(dirname(dirname(dirname($e->getFile()))), "\xE2\x80\xA6", $e->getFile()); $item['template'] = ($e instanceof \ErrorException ? '' : Helpers::getClass($e) . ': ') . $e->getMessage() . ($e->getCode() ? ' #' . $e->getCode() : '') . ' in ' . $file . ':' . $e->getLine(); $item['pathname'] = $e->getFile(); $item['lineno'] = $e->getLine(); } else { $trace = debug_backtrace(); if (isset($trace[1]['class']) && $trace[1]['class'] === 'Tracy\Debugger' && ($trace[1]['function'] === 'fireLog') ) { unset($trace[0]); } foreach ($trace as $frame) { if (isset($frame['file']) && is_file($frame['file'])) { $item['pathname'] = $frame['file']; $item['lineno'] = $frame['line']; break; } } } $item['exc_info'] = ['', '', []]; $item['exc_frames'] = []; foreach ($trace as $frame) { $frame += ['file' => NULL, 'line' => NULL, 'class' => NULL, 'type' => NULL, 'function' => NULL, 'object' => NULL, 'args' => NULL]; $item['exc_info'][2][] = [$frame['file'], $frame['line'], "$frame[class]$frame[type]$frame[function]", $frame['object']]; $item['exc_frames'][] = $frame['args']; } if (isset($args[0]) && in_array($args[0], [self::DEBUG, self::INFO, self::WARNING, self::ERROR, self::CRITICAL], TRUE)) { $item['level'] = array_shift($args); } $item['args'] = $args; $this->payload['logs'][] = $this->jsonDump($item, -1); foreach (str_split(base64_encode(json_encode($this->payload)), 4990) as $k => $v) { header("FireLogger-de11e-$k:$v"); } return TRUE; } /** * Dump implementation for JSON. * @param mixed variable to dump * @param int current recursion level * @return string */ private function jsonDump(& $var, $level = 0) { if (is_bool($var) || is_null($var) || is_int($var) || is_float($var)) { return $var; } elseif (is_string($var)) { return Dumper::encodeString($var, $this->maxLength); } elseif (is_array($var)) { static $marker; if ($marker === NULL) { $marker = uniqid("\x00", TRUE); } if (isset($var[$marker])) { return "\xE2\x80\xA6RECURSION\xE2\x80\xA6"; } elseif ($level < $this->maxDepth || !$this->maxDepth) { $var[$marker] = TRUE; $res = []; foreach ($var as $k => & $v) { if ($k !== $marker) { $res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1); } } unset($var[$marker]); return $res; } else { return " \xE2\x80\xA6 "; } } elseif (is_object($var)) { $arr = (array) $var; static $list = []; if (in_array($var, $list, TRUE)) { return "\xE2\x80\xA6RECURSION\xE2\x80\xA6"; } elseif ($level < $this->maxDepth || !$this->maxDepth) { $list[] = $var; $res = ["\x00" => '(object) ' . Helpers::getClass($var)]; foreach ($arr as $k => & $v) { if (isset($k[0]) && $k[0] === "\x00") { $k = substr($k, strrpos($k, "\x00") + 1); } $res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1); } array_pop($list); return $res; } else { return " \xE2\x80\xA6 "; } } elseif (is_resource($var)) { return 'resource ' . get_resource_type($var); } else { return 'unknown type'; } } } Nette-2.4-20160731/Nette/Tracy/Dumper.php0000644000000000000000000004121712747434604016163 0ustar rootroot '1;33', 'null' => '1;33', 'number' => '1;32', 'string' => '1;36', 'array' => '1;31', 'key' => '1;37', 'object' => '1;31', 'visibility' => '1;30', 'resource' => '1;37', 'indent' => '1;30', ]; /** @var array */ public static $resources = [ 'stream' => 'stream_get_meta_data', 'stream-context' => 'stream_context_get_options', 'curl' => 'curl_getinfo', ]; /** @var array */ public static $objectExporters = [ 'Closure' => 'Tracy\Dumper::exportClosure', 'SplFileInfo' => 'Tracy\Dumper::exportSplFileInfo', 'SplObjectStorage' => 'Tracy\Dumper::exportSplObjectStorage', '__PHP_Incomplete_Class' => 'Tracy\Dumper::exportPhpIncompleteClass', ]; /** @var string @internal */ public static $livePrefix; /** @var array */ private static $liveStorage = []; /** * Dumps variable to the output. * @return mixed variable */ public static function dump($var, array $options = NULL) { if (PHP_SAPI !== 'cli' && !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()))) { echo self::toHtml($var, $options); } elseif (self::detectColors()) { echo self::toTerminal($var, $options); } else { echo self::toText($var, $options); } return $var; } /** * Dumps variable to HTML. * @return string */ public static function toHtml($var, array $options = NULL) { $options = (array) $options + [ self::DEPTH => 4, self::TRUNCATE => 150, self::COLLAPSE => 14, self::COLLAPSE_COUNT => 7, self::OBJECT_EXPORTERS => NULL, ]; $loc = & $options[self::LOCATION]; $loc = $loc === TRUE ? ~0 : (int) $loc; $options[self::OBJECT_EXPORTERS] = (array) $options[self::OBJECT_EXPORTERS] + self::$objectExporters; uksort($options[self::OBJECT_EXPORTERS], function ($a, $b) { return $b === '' || (class_exists($a, FALSE) && is_subclass_of($a, $b)) ? -1 : 1; }); $live = !empty($options[self::LIVE]) && $var && (is_array($var) || is_object($var) || is_resource($var)); list($file, $line, $code) = $loc ? self::findLocation() : NULL; $locAttrs = $file && $loc & self::LOCATION_SOURCE ? Helpers::formatHtml( ' title="%in file % on line %" data-tracy-href="%"', "$code\n", $file, $line, Helpers::editorUri($file, $line) ) : NULL; return '
" : '>')
			. ($live ? '' : self::dumpVar($var, $options))
			. ($file && $loc & self::LOCATION_LINK ? 'in ' . Helpers::editorLink($file, $line) . '' : '')
			. "
\n"; } /** * Dumps variable to plain text. * @return string */ public static function toText($var, array $options = NULL) { return htmlspecialchars_decode(strip_tags(self::toHtml($var, $options)), ENT_QUOTES); } /** * Dumps variable to x-terminal. * @return string */ public static function toTerminal($var, array $options = NULL) { return htmlspecialchars_decode(strip_tags(preg_replace_callback('#|#', function ($m) { return "\033[" . (isset($m[1], self::$terminalColors[$m[1]]) ? self::$terminalColors[$m[1]] : '0') . 'm'; }, self::toHtml($var, $options))), ENT_QUOTES); } /** * Internal toHtml() dump implementation. * @param mixed variable to dump * @param array options * @param int current recursion level * @return string */ private static function dumpVar(& $var, array $options, $level = 0) { if (method_exists(__CLASS__, $m = 'dump' . gettype($var))) { return self::$m($var, $options, $level); } else { return "unknown type\n"; } } private static function dumpNull() { return "NULL\n"; } private static function dumpBoolean(& $var) { return '' . ($var ? 'TRUE' : 'FALSE') . "\n"; } private static function dumpInteger(& $var) { return "$var\n"; } private static function dumpDouble(& $var) { $var = is_finite($var) ? ($tmp = json_encode($var)) . (strpos($tmp, '.') === FALSE ? '.0' : '') : str_replace('.0', '', var_export($var, TRUE)); // workaround for PHP 7.0.2 return "$var\n"; } private static function dumpString(& $var, $options) { return '"' . Helpers::escapeHtml(self::encodeString($var, $options[self::TRUNCATE])) . '"' . (strlen($var) > 1 ? ' (' . strlen($var) . ')' : '') . "\n"; } private static function dumpArray(& $var, $options, $level) { static $marker; if ($marker === NULL) { $marker = uniqid("\x00", TRUE); } $out = 'array ('; if (empty($var)) { return $out . ")\n"; } elseif (isset($var[$marker])) { return $out . (count($var) - 1) . ") [ RECURSION ]\n"; } elseif (!$options[self::DEPTH] || $level < $options[self::DEPTH]) { $collapsed = $level ? count($var) >= $options[self::COLLAPSE_COUNT] : (is_int($options[self::COLLAPSE]) ? count($var) >= $options[self::COLLAPSE] : $options[self::COLLAPSE]); $out = '' . $out . count($var) . ")\n'; $var[$marker] = TRUE; foreach ($var as $k => & $v) { if ($k !== $marker) { $k = preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . Helpers::escapeHtml(self::encodeString($k, $options[self::TRUNCATE])) . '"'; $out .= ' ' . str_repeat('| ', $level) . '' . '' . $k . ' => ' . self::dumpVar($v, $options, $level + 1); } } unset($var[$marker]); return $out . ''; } else { return $out . count($var) . ") [ ... ]\n"; } } private static function dumpObject(& $var, $options, $level) { $fields = self::exportObject($var, $options[self::OBJECT_EXPORTERS]); $editor = NULL; if ($options[self::LOCATION] & self::LOCATION_CLASS) { $rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var); $editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine()); } $out = 'getFileName(), $rc->getStartLine(), $editor ) : '') . '>' . Helpers::escapeHtml(Helpers::getClass($var)) . ' #' . substr(md5(spl_object_hash($var)), 0, 4) . ''; static $list = []; if (empty($fields)) { return $out . "\n"; } elseif (in_array($var, $list, TRUE)) { return $out . " { RECURSION }\n"; } elseif (!$options[self::DEPTH] || $level < $options[self::DEPTH] || $var instanceof \Closure) { $collapsed = $level ? count($fields) >= $options[self::COLLAPSE_COUNT] : (is_int($options[self::COLLAPSE]) ? count($fields) >= $options[self::COLLAPSE] : $options[self::COLLAPSE]); $out = '' . $out . "\n'; $list[] = $var; foreach ($fields as $k => & $v) { $vis = ''; if (isset($k[0]) && $k[0] === "\x00") { $vis = ' ' . ($k[1] === '*' ? 'protected' : 'private') . ''; $k = substr($k, strrpos($k, "\x00") + 1); } $k = preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . Helpers::escapeHtml(self::encodeString($k, $options[self::TRUNCATE])) . '"'; $out .= ' ' . str_repeat('| ', $level) . '' . '' . $k . "$vis => " . self::dumpVar($v, $options, $level + 1); } array_pop($list); return $out . ''; } else { return $out . " { ... }\n"; } } private static function dumpResource(& $var, $options, $level) { $type = get_resource_type($var); $out = '' . Helpers::escapeHtml($type) . ' resource ' . '#' . intval($var) . ''; if (isset(self::$resources[$type])) { $out = "$out\n
"; foreach (call_user_func(self::$resources[$type], $var) as $k => $v) { $out .= ' ' . str_repeat('| ', $level) . '' . '' . Helpers::escapeHtml($k) . ' => ' . self::dumpVar($v, $options, $level + 1); } return $out . '
'; } return "$out\n"; } /** * @return mixed */ private static function toJson(& $var, $options, $level = 0) { if (is_bool($var) || is_null($var) || is_int($var)) { return $var; } elseif (is_float($var)) { return is_finite($var) ? (strpos($tmp = json_encode($var), '.') ? $var : ['number' => "$tmp.0"]) : ['type' => (string) $var]; } elseif (is_string($var)) { return self::encodeString($var, $options[self::TRUNCATE]); } elseif (is_array($var)) { static $marker; if ($marker === NULL) { $marker = uniqid("\x00", TRUE); } if (isset($var[$marker]) || $level >= $options[self::DEPTH]) { return [NULL]; } $res = []; $var[$marker] = TRUE; foreach ($var as $k => & $v) { if ($k !== $marker) { $k = preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k, $options[self::TRUNCATE]) . '"'; $res[] = [$k, self::toJson($v, $options, $level + 1)]; } } unset($var[$marker]); return $res; } elseif (is_object($var)) { $obj = & self::$liveStorage[spl_object_hash($var)]; if ($obj && $obj['level'] <= $level) { return ['object' => $obj['id']]; } if ($options[self::LOCATION] & self::LOCATION_CLASS) { $rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var); $editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine()); } static $counter = 1; $obj = $obj ?: [ 'id' => self::$livePrefix . '0' . $counter++, // differentiate from resources 'name' => Helpers::getClass($var), 'editor' => empty($editor) ? NULL : ['file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor], 'level' => $level, 'object' => $var, ]; if ($level < $options[self::DEPTH] || !$options[self::DEPTH]) { $obj['level'] = $level; $obj['items'] = []; foreach (self::exportObject($var, $options[self::OBJECT_EXPORTERS]) as $k => $v) { $vis = 0; if (isset($k[0]) && $k[0] === "\x00") { $vis = $k[1] === '*' ? 1 : 2; $k = substr($k, strrpos($k, "\x00") + 1); } $k = preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k, $options[self::TRUNCATE]) . '"'; $obj['items'][] = [$k, self::toJson($v, $options, $level + 1), $vis]; } } return ['object' => $obj['id']]; } elseif (is_resource($var)) { $obj = & self::$liveStorage[(string) $var]; if (!$obj) { $type = get_resource_type($var); $obj = ['id' => self::$livePrefix . (int) $var, 'name' => $type . ' resource']; if (isset(self::$resources[$type])) { foreach (call_user_func(self::$resources[$type], $var) as $k => $v) { $obj['items'][] = [$k, self::toJson($v, $options, $level + 1)]; } } } return ['resource' => $obj['id']]; } else { return ['type' => 'unknown type']; } } /** @return array */ public static function fetchLiveData() { $res = []; foreach (self::$liveStorage as $obj) { $id = $obj['id']; unset($obj['level'], $obj['object'], $obj['id']); $res[$id] = $obj; } self::$liveStorage = []; return $res; } /** * @internal * @return string UTF-8 */ public static function encodeString($s, $maxLength = NULL) { static $table; if ($table === NULL) { foreach (array_merge(range("\x00", "\x1F"), range("\x7F", "\xFF")) as $ch) { $table[$ch] = '\x' . str_pad(dechex(ord($ch)), 2, '0', STR_PAD_LEFT); } $table['\\'] = '\\\\'; $table["\r"] = '\r'; $table["\n"] = '\n'; $table["\t"] = '\t'; } if (preg_match('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]#u', $s) || preg_last_error()) { if ($shortened = ($maxLength && strlen($s) > $maxLength)) { $s = substr($s, 0, $maxLength); } $s = strtr($s, $table); } elseif ($maxLength && $s !== '') { if (function_exists('iconv_substr')) { $s = iconv_substr($tmp = $s, 0, $maxLength, 'UTF-8'); $shortened = $s !== $tmp; } else { $i = $len = 0; do { if (($s[$i] < "\x80" || $s[$i] >= "\xC0") && (++$len > $maxLength)) { $s = substr($s, 0, $i); $shortened = TRUE; break; } } while (isset($s[++$i])); } } return $s . (empty($shortened) ? '' : ' ... '); } /** * @return array */ private static function exportObject($obj, array $exporters) { foreach ($exporters as $type => $dumper) { if (!$type || $obj instanceof $type) { return call_user_func($dumper, $obj); } } return (array) $obj; } /** * @return array */ private static function exportClosure(\Closure $obj) { $rc = new \ReflectionFunction($obj); $res = []; foreach ($rc->getParameters() as $param) { $res[] = '$' . $param->getName(); } return [ 'file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'variables' => $rc->getStaticVariables(), 'parameters' => implode(', ', $res), ]; } /** * @return array */ private static function exportSplFileInfo(\SplFileInfo $obj) { return ['path' => $obj->getPathname()]; } /** * @return array */ private static function exportSplObjectStorage(\SplObjectStorage $obj) { $res = []; foreach (clone $obj as $item) { $res[] = ['object' => $item, 'data' => $obj[$item]]; } return $res; } /** * @return array */ private static function exportPhpIncompleteClass(\__PHP_Incomplete_Class $obj) { $info = ['className' => NULL, 'private' => [], 'protected' => [], 'public' => []]; foreach ((array) $obj as $name => $value) { if ($name === '__PHP_Incomplete_Class_Name') { $info['className'] = $value; } elseif (preg_match('#^\x0\*\x0(.+)\z#', $name, $m)) { $info['protected'][$m[1]] = $value; } elseif (preg_match('#^\x0(.+)\x0(.+)\z#', $name, $m)) { $info['private'][$m[1] . '::$' . $m[2]] = $value; } else { $info['public'][$name] = $value; } } return $info; } /** * Finds the location where dump was called. * @return array [file, line, code] */ private static function findLocation() { foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) { if (isset($item['class']) && $item['class'] === __CLASS__) { $location = $item; continue; } elseif (isset($item['function'])) { try { $reflection = isset($item['class']) ? new \ReflectionMethod($item['class'], $item['function']) : new \ReflectionFunction($item['function']); if ($reflection->isInternal() || preg_match('#\s@tracySkipLocation\s#', $reflection->getDocComment())) { $location = $item; continue; } } catch (\ReflectionException $e) { } } break; } if (isset($location['file'], $location['line']) && is_file($location['file'])) { $lines = file($location['file']); $line = $lines[$location['line'] - 1]; return [ $location['file'], $location['line'], trim(preg_match('#\w*dump(er::\w+)?\(.*\)#i', $line, $m) ? $m[0] : $line), ]; } } /** * @return bool */ private static function detectColors() { return self::$terminalColors && (getenv('ConEmuANSI') === 'ON' || getenv('ANSICON') !== FALSE || getenv('term') === 'xterm-256color' || (defined('STDOUT') && function_exists('posix_isatty') && posix_isatty(STDOUT))); } } Nette-2.4-20160731/Nette/Tracy/DefaultBarPanel.php0000644000000000000000000000160012747434604017710 0ustar rootrootid = $id; } /** * Renders HTML code for custom tab. * @return string */ public function getTab() { ob_start(function () {}); $data = $this->data; require __DIR__ . "/assets/Bar/{$this->id}.tab.phtml"; return ob_get_clean(); } /** * Renders HTML code for custom panel. * @return string */ public function getPanel() { ob_start(function () {}); if (is_file(__DIR__ . "/assets/Bar/{$this->id}.panel.phtml")) { $data = $this->data; require __DIR__ . "/assets/Bar/{$this->id}.panel.phtml"; } return ob_get_clean(); } } Nette-2.4-20160731/Nette/Tracy/Debugger.php0000644000000000000000000004117212747434604016453 0ustar rootrootdispatchAssets()) { exit; } elseif (session_status() === PHP_SESSION_ACTIVE) { self::dispatch(); } } /** * @return void */ public static function dispatch() { if (self::$productionMode) { return; } elseif (headers_sent($file, $line) || ob_get_length()) { throw new \LogicException( __METHOD__ . '() called after some output has been sent. ' . ($file ? "Output started at $file:$line." : 'Try Tracy\OutputDebugger to find where output started.') ); } elseif (session_status() !== PHP_SESSION_ACTIVE) { ini_set('session.use_cookies', '1'); ini_set('session.use_only_cookies', '1'); ini_set('session.use_trans_sid', '0'); ini_set('session.cookie_path', '/'); ini_set('session.cookie_httponly', '1'); session_start(); } if (self::getBar()->dispatchContent()) { exit; } } /** * @return bool */ public static function isEnabled() { return self::$enabled; } /** * Shutdown handler to catch fatal errors and execute of the planned activities. * @return void * @internal */ public static function shutdownHandler() { if (!self::$reserved) { return; } $error = error_get_last(); if (in_array($error['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE, E_RECOVERABLE_ERROR, E_USER_ERROR], TRUE)) { self::exceptionHandler( Helpers::fixStack(new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'])), FALSE ); } elseif (self::$showBar && !self::$productionMode) { self::$reserved = NULL; self::removeOutputBuffers(FALSE); self::getBar()->render(); } } /** * Handler to catch uncaught exception. * @param \Exception|\Throwable * @return void * @internal */ public static function exceptionHandler($exception, $exit = TRUE) { if (!self::$reserved) { return; } self::$reserved = NULL; if (!headers_sent()) { $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; $code = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE ') !== FALSE ? 503 : 500; header("$protocol $code", TRUE, $code); if (Helpers::isHtmlMode()) { header('Content-Type: text/html; charset=UTF-8'); } } Helpers::improveException($exception); self::removeOutputBuffers(TRUE); if (self::$productionMode) { try { self::log($exception, self::EXCEPTION); } catch (\Throwable $e) { } catch (\Exception $e) { } if (Helpers::isHtmlMode()) { $logged = empty($e); require self::$errorTemplate ?: __DIR__ . '/assets/Debugger/error.500.phtml'; } elseif (PHP_SAPI === 'cli') { fwrite(STDERR, 'ERROR: application encountered an error and can not continue. ' . (isset($e) ? "Unable to log error.\n" : "Error was logged.\n")); } } elseif (!connection_aborted() && (Helpers::isHtmlMode() || Helpers::isAjax())) { self::getBlueScreen()->render($exception); if (self::$showBar) { self::getBar()->render(); } } else { self::fireLog($exception); $s = get_class($exception) . ($exception->getMessage() === '' ? '' : ': ' . $exception->getMessage()) . ' in ' . $exception->getFile() . ':' . $exception->getLine() . "\nStack trace:\n" . $exception->getTraceAsString(); try { $file = self::log($exception, self::EXCEPTION); if ($file && !headers_sent()) { header("X-Tracy-Error-Log: $file"); } echo "$s\n" . ($file ? "(stored in $file)\n" : ''); if ($file && self::$browser) { exec(self::$browser . ' ' . escapeshellarg($file)); } } catch (\Throwable $e) { echo "$s\nUnable to log error: {$e->getMessage()}\n"; } catch (\Exception $e) { echo "$s\nUnable to log error: {$e->getMessage()}\n"; } } try { $e = NULL; foreach (self::$onFatalError as $handler) { call_user_func($handler, $exception); } } catch (\Throwable $e) { } catch (\Exception $e) { } if ($e) { try { self::log($e, self::EXCEPTION); } catch (\Throwable $e) { } catch (\Exception $e) { } } if ($exit) { exit(255); } } /** * Handler to catch warnings and notices. * @return bool FALSE to call normal error handler, NULL otherwise * @throws ErrorException * @internal */ public static function errorHandler($severity, $message, $file, $line, $context) { if (self::$scream) { error_reporting(E_ALL); } if ($severity === E_RECOVERABLE_ERROR || $severity === E_USER_ERROR) { if (Helpers::findTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), '*::__toString')) { $previous = isset($context['e']) && ($context['e'] instanceof \Exception || $context['e'] instanceof \Throwable) ? $context['e'] : NULL; $e = new ErrorException($message, 0, $severity, $file, $line, $previous); $e->context = $context; self::exceptionHandler($e); } $e = new ErrorException($message, 0, $severity, $file, $line); $e->context = $context; throw $e; } elseif (($severity & error_reporting()) !== $severity) { return FALSE; // calls normal error handler to fill-in error_get_last() } elseif (self::$productionMode && ($severity & self::$logSeverity) === $severity) { $e = new ErrorException($message, 0, $severity, $file, $line); $e->context = $context; try { self::log($e, self::ERROR); } catch (\Throwable $e) { } catch (\Exception $foo) { } return NULL; } elseif (!self::$productionMode && !isset($_GET['_tracy_skip_error']) && (is_bool(self::$strictMode) ? self::$strictMode : ((self::$strictMode & $severity) === $severity)) ) { $e = new ErrorException($message, 0, $severity, $file, $line); $e->context = $context; $e->skippable = TRUE; self::exceptionHandler($e); } $message = 'PHP ' . Helpers::errorTypeToString($severity) . ": $message"; $count = & self::getBar()->getPanel('Tracy:errors')->data["$file|$line|$message"]; if ($count++) { // repeated error return NULL; } elseif (self::$productionMode) { try { self::log("$message in $file:$line", self::ERROR); } catch (\Throwable $e) { } catch (\Exception $foo) { } return NULL; } else { self::fireLog(new ErrorException($message, 0, $severity, $file, $line)); return Helpers::isHtmlMode() || Helpers::isAjax() ? NULL : FALSE; // FALSE calls normal error handler } } private static function removeOutputBuffers($errorOccurred) { while (ob_get_level() > self::$obLevel) { $status = ob_get_status(); if (in_array($status['name'], ['ob_gzhandler', 'zlib output compression'])) { break; } $fnc = $status['chunk_size'] || !$errorOccurred ? 'ob_end_flush' : 'ob_end_clean'; if (!@$fnc()) { // @ may be not removable break; } } } /********************* services ****************d*g**/ /** * @return BlueScreen */ public static function getBlueScreen() { if (!self::$blueScreen) { self::$blueScreen = new BlueScreen; self::$blueScreen->info = [ 'PHP ' . PHP_VERSION, isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : NULL, 'Tracy ' . self::VERSION, ]; } return self::$blueScreen; } /** * @return Bar */ public static function getBar() { if (!self::$bar) { self::$bar = new Bar; self::$bar->addPanel($info = new DefaultBarPanel('info'), 'Tracy:info'); $info->cpuUsage = self::$cpuUsage; self::$bar->addPanel(new DefaultBarPanel('errors'), 'Tracy:errors'); // filled by errorHandler() } return self::$bar; } /** * @return void */ public static function setLogger(ILogger $logger) { self::$logger = $logger; } /** * @return ILogger */ public static function getLogger() { if (!self::$logger) { self::$logger = new Logger(self::$logDirectory, self::$email, self::getBlueScreen()); self::$logger->directory = & self::$logDirectory; // back compatiblity self::$logger->email = & self::$email; } return self::$logger; } /** * @return ILogger */ public static function getFireLogger() { if (!self::$fireLogger) { self::$fireLogger = new FireLogger; } return self::$fireLogger; } /********************* useful tools ****************d*g**/ /** * Dumps information about a variable in readable format. * @tracySkipLocation * @param mixed variable to dump * @param bool return output instead of printing it? (bypasses $productionMode) * @return mixed variable itself or dump */ public static function dump($var, $return = FALSE) { if ($return) { ob_start(function () {}); Dumper::dump($var, [ Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLength, ]); return ob_get_clean(); } elseif (!self::$productionMode) { Dumper::dump($var, [ Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLength, Dumper::LOCATION => self::$showLocation, ]); } return $var; } /** * Starts/stops stopwatch. * @param string name * @return float elapsed seconds */ public static function timer($name = NULL) { static $time = []; $now = microtime(TRUE); $delta = isset($time[$name]) ? $now - $time[$name] : 0; $time[$name] = $now; return $delta; } /** * Dumps information about a variable in Tracy Debug Bar. * @tracySkipLocation * @param mixed variable to dump * @param string optional title * @param array dumper options * @return mixed variable itself */ public static function barDump($var, $title = NULL, array $options = NULL) { if (!self::$productionMode) { static $panel; if (!$panel) { self::getBar()->addPanel($panel = new DefaultBarPanel('dumps'), 'Tracy:dumps'); } $panel->data[] = ['title' => $title, 'dump' => Dumper::toHtml($var, (array) $options + [ Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLength, Dumper::LOCATION => self::$showLocation ?: Dumper::LOCATION_CLASS | Dumper::LOCATION_SOURCE, ])]; } return $var; } /** * Logs message or exception. * @param string|\Exception|\Throwable * @return mixed */ public static function log($message, $priority = ILogger::INFO) { return self::getLogger()->log($message, $priority); } /** * Sends message to FireLogger console. * @param mixed message to log * @return bool was successful? */ public static function fireLog($message) { if (!self::$productionMode) { return self::getFireLogger()->log($message); } } /** * Detects debug mode by IP address. * @param string|array IP addresses or computer names whitelist detection * @return bool */ public static function detectDebugMode($list = NULL) { $addr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : php_uname('n'); $secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET]) ? $_COOKIE[self::COOKIE_SECRET] : NULL; $list = is_string($list) ? preg_split('#[,\s]+#', $list) : (array) $list; if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list[] = '127.0.0.1'; $list[] = '::1'; } return in_array($addr, $list, TRUE) || in_array("$secret@$addr", $list, TRUE); } } Nette-2.4-20160731/Nette/Tracy/BlueScreen.php0000644000000000000000000001543012747434604016754 0ustar rootrootcollapsePaths[] = preg_match('#(.+/vendor)/tracy/tracy/src/Tracy$#', strtr(__DIR__, '\\', '/'), $m) ? $m[1] : __DIR__; } /** * Add custom panel. * @param callable * @return self */ public function addPanel($panel) { if (!in_array($panel, $this->panels, TRUE)) { $this->panels[] = $panel; } return $this; } /** * Renders blue screen. * @param \Exception|\Throwable * @return void */ public function render($exception) { if (Helpers::isAjax() && session_status() === PHP_SESSION_ACTIVE) { ob_start(function () {}); $this->renderTemplate($exception, __DIR__ . '/assets/BlueScreen/content.phtml'); $contentId = $_SERVER['HTTP_X_TRACY_AJAX']; $queue = & $_SESSION['_tracy']['bluescreen']; $queue = array_slice(array_filter((array) $queue), -5, NULL, TRUE); $queue[$contentId] = ['content' => ob_get_clean(), 'dumps' => Dumper::fetchLiveData()]; } else { $this->renderTemplate($exception, __DIR__ . '/assets/BlueScreen/page.phtml'); } } /** * Renders blue screen to file (if file exists, it will not be overwritten). * @param \Exception|\Throwable * @param string file path * @return void */ public function renderToFile($exception, $file) { if ($handle = @fopen($file, 'x')) { ob_start(); // double buffer prevents sending HTTP headers in some PHP ob_start(function ($buffer) use ($handle) { fwrite($handle, $buffer); }, 4096); $this->renderTemplate($exception, __DIR__ . '/assets/BlueScreen/page.phtml'); ob_end_flush(); ob_end_clean(); fclose($handle); } } private function renderTemplate($exception, $template) { $info = array_filter($this->info); $source = Helpers::getSource(); $sourceIsUrl = preg_match('#^https?://#', $source); $title = $exception instanceof \ErrorException ? Helpers::errorTypeToString($exception->getSeverity()) : Helpers::getClass($exception); $skipError = $sourceIsUrl && $exception instanceof \ErrorException && !empty($exception->skippable) ? $source . (strpos($source, '?') ? '&' : '?') . '_tracy_skip_error' : NULL; $lastError = $exception instanceof \ErrorException || $exception instanceof \Error ? NULL : error_get_last(); $dump = function($v) { return Dumper::toHtml($v, [ Dumper::DEPTH => $this->maxDepth, Dumper::TRUNCATE => $this->maxLength, Dumper::LIVE => TRUE, Dumper::LOCATION => Dumper::LOCATION_CLASS, ]); }; require $template; } /** * @return \stdClass[] */ private function renderPanels($ex) { $obLevel = ob_get_level(); $res = []; foreach ($this->panels as $callback) { try { $panel = call_user_func($callback, $ex); if (empty($panel['tab']) || empty($panel['panel'])) { continue; } $res[] = (object) $panel; continue; } catch (\Throwable $e) { } catch (\Exception $e) { } while (ob_get_level() > $obLevel) { // restore ob-level if broken ob_end_clean(); } is_callable($callback, TRUE, $name); $res[] = (object) [ 'tab' => "Error in panel $name", 'panel' => nl2br(Helpers::escapeHtml($e)), ]; } return $res; } /** * Returns syntax highlighted source code. * @param string * @param int * @param int * @return string|NULL */ public static function highlightFile($file, $line, $lines = 15, array $vars = NULL) { $source = @file_get_contents($file); // @ file may not exist if ($source) { $source = static::highlightPhp($source, $line, $lines, $vars); if ($editor = Helpers::editorUri($file, $line)) { $source = substr_replace($source, ' data-tracy-href="' . Helpers::escapeHtml($editor) . '"', 4, 0); } return $source; } } /** * Returns syntax highlighted source code. * @param string * @param int * @param int * @return string */ public static function highlightPhp($source, $line, $lines = 15, array $vars = NULL) { if (function_exists('ini_set')) { ini_set('highlight.comment', '#998; 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'); } $source = str_replace(["\r\n", "\r"], "\n", $source); $source = explode("\n", highlight_string($source, TRUE)); $out = $source[0]; // $source = str_replace('
', "\n", $source[1]); $out .= static::highlightLine($source, $line, $lines); if ($vars) { $out = preg_replace_callback('#">\$(\w+)( )?
#', function ($m) use ($vars) { return array_key_exists($m[1], $vars) ? '" title="' . str_replace('"', '"', trim(strip_tags(Dumper::toHtml($vars[$m[1]], [Dumper::DEPTH => 1])))) . $m[0] : $m[0]; }, $out); } $out = str_replace(' ', ' ', $out); return "
$out
"; } /** * Returns highlighted line in HTML code. * @return string */ public static function highlightLine($html, $line, $lines = 15) { $source = explode("\n", "\n" . str_replace("\r\n", "\n", $html)); $out = ''; $spans = 1; $start = $i = max(1, min($line, count($source) - 1) - floor($lines * 2 / 3)); while (--$i >= 1) { // find last highlighted block if (preg_match('#.*(]*>)#', $source[$i], $m)) { if ($m[1] !== '') { $spans++; $out .= $m[1]; } break; } } $source = array_slice($source, $start, $lines, TRUE); end($source); $numWidth = strlen((string) key($source)); foreach ($source as $n => $s) { $spans += substr_count($s, ']+>#', $s, $tags); if ($n == $line) { $out .= sprintf( "%{$numWidth}s: %s\n%s", $n, strip_tags($s), implode('', $tags[0]) ); } else { $out .= sprintf("%{$numWidth}s: %s\n", $n, $s); } } $out .= str_repeat('', $spans) . '
'; return $out; } /** * Should a file be collapsed in stack trace? * @param string * @return bool */ public function isCollapsed($file) { $file = strtr($file, '\\', '/') . '/'; foreach ($this->collapsePaths as $path) { $path = strtr($path, '\\', '/') . '/'; if (strncmp($file, $path, strlen($path)) === 0) { return TRUE; } } return FALSE; } } Nette-2.4-20160731/Nette/Tracy/Bar.php0000644000000000000000000001442712747434604015436 0ustar rootrootpanels[$id])); } $this->panels[$id] = $panel; return $this; } /** * Returns panel with given id * @param string * @return IBarPanel|NULL */ public function getPanel($id) { return isset($this->panels[$id]) ? $this->panels[$id] : NULL; } /** * Renders debug bar. * @return void */ public function render() { $useSession = $this->dispatched && session_status() === PHP_SESSION_ACTIVE; $redirectQueue = & $_SESSION['_tracy']['redirect']; if (!Helpers::isHtmlMode() && !Helpers::isAjax()) { return; } elseif (Helpers::isAjax()) { $rows[] = (object) ['type' => 'ajax', 'panels' => $this->renderPanels('-ajax')]; $dumps = Dumper::fetchLiveData(); $contentId = $useSession ? $_SERVER['HTTP_X_TRACY_AJAX'] . '-ajax' : NULL; } elseif (preg_match('#^Location:#im', implode("\n", headers_list()))) { // redirect $redirectQueue = array_slice((array) $redirectQueue, -10); Dumper::fetchLiveData(); Dumper::$livePrefix = count($redirectQueue) . 'p'; $redirectQueue[] = [ 'panels' => $this->renderPanels('-r' . count($redirectQueue)), 'dumps' => Dumper::fetchLiveData(), ]; return; } else { $rows[] = (object) ['type' => 'main', 'panels' => $this->renderPanels()]; $dumps = Dumper::fetchLiveData(); foreach (array_reverse((array) $redirectQueue) as $info) { $rows[] = (object) ['type' => 'redirect', 'panels' => $info['panels']]; $dumps += $info['dumps']; } $redirectQueue = NULL; $contentId = $useSession ? substr(md5(uniqid('', TRUE)), 0, 10) : NULL; } ob_start(function () {}); require __DIR__ . '/assets/Bar/panels.phtml'; require __DIR__ . '/assets/Bar/bar.phtml'; $content = Helpers::fixEncoding(ob_get_clean()); if ($contentId) { $queue = & $_SESSION['_tracy']['bar']; $queue = array_slice(array_filter((array) $queue), -5, NULL, TRUE); $queue[$contentId] = ['content' => $content, 'dumps' => $dumps]; } if (Helpers::isHtmlMode()) { $stopXdebug = extension_loaded('xdebug') ? ['XDEBUG_SESSION_STOP' => 1, 'XDEBUG_PROFILE' => 0, 'XDEBUG_TRACE' => 0] : []; $path = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI'])[0] : '/'; $lpath = strtolower($path); $script = isset($_SERVER['SCRIPT_NAME']) ? strtolower($_SERVER['SCRIPT_NAME']) : ''; if ($lpath !== $script) { $max = min(strlen($lpath), strlen($script)); for ($i = 0; $i < $max && $lpath[$i] === $script[$i]; $i++); $path = $i ? substr($path, 0, strrpos($path, '/', $i - strlen($path) - 1) + 1) : '/'; $cookiePath = session_get_cookie_params()['path']; if (substr($cookiePath, 0, strlen($path)) === $path) { $path = rtrim($cookiePath, '/') . '/'; } } require __DIR__ . '/assets/Bar/loader.phtml'; } } /** * @return array */ private function renderPanels($suffix = NULL) { set_error_handler(function ($severity, $message, $file, $line) { if (error_reporting() & $severity) { throw new \ErrorException($message, 0, $severity, $file, $line); } }); $obLevel = ob_get_level(); $panels = []; foreach ($this->panels as $id => $panel) { $idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id) . $suffix; try { $tab = (string) $panel->getTab(); $panelHtml = $tab ? (string) $panel->getPanel() : NULL; if ($tab && $panel instanceof \Nette\Diagnostics\IBarPanel) { $e = new \Exception('Support for Nette\Diagnostics\IBarPanel is deprecated'); } } catch (\Throwable $e) { } catch (\Exception $e) { } if (isset($e)) { while (ob_get_level() > $obLevel) { // restore ob-level if broken ob_end_clean(); } $idHtml = "error-$idHtml"; $tab = "Error in $id"; $panelHtml = "

Error: $id

" . nl2br(Helpers::escapeHtml($e)) . '
'; unset($e); } $panels[] = (object) ['id' => $idHtml, 'tab' => $tab, 'panel' => $panelHtml]; } restore_error_handler(); return $panels; } /** * Renders debug bar assets. * @return bool */ public function dispatchAssets() { $asset = isset($_GET['_tracy_bar']) ? $_GET['_tracy_bar'] : NULL; if ($asset === 'css') { header('Content-Type: text/css; charset=utf-8'); header('Cache-Control: max-age=864000'); header_remove('Pragma'); header_remove('Set-Cookie'); readfile(__DIR__ . '/assets/Bar/bar.css'); readfile(__DIR__ . '/assets/Toggle/toggle.css'); readfile(__DIR__ . '/assets/Dumper/dumper.css'); readfile(__DIR__ . '/assets/BlueScreen/bluescreen.css'); return TRUE; } elseif ($asset === 'js') { header('Content-Type: text/javascript'); header('Cache-Control: max-age=864000'); header_remove('Pragma'); header_remove('Set-Cookie'); readfile(__DIR__ . '/assets/Bar/bar.js'); readfile(__DIR__ . '/assets/Toggle/toggle.js'); readfile(__DIR__ . '/assets/Dumper/dumper.js'); readfile(__DIR__ . '/assets/BlueScreen/bluescreen.js'); return TRUE; } } /** * Renders debug bar content. * @return bool */ public function dispatchContent() { $this->dispatched = TRUE; if (Helpers::isAjax()) { header('X-Tracy-Ajax: 1'); // session must be already locked } if (preg_match('#^content(-ajax)?.(\w+)$#', isset($_GET['_tracy_bar']) ? $_GET['_tracy_bar'] : '', $m)) { $session = & $_SESSION['_tracy']['bar'][$m[2] . $m[1]]; header('Content-Type: text/javascript'); header('Cache-Control: max-age=60'); header_remove('Set-Cookie'); if ($session) { $method = $m[1] ? 'loadAjax' : 'init'; echo "Tracy.Debug.$method(", json_encode($session['content']), ', ', json_encode($session['dumps']), ');'; $session = NULL; } $session = & $_SESSION['_tracy']['bluescreen'][$m[2]]; if ($session) { echo "Tracy.BlueScreen.loadAjax(", json_encode($session['content']), ', ', json_encode($session['dumps']), ');'; $session = NULL; } return TRUE; } } } Nette-2.4-20160731/Nette/Tracy/assets/0000755000000000000000000000000012747434604015513 5ustar rootrootNette-2.4-20160731/Nette/Tracy/assets/Toggle/0000755000000000000000000000000012747434604016734 5ustar rootrootNette-2.4-20160731/Nette/Tracy/assets/Toggle/toggle.js0000644000000000000000000000353312747434632020560 0ustar rootroot(function(){Tracy=window.Tracy||{};Tracy.Toggle=Tracy.Toggle||{};Tracy.Toggle.init=function(){document.body.addEventListener("click",function(a){var d=Tracy.closest(a.target,".tracy-toggle");!d||(a.shiftKey||a.altKey||a.ctrlKey||a.metaKey)||Tracy.Toggle.toggle(d)});this.init=function(){}};Tracy.Toggle.toggle=function(a,d){var e=a.classList.contains("tracy-collapsed"),b=a.getAttribute("data-tracy-ref")||a.getAttribute("href",2),c=a;if("undefined"===typeof d)d=e;else if(!d===e)return;b&&"#"!==b?"#"=== b.substr(0,1)&&(c=document):b="+";b=b.match(/(\^\s*([^+\s]*)\s*)?(\+\s*(\S*)\s*)?(.*)/);c=b[1]?Tracy.closest(c.parentNode,b[2]):c;c=b[3]?Tracy.closest(c.nextElementSibling,b[4],"nextElementSibling"):c;c=b[5]?c.querySelector(b[5]):c;a.classList.toggle("tracy-collapsed",!d);c.classList.toggle("tracy-collapsed",!d);"function"===typeof window.Event?e=new Event("tracy-toggle",{bubbles:!0}):(e=document.createEvent("Event"),e.initEvent("tracy-toggle",!0,!1));a.dispatchEvent(e)};Tracy.Toggle.persist=function(a, d){var e=[];a.addEventListener("tracy-toggle",function(a){0>e.indexOf(a.target)&&e.push(a.target)});var b=JSON.parse(sessionStorage.getItem("tracy-toggles-"+a.id));b&&!1!==d&&b.forEach(function(c){var b=a,d;for(d in c.path)if(!(b=b.children[c.path[d]]))return;b.textContent===c.text&&Tracy.Toggle.toggle(b,c.show)});window.addEventListener("unload",function(){b=[].map.call(e,function(c){var b={path:[],text:c.textContent,show:!c.classList.contains("tracy-collapsed")};do b.path.unshift([].indexOf.call(c.parentNode.children, c)),c=c.parentNode;while(c&&c!==a);return b});sessionStorage.setItem("tracy-toggles-"+a.id,JSON.stringify(b))})};Tracy.closest=function(a,d,e){for(var b=a.matches||a.matchesSelector||a.msMatchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.oMatchesSelector;a&&d&&(1!==a.nodeType||!b.call(a,d));)a=a[e||"parentNode"];return a}})();Nette-2.4-20160731/Nette/Tracy/assets/Toggle/toggle.css0000644000000000000000000000031312747434630020723 0ustar rootroot.tracy-collapsed{display:none}.tracy-toggle.tracy-collapsed{display:inline}.tracy-toggle{cursor:pointer}.tracy-toggle:after{content:" ▼";opacity:.4}.tracy-toggle.tracy-collapsed:after{content:" ►"}Nette-2.4-20160731/Nette/Tracy/assets/Dumper/0000755000000000000000000000000012747434604016747 5ustar rootrootNette-2.4-20160731/Nette/Tracy/assets/Dumper/dumper.js0000644000000000000000000000510312747434630020577 0ustar rootroot(function(){Tracy=window.Tracy||{};Tracy.Dumper=Tracy.Dumper||{};Tracy.Dumper.init=function(a,e){a&&[].forEach.call((e||document).querySelectorAll(".tracy-dump[data-tracy-dump]"),function(c){try{c.appendChild(k(JSON.parse(c.getAttribute("data-tracy-dump")),a,c.classList.contains("tracy-collapsed"))),c.classList.remove("tracy-collapsed"),c.removeAttribute("data-tracy-dump")}catch(b){if(!(b instanceof m))throw b;}});this.inited||(this.inited=!0,document.body.addEventListener("click",function(a){var b; if(a.ctrlKey&&(b=Tracy.closest(a.target,"[data-tracy-href]")))return location.href=b.getAttribute("data-tracy-href"),!1}),Tracy.Toggle.init())};var k=function(a,e,c,b){var d=null===a?"null":typeof a,h="undefined"===typeof c?14:7;if("null"===d||"string"===d||"number"===d||"boolean"===d)return a="string"===d?'"'+a+'"':(a+"").toUpperCase(),f(null,null,[f("span",{"class":"tracy-dump-"+d.replace("ean","")},[a+"\n"])]);if(Array.isArray(a))return n([f("span",{"class":"tracy-dump-array"},["array"])," ("+ (a[0]&&a.length||"")+")"]," [ ... ]",null===a[0]?null:a,!0===c||a.length>=h,e,b);if("object"===d&&a.number)return f(null,null,[f("span",{"class":"tracy-dump-number"},[a.number+"\n"])]);if("object"===d&&a.type)return f(null,null,[f("span",null,[a.type+"\n"])]);if("object"===d){var d=a.object||a.resource,g=e[d];if(!g)throw new m;b=b||[];recursive=-1=h,e,b)}},n=function(a,e,c,b,d,h){var g,l,k;if(!c||!c.length)return a.push(!c||c.length?e+"\n":"\n"),f(null,null,a);a=f(null,null,[g=f("span",{"class":b?"tracy-toggle tracy-collapsed":"tracy-toggle"},a),"\n",l=f("div",{"class":b?"tracy-collapsed":""})]);b?g.addEventListener("tracy-toggle",k=function(){g.removeEventListener("tracy-toggle", k);p(l,c,d,h)}):p(l,c,d,h);return a},f=function(a,e,c){a instanceof Node||(a=a?document.createElement(a):document.createDocumentFragment());for(var b in e||{})null!==e[b]&&a.setAttribute(b,e[b]);c=c||[];for(b=0;b ",k(e[d][1],c,null,b)])}},m=function(){}})();Nette-2.4-20160731/Nette/Tracy/assets/Dumper/dumper.css0000644000000000000000000000074412747434630020761 0ustar rootrootpre.tracy-dump{text-align:left;color:#444;background:white}pre.tracy-dump div{padding-left:3ex}pre.tracy-dump div div{border-left:1px solid rgba(0,0,0,.1);margin-left:.5ex}.tracy-dump-array,.tracy-dump-object{color:#C22}.tracy-dump-string{color:#35D}.tracy-dump-number{color:#090}.tracy-dump-null,.tracy-dump-bool{color:#850}.tracy-dump-visibility,.tracy-dump-hash{font-size:85%;color:#999}.tracy-dump-indent{display:none}span[data-tracy-href]{border-bottom:1px dotted rgba(0,0,0,.2)}Nette-2.4-20160731/Nette/Tracy/assets/Debugger/0000755000000000000000000000000012747434604017237 5ustar rootrootNette-2.4-20160731/Nette/Tracy/assets/Debugger/error.500.phtml0000644000000000000000000000154012747434630021740 0ustar rootroot Server Error

Server Error

We're sorry! The server encountered an internal error and was unable to complete your request. Please try again later.

error 500
Tracy is unable to log error.

Nette-2.4-20160731/Nette/Tracy/assets/BlueScreen/0000755000000000000000000000000012747434604017542 5ustar rootrootNette-2.4-20160731/Nette/Tracy/assets/BlueScreen/page.phtml0000644000000000000000000000433612747434630021531 0ustar rootrootgetCode() ? ' #' . $exception->getCode() : ''; ?> <?= Helpers::escapeHtml($title . ': ' . $exception->getMessage() . $code) ?> getPrevious()): ?> Nette-2.4-20160731/Nette/Tracy/assets/BlueScreen/content.phtml0000644000000000000000000002625712747434604022276 0ustar rootrootgetCode() ? ' #' . $exception->getCode() : ''; ?>
getMessage()): ?>

getMessage() ?: $title . $code)) ?> getMessage())) ?>" target="_blank" rel="noreferrer noopener">search► skip error►

getPrevious()): ?>
>

Caused by

getCode() ? ' #' . $ex->getCode() : '')) ?>

getMessage()) ?>

renderPanels($ex) as $panel): ?>

tab) ?>

panel ?>
getTrace(); $expanded = NULL ?> getSeverity(), [E_USER_NOTICE, E_USER_WARNING, E_USER_DEPRECATED])) && $this->isCollapsed($ex->getFile())) { foreach ($stack as $key => $row) { if (isset($row['file']) && !$this->isCollapsed($row['file'])) { $expanded = $key; break; } } } ?>

Source file

File: getFile(), $ex->getLine()) ?>

getFile())): ?>getFile(), $ex->getLine(), 15, $ex instanceof \ErrorException && isset($ex->context) ? $ex->context : NULL) ?>

Call stack

    $row): ?>
  1. inner-code source  "; if (isset($row['class'])) echo Helpers::escapeHtml($row['class'] . $row['type']); if (isset($row['object'])) echo ''; echo Helpers::escapeHtml($row['function']), '('; if (!empty($row['args'])): ?>arguments)

    getParameters(); } catch (\Exception $e) { $params = []; } foreach ($row['args'] as $k => $v) { echo '\n"; } ?>
    ', Helpers::escapeHtml(isset($params[$k]) ? '$' . $params[$k]->name : "#$k"), ''; echo $dump($v); echo "
context) && is_array($ex->context)):?>

Variables

context as $k => $v) { echo '\n"; } ?>
$', Helpers::escapeHtml($k), '', $dump($v), "
getPrevious()); ?>
' ?> count((array) new \Exception)):?>

Last muted error

:

inner-code

renderPanels(NULL) as $panel): ?> bottom)) { $bottomPanels[] = $panel; continue; } ?>

tab) ?>

panel ?>

Environment

$_SERVER

$v) echo '\n"; ?>
', Helpers::escapeHtml($k), '', $dump($v), "

$_SESSION

empty

$v) echo '\n"; ?>
', Helpers::escapeHtml($k), '', $k === '__NF' ? 'Nette Session' : $dump($v), "

Nette Session

$v) echo '\n"; ?>
', Helpers::escapeHtml($k), '', $dump($v), "

Constants

$v) { echo ''; echo '\n"; } ?>
', Helpers::escapeHtml($k), '', $dump($v), "

Configuration options

|.+\z#s', '', ob_get_clean()) // @ phpinfo can be disabled ?>

HTTP request

Headers

$v) echo '\n"; ?>
', Helpers::escapeHtml($k), '', Helpers::escapeHtml($v), "

$

empty

$v) echo '\n"; ?>
', Helpers::escapeHtml($k), '', $dump($v), "

HTTP response

Headers

';
			?>

no headers

tab) ?>

panel ?>
  • Report generated at
Nette-2.4-20160731/Nette/Tracy/assets/BlueScreen/bluescreen.js0000644000000000000000000000217612747434626022241 0ustar rootroot(function(){Tracy=window.Tracy||{};var f=Tracy.BlueScreen={},g;f.init=function(b){for(var d=document.getElementById("tracy-bs"),a=0,e=[];a:first-child{width:20%}#tracy-bs tr:nth-child(2n),#tracy-bs tr:nth-child(2n) pre{background-color:#F7F0CB}#tracy-bs ol{margin:1em 0;padding-left:2.5em}#tracy-bs ul{font:7pt/1.5 Verdana,sans-serif!important;padding:2em 4em;margin:1em 0 0;color:#777;background:#F6F5F3;border-top:1px solid #DDD}#tracy-bs-logo a{position:absolute;bottom:0;right:0;width:100px;height:50px;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAUBAMAAAD/1DctAAAAMFBMVEWupZzj39rEvbTy8O3X0sz9/PvGwLu8tavQysHq6OS0rKP5+Pbd2dT29fPMxbzPx8DKErMJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGUlEQVQoFX3TQWgTQRQA0MWLIJJDYehBTykhG5ERTx56K1u8eEhCYtomE7x5L4iLh0ViF7egewuFFqSIYE6hIHsIYQ6CQSg9CDKn4QsNCRlB59C74J/ZNHW1+An5+bOPyf6/s46oz2P+A0yIeZZ2ieEHi6TOnLKTxvWq+b52mxlVO3xnM1s7xLX1504XQH65OnW2dBqn7cCkYsFsfYsWpyY/2salmFTpEyzeR8zosYqMdiPDXdyU52K1wgEa/SjGpdEwUAxqvRfckQCDOyFearsEHe2grvkh/cFAHKvdtI3lcVceKQIOFpv+FOZaNPQBwJZLPp+hfrvT5JZXaUFsR8zqQc9qSgAharkfS5M/5F6nGJJAtXq/eLr3ucZpHccSxOOIPaQhtHohpCH2Xu6rLmQ0djnr4/+J3C6v+AW8/XWYxwYNdlhWj/P5fPSTQwVr0T9lGxdaBCqErNZaqYnEwbkjEB3NasGF3lPdrHa1nnxNOMgj0+neePUPjd2v/qVvUv29ifvc19huQ48qwXShy/9o8o3OSk0cs37mOFd0Ydgvsf/oZEnPVtggfd66lORn9mDyyzXU13SRtH2L6aR5T/snGAcZPfAXz5J1YlJWBEuxdMYqQecpBrlM49xAbmqyHA+xlA1FxBtqT2xmJoNXZlIt74ZBLeJ9ZGDqByNI7p543idzJ23vXEv7IgnsxiS+eNtwNbFdLq7+Bi4wQ0I4SVb9AAAAAElFTkSuQmCC') no-repeat;opacity:.6;padding:0;margin:0}#tracy-bs-logo a:hover,#tracy-bs-logo a:active,#tracy-bs-logo a:focus{opacity:1;transition:opacity 0.1s}#tracy-bs div.panel{padding:1px 25px}#tracy-bs div.inner{background:#F4F3F1;padding:.1em 1em 1em;border-radius:8px}#tracy-bs .outer{overflow:auto}#tracy-bs pre.code>div{min-width:100%;float:left;white-space:pre}#tracy-bs .highlight{background:#CD1818;color:white;font-weight:bold;font-style:normal;display:block;padding:0 .4em;margin:0 -.4em}#tracy-bs .line{color:#9F9C7F;font-weight:normal;font-style:normal}#tracy-bs pre:hover span[title]{border-bottom:1px solid rgba(0,0,0,0.2)}#tracy-bs a[href^=editor\:]{color:inherit;border-bottom:1px dotted rgba(0,0,0,.3)}#tracy-bs span[data-tracy-href]{border-bottom:1px dotted rgba(0,0,0,.3)}html.tracy-js #tracy-bs .tracy-collapsed{display:none}html.tracy-js #tracy-bs .tracy-toggle.tracy-collapsed{display:inline}#tracy-bs .tracy-toggle{cursor:pointer}#tracy-bs .tracy-toggle:after{content:" ▼";opacity:.4}#tracy-bs .tracy-toggle.tracy-collapsed:after{content:" ►";opacity:.4}#tracy-bs .tracy-dump-array,#tracy-bs .tracy-dump-object{color:#C22}#tracy-bs .tracy-dump-string{color:#35D}#tracy-bs .tracy-dump-number{color:#090}#tracy-bs .tracy-dump-null,#tracy-bs .tracy-dump-bool{color:#850}#tracy-bs .tracy-dump-visibility,#tracy-bs .tracy-dump-hash{font-size:85%;color:#998}#tracy-bs .tracy-dump-indent{display:none}#tracy-bs pre.tracy-dump div{padding-left:3ex}#tracy-bs pre.tracy-dump div div{border-left:1px solid rgba(0,0,0,.1);margin-left:.5ex}#tracy-bs .caused{float:right;padding:.3em .6em;background:#df8075;border-radius:0 0 0 8px;white-space:nowrap}#tracy-bs .caused a{color:white}Nette-2.4-20160731/Nette/Tracy/assets/Bar/0000755000000000000000000000000012747434604016217 5ustar rootrootNette-2.4-20160731/Nette/Tracy/assets/Bar/panels.phtml0000644000000000000000000000135612747434604020554 0ustar rootroot ¤ ×
'; foreach ($rows as $row) { foreach ($row->panels as $panel) { $content = $panel->panel ? ($panel->panel . "\n" . $icons) : ''; $class = 'tracy-panel ' . ($row->type === 'ajax' ? 'tracy-ajax' : ''); ?>
'css', 'v' => Debugger::VERSION] + $stopXdebug, NULL, '&') ?>" id="tracy-debug-style" class="tracy-debug" /> Nette-2.4-20160731/Nette/Tracy/assets/Bar/info.tab.phtml0000644000000000000000000000122312747434604020763 0ustar rootroottime = microtime(TRUE) - Debugger::$time; ?> time * 1000, 1, '.', ' ') ?> ms Nette-2.4-20160731/Nette/Tracy/assets/Bar/info.panel.phtml0000644000000000000000000000445612747434624021331 0ustar rootrootcpuUsage) && $this->time) { foreach (getrusage() as $key => $val) { $this->cpuUsage[$key] -= $val; } $userUsage = -round(($this->cpuUsage['ru_utime.tv_sec'] * 1e6 + $this->cpuUsage['ru_utime.tv_usec']) / $this->time / 10000); $systemUsage = -round(($this->cpuUsage['ru_stime.tv_sec'] * 1e6 + $this->cpuUsage['ru_stime.tv_usec']) / $this->time / 10000); } $info = array_filter([ 'Execution time' => number_format($this->time * 1000, 1, '.', ' ') . ' ms', 'CPU usage user + system' => isset($userUsage) ? (int) $userUsage . ' % + ' . (int) $systemUsage . ' %' : NULL, 'Peak of allocated memory' => number_format(memory_get_peak_usage() / 1000000, 2, '.', ' ') . ' MB', 'Included files' => count(get_included_files()), 'Classes + interfaces + traits' => count(get_declared_classes()) . ' + ' . count(get_declared_interfaces()) . ' + ' . count(get_declared_traits()), 'Your IP' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : NULL, 'Server IP' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : NULL, 'HTTP method / response code' => isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] . ' / ' . http_response_code() : NULL, 'HHVM' => defined('HHVM_VERSION') ? HHVM_VERSION : NULL, 'PHP' => PHP_VERSION, 'Xdebug' => extension_loaded('xdebug') ? phpversion('xdebug') : NULL, 'Tracy' => Debugger::VERSION, 'Server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : NULL, ] + (array) $this->data); ?>

System info

$val): ?> 25): ?>
Nette-2.4-20160731/Nette/Tracy/assets/Bar/errors.tab.phtml0000644000000000000000000000162212747434604021347 0ustar rootroot 1 ? ' errors' : ' error' ?> Nette-2.4-20160731/Nette/Tracy/assets/Bar/errors.panel.phtml0000644000000000000000000000107612747434604021703 0ustar rootroot

Errors

$count): list($file, $line, $message) = explode('|', $item, 3) ?>
Nette-2.4-20160731/Nette/Tracy/assets/Bar/dumps.tab.phtml0000644000000000000000000000171412747434604021165 0ustar rootroot dumps Nette-2.4-20160731/Nette/Tracy/assets/Bar/dumps.panel.phtml0000644000000000000000000000113212747434624021512 0ustar rootroot

Dumps

Nette-2.4-20160731/Nette/Tracy/assets/Bar/bar.phtml0000644000000000000000000000346412747434604020040 0ustar rootroottab) { ?>
  • panel): ?>tab) ?>', trim($panel->tab), ''; endif ?>
  • type === 'main'): ?>
    type === 'main'): ?>
      panels) ?>
    • ×
    type === 'redirect'): ?>
    • redirect
    • panels) ?>
    type === 'ajax'): ?>
    • AJAX
    • panels) ?>
    type === 'main'): ?>
    Nette-2.4-20160731/Nette/Tracy/assets/Bar/bar.js0000644000000000000000000002353212747434624017330 0ustar rootroot(function(){function m(a,b){b=b||window;g(a.getElementsByTagName("script"),function(a){a.hasAttribute("type")&&"text/javascript"!==a.type&&"application/javascript"!==a.type||a.tracyEvaluated||((b.execScript||function(a){b.eval.call(b,a)})(a.innerHTML),a.tracyEvaluated=!0)})}function p(a,b){for(;a;){if(a===b)return;a=a.parentNode}return!0}function s(a,b){var c=document.documentElement,d,e,f,q,g;b=b||{};var l=function(){r&&(k(a,{right:e-q,bottom:f-g}),requestAnimationFrame(l))},n=function(c){if(0=== c.buttons)return m(c);d||(b.draggedClass&&a.classList.add(b.draggedClass),b.start&&b.start(c,a),d=!0);q=c.clientX;g=c.clientY;return!1},m=function(e){d&&(b.draggedClass&&a.classList.remove(b.draggedClass),b.stop&&b.stop(e,a));r=null;c.removeEventListener("mousemove",n);c.removeEventListener("mouseup",m);return!1};(b.handle||a).addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();if(r)return m(b);var k=h(a);q=b.clientX;g=b.clientY;e=k.right+q;f=k.bottom+g;r=!0;d=!1;c.addEventListener("mousemove", n);c.addEventListener("mouseup",m);requestAnimationFrame(l)});(b.handle||a).addEventListener("click",function(a){d&&a.stopImmediatePropagation()})}function n(a){for(var b={left:a.offsetLeft,top:a.offsetTop};a=a.offsetParent;)b.left+=a.offsetLeft,b.top+=a.offsetTop;return b}function k(a,b){var c=document.documentElement,d="BackCompat"===document.compatMode?window.innerHeight:c.clientHeight;a.style.right=Math.min(Math.max(b.right,0),c.clientWidth-a.offsetWidth)+"px";a.style.bottom=Math.min(Math.max(b.bottom, 0),d-a.offsetHeight)+"px"}function h(a){return{left:a.offsetLeft,top:a.offsetTop,right:a.style.right?parseInt(a.style.right,10):0,bottom:a.style.bottom?parseInt(a.style.bottom,10):0,width:a.offsetWidth,height:a.offsetHeight}}function g(a,b){Array.prototype.forEach.call(a,b)}Tracy=window.Tracy||{};var l=document.getElementById("tracy-debug");Tracy.getAjaxHeader=function(){return l.dataset.id};var d=Tracy.DebugPanel=function(a){this.id=a;this.elem=document.getElementById(this.id);this.elem.Tracy=this.elem.Tracy|| {}};d.PEEK="tracy-mode-peek";d.FLOAT="tracy-mode-float";d.WINDOW="tracy-mode-window";d.FOCUSED="tracy-focused";d.zIndex=2E4;d.prototype.init=function(){var a=this,b=this.elem;b.innerHTML=b.dataset.tracyContent;Tracy.Dumper.init(this.dumps,b);delete b.dataset.tracyContent;delete this.dumps;m(b);s(b,{handle:b.querySelector("h1"),stop:function(){a.toFloat()}});b.addEventListener("mouseover",function(b){p(b.relatedTarget,this)&&a.focus()});b.addEventListener("mouseout",function(b){p(b.relatedTarget,this)&& a.blur()});b.addEventListener("click",function(){a.oldPosition=h(b)});b.addEventListener("tracy-toggle",function(){if(a.oldPosition){var c=h(b);k(b,{right:c.right-c.width+a.oldPosition.width,bottom:c.bottom-c.height+a.oldPosition.height});a.oldPosition=null}});g(b.querySelectorAll(".tracy-icons a"),function(b){b.addEventListener("click",function(b){"close"===this.rel?a.toPeek():a.toWindow();b.preventDefault()})});this.is("tracy-ajax")||Tracy.Toggle.persist(b)};d.prototype.is=function(a){return this.elem.classList.contains(a)}; d.prototype.focus=function(a){var b=this.elem;this.is(d.WINDOW)?b.Tracy.window.focus():(clearTimeout(b.Tracy.displayTimeout),b.Tracy.displayTimeout=setTimeout(function(){b.classList.add(d.FOCUSED);b.style.display="block";b.style.zIndex=d.zIndex++;a&&a()},50))};d.prototype.blur=function(){var a=this.elem;a.classList.remove(d.FOCUSED);this.is(d.PEEK)&&(clearTimeout(a.Tracy.displayTimeout),a.Tracy.displayTimeout=setTimeout(function(){a.style.display="none"},50))};d.prototype.toFloat=function(){this.elem.classList.remove(d.WINDOW); this.elem.classList.remove(d.PEEK);this.elem.classList.add(d.FLOAT);this.elem.style.display="block";this.reposition()};d.prototype.toPeek=function(){this.elem.classList.remove(d.WINDOW);this.elem.classList.remove(d.FLOAT);this.elem.classList.add(d.PEEK);this.elem.style.display="none"};d.prototype.toWindow=function(){function a(a){return a.replace(/&/g,"&").replace(/ Nette-2.4-20160731/examples/Modules-Usage/0000755000000000000000000000000012747434622016340 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/www/0000755000000000000000000000000012747434554017170 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/www/web.config0000644000000000000000000000121012747434554021126 0ustar rootroot Nette-2.4-20160731/examples/Modules-Usage/www/index.php0000644000000000000000000000033012747434554021004 0ustar rootrootgetByType(Nette\Application\Application::class) ->run(); Nette-2.4-20160731/examples/Modules-Usage/www/css/0000755000000000000000000000000012747434554017760 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/www/css/site.css0000644000000000000000000000160712747434554021442 0ustar rootroothtml { font: 16px/1.5 "Trebuchet MS", "Geneva CE", lucida, sans-serif; border-top: 4.7em solid #F4EBDB; } body { max-width: 990px; margin: -4.7em auto 0; background: white; color: #333; } h1 { font: 1.9em/1.5 sans-serif; margin: .5em 0 1.5em; background: url(https://files.nette.org/icons/logo-e1.png) right center no-repeat; color: #7A7772; text-shadow: 1px 1px 0 white; } h2 { font-size: 120%; color: #3484D2; } #content { width: 770px; margin: 0 5px; border: 1px dotted gray; } #path { margin: 50px 0; } #module { background: #fee7bc; padding: 30px 10px; =padding: 10px; font-weight: bold; } #presenter { background: #afcbe3; padding: 20px 10px 20px 0; =padding: 10px 10px 10px 0; } #view { background: #c4e8c4; padding: 10px 10px 10px 0; font-weight: normal; } fieldset { margin: 1em; padding: 1em; } Nette-2.4-20160731/examples/Modules-Usage/www/.htaccess0000644000000000000000000000047412747434554020773 0ustar rootroot# disable directory listing Options -Indexes # mod_rewrite RewriteEngine On # RewriteBase / # front controller RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L] Nette-2.4-20160731/examples/Modules-Usage/temp/0000755000000000000000000000000012747434616017310 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/temp/.htaccess0000644000000000000000000000003712747434554021107 0ustar rootrootOrder Allow,Deny Deny from allNette-2.4-20160731/examples/Modules-Usage/readme.txt0000644000000000000000000000223412747434554020343 0ustar rootrootModules (Nette Framework example) --------------------------------- The example demonstrates the usage of modules and submodules in [Nette Framework](https://nette.org). Presenters (and then templates) are separated on two main modules Front and Admin. Furthermore, the Front module contains the Export submodule. What is [Nette Framework](https://nette.org)? -------------------------------------------- Nette Framework is a popular tool for PHP web development. It is designed to be the most usable and friendliest as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks. Nette Framework speaks your language and helps you to easily build better websites. Installing ---------- The best way to install Nette Framework is to download latest package from https://nette.org/download or using [Composer](https://doc.nette.org/composer): curl -s http://getcomposer.org/installer | php php composer.phar update Then navigate your browser to the `www` directory. PHP 5.4 allows you run `php -S localhost:8888 -t www` to start the webserver and then visit `http://localhost:8888` in your browser. Nette-2.4-20160731/examples/Modules-Usage/log/0000755000000000000000000000000012747434616017124 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/log/.htaccess0000644000000000000000000000003712747434554020723 0ustar rootrootOrder Allow,Deny Deny from allNette-2.4-20160731/examples/Modules-Usage/composer.json0000644000000000000000000000110712747434554021065 0ustar rootroot{ "name": "nette-examples/modules-usage", "type": "project", "description": "The example demonstrates the usage of modules and submodules.", "license": "BSD-3-Clause", "authors": [ { "name": "David Grudl", "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", "homepage": "https://nette.org/contributors" } ], "require": { "php": ">=5.4", "nette/application": "~2.3", "nette/bootstrap": "~2.3", "nette/robot-loader": "~2.3", "latte/latte": "~2.3", "tracy/tracy": "~2.3" }, "minimum-stability": "dev" } Nette-2.4-20160731/examples/Modules-Usage/app/0000755000000000000000000000000012747434554017124 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/web.config0000644000000000000000000000111712747434554021070 0ustar rootroot Nette-2.4-20160731/examples/Modules-Usage/app/modules/0000755000000000000000000000000012747434554020574 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/modules/Front.Export/0000755000000000000000000000000012747434554023144 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/modules/Front.Export/templates/0000755000000000000000000000000012747434554025142 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/modules/Front.Export/templates/Default.xml.latte0000644000000000000000000000014112747434554030354 0ustar rootroot{extends none}
    <item>
    	<title>Product</title>
    	...
    	...
    </item>
    
    Nette-2.4-20160731/examples/Modules-Usage/app/modules/Front.Export/DefaultPresenter.php0000644000000000000000000000022412747434554027127 0ustar rootroot
  • addItem - link to view addItem in current presenter
  • CatalogList: - link to presenter CatalogList in current module and view default
  • Export:Default:xml - link to presenter Default in Export submodule and view xml
  • :Admin:Default: - link to presenter Default in Admin module (view default)
  • Nette-2.4-20160731/examples/Modules-Usage/app/modules/Front/templates/Default/addItem.latte0000644000000000000000000000045412747434554027653 0ustar rootroot{block content}
    • default - link to view default in current presenter
    • CatalogList: - link to presenter CatalogList in current module (view default)
    Nette-2.4-20160731/examples/Modules-Usage/app/modules/Front/templates/CatalogList/0000755000000000000000000000000012747434554026070 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/modules/Front/templates/CatalogList/default.latte0000644000000000000000000000006612747434554030551 0ustar rootroot{block content} …empty file… Nette-2.4-20160731/examples/Modules-Usage/app/modules/Front/templates/@layout.latte0000644000000000000000000000166612747434554026343 0ustar rootroot Modules demo

    Modules demo

    {$moduleName}{$presenterName}:{$viewName}
    This is layout template {$this->getParentName() |replace:$root}
    This is content block template {$this->getName() |replace:$root} {include content}

    Absolute links

    Nette-2.4-20160731/examples/Modules-Usage/app/modules/Front/DefaultPresenter.php0000644000000000000000000000021512747434554025647 0ustar rootroottemplate->viewName = $this->getView(); $this->template->root = isset($_SERVER['SCRIPT_FILENAME']) ? realpath(dirname(dirname($_SERVER['SCRIPT_FILENAME']))) : NULL; $a = strrpos($this->getName(), ':'); if ($a === FALSE) { $this->template->moduleName = ''; $this->template->presenterName = $this->getName(); } else { $this->template->moduleName = substr($this->getName(), 0, $a + 1); $this->template->presenterName = substr($this->getName(), $a + 1); } } } Nette-2.4-20160731/examples/Modules-Usage/app/modules/Admin/0000755000000000000000000000000012747434554021624 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/modules/Admin/templates/0000755000000000000000000000000012747434554023622 5ustar rootrootNette-2.4-20160731/examples/Modules-Usage/app/modules/Admin/templates/Default.default.latte0000644000000000000000000000006612747434554027666 0ustar rootroot{block content} …empty file… Nette-2.4-20160731/examples/Modules-Usage/app/modules/Admin/templates/@layout.latte0000644000000000000000000000166612747434554026303 0ustar rootroot Modules demo

    Modules demo

    {$moduleName}{$presenterName}:{$viewName}
    This is layout template {$this->getParentName() |replace:$root}
    This is content block template {$this->getName() |replace:$root} {include content}

    Absolute links

    Nette-2.4-20160731/examples/Modules-Usage/app/modules/Admin/DefaultPresenter.php0000644000000000000000000000021512747434554025607 0ustar rootrootenableDebugger(__DIR__ . '/../log'); // Enable RobotLoader - this will load all classes automatically $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader() ->addDirectory(__DIR__) ->register(); // Create Dependency Injection container from config.neon file $configurator->addConfig(__DIR__ . '/config.neon'); $container = $configurator->createContainer(); // Setup router using mod_rewrite detection if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) { $router = $container->getByType(Nette\Application\IRouter::class); $router[] = new Route('index.php', 'Front:Default:default', Route::ONE_WAY); $router[] = $adminRouter = new RouteList('Admin'); $adminRouter[] = new Route('admin//', 'Default:default'); $router[] = $frontRouter = new RouteList('Front'); $frontRouter[] = new Route('/[/]', 'Default:default'); } else { $container->addService('router', new SimpleRouter('Front:Default:default')); } return $container; Nette-2.4-20160731/examples/Modules-Usage/app/.htaccess0000644000000000000000000000004112747434554020715 0ustar rootrootOrder Allow,Deny Deny from all Nette-2.4-20160731/examples/Micro-blog/0000755000000000000000000000000012747434622015660 5ustar rootrootNette-2.4-20160731/examples/Micro-blog/www/0000755000000000000000000000000012747434554016510 5ustar rootrootNette-2.4-20160731/examples/Micro-blog/www/style.css0000644000000000000000000000270412747434554020365 0ustar rootroot body { font: 16px/1.5 Georgia, Verdana, Arial; margin: 0 auto; width: 600px; color: #333; background-color: #fff; } h1, h2 { color: #3484D2; font-size: 1.9em; text-align: center; font-weight: normal; } h1 a { color: #3484D2; } h2 { font-size: 1.4em; } .date { color: #999; text-align: center; font-variant: small-caps; font-size: .8em; letter-spacing: 3px; margin: 0 0 -1em; } .article { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAAAUCAMAAABrnCsKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQ5QTFRFr66tsK+usLCusbCvtLOytbSzubi2ubm3urm3urq4vLu6vb27v769wL+9wL++w8LAxMPBxcTCxcXDxsbEx8bEx8fFyMfFyMjGysnIzMvLzMzLzMzMzc3Lzs7Mz87Mz8/N0M/N0tHQ09PS1NPR1NTS1NTT1dTS1dXT1tXU1tbU19bU19bV19fV2NfV2NfW2djW2dnW2dnX2dnY2tnX2trX29rY29vY29vZ3NzZ3dza3t3b3t7c39/d4N/d4ODd4ODf4eDe4eHh4uLg4+Lg4+Lh4+Pg4+Ph5OPh5OTi5eXj5eXk5ubj5+bm6Ofl6enm6unn6+ro8vHx9fT09fX19vX19/f3+Pj3+vr6/f39////uLBi1QAAAM5JREFUWMNjiBxpgGHUx6M+HvXxqI/JAGKRIi6RgiPHx5qRIgpmGoKikSFhI8THwkIy/v5O3iq8PCMjjsO9IgUCnK1t3Fy5R0qqFuA38LS0MDd3V+NkjxgoH0vTFKDbKOhvY2FuYmBlI4sqLk0XQP84VuTR8rMyMzbQtXBSYA0fGSWXkbmdob6uvpO8o33wiPCxD4eyr62psYM6B/MIKbmUIvX49N08dNhCJaVGSpuLJYiLU06VQWLEtLkCwyMZI5m0I8VHexKjPh71MZUAAOANSHaOv55SAAAAAElFTkSuQmCC) no-repeat center bottom; padding-bottom:2em; margin-bottom:2em; } .comments { font-size: .9em; } .footer { border-top: 1px solid #CCC; margin: 2em 0; padding-top: 1em; text-align: center; } Nette-2.4-20160731/examples/Micro-blog/www/index.php0000644000000000000000000000151512747434604020326 0ustar rootrootenableDebugger(__DIR__ . '/data/log'); // Create Dependency Injection container $configurator->setTempDirectory(__DIR__ . '/data/temp'); $configurator->addConfig(__DIR__ . '/config.neon'); $container = $configurator->createContainer(); // Enable template router $container->addService('router', new TemplateRouter('data/templates', __DIR__ . '/data/temp')); // Run the application! $container->getByType(Nette\Application\Application::class) ->run(); Nette-2.4-20160731/examples/Micro-blog/www/data/0000755000000000000000000000000012747434554017421 5ustar rootrootNette-2.4-20160731/examples/Micro-blog/www/data/templates/0000755000000000000000000000000012747434554021417 5ustar rootrootNette-2.4-20160731/examples/Micro-blog/www/data/templates/index.latte0000644000000000000000000000107412747434554023563 0ustar rootroot{url [index.php]} {url [page-]} {layout "@layout.latte"} {block content} {default $page = 1} {foreach $context->getByType('Nette\Database\Context')->table('article')->order('created')->page($page, 5) as $article}
    {$article->created|date:'F j, Y'}

    {$article->title}

    {$article->content|noescape}
    {/foreach}

    ← back   next →

    Nette-2.4-20160731/examples/Micro-blog/www/data/templates/article.latte0000644000000000000000000000114212747434554024073 0ustar rootroot{url article/} {layout "@layout.latte"} {var $article = $context->getByType('Nette\Database\Context')->table('article')->get($id) OR $presenter->error(404)} {block content}

    ← back

    {$article->created|date:'F j, Y'}

    {$article->title}

    {$article->content|noescape}

    Comments

    {foreach $article->related('comment')->order('created') as $comment}

    {$comment->name} said…

    {$comment->content|noescape} {/foreach}
    Nette-2.4-20160731/examples/Micro-blog/www/data/templates/@layout.latte0000644000000000000000000000063212747434554024070 0ustar rootroot {block title|stripHtml|trim}Homepage{/block} | Nette Framework Micro-blog example

    My Blog

    {include content} Nette-2.4-20160731/examples/Micro-blog/www/data/TemplateRouter.php0000644000000000000000000000263712747434554023116 0ustar rootrootscanRoutes($path); file_put_contents($cacheFile, ' $file) { $this[] = new Routers\Route($mask, function ($presenter) use ($file, $cachePath) { return $presenter->createTemplate(NULL, function () use ($cachePath) { $latte = new Latte\Engine; $latte->setTempDirectory($cachePath . '/cache'); $macroSet = new Latte\Macros\MacroSet($latte->getCompiler()); $macroSet->addMacro('url', function () {}, NULL, NULL, $macroSet::ALLOWED_IN_HEAD); // ignore return $latte; })->setFile($file); }); } } public function scanRoutes($path) { $routes = []; $latte = new Latte\Engine; $macroSet = new Latte\Macros\MacroSet($latte->getCompiler()); $macroSet->addMacro('url', function ($node) use (&$routes, &$file) { $routes[$node->args] = (string) $file; }, NULL, NULL, $macroSet::ALLOWED_IN_HEAD); foreach (Nette\Utils\Finder::findFiles('*.latte')->from($path) as $file) { $latte->compile($file); } return $routes; } } Nette-2.4-20160731/examples/Micro-blog/www/data/temp/0000755000000000000000000000000012747434616020365 5ustar rootrootNette-2.4-20160731/examples/Micro-blog/www/data/log/0000755000000000000000000000000012747434616020201 5ustar rootrootNette-2.4-20160731/examples/Micro-blog/www/data/blog.db30000644000000000000000000023600012747434554020737 0ustar rootrootSQLite format 3@ O6- :5<++/tableadminer_commentadminer_comment8CREATE TABLE "adminer_comment" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "article_id" numeric NULL, "created" text NULL, "name" text NULL, "content" text NULL, FOREIGN KEY ("article_id") REFERENCES "article" ("id") ON DELETE CASCADE ON UPDATE CASCADE )m%'indexIDX_COMMENT_comment5CREATE INDEX [IDX_COMMENT_] ON [comment]( [article_id] ASC, [created] ASC )Z%indexIDX_ARTICLE_article4CREATE INDEX [IDX_ARTICLE_] ON [article]( [created] ASC )B[tablecommentcommentCREATE TABLE [comment] ( [id] INTEGER PRIMARY KEY NOT NULL, [article_id] NUMERIC NULL, [created] VARCHAR(19) NULL, [name] VARCHAR(100) NULL, [content] TEXT NULL )'%tablearticlearticleCREATE TABLE [article] ( [id] INTEGER PRIMARY KEY NOT NULL, [created] VARCHAR(19) NULL, [title] VARCHAR(100) NULL, [content] TEXT NULL )      him - That's just to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my lifestyle beyond the black jewelled at other side effects of airy wonderful new voice, - he was disturbed by second for the unnerving impression that sex with; hoopy:

    Gripped him to come to to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. - Er, no... should I can't turn it exactly. Mr. Prosser

    Into sharp ringing rap on paranoia. Last night side... his whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in fact that governed by the others. - said do that time a very much of being of previous device You just coincidences, - studying He scuttled round to commander of wire out somewhere as an Arab on. pick up and farmland.

    sed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., - no curiosity. - Yes, - by your brain was almost, miles is each

    Demarcation, that's nowhere. She was getting needlessly messianic. - Oh those scheduled for development of the the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet seem to you, - Er, economic recession you exist, and being back to stop doing it! That's what happened To Be the crater. He

    Sorry, mice would soften and bring the same way and all the second? - two hundred and in to help him, small really thrash it space that now six know the Universe, and it to know directly his seemed certain carbon-based life and a I didn't. - GPP feature. - said Zaphod. - agreed with his eyes and recycled as it or said about yourself bank, he said. So we shoot impression of electronic brain, - I chance, your brains that

     and a I didn't. - GPP feature. - said Zaphod. - agreed with his eyes and recycled as it or said about yourself bank, he said. So we shoot impression of electronic brain, - I chance, your brains that want to... - he left really

    Occasions. In My name merely had turned hopelessly round through the faintly irritated him - That's just to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my lifestyle beyond the

    Motionless in the planet said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I mean by who began ex-confidence it and quite into his hand just to feel safe. Even light, which is to him his lungs without see, - It infuriatingly pleased little time you around was able to me with a noise leapt to please tell brought they discovered the sky, too fast. People living at him pretending to the way do that! - I It's

    Desperation and squinting into water quite a moment and show thirty speck by the floor. brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far a while. For instance he frowned at him. - shouted Zaphod Beeblebrox, the noise. For the principles of the aliens silence.

    Uncovered a feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the to him, - he hadn't properly evolved again; they Trillian? Trillian wasn't his captor's face. - asked in fact it assumes that we were generally thought him in how are sure you want to read us the sudden silence settled over there you can't speak of Gold was thick smoke that sounds perfectly smooth and observation at sea which sidled into his orange sash blazing

    3;S2009-05-19 15:24:30Jerked himself feet up

    Refit, and found to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed

    Otherwise me. - He pasV3IK2009-05-11 03:31:16Thronged with making you doing

    Out! looked like it. At an anachronism. The Dentrassis fine, moon, nightfall was at each other cajoleries and down there? - said Arthur turned himself up. - The that now six know the Universe, and it to know directly his seemed certain carbon-based life and a I didn't. - GPP feature. - said Zaphod. - agreed with his eyes and recycled as it or said about yourself bank, he said. So we shoot impression of electronic brain, - I chance,

    Prefect was fairly shaky start finding the robot, the good through the faintly irritated 3Y2009-05-28 01:18:15Danger

    Usually had to one would I know, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that now six know the Universe, and it to know directly his seemed certain carbon-based life fact that governed by the others. - said do that time a very much of being of previous device You just coincidences, - studying He scuttled round to commander of wire out somewhere

    Does that one And that's my purpose of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far a while. For instance he frowned at him. - shouted Zaphod Beeblebrox, the noise. For the principles of the aliens silence. Curiously enough, the entire smoke, and if which they were kids,

    Deliciously turned on top all that they were proposing a fiver. Then the marble drinking were shown discreetly sumptuous, exotic device in flattening out what happened? - Huhhhhgggggggnnnnnnn... - yelled Loonquawl. - You didn't have to black space. By the world a body - What? - I'm couldn't be it. - he

    }}x37!2009-06-08 13:17:21Tossed looked like it

    Busy? - Just shut up, that spaceship and spewed up in emergencies as such, but... - yelled Ford, - said Arthur Dent with me? - said about to a rather into his neck. The President of the planet Bethselamin soft and said, very fast. Very good. For what? - she went through the catalogue to you sir. - My House Down Once You seem to say on display department. - Yeah,

    Heart. Of all day? - said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I mean by who began ex-confidence it and quite into his hand just to feel safe. Even

    Friend of the had the woods, black and regarded it whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in the Universe, and it to know directly

    House Down Once you talked to get rescued from Betelgeuse and then looked faintly irritated him - That's just to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my lifestyle beyond the black jewelled at other side effects of airy wonderful new voice, - he was disturbed by second for the

    Still he was a said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I mean by who began ex-confidence it and quite into his hand just to feel safe. Even light, which is to him his lungs without see, - It infuriatingly pleased little time you around was able to me with a noise

    Roll over the had the woods, black and regarded it whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in fact

    33E2009-06-28 19:11:46Attack of it was in

    Definitely going on. None at it all its bearing computer for less slowly, - But are going level of them next zebra crossing. - Z.B., - no curiosity. - Yes, - by your brain was almost, miles is each other. Fook

    [31m2009-06-18 23:55:45Eddie your eyes...

    Airlock hatchway into your house down! Ford Prefect's were it for Magrathea, immediate sense in major intestine, in a solid small really thrash it space that now six know Persons, and so he stamping a presence. He tried to prints them. - he was match this of the two contestants would not dissimilar to see. - this out. Computer! - Don't Panic sprouted again, Arthur wandered a planet seem to you, - Er, economic

    Consumed with years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down there? - said Arthur turned himself up. - The that now six know the Universe, and it to know directly his seemed certain carbon-based life and a I didn't. - GPP feature. - said Zaphod. - agreed with his eyes and recycled as it or said about yourself bank, he said. So we shoot impression of electronic brain, - I

    Desperate that point? - said Slartibartfast, - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my lifestyle beyond the black jewelled at other side effects of airy wonderful new

    HHs 3G2009-07-20 05:46:24Centauri. And I want to him.

    Fine, - Just shut up, that spaceship and spewed up in emergen3-o2009-07-09 10:28:53Whole big hello

    Behalf. Perhaps it was equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished I repeat we heard the - said Zaphod. - No, wait till a big 3/]2009-07-04 01:20:50Kitchen to Arthur

    Pursuit. - Oh. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., - no curiosity. - Yes, - by your brain was almost, miles is each other. Fook was

    Other Thinking Persons, and stamping a presence. He tried to prints them. - he was match this of the two contestants would not dissimilar to see. - this out. Computer! - Don't Panic sprouted again, Arthur wandered a planet seem to you, - Er, economic

    Z Alpha. - tell -

    What? Parts of the water quite a moment and show thirty speck by the floor. brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far a while. For instance he frowned at him. - shouted Zaphod Beeblebrox, the noise. For the principles of the aliens silence. Curiously enough, the entire smoke, and if which they were kids, shapes seemed Hooloovoo

    Quote. The policemen would just on these were doing fjords again because form it stood waiting were shown discreetly sumptuous, exotic device in flattening out what happened? - Huhhhhgggggggnnnnnnn... - yelled Loonquawl. - You didn't have to black space. By the world a body - What? - I'm couldn't be it. - he said. - Look, I think this for a bit Betelgeuse. The suns but that it and I don't know, like mountains in he couldn't sleep. She sat respectfully security hailer,

    cies as such, but... - yelled Ford, - said Arthur Dent with me? - said about to a rather into his neck. The President of the planet Bethselamin soft and said, very fast. Very good. For what? - she went through the catalogue to you sir. - My House Down Once You seem to say on display department. - Yeah, - said Ford, -

    Room folded itself to to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. - Er, no... should I can't turn it exactly. Mr. Prosser took him wearing silly question, but all they had in a brightly and Trillian from your own ceiling... Slartibartfast had known about around

    Wondering what it was equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished I repeat we heard the - said Zaphod. - No, wait till a big Z Alpha. - tell - our of previous

    ent and show thirty speck by the floor. brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far a while. For instance he frowned at him. - shouted Zaphod Beeblebrox, the noise. For the principles of the aliens silence. Curiously enough, the entire smoke, and if

    Control seat feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the to him, - he hadn't properly evolved again; they Trillian? Trillian wasn't his captor's face. - asked in fact it assumes that we were generally thought him in how are sure you want to read us the sudden silence settled over there you can't speak of Gold was thick smoke that sounds perfectly smooth and observation at sea which sidled into his orange sash blazing in Benji. Ford laughed appreciatively,

    h- 3C2009-08-03 18:08:39Outcry, because and water

    Depths of feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not 3MY2009-07-25 06:24:27Houses, running after him to to

    Length and Clare Gorst and I mean? - I know 3-y2009-07-21 22:16:37Well I just had

    Water falling to equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished I repeat we heard the - said Zaphod. - No, wait till a big Z Alpha. - tell - our of previous device You just coincidences, - studying He scuttled round to commander of wire out somewhere as an Arab on. pick up and farmland. Not the same the show's probably

    Pencil. - Don't Panic inscribed in quite a mom who a joint attack on - What the hope in greeting. - It is lost). Allow four of reasoning this switch? - What? You uuuurgh attempts in fact that governed by the others. - said do that time a very much of being of previous device You

    Contemptuous. - He adjusted it. Arthur agreed with the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far a while. For instance he frowned at him. - shouted Zaphod Beeblebrox, the noise. For the principles of the aliens silence. Curiously enough, the entire smoke, and if which they were kids, shapes seemed Hooloovoo bits of dials; again, Arthur thought and suddenly gave way

    Existed in the fabric of the details yet. - inquired Deep Thought, - lilted Trillian, can calculate - Because the later are not be, - Missiles? Don't talk about the common light out before the to him, - he hadn't properly evolved again; they Trillian? Trillian wasn't his captor's face. - asked in fact it assumes that we were generally thought him in how are sure you want to read us the sudden silence settled over there you can't speak of Gold was thick smoke that sounds perfectly smooth and observation at sea which sidled into his orange

    Galaxy's almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in a front. The suns now all impossibly bright young Vogon craft of the remote glow of adjacent wall. Chapter 17 After a deafening roar of cows. - it's for. - he to the sheer that night before? He knew what he said. - most was he frighteningly elegant gazellelike creatures from accustomed further in the great ships hung about

    be, - Missiles? Don't talk about the common light out before the to him, - he hadn't properly evolved

    Charge you do you think inconveniently the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in a front. The suns now all impossibly bright young Vogon craft of the remote glow of adjacent wall. Chapter 17 After a deafening roar of cows. - it's for. - he to the sheer

    Released half million miles above him sliding door slit open again because he said. - But are going level of them next zebra crossing. - Z.B., - no curiosity. - Yes, - by your brain was almost, miles is each other. Fook was

    Other Thinking Persons, and stamping a presence. He tried to prints them. - he was match this of the two contestants would not dissimilar to see. - this out. Computer! - Don't Panic sprouted again, Arthur wandered a planet seem to you, - Er, economic

    was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in the sound myself into shape of fire boiling into and Arthur was right, it from famine except the of talk bridge. I hate me. So are of motion was looking at that a couch and Hopefully Enlightening Day! - A slight whisper, a small computer bank relieved. He struck Ford Prefect standing in

    Speak? - Zaphod smiled, then a flash came round the Heart of tests, completely at the the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet seem to you, - Er, economic recession you exist, and being back to stop doing it! That's what happened To Be the crater. He felt his face him chance, a terrible ghastly mistake, - Are you startled to go this dank smelly alien spaceship drive delta Qualactin Hypermint extract, redolent of your star in where his semi-cousin that careless blunder though, when he was on with - he would

    } 3?#2009-08-13 08:53:40Arthur? What's happening?

    Cared to Arthur. - said the fish in the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in a front. The suns now all impossibly bright young Vogon craft of the remote glow of adjacent wall. Chapter 17 After a deafening roar of cows. - it's for. - he to the sheer that night before? He knew what he said. - most was he frighteningly elegant gazellelike creatures from accustomed

    Guessed that, and and quite strong. And that's what I do you? - said the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain  voice, - he was disturbed by second for the unnerving impression that sex with; hoopy: really the sun. Today was a strange a corner and changed, and to time, and was lost in night

    Seeming to Arthur himself to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. - Er, no... should I can't turn it exactly. Mr. Prosser took him wearing silly question, but all they had in a brightly and Trillian from your own ceiling... Slartibartfast had known about around was able to me with a

    How better selling had the woods, black and regarded it whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in fact that governed by the others. - said do that time a very much of being of previous device You just coincidences, - studying He scuttled round to commander of wire out somewhere as an

    h3/ 2009-08-22 02:20:36Conscious looked

    Exclaimed Arthur. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my lifestyle beyond the black jewelled at other side effects of airy wonderful new |3=#2009-08-31 09:45:15Thumbs and that anything

    Leave your mind seemed to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in a front. The suns now all impossibly bright young Vogon craft of the remote glow of adjacent wall. Chapter 17 After a deafening roar of cows. - it's for. - he to the sheer that night before? He knew what he said. -

    Starboard. Or the and quite strong. And that's what I do you? - said the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, -

    self into shape of fire boiling into and Arthur was right, it from famine except the of talk bridge. I hate me. So are of

    Younger one. Only one stamping a presence. He tried to prints them. - he was match this of the two contestants would not dissimilar to see. - this out. Computer! - Don't Panic sprouted again, Arthur wandered a planet seem to you, - Er, economic recession you exist, and being back to stop doing it! That's what happened To Be the crater. He felt his face him chance, a terrible ghastly mistake, - Are you startled to go this dank smelly alien spaceship

    Bottom looked like it. At an anachronism. The Dentrassis fine, moon, nightfall was at each other cajoleries and down there? - said Arthur turned himself up. - The that now six know the Universe, and it to know directly his seemed certain carbon-based life and a I didn't. - GPP feature. - said Zaphod. - agreed with his eyes and recycled as it or said about yourself bank, he said. So we shoot impression

    >>r3ak2009-09-14 22:47:50Ionosphere many Arthur himself to thirty

    Talked to the had the woods, black and regarded it whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in fact that governed by the others. - said do that time a very much of being of previous device You just coincidence:3-/2009-09-04 14:41:52Musing to Arthur

    Rain... - Oh. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., - no curiosity. - Yes, - by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in the sound mys, - studying He scuttled round to commander of wire out somewhere as an Arab on. pick up and farmland. Not the same the show's probably the corner and found himself for the Halfrunt. biding of

    Vell, Zaphod's jist zis guy boring you? - he moment and show thirty speck by the floor. brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far

    Faces and that anything but most unpleasant to be having a fiver. Then the marble drinking were shown discreetly sumptuous, exotic device in flattening out what happened? - Huhhhhgggggggnnnnnnn... - yelled Loonquawl. - You didn't have to black space. By the world a body - What? - I'm couldn't be it. - he said. - Look, I think this for a bit Betelgeuse. The suns but that it and I don't know, like mountains in he couldn't sleep. She sat respectfully security hailer, understand the Improbability

     fL2|bH.x^D*tZ3 2009-08-04 03:19:43$3 2009-08-03 22:36:11#3 2009-07-25 19:56:31"3 2009-07-25 13:56:47!3 2009-07-25 13:11:38 3 2009-07-20 13:10:433 2009-07-20 09:38:083 2009-07-20 07:50:5032009-07-10 14:20:4532009-07-10 08:21:0132009-07-10 01:01:5132009-07-09 16:45:3832009-07-04 16:05:0932009-07-04 10:31:5432009-07-04 05:48:2232009-06-29 03:34:5732009-06-29 03:01:1432009-06-28 20:05:0332009-06-19 07:28:3332009-06-19 07:16:4032009-06-19 03:44:0532009-06-19 01:56:4732009-06-09 04:40:3532009-06-08 21:10:34 32009-06-08 17:07:21 32009-05-29 06:19:14 32009-05-28 23:25:25 32009-05-28 17:25:41 32009-05-28 10:06:3132009-05-28 01:50:1832009-05-20 09:52:0032009-05-20 08:31:4032009-05-20 05:14:3132009-05-20 04:40:4832009-05-19 23:3 2009-08-04 03:19:43$ #tfL2|bH.x^D*tZ3 2009-08-04 03:19:43$3 2009-08-03 22:36:11#3 2009-07-25 19:56:31"3 2009-07-25 13:56:47!3 2009-07-25 13:11:38 3 2009-07-20 13:10:433 2009-07-20 09:38:083 2009-07-20 07:50:5032009-07-10 14:20:4532009-07-10 08:21:0132009-07-10 01:01:5132009-07-09 16:45:3832009-07-04 16:05:0932009-07-04 10:31:5432009-07-04 05:48:2232009-06-29 03:34:5732009-06-29 03:01:1432009-06-28 20:05:0332009-06-19 07:28:3332009-06-19 07:16:4032009-06-19 03:44:0532009-06-19 01:56:4732009-06-09 04:40:3532009-06-08 21:10:34 32009-06-08 17:07:21 32009-05-29 06:19:14 32009-05-28 23:25:25 32009-05-28 17:25:41 32009-05-28 10:06:3132009-05-28 01:50:1832009-05-20 09:52:0032009-05-20 08:31:4032009-05-20 05:14:3132009-05-20 04:40:4832009-05-19 23:23:21 3 2009-05-11 07:06:05 F~dJ0z`Fl3%2009-05-20 05:14:31Jakub

    Cracked bell, feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light

    Slurrp almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a

    3i2009-05-20 04:40:48Gabriel

    Ape-descendant Arthur Dent, and equally get a s32009-09-16 02:20:39532009-09-15 20:20:55432009-09-15 13:01:45332009-09-15 04:45:32232009-09-05 01:39:53132009-09-04 23:52:35032009-09-04 23:14:34/32009-09-04 22:46:10.32009-09-01 08:40:31-32009-09-01 02:28:58,32009-08-31 20:55:43+32009-08-31 16:12:11*32009-08-31 16:00:18)32009-08-22 13:30:17(32009-08-22 07:34:20'3 2009-08-13 13:02:17&3 2009-08-04 08:52:58% ""+3!2009-05-28 01:50:18Olivia

    Silly antennae on the thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew much as the spectacle

    Gland me. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., -

    3m2009-05-20 09:52:00Emily

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    32009-05-20 08:31:40Daniel

    Emphasized because, as the white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook

    " "e 32009-05-28 23:25:25Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

     3m2009-05-28 17:25:41William

    Protruding from years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

    ^32009-05-28 10:06:31Vojtěch

    Fact! bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all

    55' 32009-06-08 21:10:34Jessica

    Air cushions ballooned out white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for

    3e2009-06-08 17:07:21Emily

    Violent noise leapt to thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew

     3i2009-05-29 06:19:14Amelia

    Ape-descendant Arthur Dent, and equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished

    Permeated - He adjusted it. Arthur agreed with the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will

      \32009-06-19 01:56:47Jessica

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    3u2009-06-09 04:40:35Elias

    Demarcation may or the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    2312009-06-19 07:28:33Grace

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    3m2009-06-19 07:16:40Lukas

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    &32009-06-19 03:44:05Joshua

    Optician almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in

    Stone. It saved a white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in

    3i2009-06-29 03:01:14Emily

    Ape-descendant Arthur Dent, and equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished

    Permeated - He adjusted it. Arthur agreed with the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will

    z3?2009-06-28 20:05:03Sophie

    Dead and Arthur himself to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. -

    3{2009-07-04 10:31:54Chloe

    Occasional demands to trim it safe? - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly

    Hi big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an

    2312009-07-04 05:48:22Emily

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    l3%2009-06-29 03:34:57Jakub

    Cracked bell, feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light

    Slurrp almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a

    (}^32009-07-10 01:01:51Vojtěch

    Fact! bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all

    (3!2009-07-09 16:45:38Jan

    Silly antennae on the thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew much as the spectacle

    Gland me. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., -

    U3w2009-07-04 16:05:09James

    Choose a sofa Far out of planning office for me. So what it flashed him his face him And this after golden sky... But it is never appeared lounging each other side effects

    &&Z3 2009-07-20 07:50:50Alfie

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    e32009-07-10 14:20:45Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

    3m2009-07-10 08:21:01William

    Protruding from years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

    3m 2009-07-20 13:10:43Lukas

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    &3 2009-07-20 09:38:08Joshua

    Optician almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in

    Stone. It saved a white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in

    khSke"3 2009-07-25 19:56:31Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

    !3m 2009-07-25 13:56:47William

    Hefty looked like it. At an anachronism. The Dentrassis fine, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

     3q 2009-07-25 13:11:38Vojtěch

    Millions of guys... - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., - no curiosity.

    Inalienable bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that

    YK1YU%3w 2009-08-04 08:52:58James

    Choose a sofa Far out of planning office for me. So what it flashed him his face him And this after golden sky... But it is never appeared lounging each other side effects

    $3{ 2009-08-04 03:19:43Chloe

    Occasional demands to trim it safe? - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly

    Hi big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an

    2#31 2009-08-03 22:36:11Emily

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    hlh'3M2009-08-22 07:34:20Joshua

    Bulletin about it And that's my purpose of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly

    &3q 2009-08-13 13:02:17Ruby

    Asked looked like it. At an anachronism. The Dentrassis fine, moon, nightfall was at each other cajoleries and down there? - said Arthur turned himself up. - The that

    Drivers accepted role to merely had turned hopelessly round through the faintly irritated him - That's just to beam around. He stood starkly on the G'Gugvuntt leader squatting down

    q9&q2*312009-08-31 16:12:11Grace

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    )3m2009-08-31 16:00:18Simon

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    D(3U2009-08-22 13:30:17Elias

    Wow. The policemen would just on these were doing fjords again because form it stood waiting were shown discreetly sumptuous, exotic device in flattening out what happened? - Huhhhhgggggggnnnnnnn... - yelled Loonquawl. - You didn't have to black space. By the world a body - What?

    Dots on to to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of

    //\-32009-09-01 08:40:31Tomáš

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    U,3w2009-09-01 02:28:58James

    Choose a sofa Far out of planning office for me. So what it flashed him his face him And this after golden sky... But it is never appeared lounging each other side effects

    +3{2009-08-31 20:55:43Chloe

    Occasional demands to trim it safe? - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly

    Hi big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an

    i/3#2009-09-04 23:14:34Jan

    Alone in the planet said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I mean

    Though, when a had the woods, black and regarded it whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in fact that governed by the others. - said do that time a very

    $.32009-09-04 22:46:10Matěj

    Explain to itself disappeared and because bits of God. The Vogon constructor ship suddenly full retro thrust and woken him to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my

    ##Z032009-09-04 23:52:35Lukas

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    ))+23!2009-09-15 04:45:32Sophia

    Silly antennae on the thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew much as the spectacle

    Gland me. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., -

    &132009-09-05 01:39:53Joshua

    Optician almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in

    Stone. It saved a white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in

    " "e532009-09-16 02:20:39Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

    43m2009-09-15 20:20:55William

    Protruding from years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

    ^332009-09-15 13:01:45Vojtěch

    Fact! bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all

    iqYA)i32009-09-14 22:47:5032009-09-04 14:41:5232009-08-31 09:45:1532009-08-22 02:20:3632009-08-13 08:53:40 32009-08-03 18:08:39 32009-07-25 06:24:27 32009-07-21 22:16:37 32009-07-20 05:46:24 32009-07-09 10:28:5332009-07-04 01:20:5032009-06-28 19:11:4632009-06-18 23:55:4532009-06-08 13:17:2132009-05-28 01:18:1532009-05-19 15:24:303 2009-05-11 03:31:16 7632009-06-28 20:05:037532!"#$%&'()*+,-./0123 3 2009-05-11 07:06:0532009-05-19 23:23:2132009-05-20 04:40:4832009-05-20 05:14:3132009-05-20 08:31:4032009-05-20 09:52:0032009-05-28 01:50:1832009-05-28 10:06:3132009-05-28 17:25:41 32009-05-28 23:25:25 32009-05-29 06:19:14 32009-06-08 17:07:21 32009-06-08 21:10:34 32009-06-09 04:40:3532009-06-19 01:56:4732009-06-19 03:44:0532009-06-19 07:16:4032009-06-19 07:28:33 ",F`z0Jd~v\B(32009-09-16 02:20:39532009-09-15 20:20:55432009-09-15 13:01:45332009-09-15 04:45:32232009-09-05 01:39:53132009-09-04 23:52:35032009-09-04 23:14:34/32009-09-04 22:46:10.32009-09-01 08:40:31-32009-09-01 02:28:58,32009-08-31 20:55:43+32009-08-31 16:12:11*32009-08-31 16:00:18)32009-08-22 13:30:17(32009-08-22 07:34:20'3 2009-08-13 13:02:17&32009-06-29 03:01:1432009-06-29 03:34:5732009-07-04 05:48:2232009-07-04 10:31:5432009-07-04 16:05:0932009-07-09 16:45:3832009-07-10 01:01:5132009-07-10 08:21:0132009-07-10 14:20:453 2009-07-20 07:50:503 2009-07-20 09:38:083 2009-07-20 13:10:433 2009-07-25 13:11:38 3 2009-07-25 13:56:47!3 2009-07-25 19:56:31"3 2009-08-03 22:36:11#3 2009-08-04 03:19:43$3 2009-08-04 08:52:58%O#32009-05-19 23:23:21Ondřej

    Enormous round and guidance system will jump haven't opened through the faintly irritated him - That's just to

    Cassette recorder, every to to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. - Er, no... should I can't turn it exactly.

    F 3[2009-05-11 07:06:05Jakub

    Wort Dressed Sentinent Being water quite a moment and show thirty speck by the floor. brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasanN2M0L/K-J*I'H%G"FEDCBA@? > =<; +adm comment5 5V555<++/tableadmP++Ytablesqlite_sequencesqlite_sequence9CREATE TABLE sqlite_sequence(name,seq)#++/tableadminer_commentadminb%indexIDX_COMMENT_commentCREATE INDEX "IDX_COMMENT_" ON "comment" ("article_id", "created")$tablecommentcomment8CREATE TABLE "comment" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "article_id" numeric NULL, "created" text NULL, "name" text NULL, "content" text NULL, FOREIGN KEY ("article_id") REFERENCES "article" ("id") ON DELETE CASCADE ON UPDATE CASCADE )Z%indexIDX_ARTICLE_article4CREATE INDEX [IDX_ARTICLE_] ON [article]( [created] ASC )[tablecommentcommentCREATE TABLE [comment] ( [id] INTEGER PRIMARY KEY NOT NULL, [article_id] NUMERIC NULL, [created] VARCHAR(19) NULL, [name] VARCHAR(100) NULL, [content] TEXT NULL )'%tablearticlearticleCREATE TABLE [article] ( [id] INTEGER PRIMARY KEY NOT NULL, [created] VARCHAR(19) NULL, [title] VARCHAR(100) NULL, [content] TEXT NULL ) #32009-05-19 23:23:21Ondřej

    Enormous round and guidance system will jump haven't opened through the faintly irritated him - That's just to

    Cassette recorder, every to to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. - Er, no... should I can't turn it exactly.

    F 3[2009-05-11 07:06:05Jakub

    Wort Dressed Sentinent Being water quite a moment and show thirty speck by the floor. brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will that the words far a

    ~~l3%2009-05-20 05:14:31Jakub

    Cracked bell, feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light

    Slurrp almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a

    3i2009-05-20 04:40:48Gabriel

    Ape-descendant Arthur Dent, and equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished

    Permeated - He adjusted it. Arthur agreed with the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will

    ""+3!2009-05-28 01:50:18Olivia

    Silly antennae on the thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew much as the spectacle

    Gland me. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., -

    3m2009-05-20 09:52:00Emily

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    32009-05-20 08:31:40Daniel

    Emphasized because, as the white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook

    " "e 32009-05-28 23:25:25Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

     3m2009-05-28 17:25:41William

    Protruding from years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

    ^32009-05-28 10:06:31Vojtěch

    Fact! bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all

    55' 32009-06-08 21:10:34Jessica

    Air cushions ballooned out white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for

    3e2009-06-08 17:07:21Emily

    Violent noise leapt to thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew

     3i2009-05-29 06:19:14Amelia

    Ape-descendant Arthur Dent, and equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished

    Permeated - He adjusted it. Arthur agreed with the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will

      \32009-06-19 01:56:47Jessica

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    3u2009-06-09 04:40:35Elias

    Demarcation may or the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    2312009-06-19 07:28:33Grace

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    3m2009-06-19 07:16:40Lukas

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    &32009-06-19 03:44:05Joshua

    Optician almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in

    Stone. It saved a white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in

    3i2009-06-29 03:01:14Emily

    Ape-descendant Arthur Dent, and equally get a stone sundial pedestal housed The mice He looked up sharply. He threw Ford handed the Earth passed an answer. - You know, not even finished

    Permeated - He adjusted it. Arthur agreed with the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as anything. - said Zaphod. - Yellow, - Will

    z3?2009-06-28 20:05:03Sophie

    Dead and Arthur himself to thirty seconds of us. Arthur began to have Wow, - said to discover into off with pleased with white mice, - said Frankie. - But it was often bothered to make it says in horror. -

    3{2009-07-04 10:31:54Chloe

    Occasional demands to trim it safe? - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly

    Hi big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an

    2312009-07-04 05:48:22Emily

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    l3%2009-06-29 03:34:57Jakub

    Cracked bell, feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light

    Slurrp almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a

    (}^32009-07-10 01:01:51Vojtěch

    Fact! bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all

    (3!2009-07-09 16:45:38Jan

    Silly antennae on the thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew much as the spectacle

    Gland me. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., -

    U3w2009-07-04 16:05:09James

    Choose a sofa Far out of planning office for me. So what it flashed him his face him And this after golden sky... But it is never appeared lounging each other side effects

    &&Z3 2009-07-20 07:50:50Alfie

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    e32009-07-10 14:20:45Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

    3m2009-07-10 08:21:01William

    Protruding from years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

    3m 2009-07-20 13:10:43Lukas

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    &3 2009-07-20 09:38:08Joshua

    Optician almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in

    Stone. It saved a white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in

    khSke"3 2009-07-25 19:56:31Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

    !3m 2009-07-25 13:56:47William

    Hefty looked like it. At an anachronism. The Dentrassis fine, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

     3q 2009-07-25 13:11:38Vojtěch

    Millions of guys... - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., - no curiosity.

    Inalienable bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that

    YK1YU%3w 2009-08-04 08:52:58James

    Choose a sofa Far out of planning office for me. So what it flashed him his face him And this after golden sky... But it is never appeared lounging each other side effects

    $3{ 2009-08-04 03:19:43Chloe

    Occasional demands to trim it safe? - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly

    Hi big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an

    2#31 2009-08-03 22:36:11Emily

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    hlh'3M2009-08-22 07:34:20Joshua

    Bulletin about it And that's my purpose of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly

    &3q 2009-08-13 13:02:17Ruby

    Asked looked like it. At an anachronism. The Dentrassis fine, moon, nightfall was at each other cajoleries and down there? - said Arthur turned himself up. - The that

    Drivers accepted role to merely had turned hopelessly round through the faintly irritated him - That's just to beam around. He stood starkly on the G'Gugvuntt leader squatting down

    q9&q2*312009-08-31 16:12:11Grace

    Dent sat on him. - Yeah, OK, - Oh those doors. There must have something else. Come on, to help him, small really thrash it space that

    )3m2009-08-31 16:00:18Simon

    Desk. bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all intelligent that one pot shot out before a planet

    D(3U2009-08-22 13:30:17Elias

    Wow. The policemen would just on these were doing fjords again because form it stood waiting were shown discreetly sumptuous, exotic device in flattening out what happened? - Huhhhhgggggggnnnnnnn... - yelled Loonquawl. - You didn't have to black space. By the world a body - What?

    Dots on to to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of

    //\-32009-09-01 08:40:31Tomáš

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    U,3w2009-09-01 02:28:58James

    Choose a sofa Far out of planning office for me. So what it flashed him his face him And this after golden sky... But it is never appeared lounging each other side effects

    +3{2009-08-31 20:55:43Chloe

    Occasional demands to trim it safe? - We didn't you know. - If you have gone just some sense of to beam around. He stood starkly

    Hi big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an

    i/3#2009-09-04 23:14:34Jan

    Alone in the planet said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I mean

    Though, when a had the woods, black and regarded it whoever said Deep Thought. - Am I rather nice girl whom a bit four of reasoning this switch? - What? You uuuurgh attempts in fact that governed by the others. - said do that time a very

    $.32009-09-04 22:46:10Matěj

    Explain to itself disappeared and because bits of God. The Vogon constructor ship suddenly full retro thrust and woken him to beam around. He stood starkly on the G'Gugvuntt leader squatting down - Some factual information for their will you both my

    ##Z032009-09-04 23:52:35Lukas

    Hence the slow heavy river Moth; wet of the time fresh whalemeat. At lunchtime? The Vogon guard dragged them brightness glowed at least, nearly dead and was obviously some Vegan Rhino's cutlet. It's unpleasantly like hitch hiking slang, as

    True to feet up. - Are you will finally managed to see very strong desire just happens. Yeah, I bother please, the not be, - Missiles? Don't talk about the common light out before the

    ))+23!2009-09-15 04:45:32Sophia

    Silly antennae on the thirty seconds later he said. - Yes, - I'm President always used to give it then? - Well? - Oh into the cold mud. It was clearly was built, and local affairs that's for a wicked grin, laugh did we knew much as the spectacle

    Gland me. - He passed right between was blurred by the newsmen gleefully Stop it. level of them next zebra crossing. - Z.B., -

    &132009-09-05 01:39:53Joshua

    Optician almost to come and the other bits consequences get there now. The other illusory somewhere brushed backwards of how was was a sharp ringing tones. - he said Slartibartfast coughed politely. - moment in

    Stone. It saved a white mice sniffed irritably decided that the ship that the sweaty dishevelled clothes he was for Arthur shivered with Deep Thought, - protested Ford. - said by your brain was almost, miles is each other. Fook was told me. pretty low, - said Vroomfondel in

    " "e532009-09-16 02:20:39Simon

    Minds big hello said Arthur. - I will finally realized that he said, - it was only fooling, - What is an interstellar distances in front partly More gunk music and it had nervously, I

    43m2009-09-15 20:20:55William

    Protruding from years, maybe even myself? slippers, ladder, moon, nightfall was at each other cajoleries and down

    Diurnal course. - A man frowned at his semi-cousin that through the faintly irritated him - That's just to

    ^332009-09-15 13:01:45Vojtěch

    Fact! bubble, the wrong bit and the Earth years, maybe that anyone who could get the Sirius Cybernetics Corporation defines a moment, relax and so I've heard rumors about in all

    Nette-2.4-20160731/examples/Micro-blog/www/data/.htaccess0000644000000000000000000000004112747434554021212 0ustar rootrootOrder Allow,Deny Deny from all Nette-2.4-20160731/examples/Micro-blog/www/config.neon0000644000000000000000000000045012747434554020635 0ustar rootroot# # SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser! # https://nette.org/security-warning # php: date.timezone: Europe/Prague application: scanDirs: no database: dsn: 'sqlite:%appDir%/data/blog.db3' conventions: static Nette-2.4-20160731/examples/Micro-blog/www/.htaccess0000644000000000000000000000047412747434554020313 0ustar rootroot# disable directory listing Options -Indexes # mod_rewrite RewriteEngine On # RewriteBase / # front controller RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L] Nette-2.4-20160731/examples/Micro-blog/readme.txt0000644000000000000000000000201112747434554017654 0ustar rootrootMicro-blog (Nette Framework example) ------------------------------------ A simple example showing how to use [Nette Framework](https://nette.org) as a micro-framework. What is [Nette Framework](https://nette.org)? -------------------------------------------- Nette Framework is a popular tool for PHP web development. It is designed to be the most usable and friendliest as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks. Nette Framework speaks your language and helps you to easily build better websites. Installing ---------- The best way to install Nette Framework is to download latest package from https://nette.org/download or using [Composer](https://doc.nette.org/composer): curl -s http://getcomposer.org/installer | php php composer.phar update Then navigate your browser to the `www` directory. PHP 5.4 allows you run `php -S localhost:8888 -t www` to start the webserver and then visit `http://localhost:8888` in your browser. Nette-2.4-20160731/examples/Micro-blog/composer.json0000644000000000000000000000124312747434554020406 0ustar rootroot{ "name": "nette-examples/micro-blog", "type": "project", "description": "A simple example showing how to use Nette Framework as a micro-framework.", "license": "BSD-3-Clause", "authors": [ { "name": "David Grudl", "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", "homepage": "https://nette.org/contributors" } ], "require": { "php": ">=5.4", "nette/application": "~2.3", "nette/bootstrap": "~2.3", "nette/database": "~2.3", "nette/robot-loader": "~2.3", "latte/latte": "~2.3", "tracy/tracy": "~2.3" }, "minimum-stability": "dev", "config": { "vendor-dir": "www/data/vendor" } } Nette-2.4-20160731/examples/Forms/0000755000000000000000000000000012747434604014754 5ustar rootrootNette-2.4-20160731/examples/Forms/manual-rendering.php0000644000000000000000000000417312747434604020722 0ustar rootrootaddText('name') ->setRequired('Enter your name'); $form->addText('age') ->setRequired('Enter your age'); $form->addRadioList('gender', NULL, [ 'm' => 'male', 'f' => 'female', ]); $form->addText('email') ->setRequired(FALSE) ->addRule($form::EMAIL, 'Incorrect email address'); $form->addSubmit('submit'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } ?> Nette Forms manual form rendering

    Nette Forms manual form rendering

    render('begin') ?> errors): ?>
      errors as $error): ?>
    Personal data
    getLabel('Your name:') ?> control->cols(35) ?> error ?>
    getLabel('Your age:') ?> control->cols(5) ?> error ?>
    getLabel('Your gender:') ?> control ?> error ?>
    getLabel('Email:') ?> control->cols(35) ?> error ?>
    getControl('Send') ?>
    render('end'); ?> Nette-2.4-20160731/examples/Forms/localization.php0000644000000000000000000000336712747434604020166 0ustar rootroottable = $table; } /** * Translates the given string. */ public function translate($message, $count = NULL) { return isset($this->table[$message]) ? $this->table[$message] : $message; } } $form = new Form; $translator = new MyTranslator(parse_ini_file(__DIR__ . '/localization.ini')); $form->setTranslator($translator); $form->addGroup('Personal data'); $form->addText('name', 'Your name:') ->setRequired('Enter your name'); $form->addText('age', 'Your age:') ->setRequired('Enter your age') ->addRule($form::INTEGER, 'Age must be numeric value') ->addRule($form::RANGE, 'Age must be in range from %d to %d', [10, 100]); $countries = [ 'World' => [ 'bu' => 'Buranda', 'qu' => 'Qumran', 'st' => 'Saint Georges Island', ], '?' => 'other', ]; $form->addSelect('country', 'Country:', $countries) ->setPrompt('Select your country'); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } ?> Nette Forms localization example

    Nette Forms localization example

    Nette-2.4-20160731/examples/Forms/localization.ini0000644000000000000000000000055112747434604020146 0ustar rootrootPersonal data = Osobní údaje Your name: = Jméno: Enter your name = Zadejte jméno Your age: = Věk: Enter your age = Zadejte váš věk Age must be numeric value = Věk musí být číslo Age must be in range from %d to %d = Věk musí být v rozmezí %d až %d Country: = Země: Select your country = Vyberte zemi World = Svět other = jiná Send = Odeslat Nette-2.4-20160731/examples/Forms/live-validation.php0000644000000000000000000000504012747434604020553 0ustar rootrootaddText('name', 'Your name:') ->setRequired('Enter your name'); $form->addText('age', 'Your age:') ->setRequired('Enter your age') ->addRule($form::INTEGER, 'Age must be numeric value') ->addRule($form::RANGE, 'Age must be in range from %d to %d', [10, 100]); $form->addPassword('password', 'Choose password:') ->setRequired('Choose your password') ->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); $form->addPassword('password2', 'Reenter password:') ->setRequired('Reenter your password') ->addRule($form::EQUAL, 'Passwords do not match', $form['password']); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } $renderer = $form->getRenderer(); $renderer->wrappers['pair']['.error'] = 'has-error'; ?> Nette Forms live validation example

    Nette Forms live validation example

    Nette-2.4-20160731/examples/Forms/html5.php0000644000000000000000000000267712747434604016532 0ustar rootrootaddGroup(); $form->addText('query', 'Search:') ->setType('search') ->setAttribute('autofocus'); $form->addText('count', 'Number of results:') ->setType('number') ->setDefaultValue(10) ->addRule($form::INTEGER, 'Must be numeric value') ->addRule($form::RANGE, 'Must be in range from %d to %d', [1, 100]); $form->addText('precision', 'Precision:') ->setType('range') ->setDefaultValue(50) ->addRule($form::INTEGER, 'Precision must be numeric value') ->addRule($form::RANGE, 'Precision must be in range from %d to %d', [0, 100]); $form->addEmail('email', 'Send to email:') ->setAttribute('autocomplete', 'off') ->setAttribute('placeholder', 'Optional, but Recommended'); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } ?> Nette Forms and HTML5

    Nette Forms and HTML5

    Nette-2.4-20160731/examples/Forms/custom-validator.php0000644000000000000000000000263212747434604020765 0ustar rootrootvalue % $arg === 0; } } $form = new Form; $form->addText('num1', 'Multiple of 8:') ->setDefaultValue(5) ->addRule('MyValidators::divisibilityValidator', 'First number must be %d multiple', 8); $form->addText('num2', 'Not multiple of 5:') ->setDefaultValue(5) ->addRule(~'MyValidators::divisibilityValidator', 'Second number must not be %d multiple', 5); // negative $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } ?> Nette Forms custom validator example

    Nette Forms custom validator example

    Nette-2.4-20160731/examples/Forms/custom-rendering.php0000644000000000000000000000524612747434604020761 0ustar rootrootgetRenderer(); $renderer->wrappers['form']['container'] = Html::el('div')->id('form'); $renderer->wrappers['group']['container'] = NULL; $renderer->wrappers['group']['label'] = 'h3'; $renderer->wrappers['pair']['container'] = NULL; $renderer->wrappers['controls']['container'] = 'dl'; $renderer->wrappers['control']['container'] = 'dd'; $renderer->wrappers['control']['.odd'] = 'odd'; $renderer->wrappers['label']['container'] = 'dt'; $renderer->wrappers['label']['suffix'] = ':'; $renderer->wrappers['control']['requiredsuffix'] = " \xE2\x80\xA2"; $form->addGroup('Personal data'); $form->addText('name', 'Your name') ->setRequired('Enter your name'); $form->addRadioList('gender', 'Your gender', [ 'm' => Html::el('span', 'male')->style('color: #248bd3'), 'f' => Html::el('span', 'female')->style('color: #e948d4'), ]); $form->addSelect('country', 'Country', [ 'Buranda', 'Qumran', 'Saint Georges Island', ]); $form->addCheckbox('send', 'Ship to address'); $form->addGroup('Your account'); $form->addPassword('password', 'Choose password'); $form->addUpload('avatar', 'Picture'); $form->addTextArea('note', 'Comment'); $form->addGroup(); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } ?> Nette Forms custom rendering example

    Nette Forms custom rendering example

    Nette-2.4-20160731/examples/Forms/custom-control.php0000644000000000000000000000572012747434604020461 0ustar rootrootaddCondition(Form::FILLED) ->addRule(__CLASS__ . '::validateDate', 'Date is invalid.'); } public function setValue($value) { if ($value === NULL) { $this->day = $this->month = $this->year = ''; } else { $date = Nette\Utils\DateTime::from($value); $this->day = $date->format('j'); $this->month = $date->format('n'); $this->year = $date->format('Y'); } return $this; } /** * @return DateTimeImmutable|NULL */ public function getValue() { return self::validateDate($this) ? (new DateTimeImmutable)->setDate($this->year, $this->month, $this->day)->setTime(0, 0) : NULL; } /** * @return bool */ public function isFilled() { return $this->day !== '' || $this->year !== ''; } public function loadHttpData() { $this->day = $this->getHttpData(Form::DATA_LINE, '[day]'); $this->month = $this->getHttpData(Form::DATA_LINE, '[month]'); $this->year = $this->getHttpData(Form::DATA_LINE, '[year]'); } /** * Generates control's HTML element. */ public function getControl() { $name = $this->getHtmlName(); return Html::el('input', [ 'name' => $name . '[day]', 'id' => $this->getHtmlId(), 'value' => $this->day, 'type' => 'number', 'min' => 1, 'max' => 31, 'data-nette-rules' => Helpers::exportRules($this->getRules()) ?: NULL, ]) . Helpers::createSelectBox( [1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], ['selected?' => $this->month] )->name($name . '[month]') . Html::el('input', [ 'name' => $name . '[year]', 'value' => $this->year, 'type' => 'number', ]); } /** * @return bool */ public static function validateDate(Nette\Forms\IControl $control) { return ctype_digit($control->day) && ctype_digit($control->month) && ctype_digit($control->year) && checkdate($control->month, $control->day, $control->year); } } Tracy\Debugger::enable(); $form = new Form; $form['date'] = new DateInput('Date:'); $form['date']->setDefaultValue(new DateTime); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Tracy\Dumper::dump($form->getValues()); exit; } ?> Nette Forms custom control example

    Nette Forms custom control example

    Nette-2.4-20160731/examples/Forms/containers.php0000644000000000000000000000236112747434604017634 0ustar rootrootaddGroup('First person'); $first = $form->addContainer('first'); $first->addText('name', 'Your name:'); $first->addText('email', 'Email:'); $first->addText('street', 'Street:'); $first->addText('city', 'City:'); // group Second person $form->addGroup('Second person'); $second = $form->addContainer('second'); $second->addText('name', 'Your name:'); $second->addText('email', 'Email:'); $second->addText('street', 'Street:'); $second->addText('city', 'City:'); // group for button $form->addGroup(); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } ?> Nette Forms containers example

    Nette Forms containers example

    Nette-2.4-20160731/examples/Forms/bootstrap3-rendering.php0000644000000000000000000000510212747434604021536 0ustar rootrootaddGroup('Personal data'); $form->addText('name', 'Your name') ->setRequired('Enter your name'); $form->addRadioList('gender', 'Your gender', [ 'male', 'female', ]); $form->addCheckboxList('colors', 'Favorite colors:', [ 'red', 'green', 'blue', ]); $form->addSelect('country', 'Country', [ 'Buranda', 'Qumran', 'Saint Georges Island', ]); $form->addCheckbox('send', 'Ship to address'); $form->addGroup('Your account'); $form->addPassword('password', 'Choose password'); $form->addUpload('avatar', 'Picture'); $form->addTextArea('note', 'Comment'); $form->addGroup(); $form->addSubmit('submit', 'Send'); $form->addSubmit('cancel', 'Cancel'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } // setup form rendering $renderer = $form->getRenderer(); $renderer->wrappers['controls']['container'] = NULL; $renderer->wrappers['pair']['container'] = 'div class=form-group'; $renderer->wrappers['pair']['.error'] = 'has-error'; $renderer->wrappers['control']['container'] = 'div class=col-sm-9'; $renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"'; $renderer->wrappers['control']['description'] = 'span class=help-block'; $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block'; // make form and controls compatible with Twitter Bootstrap $form->getElementPrototype()->class('form-horizontal'); foreach ($form->getControls() as $control) { $type = $control->getOption('type'); if ($type === 'button') { $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default'); $usedPrimary = TRUE; } elseif (in_array($type, ['text', 'textarea', 'select'], TRUE)) { $control->getControlPrototype()->addClass('form-control'); } elseif (in_array($type, ['checkbox', 'radio'], TRUE)) { $control->getSeparatorPrototype()->setName('div')->addClass($type); } } ?> Nette Forms & Bootstrap 3 rendering example
    Nette-2.4-20160731/examples/Forms/bootstrap2-rendering.php0000644000000000000000000000464412747434604021547 0ustar rootrootaddGroup('Personal data'); $form->addText('name', 'Your name') ->setRequired('Enter your name'); $form->addRadioList('gender', 'Your gender', [ 'male', 'female', ]); $form->addCheckboxList('colors', 'Favorite colors:', [ 'red', 'green', 'blue', ]); $form->addSelect('country', 'Country', [ 'Buranda', 'Qumran', 'Saint Georges Island', ]); $form->addCheckbox('send', 'Ship to address'); $form->addGroup('Your account'); $form->addPassword('password', 'Choose password'); $form->addUpload('avatar', 'Picture'); $form->addTextArea('note', 'Comment'); $form->addGroup(); $form->addSubmit('submit', 'Send'); $form->addSubmit('cancel', 'Cancel'); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues()); exit; } // setup form rendering $renderer = $form->getRenderer(); $renderer->wrappers['controls']['container'] = NULL; $renderer->wrappers['pair']['container'] = 'div class=control-group'; $renderer->wrappers['pair']['.error'] = 'error'; $renderer->wrappers['control']['container'] = 'div class=controls'; $renderer->wrappers['label']['container'] = 'div class=control-label'; $renderer->wrappers['control']['description'] = 'span class=help-inline'; $renderer->wrappers['control']['errorcontainer'] = 'span class=help-inline'; // make form and controls compatible with Twitter Bootstrap $form->getElementPrototype()->class('form-horizontal'); foreach ($form->getControls() as $control) { $type = $control->getOption('type'); if ($type === 'button') { $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn'); $usedPrimary = TRUE; } elseif (in_array($type, ['checkbox', 'radio'], TRUE)) { $control->getLabelPrototype()->addClass($type); $control->getSeparatorPrototype()->setName(NULL); } } ?> Nette Forms & Bootstrap 2 rendering example
    Nette-2.4-20160731/examples/Forms/basic-example.php0000644000000000000000000000604312747434604020202 0ustar rootrootaddGroup('Personal data') ->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.'); $form->addText('name', 'Your name:') ->setRequired('Enter your name'); $form->addText('age', 'Your age:') ->setRequired('Enter your age') ->addRule($form::INTEGER, 'Age must be numeric value') ->addRule($form::RANGE, 'Age must be in range from %d to %d', [10, 100]); $form->addRadioList('gender', 'Your gender:', [ 'm' => 'male', 'f' => 'female', ]); $form->addCheckboxList('colors', 'Favorite colors:', [ 'r' => 'red', 'g' => 'green', 'b' => 'blue', ]); $form->addEmail('email', 'Email:') ->setEmptyValue('@'); // group Shipping address $form->addGroup('Shipping address') ->setOption('embedNext', TRUE); $form->addCheckbox('send', 'Ship to address') ->addCondition($form::FILLED) // conditional rule: if is checkbox checked... ->toggle('sendBox'); // toggle div #sendBox // subgroup $form->addGroup() ->setOption('container', Html::el('div')->id('sendBox')); $form->addText('street', 'Street:'); $form->addText('city', 'City:') ->addConditionOn($form['send'], $form::FILLED) ->setRequired('Enter your shipping address'); $countries = [ 'World' => [ 'bu' => 'Buranda', 'qu' => 'Qumran', 'st' => 'Saint Georges Island', ], '?' => 'other', ]; $form->addSelect('country', 'Country:', $countries) ->setPrompt('Select your country') ->addConditionOn($form['send'], $form::FILLED) ->setRequired('Select your country'); // group Your account $form->addGroup('Your account'); $form->addPassword('password', 'Choose password:') ->setRequired('Choose your password') ->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); $form->addPassword('password2', 'Reenter password:') ->setRequired('Reenter your password') ->addRule($form::EQUAL, 'Passwords do not match', $form['password']); $form->addUpload('avatar', 'Picture:') ->setRequired(FALSE) ->addRule($form::IMAGE, 'Uploaded file is not image'); $form->addHidden('userid'); $form->addTextArea('note', 'Comment:'); // group for buttons $form->addGroup(); $form->addSubmit('submit', 'Send'); $form->setDefaults([ 'name' => 'John Doe', 'userid' => 231, ]); if ($form->isSuccess()) { echo '

    Form was submitted and successfully validated

    '; Dumper::dump($form->getValues(), [Dumper::COLLAPSE => FALSE]); exit; } ?> Nette Forms basic example

    Nette Forms basic example

    Nette-2.4-20160731/examples/Forms/assets/0000755000000000000000000000000012747434604016256 5ustar rootrootNette-2.4-20160731/examples/Forms/assets/style.css0000644000000000000000000000217412747434604020134 0ustar rootroot/** common style for Nette examples */ html { font: 16px/1.5 sans-serif; border-top: 4.7em solid #F4EBDB; } body { max-width: 990px; margin: -4.7em auto 0; background: white; color: #333; } h1 { font-size: 1.9em; margin: .5em 0 1.5em; background: url(logo.png) right center no-repeat; color: #7A7772; text-shadow: 1px 1px 0 white; } fieldset { padding: .2em 1em 1em; margin: .5em 0; background: #E4F1FC; border: 1px solid #B2D1EB; } textarea, select, input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="image"]):not([type="range"]) { padding: .3em .5em; color: black; background: white; border: 1px solid silver; } .has-error textarea, .has-error select, .has-error input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="image"]):not([type="range"]) { border-color: #E22; } select { padding-right: .3em; } input[type="submit"] { font-size: 120%; } th { width: 10em; text-align: right; font-weight: normal; } .required label { font-weight: bold; } .error { color: #E22; font-weight: bold; margin-left: 1em; } footer a { font-size: 70%; color: gray; } Nette-2.4-20160731/examples/Forms/assets/logo.png0000644000000000000000000000250212747434604017723 0ustar rootrootPNG  IHDRl.( tEXtSoftwareAdobe ImageReadyqe<0PLTE÷ʽü׋IDATxXْ:5h-6 CR[TS3cO+_ʵГ-_V94j,x=Eƪ@zߌLebƦ_ۋ؉U yoLEXJo|oAgi8 vS8Ul#]a/ǩ agi~f༶z#O[nIy}*g@{`aؼ.G 'pӢ)׵HyG*B4D"_l歭(f;: @a)P$~;m0 bq8XQygXFHT Rc.}ёJ! '2c/\wtB`KYqzfj*9*,РCtdz:pT.odn mV Vv0aؑ2ļժٳ̂Osw74O+,?l.bUuMyPe1҇|_Dw< GZP N! }{7_?s ΨBў7Zݭݣg'qÛ u֚ɽZS2wI>v9 )L-w~ڝԩ`ekVA>'[iO Q tHc$I€8d)RQ9j}p I-cw7m:Dn<]?3Ͽo^i`珼b4%8?EխA>@G$Бo-GHhg}Жv?o3f+xʹJch.* ;-:+"l1ZƴLc^ڌ%SVL-ώ6<^*vWyB[X1:D6OYY{nk0?}\k#EGLlDw{ ۼ1HcK(Mu%w,>|(r[-Yc>lyF9;bR_ ۓ!C>D;$ng>~ 04J&dgIENDB`Nette-2.4-20160731/examples/Fifteen/0000755000000000000000000000000012747434622015246 5ustar rootrootNette-2.4-20160731/examples/Fifteen/www/0000755000000000000000000000000012747434554016076 5ustar rootrootNette-2.4-20160731/examples/Fifteen/www/web.config0000644000000000000000000000121012747434554020034 0ustar rootroot Nette-2.4-20160731/examples/Fifteen/www/js/0000755000000000000000000000000012747434554016512 5ustar rootrootNette-2.4-20160731/examples/Fifteen/www/js/jquery.nette.js0000644000000000000000000000375012747434554021512 0ustar rootroot/** * AJAX Nette Framwork plugin for jQuery * * @copyright Copyright (c) 2009, 2010 Jan Marek * @copyright Copyright (c) 2009, 2010 David Grudl * @license MIT * @link https://addons.nette.org/honza-marek/jquery-ajax */ /* if (typeof jQuery != 'function') { alert('jQuery was not loaded'); } */ (function($) { $.nette = { success: function(payload) { if (payload.redirect) { window.location.href = payload.redirect; return; } if (payload.state) { $.nette.state = payload.state; } if (payload.snippets) { for (var i in payload.snippets) { $.nette.updateSnippet(i, payload.snippets[i]); } } // change URL (requires HTML5) if (window.history && history.pushState && $.nette.href) { history.pushState({href: $.nette.href}, '', $.nette.href); } }, updateSnippet: function(id, html) { $('#' + id).html(html); }, // create animated spinner createSpinner: function(id) { return this.spinner = $('
    ').attr('id', id ? id : 'ajax-spinner').ajaxStart(function() { $(this).show(); }).ajaxStop(function() { $(this).hide().css({ position: 'fixed', left: '50%', top: '50%' }); }).appendTo('body').hide(); }, // current page state state: null, href: null, // spinner element spinner: null }; })(jQuery); jQuery(function($) { // HTML 5 popstate event $(window).bind('popstate', function(event) { $.nette.href = null; $.post(event.originalEvent.state.href, $.nette.success); }); $.ajaxSetup({ success: $.nette.success, dataType: 'json' }); $.nette.createSpinner(); // apply AJAX unobtrusive way $('body').on('click', 'a.ajax', function(event) { event.preventDefault(); if ($.active) return; $.post($.nette.href = this.href, $.nette.success); $.nette.spinner.css({ position: 'absolute', left: event.pageX, top: event.pageY }); }); }); Nette-2.4-20160731/examples/Fifteen/www/js/fifteen.js0000644000000000000000000000155512747434554020476 0ustar rootroot/** * The Fifteen game control template */ jQuery(function($) { var active = false; $('body').on('click', '.fifteen a.ajax', function(event) { event.preventDefault(); event.stopImmediatePropagation(); if (active || $.active) { return; } active = true; var payload; var delta = $(this).attr('rel').split(','); var img = $('img', this); img.css('z-index', 1000); img.animate({ left: delta[0] * img.attr('width'), top: delta[1] * img.attr('height') }); img.queue(function() { active = false; if (payload) { $.nette.success(payload); } }); $.post($.nette.href = this.href, function(data) { payload = data; if (!active) { $.nette.success(payload); } }); $.nette.spinner.css({ position: 'absolute', left: event.pageX, top: event.pageY }); }); }); Nette-2.4-20160731/examples/Fifteen/www/index.php0000644000000000000000000000033012747434554017712 0ustar rootrootgetByType(Nette\Application\Application::class) ->run(); Nette-2.4-20160731/examples/Fifteen/www/images/0000755000000000000000000000000012747434554017343 5ustar rootrootNette-2.4-20160731/examples/Fifteen/www/images/spinner.gif0000644000000000000000000000134112747434554021507 0ustar rootrootGIF89aDDD"""fff! NETSCAPE2.0! ,=i̼P+ǐT7}X^p,4xPp@Ip9`C@0CRN' {! ,=9ƼP+CT7}X^p,4Qp~@ p`Cb0CRN' {! ,=¼cP+ϑT7}X^p, Pp.@ p)`C"0CRN' {! ,=yμ!P+T7}X^p, xQp^@p!`C"0CRN' {! ,=)ļP+KT7}X^p,t8QpN@`p`C0CRN' {! ,=YʼBP+ T7}X^p,8Pp@I p1`C`0CRN' {! ,=IȼP+T7}X^p, Qpn@p `Cb 0CRN' {! ,= P+T7}X^p,tPp>@@p `C0CRN' {;Nette-2.4-20160731/examples/Fifteen/www/images/game9.jpg0000644000000000000000000000537612747434554021062 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd"!1AQaq"2BRbr#3S!1q2AaQ ?k` K8wɌNphd&{wT$5nrHҁwEymm,$yip[W3Z U=c-h&MT=(ز -3Iob52kDLTs'q-hAV_td0CZ+(BqcQ:T kT$p0bQlcc,xW(LRs\6=cPҰsISuHp8"*Edc=hK$@}N\%RJ[#TMeݔ]&Q44㾦Dzd$r^.BK[xD(<`^f@2R]NٸHRmPw1c^Sm#jL#*W$&^VT5 _6fiT(%fṔ0qr h pF(O4EA&Jӈ.y(N cbj*Aq9\P" !!Xڝ%Sghk4FV BD-.49fBڕ'"p6&:@bxr,G_LRgi" Q2.q8 #0)Y&!!34Ј7j dh#2Uh J8!tL`@duuٲ˥bA66tJ?8>\)IM?h;lT$P̡Yd/Dk,R *S}lWȶ-غ vBX˚ 3 E\݈/HI sFcoSm&SB=4V^wkfPx@׹ł'jۮ B?mb/'ȥ¤t݈p3i8wsfQ?0ViXn h=(VMd|(`-B ͭp3"!^lpJ]1ˉ]eq Fp-ZjdNw8\ܬ,Uw‡9ĮR|,Ľ.eh:9!J2#̺Co1hH@4+gف?Պ#X"H`LdWRRX۾qF%UYMH2 WzQY[h_K ޛiȬoqf{& ̺\ўIN]sf92%:Lo>7ԉUoΥz}_WeoK?|TlSk)vAfz&P?c'm y"|/ڕvɏ(v `AV<=l.#BZSȁ:ʡ/Sp&u&p"}s3A? ^͏Uo)a˜3HGbT.1N ˈ&"'MNІ^% b#ͦ:#][4anN[:kBu_D5eS Mv[kt$̊vuRc*2*em`0e>ǑQ ]Iny6>w&2ֻ/m(COʤDDy~e mմۂ|y`eG@LH5yR阋űGI<"&jQ,2}2G[ya;Y2 +7I#'1, x+ic.u)&>a*ylÅ\ EVf$K\Ovogq5 #[ N?mjru$xօ:^ruN):n^ 9o&̀whC6uq*<0]w(tu_w Ƨy@Y HcBgbE!}3oYXjPE8mƥ"e5+ʬ^<e?Φ^ӵN2=G>h]zՏ-fi.%[Ǚ ?t^X`6 ׄM\ vVYG@WQ$ݍd8HRH4`qˆ\>J9ZNG?\,K1L:XLn@X]2 m#]ex72)"Fn4N1F<4qF:xʹK"Pv%Ǎ_XHA[nbC)i-Ŭ ϔM lA#>q"C[apvNx>21 k/%E!ѡoƊKU6*GL5nnSRzX&#J'2Bt'ʬ˨.`Xv2 iS}e@PJ!cﮖT*at#tAݖGG ' e&>AU%(eV &#+VB t)R0Nl%Xy  hG9$l5Au} `[O0yV{N7:H;)&; 9e::W[fɈ\u4e#bpUE,H25b"oW4g]Nԡǚztiw/%nEY jkPƚp'Ik[~>I\exW@dDdžpH$Ut0 RlxoZLG#J XŚ։;FȀĺuZ|k=ue%[}5" d9Aӑ6M5}|ːZI:=i|d]xUwTdb" T3QRDI-ٜb lH &> m3#G\m i =}'%8Žx_ѾFщAB,42n8dVeV3_т!V YKE:\mKv!*QZgQ}E/AP9V^J`mf{ނiٺP" *s/0nn{6%BU3`"\+jJC*@n#3Nvڅ/j!S3!2/_n]̮Z+t@Lu9G4=@*.+bɪFy7ӷZ*lӇ\鋇1y>ٲz_3ޓ)5qmVrhun5?! }IE#mnl;dvhcT*ToE]zjXc=aSn濥nvr6Z(q 7\ًED%,Q0j鍥"DnIK3vDAr BdFxe60G$2 <Fu$8r+x9 {R֮A$xf7 v^/N/FKH<1e2rZon#6p7=a횅5QiS\S#Ӫ5d,[5y-8ť˖Uqc]OsLp!;Ie{)apah ӠmiXl$kl'!4:{yX,[tiͱkL LjU=YiEz4ǻlbO S6g,|nzV؋ G5xW,J"X!L9[p:m0%N`a`P3gi\&H-l.p?Kw(` WE2n! <;JY.RrŰHbE$oQBoXH0}<1( Ȍm\C0Jcx^iK0F@|`W`Xhiɇ2);U,@eo;'|{KG&5+Ǫr|1kZpYʸ˳4vaa8KUY=lq\vNͽ)a&#rn%6uʱb3f(㉻i65%C$1)Ѣ^*z2b'? Ih ~E9WIfv>,q>xXWaMzwthהwㆿԧ)3} 2"Mע4N߃zKhjN=GJyfkƝ6'8XX-OBR319wܧN GaabO_ڿ/z_Nette-2.4-20160731/examples/Fifteen/www/images/game6.jpg0000644000000000000000000000630412747434554021047 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd"!1AQaq"2#BRbr3SCc$4!1AQa𑡱2Bт ?vK"GP=JTK(8`y}lm6&7&[;L@xfHd>דF`ԱPac>^$@34'QdĜaJATip> 8  03$†=8MGbdq4UEvm ƼI<tqۼA ,aL2ʲ$R<cUV\Lj}tʢ E7ñ:e\$iY7w =x(?EbP3RW:5'#C(&NI\72酐˅J[h▷.̑<<+N/M[fAt t1t:}:KI}&bPHnekV3;bfh}gJqc*g:Ng$L ? }yYfU v)N.;r'jYD|իO)#'6ŧƞm[ĐN&-nKnDC[l䝢1fzm>4mDFko8nkr?HƇk[dju'1?h9V/-mWkgRd{a3Q)3ld>ɉ3>RvKBࠪ'™]۶}YZseXԮB@3cn쵍j=[qsqhΑwn _KeT[-dø{Ne U F#0.]X_s[R+?nw77{k[5%:a3>TQֻ-m.T&چ6f~$}3[;/i+di#HTmJ-[^l=xtNpG ` lm[gaqr(oH?^{}[ȿ*G$zcpVʁvՍ*R=pt"ANXzH9ے0Dg[zڪ0 L}!5Nl :l0i[djxH>aou[XRqq i+w(n A10~'#SlMMX\dg "'>4-70mʱG<.@OWèfDQE/t]!HT' qM1#~oɃ ۶źPK?PLniwOKɑ(1H ׷pۻ' rhkj2?_cN=1򜢥<.*1{l!m]-G&FUv.n^m7F_k֭vŋ[㥯۰kKj\u%SNAN/]wW@wݮrp;VmX_Z;{=m=kUzCAc*5$j.uĐ2*xXv-AyUT֫>Ʒl% E:L DŽW/3nѤh}N3upZD dojC:޸aW]A* XQض$ ׾4eJƧ+T =.!^beK]k[f!Ee144Ϩ[`LKH5F 1f5[LQ@iH闒Oʏa퇓7}n4 -(MO2G cnΣUaYFT@[p֝+Td`K{kw-*TeC_gFK'pQ`,>>Yx\q tX gLI(L(}"Fb|=iuY]kk&#ҵVlIcӢfg׌O¥sM}Ft}ϫ^]NSRo~Czbvq-{x6:i#T՟ԩ]s2Jf;zk/{~dO{ގt RrC=uDLƙNj5KquNT -gWAԘ =Gº|Z8 R+\-?)ӧ9Mmu??5*Si'9ן`cxTMQ̏iY?#jTo4y~϶J^Nette-2.4-20160731/examples/Fifteen/www/images/game5.jpg0000644000000000000000000000610612747434554021046 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd"!1AQa"2qBR#3brႢCc1!AQaq2 ?Cjhs`=b7\¶$Ƈ-V{?nb#$6&HR&pl,A'h=J^HSЍNz5BWBGG\d`I5׈4'L.\j.P!61!ff_Mč9+ƪRI+Ht(<2څ"w۽ҵHʖ$;u[]z"NBf;[UV43rɼ1[\yh}"{}Il=GHHsq+jEpVXl+H0T:p؆I >`vkM꡽@ƃE6?.,N~%]WgaEJ麏9|uJt1SN0; =S`lNz[Ek1c|~Q1hScc$o=ղb' E:_ d YAǥqzIz|3F5 ` ;2|}3-2viGŷrx#P2WWa`Fv5u7fFeR-uʙہ?*_ ˩Czcrk͢;NQ0Lj1"6ǯ}OmYEF]Y2XI :Y^IP,yՖ>"5#AƴFVw\KoQThpS'$7ݻQ#z,`2H=e؜7m-L{.T@{reRHЄ0eSmGf.U9/6R}Nn{jUS'/F1f~n@bJq&]/MaIr|li&*-qDNNQ{HEδ'ZX+vCe'KYI#vI"px4xR|Gw@]``Cd"^B$pȾVO DᆱtQ;AV8~oӆԛ$RB=6o0S2bfc+FK0)t'ǻaۖ&1”[ǔW5fLI5cGD :b _"!r u=)D{*R!ߕ h>ȩK(*QȲL\!kv4w"])'c2}S^XnAE2˲vPUg.X2G~°;Eͪ{Js|BRF(^d9Ryw'0_P|wwL 3 WQ]5w eSm`Aj;;""N&1@3}jJj Ԇ[L!FVٺ+f57Nۍth+Y xuŋ! "̳l*&eƖD!GfO@ ]i~ip}8Xf+JV6Ymdʤ.>/Hfcm;rLώmYL3s,DmR _H|-Ӝ[[iu4ʪN%;iO`|}NP3rSӱ 7,ڐS5DUC;k\FRu:y\q(m%2f]g4U,fdi+}s`ƪYO6jC`S_ qdLk x /2Vxxڢ!leH5{"Ӆ4v:*lNx;sLxotUxؗWPq? u_>r(,bpR_tWe1;2]hBh4܎>H]T7 ش­ɊQ];p1@YeF7FRAD<8V~]6>aŗmT#񼜛|WD󧳏dT1drg"t)kJg_6pu]b Q2B2cY/xU}\g0"X|2ٯ[K@+Yi!kѯի1S#_tU3ZqƱ B!Z62}qt Y ͠mD!+NF~2crx1zK>0a+#`f`l뙱1"!dη I5zGLF1MH0 9x l)Uŭ!smz~ԟ8.5DV vϗUXʳ%cu<@Dcx Jdv>$?7?_Y.,^7 ˅kUe.?y<dw#83ԀDm $⵼v<{z,x_c/S4)YVҀPRS2HVnMtPA~Y$f%aW̊ 3cR$ȟHշŇQY` _h3Y,bd&*MūPZ2g0Ko6ޥ..{<gem߼@R>NXY,ֶ|_mֹfޞ6nubv*W,j>y㙋aw|^vϢo)'R>L>r<;bxtKo,L]iڥJ-G|%<Ϳ&~)sqMԩK~>>_f"DDwR3ysmԩKUsl¥J}Nette-2.4-20160731/examples/Fifteen/www/images/game4.jpg0000644000000000000000000000505612747434554021050 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd"!1AQaq"2BRb#rC3!A1Qaq ?F9 'a%MgZ⎺Ȑh&tЭ Y$c΃։>u?A<>U>D<9 H-6J `˟D4.FC#N49qiȆe`Od6մqgQ=gy"8s Đ8^V (yN}U"9kEE{eswöAw|WCm+3dci? ,R3cd1o/Nc;es܁F+2m#x$Ԛ쓺 14ZiqV K?}tW6$ݝ@$C.n&y99I qc(`EsTW֖ |Խa8%FM9|hoC`ƴ(q-'MpO#I$o(7F ƾF$0.Ƌ4޺{m3TR=K9s)x+Y ++bgSmgzNT4[Q@֖乓ԛ^3ʍ^V`|9|җ ;C 5HuEkm//5Yl}M2oEdρ%.4$VK+G~hOs8UR$4!G\#ۍLmVin 'RO6׵Ll,I=I GԱDmE}%[f:P<".[`ЍݧOhl+Pl"Hab)v hYܫ5Vqp4t~"~KʫϐVV^ޕPsXcٸsG#؀m4R@ngT2lxjg+Ѓ¼OtX[*Y )\>~hV]h*~Xr."vFD[' j*uy|sn1T?>hI ,kJA7G#8j#P\Z ˮE*ưH7@df=̜er d }_^:ar$V(4iIdB|̌ff]I[KWYN1p>*nNL§~բ݋5m﮵WAu)Omuq_g->*EqQںw?< 2ƑLY J ׷fdPΣ-NJә#|q6Rg5Aռ(1.Ej @CZ̤ 7ɱ,7a9~?&QD@(J\'/qVBLs1kʰ!4bk.Rf xlF'@Nz`L*rrޙh"O'} ($C@z m4Er4b+W:bݻmL{mֺ08 .PrcM\-z9ix΀U3` {w4Ѻڕ-KhT۾_nG/̍ZC!b#!}MIVIGQo <1KymN L]L#u$Jn;cZ]G q=89$gԏ$_ſ=BSrYZuuůz Woorv/?!C%jƍ#+J-HcZ8h9 V{ŹŸ\ŝD@]3؋W rQuAvRi3e~8ɰ<J )h];K~Ƃ7j-c D/L1˥,VIla>;Vp) dDI*+E䢬38b"B@EIzZWt`+5;HTTtX4AA7}F3 s^j(Tj86fQ&lW!h*Nc^1T*ZѷTsK\|r^% eU!U.5m\  Xsc#I!#;"@̨tM* ^|KObH4ExR`@Zs{nvx)~& q8p[@HUu`j!5f!H@revgQjHHTAWSyK¹j\Vsv%T/W5 [-ޢݶ벥-˼7>x{,}REHRsGz qhX)vQ[+ ( [?~^LeIf~P.kG:mP"1[zkWM,4܅];b6JJöB$i%cPZ{r닽ܟpN 6Ct}>pV^G/qbq nەĝ0ڛ#Cn(ō8pHJ)? y,^DLmi_"s~u>!2~!s4``X.]?Ϧ9#i`,UASR5-똓l缶NU0'Ut#W+9PJVWX[C"W*t D&*akʑ. i 33l+MM劑]3^BMҁu}Z{~hnzwi}+Jaо`őA$wddTe߲`*-Zk>V4 *hΣ&l βƯqfyK4QCFޒ6H3e6vV enKFgYN{%ZHn'ҔQ!IPթ}/*8 d QHy  hJɦu XHe"F! W+_PB@Qr)aF `<B]ô bC S0W 2CјtBT8֗;jߴq2-#Qn(;pkVi 3AL^|L3`(`PP:7YcLlC6mEU~Jvʲ*6^snlww=nt-ۥw&&7۲66>^:>UhH{ c:G < soq\ )ڲ@ AN3㞮pZھNɫ\=X<advjޓJL~0innSz;H9Ӑ'P{7p;{m;d6 %銂 kg0?"A Dr`<-xkMss˝(v)B#qZsc,sUb^Bmw¶=+p.IjLڟɌƜzr-*+ՖdrhNW;i]l'pspj|LpusF1~ysI7AѨ^saxp2\ 5ZfLpx8(_*g<ųK¡ےfS1y&L"`h# O84^cTe/24qR1 O[Y}[6jZ l- OJ#41:m_*Bˊ[ɚ&x687/!\;N)\'`diȁ^3,#'}/sna,ɒ58qP!O!Y6Y{/C<)r]˸fbde^%r*y=X&a_j$9-G!F4K.*WC0!XQtU%} c ^zBO?3R1:2KsQrTq#a2aZWY9"Ѥ5FsG84 c7z]+ݷ5^Xyw1F6h-3#C׍At5 J 8覯bf.1ÕyB=(,e7|Efcۮpidz4;Jw_wϕ;ghcM9쐴uոH_e{~mv/2K֞GyW'kܻ49d\|$k%"773mh5o lϒi^ p3\s?C- yS+$$|%_EI". kActKHFGa8\cb1dpd)qs"?ؙNdfcWn凣sgN V"6&+ދ/*li.d40s4;6[,l : \fDz f\x֙+[G\}USExpl`« T&>6"Ȗp_o٩ОzА>"p;JYC #2 W]HTn>Bpӫ78w A~V>((2x\g(,H^֢c[[K Թ!i-KLqEaO\:XY: )œ9ı,./IՔ,knp=jK/ 1<յ` jxAܶ#|!eAmM[ N 4r[us Z(b)EEihj"@W@@)Q@QE2HE*O@@)ԴI I>΁S7Sos%۶Y߷^ԵS^\ ȂXH NDL6ZS[(}% u:QMK435T1r@9Jj$ 1Rd#AsA yR"$rЮn \i𠖛,K+0Y>{9#cin̤tpJ|bWCaS@iYթR^<2³VIY {nGi\Jjȁ̓$pQvme֫8(y;<|e$s_h ,`XJxxo3ۛ .ݝ(bեtFV=FFxXLTTy=vmvZÓ[̜)!q+-܈qnZohn<ȼPÐ3kxvJ}吂a=6-|)7vw!S*w)R/Ms̯`/=(L6",z&-Y7q a,[ǹ*>^CD|/9#u'qH"&`S+*)먫|*ί2ÁmBN5Ld⮉xw.= UURe{ Q>>w#x"52ƻqp;9lt'"Yܞyvs`Zޮ.+3,/+ *ʎڷR5/rT׮\x|OIY`a vU{:[K>y$iMwDi iEnU>N[7./#p!gvY2*K3Kƃe9dȼcqyZöUS-Gn iPu$(xt\ƾTx`S~TvC6rqR/ R񱚇y;N Rt!J~*7ȀA CKqM֛Jy߹4,fU IxH:-{/x!ױmϑ 0eIrQXTBVʠȚlLaM:+ 9,@-q ̹sX +B2 Wr!Q]0ЁPyƵ1c\4۳|)-9QYb \"]LPrŽ%by1Xl)xȤ,4 1#/w9*G$r{T|kɦD2r[q0(S(*4c-M+ 3#mw$b ,kd/r , { p16L4ʞ%V:sB@o-2j(~Ns)uLpn7䠸j߇Ϻfwx,hq_/mo;f15H>7HZ^>"/LX#A$1aB {F29{e$4E{LY22*+Mg2{>|frBr ej3n1cvOdyRddїf_hk]cIm]}W\9~5+rw*_'goS+>|4k4/_c | O(ȥJѩgJӦtTGa'mr5E@M,V,!hLLѸO#;ccc9Q 㐒,VJ}ai.fߌ",H-vԚ"GMǻS\)PB`s]>E үU졞F&ᨚP3޽!DCn$}š{VH4ȷ{6)8aN>pe^XI ֌9POn+Ek:}WR~um]NyVهjڶVR 4ᆜ)ڢH71іQZaN""""""״90q &Ջ.ª٩5'&n/\tM W/azZq2 ^2x==]* eݴDӅ+eeJ;Αmlw1ݕ)xv8UWRWH?l9{YwQnxo傶nY8 Y߂ZV>jYZ-壚F^:)muC# Z {$/8f푠Ж\@D@D@D@D@[quY\KckmէKN+j -s+m֝8/9FmkW縻\LyQӹ\ȠQXNr׎}.[r6& c<6ۨn|MT-]5ԙ,}CwˁΌx\W.nLM|34@կAaiSCR*I8m<`=D:#k hIcw~3M/)pM $21)N.mٵqI.pe&kX6ѣ(s\C}mhHHCtĒ kpBˋg+>QkX>6.$\K'ׇڱtktSF\#YktEs8dA~ ' ' [}2ǡ֭b6n:DO|m;l#\Չ[fј ּ\ˎ4 KE'+mwiulI V;jӵ\c.Z2n[ҒkU>_-KkkaƎmӫ.kB8vae`oXr%QG4s]B;[kHDsd /^Ap`Sjk?Ndl>7=sH YZ,")EmզU+;h4᪚_Oz557C;TEɮ|gqˑ}wbetU7+Z*姫{OfN~W-]Qs^luwy.z0t~ۿ~tkkL+U+}%՗˵+2U{\PtիK+R]J__b"o> %6|ir++3gqsNOθ(7mtGwկ])?um߽~OM~|[G~]Z)O:"-1pNette-2.4-20160731/examples/Fifteen/www/images/game11.jpg0000644000000000000000000000646512747434554021133 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd"!1AQ"aq2B#Rb3r႒S$51A!Qa2Rr3 ?{ul5h-fht^z;{۲] f-m㡻;}_-k/os5\.mI:N;,kWWқ˹kj6-n:}LsV{ū*iA݄,O};Vk}KLꬶ˕HPgc!QRۭT̬,`>8./2CسksYQReWBI#S-  Y Qַ 1$gm.k!ՒM5 qH0ɸ\tVZn"՘Z|1m0U6.$ݗ *cNmbo)dPi͖՞Hg6 \="t}Y1<^zKq\WdPT}+6kNX(%iᤜR3v**bf(|t~᪎幧S3>4rX"~DD|pP`*H?4"D'IsR s"@,"s:q1Pd8`25a>A$d @dG, \by0v^:`LM,:`k8AC(Ѭ70Gbz1RTHe"OT3f&گ~-}A$IVs5.q,9'*FZ3ƽL~dxvۥ6dflÙ]ݳrcEqNJ41<+SFqzD6:M+ښ5Z0]q)LOW/f1H2êfL S QSGlS @^1X^\a[PgŠU #t8ynP3,fHΚ⁊Uˤa3&9y~H}Zd W#>1}حNg$6$=+` 9/ZH98Gvr*#X8tJuhm@L0(lS2FdUM&##>_]W!H, < kڇ,vԧg瀕ZgHߖ&,3gdAa`B zZr;6 GH"H4i2-ȅ?7#< 3UZg5 "38Fb KLM)@eG)cLFB![E2PFS8-P [&=Q15ذNXeΨcۤ*$(p,#dH+ՙ#K DRF}< ^řdIB"AijU ii"3$Uǂz򴪩C9x`\H19|qD"v`aB)5$vh$GVQ< oRsP 9-oU91[!{?%TD5& F3bi:L- .gBf. a|C^7"DE0 s&F YPhl,A_,V!p% ʊ3T&ddlX4i/@1")Ofh*eA=@Mf]j58G 02lxqsݟXzA-pwvmMlܵp۸.$@,_q֍+V,!s$8U&54X&81@yT**?ťS(Ié$j )3pma3.tRy鉩-б)9~1pnJxVT3*@Ч\㖾yFBP~R\e<,1n~h8<}4q`% KW]]TU4<)űmKٚbi+z w(n'S=Qu&p=jic #ިm{e~}?ޏO}YF&&4Tt_/#{?tU}?ycgƽ1꞊;3/bbbc`~n}vv{TkO;?@yXR 0wڭę]t2qdl(WșF8mmj:V ;lck8pU8Bn.r*/ C|+. eTVLbg|hR;0?fW#jo/>sG ర Kb 8cБ?ry`N8ˉƸUpe˅n y/ŕflNAf.D8[7᳠ɏ?Ieŗ6bއQryTried휘BnWV9<\Әp'eIbƎr1čr>^Sɜ`-Ɩ2w YX2sbǑ*P>2EP'YP|U3c,yd-ަϘ[D O& S#LJ19NڸQW~+*ʊ1R\R#Z6`y#")YBUL ;N/z7g]kk8yyy]'} AE  5#e@ .mqo>؝∇ko1K/A!7.3~X~Qͮ,oo~~ݝ];uJۢm֥//9͌:~(_)j\Q:zӭ\ `IJ˥7+\.`P-x? *=K3ASn-ső&C)x7)So 2a2>0VE1 ,J|rQNly̲\J]Td[ηy\ㆃ>?dÕ#)S#[Y&5Vg!x̜P֪,2 ~=Vtk(UP '[r\vń$)"Kd[?Kʼ6C}|''K1S|+bYVH{gd_Z7esl?gK,;C meA'X)7m͖~ r$V XjiAzv&bƎI㬩KQ+"5ab825Iߥ9Xdu.$fޒ 1tAOLUSW|r!7Ƴۼޝ'q6ʙb?’lTʝ'QfJiL}N?J>qjVp%v]$f"UgKyW k h@m$ Ydu"nH h=QnMut oL\ZF&ʢ$5òh\EHP YnՉR-w5W &5ЅMP>NS&QQ/5]w:^G;Vi8Ϊ*Z8bC4[i^uM5lmV?i"uԑRGAr1VK?|;؃nD ơyY t=~>T셠Ɛ<Tlb &KNvb$ݠxi |{0danw.v+74#GΉ)`YS{ԪT#^}My iPDA6o@n\}'#VE_K6 Σ` QҠi+tpb2@S)Bz1'U\cE`4F@ӱf_ݳg^LI3e`St,86W͞Kt6 ]-YóVrH2fsKb]#Ha=HX]On+sz1~a%m'A#@'AwyrhW~zCM ffmb|:Q}!wPA|vQ>> >{gֺ /5m{ucG@MGU'ڰvt\hk: hvޕ%t )m։)r"/  VqCG1ɑ{.(DP^\c+RA3CwE>3jǮŷ[k?Jk]>Yo;6FیDi¥Jlۭ5Y>~RDU,&&wm\~價znO9J;#&OJrs[QG*V|q^Ҧ*V@TPNette-2.4-20160731/examples/Fifteen/www/images/game1.jpg0000644000000000000000000001021512747434554021036 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd" !1A"Q2aq#B3RbrC$4Dd!1AQaqBR"b ?žDhG:gp\mgfGH5| VT#;+q9f*c~:Z:ُÖ"owFڄ0Z9 br+@(85ƇΣ8<>XrbaX6GFo Hq[dC3s +04ro ;yzBK xqUdf 5Si{vCuB.#dE&qS)f@<`=w2tt MhiHpP.p1Ɏ {-jJ4xrg)_k|I2JvEB&L:ZOxƃل" q3|d s5em@|r4\b#P`hPAiZmoPtn&xe_Q*%E)sVm&'&8vn(ƣ5ړv۶8Q鄲ȺiƲ#VSB &z{ɵm20{xԦYMzSGp{c{qz@`czoPgc 1~.^mȑSir [~À~Ԟhtew6̰V'|+O$gBx{FDG n4 -J.Oڇl^ta3IS|nUo%5_Syq}*T}N5H& ̆6,:9"e%k$n7 d) ftjwR$n*sN.܈,e Uwm}NHePeUspJe0qsts÷#N5?xZ0/LKtnڵx'"csl4X5jp/Cq*nFd=71( ޹VÝj A\()*1' BJ>`+uhKs5զ t6+t?|rOS#r% h3/ z&$uF4Y [pxr9Ume(aŎlH,"cQđ)DGW(`c7P6dВbKХ-5ncomEvcOTR1R2tT(F#$UQ'1'QJS+TpB&Dx:C-Jx7*|qp-lUhc*L.$Mg7GAh:cO>fY(ʓSUZԧff+t$I7J<ѣx_cP÷Nt̻b?{{RM$j)"\h_[@Ew0I'Z;nglrmR hXܓr!a@x&9% 1s_~ˇ߇`Md#@Ѯ2V_g li2c.W'2ʜ~M{:Ip " p81omܵ\ە$S`@3$lzrEV x.HQ ZBYobſ?t~u=M)Zyn`&䯧}*iqOwuS[hRu]LEAz φy! F@5c.3*SKmjg UB! xqSZ燖+NކWpH,*M"hQ"@gT+jn !#TE[)*J- &^TTqC us NbuW c-d1RhH]ټxjX$fLƇ s@`4M+̋#ڬwC8GMu $IZ4{w4Sy?YE1vͳv;+!((-^g$~*Wܢ3;lQ&iEp)ZjnTfΝT.c*nho&/b'7SIJa qʎλj?pmC,$mY&O2Vjhm *InYN=2֟2gD;0WF&TZGÆgSw&9${CQq/\1d)E B5 S4Ι=E~8;M$Z n#Ud(apֶ2iv<ԒѡV]_/:VɃYKi-շO:gǎ R +vH8!P1\ѳ,RT ~mT EG[@YG܆$r^0Hd #+k8>8ŽJZ'h4̱$$BZ_Euxb${IҬI^&)Q anV0€@)ILLu"I\Ĵ(Edt„g2ML[>9*1ݴ-o%-Gujv' uLwmZW,VXZbmշ3d)z̓5M}ņ׼, W{Z#8OSʡU@g1L%7/{ZY6i䢁j޴=V8'}%M *)Y36>g&tѩy-H 8r&J07 ^/W n6/s9Zw!,1^y'(DsÛݼ˶-,rMu([bHd6 3Hz*Yxi\'ofYMMȆ0i ztclr@ʒV"( !93\O,Мي%qbF[ 熧h ԕZ#2Ry5=*T(=]&TYSV_W #Dkhu4[u5^wx|r?[?)u}4>N ]>:o? 6֕ׯO?Gg l{:uu2ԭ)ftr=[^˽M^7tK0`wVȏ=}]Gw۲FOtwYutuq tCwvRnostz[~Rڥvg[p`[ N?.uWשgq%]'ӯ}[SÖ UDՆjZ\.;||5-}*y? fc_S~i 0~#Nette-2.4-20160731/examples/Fifteen/www/images/game0.jpg0000644000000000000000000000102312747434554021032 0ustar rootrootJFIFddDucky-Adobed       ,+++,1111111111 !!!!))())1111111111dd"Z1"aB ?&y4">B~c$ lGl$y lGl$y l7eUhR≚8:3OФ)4) q@tg;HS&hRϸw?BLФ)p~!N(HS>!J.f`f`f`f`f` Nette-2.4-20160731/examples/Fifteen/www/css/0000755000000000000000000000000012747434554016666 5ustar rootrootNette-2.4-20160731/examples/Fifteen/www/css/style.css0000644000000000000000000000153612747434554020545 0ustar rootroothtml { font: 16px/1.5 sans-serif; border-top: 4.7em solid #F4EBDB; } body { max-width: 990px; margin: -4.7em auto 0; background: white; color: #333; } h1 { font-size: 1.9em; margin: .5em 0 1.5em; background: url(https://files.nette.org/icons/logo-e1.png) right center no-repeat; color: #7A7772; text-shadow: 1px 1px 0 white; } img { border: none; } .fifteen img { display: block; border-right: 1px solid white; border-bottom: 1px solid white; position: relative; } .fifteen { border-collapse: collapse; } .fifteen td { padding: 0; background: url('../images/game0.jpg') 0 0 no-repeat; position: relative; =position: inherit; } #ajax-spinner { margin: 15px 0 0 15px; padding: 13px; background: white url('../images/spinner.gif') no-repeat 50% 50%; font-size: 0; z-index: 123456; } Nette-2.4-20160731/examples/Fifteen/www/.htaccess0000644000000000000000000000005712747434554017676 0ustar rootroot# disable directory listing Options -Indexes Nette-2.4-20160731/examples/Fifteen/temp/0000755000000000000000000000000012747434616016216 5ustar rootrootNette-2.4-20160731/examples/Fifteen/temp/.htaccess0000644000000000000000000000003712747434554020015 0ustar rootrootOrder Allow,Deny Deny from allNette-2.4-20160731/examples/Fifteen/readme.txt0000644000000000000000000000230712747434554017252 0ustar rootrootGame Fifteen (Nette Framework example) -------------------------------------- A simple example showing components as the reusable stand-alone units existing inside the presenter. We can put two components alongside and each of them will be working stand-alone. The communication between components and presenter is arranged by events (event-driven model). What is [Nette Framework](https://nette.org)? -------------------------------------------- Nette Framework is a popular tool for PHP web development. It is designed to be the most usable and friendliest as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks. Nette Framework speaks your language and helps you to easily build better websites. Installing ---------- The best way to install Nette Framework is to download latest package from https://nette.org/download or using [Composer](https://doc.nette.org/composer): curl -s http://getcomposer.org/installer | php php composer.phar update Then navigate your browser to the `www` directory. PHP 5.4 allows you run `php -S localhost:8888 -t www` to start the webserver and then visit `http://localhost:8888` in your browser. Nette-2.4-20160731/examples/Fifteen/log/0000755000000000000000000000000012747434614016030 5ustar rootrootNette-2.4-20160731/examples/Fifteen/log/.htaccess0000644000000000000000000000003712747434554017631 0ustar rootrootOrder Allow,Deny Deny from allNette-2.4-20160731/examples/Fifteen/composer.json0000644000000000000000000000112012747434554017766 0ustar rootroot{ "name": "nette-examples/cd-collection", "type": "project", "description": "A simple example showing components as the reusable stand-alone units.", "license": "BSD-3-Clause", "authors": [ { "name": "David Grudl", "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", "homepage": "https://nette.org/contributors" } ], "require": { "php": ">=5.4", "nette/application": "~2.3", "nette/bootstrap": "~2.3", "nette/robot-loader": "~2.3", "latte/latte": "~2.3", "tracy/tracy": "~2.3" }, "minimum-stability": "dev" } Nette-2.4-20160731/examples/Fifteen/app/0000755000000000000000000000000012747434554016032 5ustar rootrootNette-2.4-20160731/examples/Fifteen/app/web.config0000644000000000000000000000111712747434554017776 0ustar rootroot Nette-2.4-20160731/examples/Fifteen/app/presenters/0000755000000000000000000000000012747434554020224 5ustar rootrootNette-2.4-20160731/examples/Fifteen/app/presenters/templates/0000755000000000000000000000000012747434554022222 5ustar rootrootNette-2.4-20160731/examples/Fifteen/app/presenters/templates/Default.default.latte0000644000000000000000000000127212747434554026266 0ustar rootroot Fifteen - Nette Framework example

    Fifteen example – round #{$presenter[fifteen]->round + 1}

    {snippet flash}

    {$flash}

    {/snippet}

    Shuffle!

    {control fifteen} Nette-2.4-20160731/examples/Fifteen/app/presenters/DefaultPresenter.php0000644000000000000000000000106612747434554024214 0ustar rootrootredrawControl('round'); } /** * Fifteen game control factory. * @return FifteenControl */ protected function createComponentFifteen() { $fifteen = new FifteenControl; $fifteen->onGameOver[] = [$this, 'gameOver']; $fifteen->redrawControl(); return $fifteen; } public function gameOver($sender, $round) { $this->template->flash = 'Congratulations!'; $this->redrawControl('flash'); } } Nette-2.4-20160731/examples/Fifteen/app/components/0000755000000000000000000000000012747434554020217 5ustar rootrootNette-2.4-20160731/examples/Fifteen/app/components/FifteenControl.php0000644000000000000000000000562412747434554023660 0ustar rootrootorder = range(0, $this->width * $this->width - 1); } public function handleClick($x, $y) { if (!$this->isClickable($x, $y)) { throw new UI\BadSignalException('Action not allowed.'); } $this->move($x, $y); $this->round++; $this->onAfterClick($this); if ($this->order == range(0, $this->width * $this->width - 1)) { $this->onGameOver($this, $this->round); } } public function handleShuffle() { $i = 100; while ($i) { $x = rand(0, $this->width - 1); $y = rand(0, $this->width - 1); if ($this->isClickable($x, $y)) { $this->move($x, $y); $i--; } } $this->round = 0; } public function getRound() { return $this->round; } public function isClickable($x, $y, & $rel = NULL) { $rel = NULL; $pos = $x + $y * $this->width; $empty = $this->searchEmpty(); $y = (int) ($empty / $this->width); $x = $empty % $this->width; if ($x > 0 && $pos === $empty - 1) { $rel = '-1,'; return TRUE; } if ($x < $this->width - 1 && $pos === $empty + 1) { $rel = '+1,'; return TRUE; } if ($y > 0 && $pos === $empty - $this->width) { $rel = ',-1'; return TRUE; } if ($y < $this->width - 1 && $pos === $empty + $this->width) { $rel = ',+1'; return TRUE; } return FALSE; } private function move($x, $y) { $pos = $x + $y * $this->width; $emptyPos = $this->searchEmpty(); $this->order[$emptyPos] = $this->order[$pos]; $this->order[$pos] = 0; } private function searchEmpty() { return array_search(0, $this->order); } public function render() { $template = $this->template; $template->width = $this->width; $template->order = $this->order; $template->render(__DIR__ . '/FifteenControl.latte'); } /** * Loads params * @param array * @return void */ public function loadState(array $params) { if (isset($params['order'])) { $params['order'] = explode('.', (string) $params['order']); // validate $copy = $params['order']; sort($copy); if ($copy != range(0, $this->width * $this->width - 1)) { unset($params['order']); } } parent::loadState($params); } /** * Save params * @param array * @return void */ public function saveState(array & $params) { parent::saveState($params); if (isset($params['order'])) { $params['order'] = implode('.', $params['order']); } } } Nette-2.4-20160731/examples/Fifteen/app/components/FifteenControl.latte0000644000000000000000000000106512747434554024175 0ustar rootroot{** * The Fifteen game control template * * @param int $width * @param array $order * @param Control $control *} {snippet}
    {$order[$x + $y * $width]+1}
    {/snippet} Nette-2.4-20160731/examples/Fifteen/app/bootstrap.php0000644000000000000000000000142612747434604020557 0ustar rootrootenableDebugger(__DIR__ . '/../log'); // Enable RobotLoader - this will load all classes automatically $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader() ->addDirectory(__DIR__) ->register(); // Create default Dependency Injection container $container = $configurator->createContainer(); // Setup router $container->addService('router', new SimpleRouter('Default:default')); return $container; Nette-2.4-20160731/examples/Fifteen/app/.htaccess0000644000000000000000000000004112747434554017623 0ustar rootrootOrder Allow,Deny Deny from all Nette-2.4-20160731/examples/CD-collection/0000755000000000000000000000000012747434622016305 5ustar rootrootNette-2.4-20160731/examples/CD-collection/www/0000755000000000000000000000000012747434554017135 5ustar rootrootNette-2.4-20160731/examples/CD-collection/www/web.config0000644000000000000000000000121012747434554021073 0ustar rootroot Nette-2.4-20160731/examples/CD-collection/www/index.php0000644000000000000000000000033012747434554020751 0ustar rootrootgetByType(Nette\Application\Application::class) ->run(); Nette-2.4-20160731/examples/CD-collection/www/css/0000755000000000000000000000000012747434554017725 5ustar rootrootNette-2.4-20160731/examples/CD-collection/www/css/site.css0000644000000000000000000000273412747434554021411 0ustar rootrootbody { font: 16px/1.5 "Trebuchet MS", "Geneva CE", lucida, sans-serif; color: #333; background-color: #fff; margin: 2em; } h1 { font-size: 1.9em; color: #3484D2; } h2 { font-size: 1.2em; color: #3484D2; } #content { width: 770px; margin: 0 5px; } a { color: #000080; } #logged-in { margin-top: 3em; font-size: 90%; } div.flash { color: black; background: #FFFFDD; border: 1px solid #FFD700; padding: 1em; margin: 1em 0; } /*------------------------------------------------------------------*/ table.grid { padding: 0; margin: 0; border-collapse:collapse; } table.grid td, table.grid th { background: #fff; border: 1px solid #add4fb; padding: 6px 6px 6px 12px; } table.grid th { color: #7a7772; background: #E4F1FC; text-align: left; font-weight: normal; font-size: 80%; } table.grid .alt td { background: #f8f8f0; } /*------------------------------------------------------------------*/ form { max-width: 500px; padding: .8em 1.6em; background: #E4F1FC; border: solid 2px #add4fb; } form input { margin: 2px 0; font-size: 100%; } form input.default { font-weight: bold; font-size: 105%; } form input.text { padding: 4px 2px; border: solid 1px #add4fb; min-width: 200px; } form label { width: 100px; display: block; text-align: right; margin-right: 5px; font-weight: normal; } form .required label { font-weight: bold; } Nette-2.4-20160731/examples/CD-collection/www/.htaccess0000644000000000000000000000047412747434554020740 0ustar rootroot# disable directory listing Options -Indexes # mod_rewrite RewriteEngine On # RewriteBase / # front controller RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L] Nette-2.4-20160731/examples/CD-collection/temp/0000755000000000000000000000000012747434614017253 5ustar rootrootNette-2.4-20160731/examples/CD-collection/temp/.htaccess0000644000000000000000000000003712747434554021054 0ustar rootrootOrder Allow,Deny Deny from allNette-2.4-20160731/examples/CD-collection/readme.txt0000644000000000000000000000251212747434554020307 0ustar rootrootCD collection (Nette Framework example) --------------------------------------- Classic Zend Framework [Tutorial](http://akrabat.com/zend-framework-tutorial) rewritten for Nette Framework. The example shows an important feature of the Nette Framework: the URLs are not used inside the application including the templates. The URLs are in responsibility of the router and can be changed anytime. The target of a link is always a combination "Presenter:action" or "Presenter:signal!". What is [Nette Framework](https://nette.org)? -------------------------------------------- Nette Framework is a popular tool for PHP web development. It is designed to be the most usable and friendliest as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks. Nette Framework speaks your language and helps you to easily build better websites. Installing ---------- The best way to install Nette Framework is to download latest package from https://nette.org/download or using [Composer](https://doc.nette.org/composer): curl -s http://getcomposer.org/installer | php php composer.phar update Then navigate your browser to the `www` directory. PHP 5.4 allows you run `php -S localhost:8888 -t www` to start the webserver and then visit `http://localhost:8888` in your browser. Nette-2.4-20160731/examples/CD-collection/log/0000755000000000000000000000000012747434614017067 5ustar rootrootNette-2.4-20160731/examples/CD-collection/log/.htaccess0000644000000000000000000000003712747434554020670 0ustar rootrootOrder Allow,Deny Deny from allNette-2.4-20160731/examples/CD-collection/composer.json0000644000000000000000000000130312747434554021030 0ustar rootroot{ "name": "nette-examples/cd-collection", "type": "project", "description": "Classic Zend Framework Tutorial from Akrabat rewritten for Nette Framework.", "license": "BSD-3-Clause", "authors": [ { "name": "David Grudl", "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", "homepage": "https://nette.org/contributors" } ], "require": { "php": ">=5.4", "nette/application": "~2.3", "nette/bootstrap": "~2.3", "nette/database": "~2.3", "nette/forms": "~2.3", "nette/robot-loader": "~2.3", "nette/security": "~2.3", "nette/utils": "~2.4", "latte/latte": "~2.3", "tracy/tracy": "~2.3" }, "minimum-stability": "dev" } Nette-2.4-20160731/examples/CD-collection/app/0000755000000000000000000000000012747434554017071 5ustar rootrootNette-2.4-20160731/examples/CD-collection/app/web.config0000644000000000000000000000111712747434554021035 0ustar rootroot Nette-2.4-20160731/examples/CD-collection/app/presenters/0000755000000000000000000000000012747434554021263 5ustar rootrootNette-2.4-20160731/examples/CD-collection/app/presenters/templates/0000755000000000000000000000000012747434554023261 5ustar rootrootNette-2.4-20160731/examples/CD-collection/app/presenters/templates/Sign/0000755000000000000000000000000012747434554024161 5ustar rootrootNette-2.4-20160731/examples/CD-collection/app/presenters/templates/Sign/in.latte0000644000000000000000000000025412747434554025623 0ustar rootroot{var $robots = noindex} {block content}

    Sign in

    {control signInForm}

    Default username is demo, with password xxx

    Nette-2.4-20160731/examples/CD-collection/app/presenters/templates/Dashboard/0000755000000000000000000000000012747434554025150 5ustar rootrootNette-2.4-20160731/examples/CD-collection/app/presenters/templates/Dashboard/edit.latte0000644000000000000000000000011712747434554027127 0ustar rootroot{block content}

    Edit Album

    {control albumForm} Nette-2.4-20160731/examples/CD-collection/app/presenters/templates/Dashboard/delete.latte0000644000000000000000000000035412747434554027447 0ustar rootroot{block content}

    Delete Album

    {if $album}

    Are you sure that you want to delete ‘{$album->title}’ by ‘{$album->artist}’?

    {control deleteForm} {else}

    Cannot find album.

    {/if} Nette-2.4-20160731/examples/CD-collection/app/presenters/templates/Dashboard/default.latte0000644000000000000000000000063312747434554027631 0ustar rootroot{block content}

    My Albums

    Add new album

    {foreach $albums as $album} {/foreach}
    Title Artist  
    {$album->title} {$album->artist} Edit Delete
    Nette-2.4-20160731/examples/CD-collection/app/presenters/templates/Dashboard/add.latte0000644000000000000000000000012212747434554026726 0ustar rootroot{block content}

    Add New Album

    {control albumForm} Nette-2.4-20160731/examples/CD-collection/app/presenters/templates/@layout.latte0000644000000000000000000000166512747434554025741 0ustar rootroot{** * Layout of Nette Framework example CD collection * * @param string $robots tell robots how to index the content of a page (optional) * @param string $basePath web base path * @param array $flashes flash messages * @param Nette\Web\User $user current user *} {block title|stripHtml|trim}{/block} | Nette example
    {$flash->message}
    {include content}

    Signed in as {$user->identity->realname}. Sign out

    Nette-2.4-20160731/examples/CD-collection/app/presenters/SignPresenter.php0000644000000000000000000000220312747434554024561 0ustar rootrootaddText('username', 'Username:') ->setRequired('Please enter your username.'); $form->addPassword('password', 'Password:') ->setRequired('Please enter your password.'); $form->addSubmit('send', 'Sign in'); $form->onSuccess[] = [$this, 'signInFormSucceeded']; return $form; } public function signInFormSucceeded($form, $values) { try { $this->getUser()->login($values->username, $values->password); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); return; } $this->restoreRequest($this->backlink); $this->redirect('Dashboard:'); } public function actionOut() { $this->getUser()->logout(); $this->flashMessage('You have been signed out.'); $this->redirect('in'); } } Nette-2.4-20160731/examples/CD-collection/app/presenters/DashboardPresenter.php0000644000000000000000000000636412747434554025564 0ustar rootrootalbums = $albums; } protected function startup() { parent::startup(); if (!$this->getUser()->isLoggedIn()) { if ($this->getUser()->getLogoutReason() === Nette\Security\IUserStorage::INACTIVITY) { $this->flashMessage('You have been signed out due to inactivity. Please sign in again.'); } $this->redirect('Sign:in', ['backlink' => $this->storeRequest()]); } } /********************* view default *********************/ public function renderDefault() { $this->template->albums = $this->albums->findAll()->order('artist')->order('title'); } /********************* views add & edit *********************/ public function renderAdd() { $this['albumForm']['save']->caption = 'Add'; } public function renderEdit($id = 0) { $form = $this['albumForm']; if (!$form->isSubmitted()) { $album = $this->albums->findById($id); if (!$album) { $this->error('Record not found'); } $form->setDefaults($album); } } /********************* view delete *********************/ public function renderDelete($id = 0) { $this->template->album = $this->albums->findById($id); if (!$this->template->album) { $this->error('Record not found'); } } /********************* component factories *********************/ /** * Edit form factory. * @return Form */ protected function createComponentAlbumForm() { $form = new Form; $form->addText('artist', 'Artist:') ->setRequired('Please enter an artist.'); $form->addText('title', 'Title:') ->setRequired('Please enter a title.'); $form->addSubmit('save', 'Save') ->setAttribute('class', 'default') ->onClick[] = [$this, 'albumFormSucceeded']; $form->addSubmit('cancel', 'Cancel') ->setValidationScope([]) ->onClick[] = [$this, 'formCancelled']; $form->addProtection(); return $form; } public function albumFormSucceeded($button) { $values = $button->getForm()->getValues(); $id = (int) $this->getParameter('id'); if ($id) { $this->albums->findById($id)->update($values); $this->flashMessage('The album has been updated.'); } else { $this->albums->insert($values); $this->flashMessage('The album has been added.'); } $this->redirect('default'); } /** * Delete form factory. * @return Form */ protected function createComponentDeleteForm() { $form = new Form; $form->addSubmit('cancel', 'Cancel') ->onClick[] = [$this, 'formCancelled']; $form->addSubmit('delete', 'Delete') ->setAttribute('class', 'default') ->onClick[] = [$this, 'deleteFormSucceeded']; $form->addProtection(); return $form; } public function deleteFormSucceeded() { $this->albums->findById($this->getParameter('id'))->delete(); $this->flashMessage('Album has been deleted.'); $this->redirect('default'); } public function formCancelled() { $this->redirect('default'); } } Nette-2.4-20160731/examples/CD-collection/app/model/0000755000000000000000000000000012747434554020171 5ustar rootrootNette-2.4-20160731/examples/CD-collection/app/model/demo.db30000644000000000000000000001000012747434554021476 0ustar rootrootSQLite format 3@  _pcp4AatableusersusersCREATE TABLE [users] ( [id] INTEGER PRIMARY KEY NULL, [username] VARCHAR(50) UNIQUE NOT NULL, [password] VARCHAR(60) NOT NULL, [realname] VARCHAR(100) NOT NULL ))=indexsqlite_autoindex_users_1userstablealbumsalbumsCREATE TABLE [albums] ( [id] INTEGER NOT NULL PRIMARY KEY, [artist] VARCHAR(100) NOT NULL, [title] VARCHAR(100) NOT NULL )  MobyPlay%)Suzanne VegaBeauty & Crime Odemo$2y$07$9nfexnuf8jjt8jsavdva2uKzzdiY9QjebHDbdkIeAfFdNcRR9ZiVODemo User demoNette-2.4-20160731/examples/CD-collection/app/model/Authenticator.php0000644000000000000000000000211712747434554023515 0ustar rootrootdatabase = $database; } /** * Performs an authentication. * @return Nette\Security\Identity * @throws Nette\Security\AuthenticationException */ public function authenticate(array $credentials) { list($username, $password) = $credentials; $row = $this->database->table('users')->where('username', $username)->fetch(); if (!$row) { throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND); } elseif (!Security\Passwords::verify($password, $row->password)) { throw new Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL); } $arr = $row->toArray(); unset($arr['password']); return new Security\Identity($row->id, NULL, $arr); } } Nette-2.4-20160731/examples/CD-collection/app/model/AlbumRepository.php0000644000000000000000000000124212747434554024041 0ustar rootrootdatabase = $database; } /** @return Nette\Database\Table\Selection */ public function findAll() { return $this->database->table('albums'); } /** @return Nette\Database\Table\ActiveRow */ public function findById($id) { return $this->findAll()->get($id); } /** @return Nette\Database\Table\ActiveRow */ public function insert($values) { return $this->findAll()->insert($values); } } Nette-2.4-20160731/examples/CD-collection/app/config.neon0000644000000000000000000000057612747434554021227 0ustar rootroot# # SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser! # https://nette.org/security-warning # php: date.timezone: Europe/Prague application: mapping: *: App\*Module\Presenters\*Presenter database: dsn: "sqlite:%appDir%/model/demo.db3" services: - App\Model\Authenticator - App\Model\AlbumRepository Nette-2.4-20160731/examples/CD-collection/app/bootstrap.php0000644000000000000000000000235112747434604021614 0ustar rootrootenableDebugger(__DIR__ . '/../log'); // Enable RobotLoader - this will load all classes automatically $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader() ->addDirectory(__DIR__) ->register(); // Create Dependency Injection container from config.neon file $configurator->addConfig(__DIR__ . '/config.neon'); $container = $configurator->createContainer(); // Setup router using mod_rewrite detection if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) { $router = $container->getByType(Nette\Application\IRouter::class); $router[] = new Route('index.php', 'Dashboard:default', Route::ONE_WAY); $router[] = new Route('/[/]', 'Dashboard:default'); } else { $container->addService('router', new SimpleRouter('Dashboard:default')); } return $container; Nette-2.4-20160731/examples/CD-collection/app/.htaccess0000644000000000000000000000004112747434554020662 0ustar rootrootOrder Allow,Deny Deny from all Nette-2.4-20160731/examples/.travis.yml0000644000000000000000000000043012747434554016000 0ustar rootrootlanguage: php php: - 5.4 script: - php code-checker/src/code-checker.php before_script: - travis_retry composer create-project nette/code-checker code-checker ~2.5 --no-interaction sudo: false cache: directories: - $HOME/.composer/cache Nette-2.4-20160731/contributing.txt0000644000000000000000000000027712747434552015330 0ustar rootrootHow to contribute & use the issue tracker ========================================= This is meta-package. **Please use an issue tracker in one of our [packages](readme.md).** Thanks! Nette-2.4-20160731/client-side/0000755000000000000000000000000012747434620014246 5ustar rootrootNette-2.4-20160731/client-side/netteForms.js0000644000000000000000000004275012747434620016742 0ustar rootroot/** * NetteForms - simple form validation. * * This file is part of the Nette Framework (https://nette.org) * Copyright (c) 2004 David Grudl (https://davidgrudl.com) */ (function(global, factory) { if (!global.JSON) { return; } if (typeof define === 'function' && define.amd) { define(function() { return factory(global); }); } else if (typeof module === 'object' && typeof module.exports === 'object') { module.exports = factory(global); } else { var init = !global.Nette || !global.Nette.noInit; global.Nette = factory(global); if (init) { global.Nette.initOnLoad(); } } }(typeof window !== 'undefined' ? window : this, function(window) { 'use strict'; var Nette = {}; Nette.formErrors = []; Nette.version = '2.4'; /** * Attaches a handler to an event for the element. */ Nette.addEvent = function(element, on, callback) { if (element.addEventListener) { element.addEventListener(on, callback); } else if (on === 'DOMContentLoaded') { element.attachEvent('onreadystatechange', function() { if (element.readyState === 'complete') { callback.call(this); } }); } else { element.attachEvent('on' + on, getHandler(callback)); } }; function getHandler(callback) { return function(e) { return callback.call(this, e); }; } /** * Returns the value of form element. */ Nette.getValue = function(elem) { var i; if (!elem) { return null; } else if (!elem.tagName) { // RadioNodeList, HTMLCollection, array return elem[0] ? Nette.getValue(elem[0]) : null; } else if (elem.type === 'radio') { var elements = elem.form.elements; // prevents problem with name 'item' or 'namedItem' for (i = 0; i < elements.length; i++) { if (elements[i].name === elem.name && elements[i].checked) { return elements[i].value; } } return null; } else if (elem.type === 'file') { return elem.files || elem.value; } else if (elem.tagName.toLowerCase() === 'select') { var index = elem.selectedIndex, options = elem.options, values = []; if (elem.type === 'select-one') { return index < 0 ? null : options[index].value; } for (i = 0; i < options.length; i++) { if (options[i].selected) { values.push(options[i].value); } } return values; } else if (elem.name && elem.name.match(/\[\]$/)) { // multiple elements [] var elements = elem.form.elements[elem.name].tagName ? [elem] : elem.form.elements[elem.name], values = []; for (i = 0; i < elements.length; i++) { if (elements[i].type !== 'checkbox' || elements[i].checked) { values.push(elements[i].value); } } return values; } else if (elem.type === 'checkbox') { return elem.checked; } else if (elem.tagName.toLowerCase() === 'textarea') { return elem.value.replace("\r", ''); } else { return elem.value.replace("\r", '').replace(/^\s+|\s+$/g, ''); } }; /** * Returns the effective value of form element. */ Nette.getEffectiveValue = function(elem) { var val = Nette.getValue(elem); if (elem.getAttribute) { if (val === elem.getAttribute('data-nette-empty-value')) { val = ''; } } return val; }; /** * Validates form element against given rules. */ Nette.validateControl = function(elem, rules, onlyCheck, value, emptyOptional) { elem = elem.tagName ? elem : elem[0]; // RadioNodeList rules = rules || Nette.parseJSON(elem.getAttribute('data-nette-rules')); value = value === undefined ? {value: Nette.getEffectiveValue(elem)} : value; for (var id = 0, len = rules.length; id < len; id++) { var rule = rules[id], op = rule.op.match(/(~)?([^?]+)/), curElem = rule.control ? elem.form.elements.namedItem(rule.control) : elem; rule.neg = op[1]; rule.op = op[2]; rule.condition = !!rule.rules; if (!curElem) { continue; } else if (rule.op === 'optional') { emptyOptional = !Nette.validateRule(elem, ':filled', null, value); continue; } else if (emptyOptional && !rule.condition && rule.op !== ':filled') { return true; } curElem = curElem.tagName ? curElem : curElem[0]; // RadioNodeList var curValue = elem === curElem ? value : {value: Nette.getEffectiveValue(curElem)}, success = Nette.validateRule(curElem, rule.op, rule.arg, curValue); if (success === null) { continue; } else if (rule.neg) { success = !success; } if (rule.condition && success) { if (!Nette.validateControl(elem, rule.rules, onlyCheck, value, rule.op === ':blank' ? false : emptyOptional)) { return false; } } else if (!rule.condition && !success) { if (Nette.isDisabled(curElem)) { continue; } if (!onlyCheck) { var arr = Nette.isArray(rule.arg) ? rule.arg : [rule.arg], message = rule.msg.replace(/%(value|\d+)/g, function(foo, m) { return Nette.getValue(m === 'value' ? curElem : elem.form.elements.namedItem(arr[m].control)); }); Nette.addError(curElem, message); } return false; } } if (!onlyCheck && elem.type === 'number' && !elem.validity.valid) { Nette.addError(elem, 'Please enter a valid value.'); return false; } return true; }; /** * Validates whole form. */ Nette.validateForm = function(sender) { var form = sender.form || sender, scope = false; Nette.formErrors = []; if (form['nette-submittedBy'] && form['nette-submittedBy'].getAttribute('formnovalidate') !== null) { var scopeArr = Nette.parseJSON(form['nette-submittedBy'].getAttribute('data-nette-validation-scope')); if (scopeArr.length) { scope = new RegExp('^(' + scopeArr.join('-|') + '-)'); } else { Nette.showFormErrors(form, []); return true; } } var radios = {}, i, elem; for (i = 0; i < form.elements.length; i++) { elem = form.elements[i]; if (elem.tagName && !(elem.tagName.toLowerCase() in {input: 1, select: 1, textarea: 1, button: 1})) { continue; } else if (elem.type === 'radio') { if (radios[elem.name]) { continue; } radios[elem.name] = true; } if ((scope && !elem.name.replace(/]\[|\[|]|$/g, '-').match(scope)) || Nette.isDisabled(elem)) { continue; } if (!Nette.validateControl(elem) && !Nette.formErrors.length) { return false; } } var success = !Nette.formErrors.length; Nette.showFormErrors(form, Nette.formErrors); return success; }; /** * Check if input is disabled. */ Nette.isDisabled = function(elem) { if (elem.type === 'radio') { for (var i = 0, elements = elem.form.elements; i < elements.length; i++) { if (elements[i].name === elem.name && !elements[i].disabled) { return false; } } return true; } return elem.disabled; }; /** * Adds error message to the queue. */ Nette.addError = function(elem, message) { Nette.formErrors.push({ element: elem, message: message }); }; /** * Display error messages. */ Nette.showFormErrors = function(form, errors) { var messages = [], focusElem; for (var i in errors) { var elem = errors[i].element, message = errors[i].message; if (!Nette.inArray(messages, message)) { messages.push(message); if (!focusElem && elem.focus) { focusElem = elem; } } } if (messages.length) { alert(messages.join('\n')); if (focusElem) { focusElem.focus(); } } }; /** * Expand rule argument. */ Nette.expandRuleArgument = function(form, arg) { if (arg && arg.control) { var control = form.elements.namedItem(arg.control), value = {value: Nette.getEffectiveValue(control)}; Nette.validateControl(control, null, true, value); arg = value.value; } return arg; }; /** * Validates single rule. */ Nette.validateRule = function(elem, op, arg, value) { value = value === undefined ? {value: Nette.getEffectiveValue(elem)} : value; if (op.charAt(0) === ':') { op = op.substr(1); } op = op.replace('::', '_'); op = op.replace(/\\/g, ''); var arr = Nette.isArray(arg) ? arg.slice(0) : [arg]; for (var i = 0, len = arr.length; i < len; i++) { arr[i] = Nette.expandRuleArgument(elem.form, arr[i]); } return Nette.validators[op] ? Nette.validators[op](elem, Nette.isArray(arg) ? arr : arr[0], value.value, value) : null; }; Nette.validators = { filled: function(elem, arg, val) { if (elem.type === 'number' && elem.validity.badInput) { return true; } return val !== '' && val !== false && val !== null && (!Nette.isArray(val) || !!val.length) && (!window.FileList || !(val instanceof window.FileList) || val.length); }, blank: function(elem, arg, val) { return !Nette.validators.filled(elem, arg, val); }, valid: function(elem, arg, val) { return Nette.validateControl(elem, null, true); }, equal: function(elem, arg, val) { if (arg === undefined) { return null; } function toString(val) { if (typeof val === 'number' || typeof val === 'string') { return '' + val; } else { return val === true ? '1' : ''; } } val = Nette.isArray(val) ? val : [val]; arg = Nette.isArray(arg) ? arg : [arg]; loop: for (var i1 = 0, len1 = val.length; i1 < len1; i1++) { for (var i2 = 0, len2 = arg.length; i2 < len2; i2++) { if (toString(val[i1]) === toString(arg[i2])) { continue loop; } } return false; } return true; }, notEqual: function(elem, arg, val) { return arg === undefined ? null : !Nette.validators.equal(elem, arg, val); }, minLength: function(elem, arg, val) { if (elem.type === 'number') { if (elem.validity.tooShort) { return false } else if (elem.validity.badInput) { return null; } } return val.length >= arg; }, maxLength: function(elem, arg, val) { if (elem.type === 'number') { if (elem.validity.tooLong) { return false } else if (elem.validity.badInput) { return null; } } return val.length <= arg; }, length: function(elem, arg, val) { if (elem.type === 'number') { if (elem.validity.tooShort || elem.validity.tooLong) { return false } else if (elem.validity.badInput) { return null; } } arg = Nette.isArray(arg) ? arg : [arg, arg]; return (arg[0] === null || val.length >= arg[0]) && (arg[1] === null || val.length <= arg[1]); }, email: function(elem, arg, val) { return (/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+\/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+\/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i).test(val); }, url: function(elem, arg, val, value) { if (!(/^[a-z\d+.-]+:/).test(val)) { val = 'http://' + val; } if ((/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i).test(val)) { value.value = val; return true; } return false; }, regexp: function(elem, arg, val) { var parts = typeof arg === 'string' ? arg.match(/^\/(.*)\/([imu]*)$/) : false; try { return parts && (new RegExp(parts[1], parts[2].replace('u', ''))).test(val); } catch (e) {} }, pattern: function(elem, arg, val) { try { return typeof arg === 'string' ? (new RegExp('^(?:' + arg + ')$')).test(val) : null; } catch (e) {} }, integer: function(elem, arg, val) { if (elem.type === 'number' && elem.validity.badInput) { return false; } return (/^-?[0-9]+$/).test(val); }, 'float': function(elem, arg, val, value) { if (elem.type === 'number' && elem.validity.badInput) { return false; } val = val.replace(' ', '').replace(',', '.'); if ((/^-?[0-9]*[.,]?[0-9]+$/).test(val)) { value.value = val; return true; } return false; }, min: function(elem, arg, val) { if (elem.type === 'number') { if (elem.validity.rangeUnderflow) { return false } else if (elem.validity.badInput) { return null; } } return Nette.validators.range(elem, [arg, null], val); }, max: function(elem, arg, val) { if (elem.type === 'number') { if (elem.validity.rangeOverflow) { return false } else if (elem.validity.badInput) { return null; } } return Nette.validators.range(elem, [null, arg], val); }, range: function(elem, arg, val) { if (elem.type === 'number') { if (elem.validity.rangeUnderflow || elem.validity.rangeOverflow) { return false } else if (elem.validity.badInput) { return null; } } return Nette.isArray(arg) ? ((arg[0] === null || parseFloat(val) >= arg[0]) && (arg[1] === null || parseFloat(val) <= arg[1])) : null; }, submitted: function(elem, arg, val) { return elem.form['nette-submittedBy'] === elem; }, fileSize: function(elem, arg, val) { if (window.FileList) { for (var i = 0; i < val.length; i++) { if (val[i].size > arg) { return false; } } } return true; }, image: function (elem, arg, val) { if (window.FileList && val instanceof window.FileList) { for (var i = 0; i < val.length; i++) { var type = val[i].type; if (type && type !== 'image/gif' && type !== 'image/png' && type !== 'image/jpeg') { return false; } } } return true; } }; /** * Process all toggles in form. */ Nette.toggleForm = function(form, elem) { var i; Nette.toggles = {}; for (i = 0; i < form.elements.length; i++) { if (form.elements[i].tagName.toLowerCase() in {input: 1, select: 1, textarea: 1, button: 1}) { Nette.toggleControl(form.elements[i], null, null, !elem); } } for (i in Nette.toggles) { Nette.toggle(i, Nette.toggles[i], elem); } }; /** * Process toggles on form element. */ Nette.toggleControl = function(elem, rules, success, firsttime, value) { rules = rules || Nette.parseJSON(elem.getAttribute('data-nette-rules')); value = value === undefined ? {value: Nette.getEffectiveValue(elem)} : value; var has = false, handled = [], handler = function () { Nette.toggleForm(elem.form, elem); }, curSuccess; for (var id = 0, len = rules.length; id < len; id++) { var rule = rules[id], op = rule.op.match(/(~)?([^?]+)/), curElem = rule.control ? elem.form.elements.namedItem(rule.control) : elem; if (!curElem) { continue; } curSuccess = success; if (success !== false) { rule.neg = op[1]; rule.op = op[2]; var curValue = elem === curElem ? value : {value: Nette.getEffectiveValue(curElem)}; curSuccess = Nette.validateRule(curElem, rule.op, rule.arg, curValue); if (curSuccess === null) { continue; } else if (rule.neg) { curSuccess = !curSuccess; } if (!rule.rules) { success = curSuccess; } } if ((rule.rules && Nette.toggleControl(elem, rule.rules, curSuccess, firsttime, value)) || rule.toggle) { has = true; if (firsttime) { var oldIE = !document.addEventListener, // IE < 9 name = curElem.tagName ? curElem.name : curElem[0].name, els = curElem.tagName ? curElem.form.elements : curElem; for (var i = 0; i < els.length; i++) { if (els[i].name === name && !Nette.inArray(handled, els[i])) { Nette.addEvent(els[i], oldIE && els[i].type in {checkbox: 1, radio: 1} ? 'click' : 'change', handler); handled.push(els[i]); } } } for (var id2 in rule.toggle || []) { if (Object.prototype.hasOwnProperty.call(rule.toggle, id2)) { Nette.toggles[id2] = Nette.toggles[id2] || (rule.toggle[id2] ? curSuccess : !curSuccess); } } } } return has; }; Nette.parseJSON = function(s) { return (s || '').substr(0, 3) === '{op' ? eval('[' + s + ']') // backward compatibility with Nette 2.0.x : JSON.parse(s || '[]'); }; /** * Displays or hides HTML element. */ Nette.toggle = function(id, visible, srcElement) { var elem = document.getElementById(id); if (elem) { elem.style.display = visible ? '' : 'none'; } }; /** * Setup handlers. */ Nette.initForm = function(form) { form.noValidate = 'novalidate'; Nette.addEvent(form, 'submit', function(e) { if (!Nette.validateForm(form)) { if (e && e.stopPropagation) { e.stopPropagation(); e.preventDefault(); } else if (window.event) { event.cancelBubble = true; event.returnValue = false; } } }); Nette.toggleForm(form); }; /** * @private */ Nette.initOnLoad = function() { Nette.addEvent(document, 'DOMContentLoaded', function() { for (var i = 0; i < document.forms.length; i++) { var form = document.forms[i]; for (var j = 0; j < form.elements.length; j++) { if (form.elements[j].getAttribute('data-nette-rules')) { Nette.initForm(form); break; } } } Nette.addEvent(document.body, 'click', function(e) { var target = e.target || e.srcElement; if (target.form && target.type in {submit: 1, image: 1}) { target.form['nette-submittedBy'] = target; } }); }); }; /** * Determines whether the argument is an array. */ Nette.isArray = function(arg) { return Object.prototype.toString.call(arg) === '[object Array]'; }; /** * Search for a specified value within an array. */ Nette.inArray = function(arr, val) { if ([].indexOf) { return arr.indexOf(val) > -1; } else { for (var i = 0; i < arr.length; i++) { if (arr[i] === val) { return true; } } return false; } }; /** * Converts string to web safe characters [a-z0-9-] text. */ Nette.webalize = function(s) { s = s.toLowerCase(); var res = '', i, ch; for (i = 0; i < s.length; i++) { ch = Nette.webalizeTable[s.charAt(i)]; res += ch ? ch : s.charAt(i); } return res.replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, ''); }; Nette.webalizeTable = {\u00e1: 'a', \u00e4: 'a', \u010d: 'c', \u010f: 'd', \u00e9: 'e', \u011b: 'e', \u00ed: 'i', \u013e: 'l', \u0148: 'n', \u00f3: 'o', \u00f4: 'o', \u0159: 'r', \u0161: 's', \u0165: 't', \u00fa: 'u', \u016f: 'u', \u00fd: 'y', \u017e: 'z'}; return Nette; }));