Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

THE DEVELOPMENT OF NELLA FRAMEWORK HAS BEEN ABANDONED

  • Loading branch information...
commit 2e1bb23c4b244a18c9040098eeda98a8b2b64ffc 1 parent ec6a040
@Vrtak-CZ Vrtak-CZ authored
Showing with 23 additions and 17,291 deletions.
  1. +0 −7 .gitattributes
  2. +0 −3  .gitignore
  3. +0 −10 .travis.yml
  4. +0 −57 LICENSE.txt
  5. +0 −199 Nella/Application/PresenterFactory.php
  6. +0 −27 Nella/Application/UI/BackendPresenter.php
  7. +0 −100 Nella/Application/UI/Control.php
  8. +0 −53 Nella/Application/UI/Form.php
  9. +0 −46 Nella/Application/UI/Presenter.php
  10. +0 −43 Nella/Application/UI/SecuredPresenter.php
  11. +0 −101 Nella/Config/Configurator.php
  12. +0 −97 Nella/Config/Extensions/NellaExtension.php
  13. +0 −128 Nella/Console/Config/Extension.php
  14. +0 −51 Nella/Console/LazyRouter.php
  15. +0 −67 Nella/Console/Router.php
  16. +0 −35 Nella/Console/composer.json
  17. +0 −56 Nella/Console/license.md
  18. +0 −25 Nella/Console/readme.md
  19. +0 −69 Nella/Diagnostics/AccessLogger.php
  20. +0 −136 Nella/Diagnostics/CallbackPanel.php
  21. +0 −123 Nella/Diagnostics/Config/Extension.php
  22. +0 −25 Nella/Diagnostics/ILoggerStorage.php
  23. +0 −119 Nella/Diagnostics/Logger.php
  24. +0 −65 Nella/Diagnostics/LoggerStorages/Curl.php
  25. +0 −63 Nella/Diagnostics/LoggerStorages/Http.php
  26. +0 −34 Nella/Diagnostics/composer.json
  27. +0 −56 Nella/Diagnostics/license.md
  28. +0 −23 Nella/Diagnostics/readme.md
  29. +0 −90 Nella/Diagnostics/templates/CallbackPanel.panel.phtml
  30. +0 −130 Nella/Doctrine/Cache.php
  31. +0 −317 Nella/Doctrine/Config/Extension.php
  32. +0 −154 Nella/Doctrine/Config/MigrationsExtension.php
  33. +0 −204 Nella/Doctrine/Diagnostics/ConnectionPanel.php
  34. +0 −57 Nella/Doctrine/Entity.php
  35. +0 −107 Nella/Doctrine/Listeners/DiscriminatorMapDiscovery.php
  36. +0 −40 Nella/Doctrine/Mapping/DiscriminatorEntry.php
  37. +0 −231 Nella/Doctrine/Repository.php
  38. +0 −40 Nella/Doctrine/composer.json
  39. +0 −56 Nella/Doctrine/license.md
  40. +0 −35 Nella/Doctrine/readme.md
  41. +0 −43 Nella/Event/Args/Application.php
  42. +0 −45 Nella/Event/Args/ApplicationError.php
  43. +0 −46 Nella/Event/Args/ApplicationRequest.php
  44. +0 −46 Nella/Event/Args/ApplicationResponse.php
  45. +0 −45 Nella/Event/Args/ApplicationShutdown.php
  46. +0 −43 Nella/Event/Args/Container.php
  47. +0 −21 Nella/Event/Args/Void.php
  48. +0 −82 Nella/Event/Config/Extension.php
  49. +0 −21 Nella/Event/EventArgs.php
  50. +0 −130 Nella/Event/EventDispatcher.php
  51. +0 −67 Nella/Event/IEventDispatcher.php
  52. +0 −29 Nella/Event/IEventSubscriber.php
  53. +0 −35 Nella/Events.php
  54. +0 −222 Nella/Forms/Container.php
  55. +0 −76 Nella/Forms/Controls/BaseDateTime.php
  56. +0 −36 Nella/Forms/Controls/Date.php
  57. +0 −42 Nella/Forms/Controls/DateTime.php
  58. +0 −259 Nella/Forms/Controls/MultipleFileUpload.php
  59. +0 −390 Nella/Forms/Controls/TagsInput.php
  60. +0 −36 Nella/Forms/Controls/Time.php
  61. +0 −222 Nella/Forms/Form.php
  62. +0 −385 Nella/Forms/Multipler.php
  63. +0 −39 Nella/Forms/MultiplerContainer.php
  64. +0 −34 Nella/Forms/composer.json
  65. +0 −56 Nella/Forms/license.md
  66. +0 −22 Nella/Forms/readme.md
  67. +0 −32 Nella/Framework.php
  68. +0 −58 Nella/Latte/Macros/UIMacros.php
  69. +0 −72 Nella/Localization/Config/Extension.php
  70. +0 −158 Nella/Localization/Dictionary.php
  71. +0 −43 Nella/Localization/DummyTranslator.php
  72. +0 −36 Nella/Localization/Helper.php
  73. +0 −32 Nella/Localization/IStorage.php
  74. +0 −253 Nella/Localization/Storages/GettextBinary.php
  75. +0 −145 Nella/Localization/Translator.php
  76. +0 −35 Nella/Localization/composer.json
  77. +0 −56 Nella/Localization/license.md
  78. +0 −23 Nella/Localization/readme.md
  79. +0 −69 Nella/Localization/shortcuts.php
  80. +0 −49 Nella/Media/Callbacks/FilePresenterCallback.php
  81. +0 −159 Nella/Media/Callbacks/ImagePresenterCallback.php
  82. +0 −269 Nella/Media/Config/Extension.php
  83. +0 −87 Nella/Media/Doctrine/BaseFacade.php
  84. +0 −122 Nella/Media/Doctrine/BaseFileEntity.php
  85. +0 −30 Nella/Media/Doctrine/FileEntity.php
  86. +0 −31 Nella/Media/Doctrine/FileFacade.php
  87. +0 −41 Nella/Media/Doctrine/ImageEntity.php
  88. +0 −77 Nella/Media/Doctrine/ImageFacade.php
  89. +0 −252 Nella/Media/Doctrine/ImageFormatEntity.php
  90. +0 −86 Nella/Media/Doctrine/ImageFormatFacade.php
  91. +0 −61 Nella/Media/Doctrine/Listener.php
  92. +0 −66 Nella/Media/Helper.php
  93. +0 −50 Nella/Media/IFile.php
  94. +0 −26 Nella/Media/IFilePresenterCallback.php
  95. +0 −27 Nella/Media/IImage.php
  96. +0 −46 Nella/Media/IImageCacheStorage.php
  97. +0 −80 Nella/Media/IImageFormat.php
  98. +0 −28 Nella/Media/IImagePresenterCallback.php
  99. +0 −37 Nella/Media/IStorage.php
  100. +0 −181 Nella/Media/ImageCacheStorages/File.php
  101. +0 −152 Nella/Media/Latte/MediaMacros.php
  102. +0 −96 Nella/Media/Model/File.php
  103. +0 −39 Nella/Media/Model/FileFacade.php
  104. +0 −26 Nella/Media/Model/IFileDao.php
  105. +0 −26 Nella/Media/Model/IImageDao.php
  106. +0 −26 Nella/Media/Model/IImageFormatDao.php
  107. +0 −42 Nella/Media/Model/Image.php
  108. +0 −39 Nella/Media/Model/ImageFacade.php
  109. +0 −151 Nella/Media/Model/ImageFormat.php
  110. +0 −93 Nella/Media/Model/ImageFormatFacade.php
  111. +0 −93 Nella/Media/Responses/ImageResponse.php
  112. +0 −82 Nella/Media/Routes/FileRoute.php
  113. +0 −91 Nella/Media/Routes/ImageRoute.php
  114. +0 −77 Nella/Media/Storages/File.php
  115. +0 −37 Nella/Media/composer.json
  116. +0 −56 Nella/Media/license.md
  117. +0 −27 Nella/Media/readme.md
  118. +0 −139 Nella/Model/Config/Extension.php
  119. +0 −41 Nella/Model/DuplicateEntryException.php
  120. +0 −41 Nella/Model/EmptyValueException.php
  121. +0 −21 Nella/Model/Exception.php
  122. +0 −138 Nella/Model/Facade.php
  123. +0 −59 Nella/Model/Helper.php
  124. +0 −61 Nella/Model/IDao.php
  125. +0 −26 Nella/Model/IObjectFactory.php
  126. +0 −38 Nella/Model/IQueryExecutor.php
  127. +0 −38 Nella/Model/IQueryObject.php
  128. +0 −26 Nella/Model/IQueryable.php
  129. +0 −41 Nella/Model/InvalidEntityException.php
  130. +0 −100 Nella/Model/QueryObject.php
  131. +0 −47 Nella/Model/Repository.php
  132. +0 −57 Nella/Security/Authenticator.php
  133. +0 −79 Nella/Security/Config/Extension.php
  134. +0 −32 Nella/Security/ISerializableIdentity.php
  135. +0 −154 Nella/Security/Model/CredentialsEntity.php
  136. +0 −77 Nella/Security/Model/CredentialsFacade.php
  137. +0 −149 Nella/Security/Model/IdentityEntity.php
  138. +0 −56 Nella/Security/UserStorage.php
  139. +0 −103 Nella/SplClassLoader.php
  140. +0 −56 Nella/Templating/Diagnostics/FilesPanel.php
  141. +0 −31 Nella/Templating/Diagnostics/templates/FilesPanel.panel.phtml
  142. +0 −25 Nella/Templating/IFilesFormatterLogger.php
  143. +0 −49 Nella/Templating/ITemplateFilesFormatter.php
  144. +0 −222 Nella/Templating/TemplateFilesFormatter.php
  145. +0 −17 Nella/loader.php
  146. +0 −31 Nella/shortcuts.php
  147. +3 −37 README.md
  148. +0 −39 before-build.sh
  149. +0 −153 build.xml
  150. +3 −21 composer.json
  151. +17 −0 index.php
  152. +0 −1  tests/.gitignore
  153. +0 −193 tests/Nella/Application/PresenterFactoryTest.phpt
  154. +0 −154 tests/Nella/Application/UI/ControlTest.phpt
  155. +0 −178 tests/Nella/Application/UI/PresenterTest.phpt
  156. +0 −83 tests/Nella/Config/ConfiguratorTest.phpt
  157. +0 −37 tests/Nella/Config/Extensions/NellaExtensionTest.phpt
  158. +0 −115 tests/Nella/Console/Config/ExtensionTest.phpt
  159. +0 −59 tests/Nella/Console/LazyRouteTest.phpt
  160. +0 −45 tests/Nella/Doctrine/CacheTest.phpt
  161. +0 −83 tests/Nella/Doctrine/Config/ExtensionTest.phpt
  162. +0 −37 tests/Nella/Doctrine/Config/MigrationsExtensionTest.phpt
  163. +0 −65 tests/Nella/Doctrine/EntityTest.phpt
  164. +0 −53 tests/Nella/Event/Args/ApplicationErrorTest.phpt
  165. +0 −56 tests/Nella/Event/Args/ApplicationRequestTest.phpt
  166. +0 −56 tests/Nella/Event/Args/ApplicationResponseTest.phpt
  167. +0 −53 tests/Nella/Event/Args/ApplicationShutdownTest.phpt
  168. +0 −47 tests/Nella/Event/Args/ApplicationTest.phpt
  169. +0 −44 tests/Nella/Event/Args/ContainerTest.phpt
  170. +0 −38 tests/Nella/Event/Args/VoidTest.phpt
  171. +0 −37 tests/Nella/Event/Config/ExtensionTest.phpt
  172. +0 −155 tests/Nella/Event/EventDispatcherTest.phpt
  173. +0 −172 tests/Nella/Forms/ContainerTest.phpt
  174. +0 −58 tests/Nella/Forms/Controls/DateTest.phpt
  175. +0 −58 tests/Nella/Forms/Controls/DateTimeTest.phpt
  176. +0 −58 tests/Nella/Forms/Controls/TimeTest.phpt
  177. +0 −170 tests/Nella/Forms/FormTest.phpt
  178. +0 −50 tests/Nella/Forms/MultiplerContainerTest.phpt
  179. +0 −217 tests/Nella/Forms/MultiplerTest.phpt
  180. +0 −62 tests/Nella/Latte/Macros/UiMacrosTest.phpt
  181. +0 −92 tests/Nella/Localization/DictionaryTest.phpt
  182. +0 −54 tests/Nella/Localization/DummyTranslatorTest.phpt
  183. +0 −48 tests/Nella/Localization/HelperTest.phpt
  184. +0 −90 tests/Nella/Localization/Storages/GettextBinaryTest.phpt
  185. +0 −75 tests/Nella/Localization/TranslatorTest.phpt
  186. +0 −61 tests/Nella/Media/Callbacks/FilePresenterCallbackTest.phpt
  187. +0 −68 tests/Nella/Media/Callbacks/ImagePresenterCallbackTest.phpt
  188. +0 −37 tests/Nella/Media/Config/ExtensionTest.phpt
  189. +0 −76 tests/Nella/Media/Doctrine/FileEntityTest.phpt
  190. +0 −77 tests/Nella/Media/Doctrine/ImageEntityTest.phpt
  191. +0 −87 tests/Nella/Media/Doctrine/ImageFormatEntityTest.phpt
  192. +0 −64 tests/Nella/Media/HelperTest.phpt
  193. +0 −171 tests/Nella/Media/ImageCacheStorages/FileTest.phpt
  194. +0 −170 tests/Nella/Media/Latte/MediaMacrosTest.phpt
  195. +0 −45 tests/Nella/Media/Model/FileFacadeTest.phpt
  196. +0 −62 tests/Nella/Media/Model/FileTest.phpt
  197. +0 −45 tests/Nella/Media/Model/ImageFacadeTest.phpt
  198. +0 −55 tests/Nella/Media/Model/ImageFormatFacadeTest.phpt
  199. +0 −102 tests/Nella/Media/Model/ImageFormatTest.phpt
  200. +0 −77 tests/Nella/Media/Model/ImageTest.phpt
  201. +0 −112 tests/Nella/Media/Storages/FileTest.phpt
  202. +0 −37 tests/Nella/Model/Config/ExtensionTest.phpt
  203. +0 −70 tests/Nella/Model/HelperTest.phpt
  204. +0 −48 tests/Nella/Model/QueryObjectTest.phpt
  205. +0 −38 tests/Nella/Security/Config/ExtensionTest.phpt
  206. +0 −92 tests/Nella/Security/Model/CredentialsEntityTest.phpt
  207. +0 −75 tests/Nella/Security/Model/IdentityEntityTest.phpt
  208. +0 −41 tests/Nella/SplClassLoaderTest.phpt
  209. +0 −281 tests/Nella/Templating/TemplateFilesFormatterTest.phpt
  210. +0 −38 tests/bootstrap.php
  211. +0 −15 tests/convert-coverage.sh
  212. +0 −15 tests/fixtures/Foo.php
  213. +0 −1  tests/fixtures/Tests/Application/UI/ControlMock.latte
  214. BIN  tests/fixtures/cs_CZ.mo
  215. BIN  tests/fixtures/logo.png
  216. +0 −22 tests/mocks/Application/Application.php
  217. +0 −28 tests/mocks/Application/UI/Control.php
  218. +0 −39 tests/mocks/Application/UI/ControlPresenter.php
  219. +0 −26 tests/mocks/Application/UI/Presenter.php
  220. +0 −25 tests/mocks/Config/Compiler.php
  221. +0 −18 tests/mocks/Config/Configurator.php
  222. +0 −66 tests/mocks/Localization/Storages/Mock.php
  223. +0 −41 tests/mocks/Media/File.php
  224. +0 −60 tests/mocks/Media/Format.php
  225. +0 −46 tests/mocks/Media/Image.php
  226. +0 −71 tests/mocks/Security/UserStorage.php
  227. +0 −6 tests/php.ini-unix
  228. +0 −11 tests/php.ini-win
  229. +0 −40 tests/run-tests.sh
  230. +0 −6 tests/temp/.gitignore
  231. +0 −2  tests/temp/cache/.gitignore
  232. +0 −2  tests/temp/log/.gitignore
  233. +0 −2  tests/temp/sessions/.gitignore
  234. +0 −2  tests/temp/uploads/.gitignore
View
7 .gitattributes
@@ -1,7 +0,0 @@
-.gitattributes export-ignore
-.gitignore export-ignore
-.travis.yml export-ignore
-before-build.sh export-ignore
-build.xml export-ignore
-phpunit.xml export-ignore
-tests export-ignore
View
3  .gitignore
@@ -1,3 +0,0 @@
-vendor
-composer.lock
-composer.phar
View
10 .travis.yml
@@ -1,10 +0,0 @@
-language: php
-
-php:
- - 5.3
- - 5.4
-
-before_script:
- - "sh -c 'composer install --dev --no-interaction'"
-
-script: "VERBOSE=true ./tests/run-tests.sh -s tests/"
View
57 LICENSE.txt
@@ -1,57 +0,0 @@
-Licenses
-========
-
-Good news! You may use Nella Framework under the terms of either
-the New BSD License or the GNU General Public License (GPL) version 2 or 3.
-
-The BSD License is recommended for most projects. It is easy to understand and it
-places almost no restrictions on what you can do with the framework. If the GPL
-fits better to your project, you can use the framework under this license.
-
-You don't have to notify anyone which license you are using. You can freely
-use Nella Framework in commercial projects as long as the copyright header
-remains intact.
-
-
-
-New BSD License
----------------
-
-Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of "Nella Framework" nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
-GNU General Public License
---------------------------
-
-GPL licenses are very very long, so instead of including them here we offer
-you URLs with full text:
-
-- GPL version 2: http://www.gnu.org/licenses/gpl-2.0.html
-- GPL version 3: http://www.gnu.org/licenses/gpl-3.0.html
View
199 Nella/Application/PresenterFactory.php
@@ -1,199 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Application;
-
-use Nette\DI\Container,
- Nette\Reflection\ClassType,
- Nette\Application\UI\Presenter,
- Nette\Utils\Strings;
-
-/**
- * Nella presenter factory
- *
- * @author Patrik Votoček
- */
-class PresenterFactory extends \Nette\Object implements \Nette\Application\IPresenterFactory
-{
- const MODULE_SUFFIX = 'Module';
-
- /** @var bool */
- public $useModuleSuffix = TRUE;
- /** @var \Nette\DI\Container */
- private $container;
- /** @var \SplPriorityQueue */
- private $namespaces;
-
- /**
- * @param \Nette\DI\Container
- */
- public function __construct(Container $container)
- {
- $this->container = $container;
- $this->namespaces = new \SplPriorityQueue;
- }
-
- /**
- * @param string
- * @param int
- * @return PresenterFactory
- */
- public function addNamespace($namespace, $priority = 5)
- {
- $this->namespaces->insert($namespace, $priority);
- return $this;
- }
-
- /**
- * Create new presenter instance.
- * @param string presenter name
- * @return \Nette\Application\IPresenter
- */
- public function createPresenter($name)
- {
- $presenter = $this->container->createInstance($this->getPresenterClass($name));
- if (method_exists($presenter, 'setContext')) {
- $this->container->callMethod(array($presenter, 'setContext'));
- }
-
- foreach (array_reverse(get_class_methods($presenter)) as $method) {
- if (substr($method, 0, 6) === 'inject') {
- $this->container->callMethod(array($presenter, $method));
- }
- }
-
- if ($presenter instanceof Presenter && $presenter->invalidLinkMode === NULL) {
- $presenter->invalidLinkMode = $this->container->parameters['debugMode']
- ? Presenter::INVALID_LINK_WARNING : Presenter::INVALID_LINK_SILENT;
- }
- return $presenter;
- }
-
- /**
- * Format presenter class with prefixes
- *
- * @param string
- * @return string
- * @throws \Nette\Application\InvalidPresenterException
- */
- private function formatPresenterClasses($name)
- {
- $class = NULL;
- $namespaces = clone $this->namespaces;
- foreach ($namespaces as $namespace) {
- $class = $this->formatPresenterClass($name, $namespace);
- if (class_exists($class)) {
- break;
- }
- }
-
- if (!class_exists($class)) {
- $class = $this->formatPresenterClass($name, reset($namespaces));
- throw new \Nette\Application\InvalidPresenterException(
- "Cannot load presenter '$name', class '$class' was not found."
- );
- }
-
- return $class;
- }
-
- /**
- * Get presenter class name
- *
- * @param string
- * @return string
- * @throws \Nette\Application\InvalidPresenterException
- */
- public function getPresenterClass(& $name)
- {
- if (!is_string($name) || !preg_match("#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*$#", $name)) {
- throw new \Nette\Application\InvalidPresenterException(
- "Presenter name must be an alphanumeric string, '$name' is invalid."
- );
- }
-
- $class = $this->formatPresenterClasses($name);
- $reflection = ClassType::from($class);
- $class = $reflection->getName();
-
- if (!$reflection->implementsInterface('Nette\Application\IPresenter')) {
- throw new \Nette\Application\InvalidPresenterException(
- "Cannot load presenter '$name', class '$class' is not Nette\\Application\\IPresenter implementor."
- );
- }
- if ($reflection->isAbstract()) {
- throw new \Nette\Application\InvalidPresenterException(
- "Cannot load presenter '$name', class '$class' is abstract."
- );
- }
-
- // canonicalize presenter name
- $realName = $this->unformatPresenterClass($class);
- if ($name !== $realName) {
- throw new \Nette\Application\InvalidPresenterException(
- "Cannot load presenter '$name', case mismatch. Real name is '$realName'."
- );
- }
-
- return $class;
- }
-
-
- /**
- * Formats presenter class name from its name.
- *
- * @param string presenter name
- * @param string
- * @return string
- */
- public function formatPresenterClass($presenter, $namespace = 'App')
- {
- if ($presenter == 'Nette:Micro') {
- return 'NetteModule\MicroPresenter';
- }
-
- $class = $presenter . 'Presenter';
- $moduleNamespace = str_replace(':', ($this->useModuleSuffix ? self::MODULE_SUFFIX : '') . '\\', $class);
- return $namespace . '\\' . $moduleNamespace;
- }
-
- /**
- * Formats presenter name from class name.
- *
- * @param string presenter class
- * @return string
- */
- public function unformatPresenterClass($class)
- {
- if ($class == 'NetteModule\MicroPresenter') {
- return 'Nette:Micro';
- }
-
- $active = '';
- $namespaces = clone $this->namespaces;
- foreach ($namespaces as $namespace) {
- if (Strings::startsWith($class, $namespace)) {
- $current = $namespace . '\\';
- if (!$active || strlen($active) < strlen($current)) {
- $active = $current;
- }
- }
- }
-
- $class = Strings::startsWith('\\', $class) ? substr($class, 1) : $class;
- $moduleSuffix = $this->useModuleSuffix ? self::MODULE_SUFFIX : '';
- if (strlen($active)) {
- return str_replace($moduleSuffix . '\\', ':', substr($class, strlen($active), -9));
- } else {
- return str_replace($moduleSuffix . '\\', ':', substr($class, 0, -9));
- }
- }
-}
-
View
27 Nella/Application/UI/BackendPresenter.php
@@ -1,27 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Application\UI;
-
-/**
- * Base backend presenter
- *
- * @author Patrik Votoček
- */
-abstract class BackendPresenter extends SecuredPresenter
-{
- protected function startup()
- {
- parent::startup();
-
- $this->setLayout('backend');
- }
-}
-
View
100 Nella/Application/UI/Control.php
@@ -1,100 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Application\UI;
-
-/**
- * Application base presenter
- *
- * @author Patrik Votoček
- */
-abstract class Control extends \Nette\Application\UI\Control
-{
- /** @var \Nella\Templating\ITemplateFilesFormatter */
- private $templateFilesFormatter;
-
- /**
- * @param Presenter
- */
- protected function attached($presenter)
- {
- if ($presenter instanceof \Nette\Application\UI\Presenter) {
- if (!$presenter instanceof Presenter) {
- throw new \Nette\InvalidStateException(
- 'Nella\Application\UI\Control supports only Nella\Application\UI\Presenter'
- . " '".get_class($presenter)."' given"
- );
- }
- $this->templateFilesFormatter = $presenter->getTemplateFilesFormatter();
- }
- parent::attached($presenter);
- }
-
- /**
- * @param string
- * @return array
- */
- private function methodToView($method)
- {
- $pos = strpos($method, '::');
- if ($pos !== FALSE) {
- $method = substr($method, strpos($method, '::')+2);
- }
- return lcfirst(substr($method, 6));
- }
-
- /**
- * Formats component template files
- *
- * @param string
- * @return array
- */
- public function formatTemplateFiles($method)
- {
- if (!$this->templateFilesFormatter) {
- throw new \Nette\InvalidStateException('Control does not attached to presenter');
- }
-
- $view = $this->methodToView($method);
- return $this->templateFilesFormatter->formatComponentTemplateFiles(get_called_class(), $view);
- }
-
- /**
- * Format component template file
- *
- * @param string
- * @return string
- * @throws \Nette\InvalidStateException
- */
- protected function formatTemplateFile($method)
- {
- $files = $this->formatTemplateFiles($method);
- foreach ($files as $file) {
- if (file_exists($file)) {
- return $file;
- }
- }
-
- throw new \Nette\InvalidStateException("No template files found for method '$method'");
- }
-
- /**
- * Render component template file
- *
- * @param string
- * @return void
- */
- protected function _render($method)
- {
- $this->template->setFile($this->formatTemplateFile($method));
- $this->template->render();
- }
-}
-
View
53 Nella/Application/UI/Form.php
@@ -1,53 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Application\UI;
-
-/**
- * UI Form
- *
- * @author Patrik Votoček
- */
-class Form extends \Nella\Forms\Form
-{
- /** @var array */
- public $onComplete = array();
-
- public function __construct()
- {
- parent::__construct();
- $this->setUp();
- $this->onSuccess[] = callback($this, 'process');
- }
-
- protected function setUp()
- {
- // ...
- }
-
- /**
- * @param Form
- */
- protected function doOnComplete(self $form)
- {
- if ($form->valid) {
- callback($this, 'onComplete')->invokeArgs(func_get_args());
- }
- }
-
- /**
- * @internal
- * @param Form
- */
- public function process(self $form)
- {
- // ...
- }
-}
View
46 Nella/Application/UI/Presenter.php
@@ -1,46 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Application\UI;
-
-/**
- * Application base presenter
- *
- * @author Patrik Votoček
- */
-abstract class Presenter extends \Nette\Application\UI\Presenter
-{
- /**
- * @return \Nella\Templating\ITemplateFilesFormatter
- */
- public function getTemplateFilesFormatter()
- {
- return $this->getContext()->nella->templateFilesFormatter;
- }
-
- /**
- * @return array
- */
- public function formatLayoutTemplateFiles()
- {
- return $this->getTemplateFilesFormatter()->formatLayoutTemplateFiles(
- $this->getName(), $this->getLayout() ? $this->getLayout() : 'layout'
- );
- }
-
- /**
- * @return array
- */
- public function formatTemplateFiles()
- {
- return $this->getTemplateFilesFormatter()->formatTemplateFiles($this->getName(), $this->getView());
- }
-}
-
View
43 Nella/Application/UI/SecuredPresenter.php
@@ -1,43 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Application\UI;
-
-/**
- * Base secured presenter
- *
- * @author Patrik Votoček
- */
-abstract class SecuredPresenter extends Presenter
-{
- /** @var string */
- protected $loginLink = ':Security:Frontend:login';
-
- /**
- * Checks for requirements such as authorization
- *
- * @param \Nette\Reflection\ClassType
- * @throws \Nette\Application\ForbiddenRequestException
- */
- public function checkRequirements($element)
- {
- parent::checkRequirements($element);
- if (!$this->getUser()->isLoggedIn()) {
- $this->redirect($this->loginLink, array('backlink' => $this->storeRequest()));
- }
- }
-
- public function handleLogout()
- {
- $this->getUser()->logout(TRUE);
- $this->redirect($this->loginLink);
- }
-}
-
View
101 Nella/Config/Configurator.php
@@ -1,101 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Config;
-
-use Nella\Framework,
- Nella\SplClassLoader,
- Nella\Console\Config\Extension as ConsoleExtension,
- Nella\Doctrine\Config\Extension as DoctrineExtension,
- Nella\Doctrine\Config\MigrationsExtension as MigrationsExtension,
- Nella\Media\Config\Extension as MediaExtension,
- Nella\Event\Config\Extension as EventExtension,
- Nella\Diagnostics\Config\Extension as DiagnosticsExtension,
- Nella\Security\Config\Extension as SecurityExtension,
- Nella\Model\Config\Extension as ModelExtension;
-
-/**
- * Initial system DI container generator.
- *
- * @author Patrik Votoček
- *
- * @property-read \Nella\SplClassLoader $splClassLoader
- */
-class Configurator extends \Nette\Config\Configurator
-{
- /**
- * @return \Nella\SplClassLoader
- */
- public function getSplClassLoader()
- {
- return SplClassLoader::getInstance();
- }
-
- /**
- * @param string
- * @param string|bool
- * @return \Nette\Config\Configurator
- */
- public function addConfig($file, $section = self::NONE)
- {
- return parent::addConfig($file, $section);
- }
-
- /**
- * @param string
- * @param string|bool
- * @return \Nette\Config\Configurator
- */
- public function addConfigIfExist($file, $section = self::NONE)
- {
- if (!file_exists($file)) {
- return $this;
- }
-
- return $this->addConfig($file, $section);
- }
-
- /**
- * @return \Nette\Config\Compiler
- */
- protected function createCompiler()
- {
- $compiler = parent::createCompiler();
- if (isset($compiler->extensions['nette'])) {
- $nette = $compiler->extensions['nette'];
- $nette->defaults['container']['debugger'] = $this->parameters['debugMode'];
- }
-
- $console = new ConsoleExtension;
- $console->defaults['name'] = Framework::NAME;
- $console->defaults['version'] = Framework::VERSION;
- $doctrine = new DoctrineExtension;
- $doctrine->defaults['entityDirs'][] = __DIR__ . '/../';
- $doctrine->defaults['console'] = TRUE;
- $doctrine->defaults['repositoryClass'] = 'Nella\Model\Repository';
- $migrations = new MigrationsExtension;
- $migrations->defaultName = Framework::NAME . ' DB Migrations';
- $media = new MediaExtension;
- $media->defaults['entityManager'] = '@' . DoctrineExtension::DEFAULT_EXTENSION_NAME . '.entityManager';
-
- $compiler->addExtension(DiagnosticsExtension::DEFAULT_EXTENSION_NAME, new DiagnosticsExtension)
- ->addExtension(ConsoleExtension::DEFAULT_EXTENSION_NAME, $console)
- ->addExtension(DoctrineExtension::DEFAULT_EXTENSION_NAME, $doctrine)
- ->addExtension(MigrationsExtension::DEFAULT_EXTENSION_NAME, $migrations)
- ->addExtension(MediaExtension::DEFAULT_EXTENSION_NAME, $media)
- ->addExtension(SecurityExtension::DEFAULT_EXTENSION_NAME, new SecurityExtension)
- ->addExtension(ModelExtension::DEFAULT_EXTENSION_NAME, new ModelExtension)
- ->addExtension(EventExtension::DEFAULT_EXTENSION_NAME, new EventExtension)
- ->addExtension(Extensions\NellaExtension::DEFAULT_EXTENSION_NAME, new Extensions\NellaExtension);
-
- return $compiler;
- }
-}
-
View
97 Nella/Config/Extensions/NellaExtension.php
@@ -1,97 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Config\Extensions;
-
-use Nette\Config\Compiler,
- Nette\Config\Configurator;
-
-/**
- * Nella Framework extension
- *
- * Registering default facade services
- *
- * @author Patrik Votoček
- */
-class NellaExtension extends \Nette\Config\CompilerExtension
-{
- const DEFAULT_EXTENSION_NAME = 'nella';
-
- /** @var array */
- public $defaults = array(
- 'useModuleSuffix' => TRUE,
- 'namespaces' => array(
- 'App' => 9,
- ),
- 'template' => array(
- 'dirs' => array(
- '%appDir%' => 2,
- ),
- 'debugger' => TRUE,
- ),
- );
-
- public function loadConfiguration()
- {
- $builder = $this->getContainerBuilder();
- $config = $this->getConfig($this->defaults);
-
- if ($builder->hasDefinition('nette.presenterFactory')) {
- $def = $builder->getDefinition('nette.presenterFactory');
- $def->setClass('Nella\Application\PresenterFactory', array('@container'));
- $def->addSetup('$useModuleSuffix', array($config['useModuleSuffix']));
-
- foreach ($config['namespaces'] as $namespace => $priority) {
- if (\Nette\Utils\Validators::isNumericInt($namespace)) {
- $def->addSetup('addNamespace', array($priority));
- } else {
- $def->addSetup('addNamespace', array($namespace, $priority));
- }
- }
- }
-
- $def = $builder->addDefinition($this->prefix('templateFilesFormatter'));
- $def->setClass('Nella\Templating\TemplateFilesFormatter');
- $def->addSetup('$useModuleSuffix', array($config['useModuleSuffix']));
- foreach ($config['template']['dirs'] as $dir => $priority) {
- if (\Nette\Utils\Validators::isNumericInt($dir)) {
- $def->addSetup('addDir', array($priority));
- } else {
- $def->addSetup('addDir', array($dir, $priority));
- }
- }
- if ($config['template']['debugger']) {
- $logger = $builder->addDefinition($this->prefix('templateFilesFormatterLogger'));
- $logger->setClass('Nella\Templating\Diagnostics\FilesPanel');
- $logger->addSetup('Nette\Diagnostics\Debugger::$bar->addPanel(?)', array('@self'));
- $def->addSetup('setLogger', array($logger));
- }
-
- if ($builder->hasDefinition('nette.latte')) {
- $builder->getDefinition('nette.latte')
- ->addSetup('Nella\Latte\Macros\UIMacros::factory', array('@self'));
- }
- }
-
- /**
- * Register extension to compiler.
- *
- * @param \Nette\Config\Configurator
- * @param string
- */
- public static function register(Configurator $configurator, $name = self::DEFAULT_EXTENSION_NAME)
- {
- $class = get_called_class();
- $configurator->onCompile[] = function (Configurator $configurator, Compiler $compiler) use ($class, $name) {
- $compiler->addExtension($name, new $class);
- };
- }
-}
-
View
128 Nella/Console/Config/Extension.php
@@ -1,128 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Console\Config;
-
-use Nette\DI\Container,
- Nette\Config\Compiler,
- Nette\Config\Configurator,
- Symfony\Component\Console\Helper\HelperSet,
- Symfony\Component\Console\Helper\DialogHelper,
- Symfony\Component\Console\Application;
-
-/**
- * Console compiler extension
- *
- * @author Patrik Votoček
- */
-class Extension extends \Nette\Config\CompilerExtension
-{
- const DEFAULT_EXTENSION_NAME = 'console',
- COMMAND_TAG_NAME = 'consoleCommand',
- HELPER_TAG_NAME = 'consoleHelper';
-
- /** @var array */
- public $defaults = array(
- 'name' => \Nette\Framework::NAME,
- 'version' => \Nette\Framework::VERSION,
- 'catchExceptions' => NULL,
- 'route' => 'lazy',
- );
-
- public function loadConfiguration()
- {
- $config = $this->getConfig($this->defaults);
- $builder = $this->getContainerBuilder();
-
- if ($config['catchExceptions'] === NULL) {
- $config['catchExceptions'] = $builder->parameters['productionMode'];
- }
-
- $helperSet = $builder->addDefinition($this->prefix('helperset'))
- ->setClass('Symfony\Component\Console\Helper\HelperSet')
- ->setFactory(get_called_class().'::createHelperSet', array('@container'));
-
- $application = $builder->addDefinition($this->prefix('application'))
- ->setClass('Symfony\Component\Console\Application')
- ->setFactory(get_called_class().'::createApplication', array(
- $config['name'], $config['version'], $helperSet, $config['catchExceptions'], '@container'
- ));
-
- switch ($config['route']) {
- case 'normal':
- $builder->addDefinition($this->prefix('route'))
- ->setClass('Nella\Console\Router', array($application))
- ->setAutowired(FALSE);
- break;
- case 'lazy':
- $builder->addDefinition($this->prefix('route'))
- ->setClass('Nella\Console\LazyRouter', array('@container'))
- ->setAutowired(FALSE);
- break;
- }
-
- if ($builder->hasDefinition('router') && $builder->hasDefinition($this->prefix('route'))) {
- $builder->getDefinition('router')
- ->addSetup('offsetSet', array(NULL, $builder->getDefinition($this->prefix('route'))));
- }
- }
-
- /**
- * @param \Nette\DI\Container
- * @return \Symfony\Component\Console\Helper\HelperSet
- */
- public static function createHelperSet(Container $container)
- {
- $helperSet = new HelperSet;
- $helperSet->set(new DialogHelper, 'dialog');
-
- foreach ($container->findByTag(static::HELPER_TAG_NAME) as $name => $value) {
- $helperSet->set($container->getService($name), $value);
- }
-
- return $helperSet;
- }
-
- /**
- * @param string
- * @param string
- * @param \Symfony\Component\Console\Helper\HelperSet
- * @param bool
- * @param \Nette\DI\Container
- * @return \Symfony\Component\Console\Application
- */
- public static function createApplication($name, $version, HelperSet $helperSet, $exceptions = FALSE, Container $container)
- {
- $application = new Application($name, $version);
- $application->setCatchExceptions($exceptions);
- $application->setHelperSet($helperSet);
-
- foreach ($container->findByTag(static::COMMAND_TAG_NAME) as $name => $value) {
- $application->add($container->getService($name));
- }
-
- return $application;
- }
-
- /**
- * Register extension to compiler.
- *
- * @param \Nette\Config\Configurator
- * @param string
- */
- public static function register(Configurator $configurator, $name = self::DEFAULT_EXTENSION_NAME)
- {
- $class = get_called_class();
- $configurator->onCompile[] = function (Configurator $configurator, Compiler $compiler) use ($class, $name) {
- $compiler->addExtension($name, new $class);
- };
- }
-}
-
View
51 Nella/Console/LazyRouter.php
@@ -1,51 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Console;
-
-use Nette\DI\Container;
-
-/**
- * Lazy application inicialization router
- *
- * For use Symfony Console
- *
- * @author Patrik Votoček
- */
-class LazyRouter extends Router
-{
- /**
- * @param \Nette\DI\Container
- */
- public function __construct(Container $container, $serviceName = NULL)
- {
- if (!$serviceName) {
- $class = 'Symfony\Component\Console\Application';
- $lower = ltrim(strtolower($class), '\\');
- if (!isset($container->classes[$lower])) {
- throw new \Nette\DI\MissingServiceException("Service of type $class not found.");
- } elseif ($container->classes[$lower] === FALSE) {
- throw new \Nette\DI\MissingServiceException("Multiple services of type $class found.");
- } else {
- $serviceName = $container->classes[$lower];
- }
- }
-
- if (!$container->hasService($serviceName)) {
- throw new \Nette\DI\MissingServiceException("Service '$serviceName' not found.");
- }
-
- $this->callback = callback(function () use ($container, $serviceName) {
- $console = $container->getService($serviceName);
- $console->run();
- });
- }
-}
-
View
67 Nella/Console/Router.php
@@ -1,67 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Console;
-
-use Nette\Application\Request,
- Nette\Http\IRequest,
- Nette\Http\Url,
- Symfony\Component\Console\Application;
-
-/**
- * Console router
- *
- * For use Symfony Console
- *
- * @author Patrik Votoček
- */
-class Router extends \Nette\Object implements \Nette\Application\IRouter
-{
- /** @var \Nette\Callback */
- protected $callback;
-
- /**
- * @param \Symfony\Component\Console\Application
- */
- public function __construct(Application $console)
- {
- $this->callback = callback(function () use ($console) {
- $console->run();
- });
- }
-
- /**
- * Maps command line arguments to a Request object
- *
- * @param \Nette\Http\IRequest
- * @return \Nette\Application\Request|NULL
- */
- public function match(IRequest $httpRequest)
- {
- if (PHP_SAPI !== 'cli') {
- return NULL;
- }
-
- return new Request('Nette:Micro', 'CLI', array('callback' => $this->callback));
- }
-
- /**
- * This router is only unidirectional
- *
- * @param \Nette\Application\Request
- * @param \Nette\Http\Url
- * @return NULL
- */
- public function constructUrl(Request $appRequest, Url $refUrl)
- {
- return NULL;
- }
-}
-
View
35 Nella/Console/composer.json
@@ -1,35 +0,0 @@
-{
- "name": "nella/console",
- "type": "nette-addon",
- "description": "Symfony 2 Console addon for Nette Framework",
- "keywords": ["console", "nette", "symfony", "nella", "addon"],
- "homepage": "http://nellafw.org",
- "license": ["BSD-3-Clause", "GPL-2.0+"],
- "authors": [
- {
- "name": "Patrik Votoček",
- "email": "patrik@votocek.cz",
- "homepage": "http://patrik.votocek.cz",
- "role": "Developer"
- },
- {
- "name": "Nella Project",
- "homepage": "http://nella-project.org"
- }
- ],
- "support":{
- "issues":"https://github.com/nella/framework/issues",
- "source":"https://github.com/nella/framework/tree/master/Nella/Console"
- },
- "autoload": {
- "psr-0": {
- "Nella\\Console": "./"
- }
- },
- "target-dir": "Nella/Console",
- "require": {
- "php": ">=5.3.2",
- "nette/nette": "2.0.*",
- "symfony/console": "2.*"
- }
-}
View
56 Nella/Console/license.md
@@ -1,56 +0,0 @@
-Licenses
-========
-
-Good news! You may use Nella Framework under the terms of either
-the New BSD License or the GNU General Public License (GPL) version 2 or 3.
-
-The BSD License is recommended for most projects. It is easy to understand and it
-places almost no restrictions on what you can do with the framework. If the GPL
-fits better to your project, you can use the framework under this license.
-
-You don't have to notify anyone which license you are using. You can freely
-use Nella Framework in commercial projects as long as the copyright header
-remains intact.
-
-
-New BSD License
----------------
-
-Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of "Nella Framework" nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-This software is provided by the copyright holders and contributors "as is" and
-any express or implied warranties, including, but not limited to, the implied
-warranties of merchantability and fitness for a particular purpose are
-disclaimed. In no event shall the copyright owner or contributors be liable for
-any direct, indirect, incidental, special, exemplary, or consequential damages
-(including, but not limited to, procurement of substitute goods or services;
-loss of use, data, or profits; or business interruption) however caused and on
-any theory of liability, whether in contract, strict liability, or tort
-(including negligence or otherwise) arising in any way out of the use of this
-software, even if advised of the possibility of such damage.
-
-
-
-GNU General Public License
---------------------------
-
-GPL licenses are very very long, so instead of including them here we offer
-you URLs with full text:
-
-- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
-- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)
View
25 Nella/Console/readme.md
@@ -1,25 +0,0 @@
-[Nette Framework](http://nette.org) - Console Extension
-=======================================================
-
-Library for easy integration [Symfony 2 Console](http://symfony.com/doc/2.0/components/console.html)
-to _Nette Framework_.
-
-Requirements
-------------
-
-- PHP 5.3.2 or later
-- Nette Framework 2.0.0 or later
-- Symfony Console 2.0.0 or later
-
-
-Installation
-------------
-
-Add `"nella/console": "*"` to *composer.json and run `composer update`.
-Edit your *bootstrap.php* and add `Nella\Console\Config\Extension::register($configurator);`
-before `$configurator->createContainer()`.
-
-
------
-
-For more info please follow [documentaion](http://doc.nellafw.org/en/console).
View
69 Nella/Diagnostics/AccessLogger.php
@@ -1,69 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics;
-
-use Nette\Http\Response,
- Nette\Http\RequestFactory;
-
-/**
- * Remote access logger
- *
- * @author Patrik Votoček
- */
-class AccessLogger extends \Nette\Object
-{
- /** @var string */
- private $storage;
-
- /**
- * @param ILoggerStorage
- */
- public function __construct(ILoggerStorage $storage)
- {
- $this->storage = $storage;
- }
-
- /**
- * @param \Nette\Http\Response
- */
- public function log(Response $res)
- {
- $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : NULL;
- if (isset($_SERVER['HTTP_X_REAL_IP'])) {
- $ip = $_SERVER['HTTP_X_REAL_IP'];
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
-
- $f = new RequestFactory;
- $req = $f->setEncoding('UTF-8')->createHttpRequest();
- $data = array(
- 'datetime' => date('c'),
- 'ua' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL,
- 'ip' => $ip,
- 'host' => isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : NULL,
- 'method' => isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : NULL,
- 'url' => (isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://')
- . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (
- isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''
- ))
- . $_SERVER['REQUEST_URI'],
- 'code' => function_exists('http_response_code') ? http_response_code() : $res->getCode(),
- 'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL,
- 'time' => isset($_SERVER['REQUEST_TIME_FLOAT']) ? (microtime(TRUE)-$_SERVER['REQUEST_TIME_FLOAT'])*1000 : 0,
- 'memory' => function_exists('memory_get_peak_usage')
- ? number_format(memory_get_peak_usage() / 1000000, 2, '.', ' ') : 0,
- );
-
- $this->storage->save($data);
- }
-}
-
View
136 Nella/Diagnostics/CallbackPanel.php
@@ -1,136 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics;
-
-use Nette\DI\Container,
- Nette\Diagnostics\Debugger;
-
-/**
- * Callback panel for nette debug bar
- *
- * @author Patrik Votoček
- */
-final class CallbackPanel extends \Nette\Object implements \Nette\Diagnostics\IBarPanel
-{
- const VERSION = "1.9",
- XHR_HEADER = "X-Nella-Callback-Panel";
-
- /** @var \Nette\DI\Container */
- private $container;
- /** @var array[]|array */
- private $callbacks = array();
- /** @var bool */
- private static $registered = FALSE;
-
- /**
- * @param \Nette\DI\Container
- * @param array[]|array
- */
- public function __construct(Container $container, array $callbacks = array())
- {
- if (static::$registered) {
- throw new \Nette\InvalidStateException("Callback panel is already registered");
- }
-
- $this->container = $container;
-
- $this->initDefaultsCallbacks();
- $this->callbacks = array_merge($this->callbacks, $callbacks);
-
- $this->run();
-
- static::$registered = TRUE;
- }
-
- protected function initDefaultsCallbacks()
- {
- if ($this->container->hasService('cacheStorage')) {
- $cacheStorage = $this->container->cacheStorage;
- $this->callbacks['cache'] = array(
- 'name' => 'Clean cache',
- 'callback' => function () use ($cacheStorage) {
- $cacheStorage->clean(array(\Nette\Caching\Cache::ALL => TRUE));
- }
- );
- }
-
- if ($this->container->hasService('session')) {
- $session = $this->container->session;
- $this->callbacks['session'] = array(
- 'name' => 'Clean session',
- 'callback' => function () use ($session) {
- if (!$session->isStarted()) {
- $session->clean();
- }
- }
- );
- }
- }
-
- /**
- * @param string
- */
- protected function invoke($id)
- {
- if (isset($this->callbacks[$id]) && isset($this->callbacks[$id]['callback'])) {
- callback($this->callbacks[$id]['callback'])->invoke();
- die(json_encode(array('status' => "OK")));
- }
- }
-
- protected function run()
- {
- $httpRequest = $this->container->httpRequest;
- if ($httpRequest->getHeader(static::XHR_HEADER)) {
- $data = (array) json_decode(file_get_contents('php://input'), TRUE);
- foreach ($data as $key => $value) {
- if (isset($this->callbacks[$key]) && isset($this->callbacks[$key]['callback']) && $value === TRUE) {
- $this->invoke($key);
- }
- }
- }
- }
-
- /**
- * Renders HTML code for custom tab
- *
- * @return string
- */
- public function getTab()
- {
- return '<span title="Callbacks"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABh0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzT7MfTgAAAY9JREFUOI2lkj1rVUEQhp93d49XjYiCUUFtgiBpFLyWFhKxEAsbGy0ErQQrG/EHCII/QMTGSrQ3hY1FijS5lQp2guBHCiFRSaLnnN0di3Pu9Rpy0IsDCwsz8+w776zMjP+J0JV48nrufMwrc2AUbt/CleMv5ycClHH1UZWWD4MRva4CByYDpHqjSgKEETcmHiHmItW5STuF/FfAg8HZvghHDDMpkKzYXScPgFcx9XBw4WImApITn26cejEAkJlxf7F/MOYfy8K3OJGtJlscKsCpAJqNGRknd+jO6TefA8B6WU1lMrBZ6fiE1R8Zs7hzVJHSjvJnNMb/hMSmht93IYIP5Qhw99zSx1vP+5eSxZmhzpzttmHTbcOKk+413Sav4v3J6ZsfRh5sFdefnnhr2Gz75rvHl18d3aquc43f1/BjaN9V1wn4tq6eta4LtnUCQuPWHmAv0AOKDNXstZln2/f3zgCUX8oFJx1zDagGSmA1mn2VmREk36pxw5NgzVqDhOTFLhjtOgMxmqVOE/81fgFilqPyaom5BAAAAABJRU5ErkJggg=="></span>';
- }
-
- /**
- * Renders HTML code for custom panel
- *
- * @return string
- */
- public function getPanel()
- {
- $callbacks = $this->callbacks;
- $absoluteUrl = $this->container->httpRequest->url->absoluteUrl;
- ob_start();
- require_once __DIR__ . "/templates/CallbackPanel.panel.phtml";
- return ob_get_clean();
- }
-
- /**
- * @param \Nette\DI\Container
- * @param array[]|array
- */
- public static function register(\Nette\DI\Container $container, array $callbacks = array())
- {
- if (Debugger::$bar) {
- Debugger::$bar->addPanel(new static($container, $callbacks));
- }
- }
-}
View
123 Nella/Diagnostics/Config/Extension.php
@@ -1,123 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics\Config;
-
-use Nette\Config\Configurator,
- Nette\Config\Compiler,
- Nette\Application\Application,
- Nette\Http\Response,
- Nella\Diagnostics\AccessLogger,
- Nette\Utils\PhpGenerator\ClassType;
-
-/**
- * Diagnostics services
- *
- * @author Patrik Votoček
- */
-class Extension extends \Nette\Config\CompilerExtension
-{
- const DEFAULT_EXTENSION_NAME = 'diagnostics';
-
- /** @var array */
- public $defaults = array(
- 'loggerUrl' => 'http://localhost:50921/api/log.json',
- 'accessLoggerUrl' => 'http://localhost:50921/api/access.json',
- 'storage' => 'curl',
- 'callbackPanel' => TRUE,
- );
-
- /**
- * Processes configuration data
- *
- * @throws \Nette\InvalidStateException
- */
- public function loadConfiguration()
- {
- $config = $this->getConfig($this->defaults);
- $builder = $this->getContainerBuilder();
-
- if (!isset($config['appId']) || !isset($config['appSecret'])) {
- return;
- }
-
- switch($config['storage']) {
- case 'curl':
- $storageClass = 'Nella\Diagnostics\LoggerStorages\Curl';
- break;
- default:
- $storageClass = 'Nella\Diagnostics\LoggerStorages\Http';
- break;
- }
-
-
- $builder->addDefinition($this->prefix('accessStorage'))
- ->setClass($storageClass, array(
- $config['appId'], $config['appSecret'], $config['accessLoggerUrl']
- ));
- $builder->addDefinition($this->prefix('accessLogger'))
- ->setClass('Nella\Diagnostics\AccessLogger', array($this->prefix('@accessStorage')));
- }
-
- /**
- * @param \Nette\Application\Application
- * @param \Nette\Http\Response
- * @param \Nella\Diagnostics\AccessLogger
- */
- public static function setCallback(Application $application, Response $res, AccessLogger $logger)
- {
- $application->onShutdown[] = function (Application $application) use ($logger, $res) {
- $logger->log($res);
- };
- }
-
- /**
- * @param \Nette\Utils\PhpGenerator\ClassType
- */
- public function afterCompile(ClassType $class)
- {
- $config = $this->getConfig($this->defaults);
- $initialize = $class->methods['initialize'];
-
- if ($config['callbackPanel']) {
- $initialize->addBody('Nella\Diagnostics\CallbackPanel::register($this);');
- }
-
- if (!isset($config['appId']) || !isset($config['appSecret'])) {
- return;
- }
-
- $password = isset($config['password']) ? $config['password'] : FALSE;
-
- $initialize->addBody('\Nella\Diagnostics\Logger::register(?, ?, ?, ?);', array(
- $config['appId'], $config['appSecret'], $password, $config['loggerUrl']
- ));
-
- $initialize->addBody(
- get_called_class().'::setCallback($this->getService(?), $this->getService(?), $this->getService(?));',
- array('application', 'httpResponse', $this->prefix('accessLogger'))
- );
- }
-
- /**
- * Register extension to compiler.
- *
- * @param \Nette\Config\Configurator
- * @param string
- */
- public static function register(Configurator $configurator, $name = self::DEFAULT_EXTENSION_NAME)
- {
- $class = get_called_class();
- $configurator->onCompile[] = function (Configurator $configurator, Compiler $compiler) use ($class, $name) {
- $compiler->addExtension($name, new $class);
- };
- }
-}
-
View
25 Nella/Diagnostics/ILoggerStorage.php
@@ -1,25 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics;
-
-/**
- * Logger storage interface
- *
- * @author Patrik Votoček
- */
-interface ILoggerStorage
-{
- /**
- * @param array
- */
- public function save(array $data);
-}
-
View
119 Nella/Diagnostics/Logger.php
@@ -1,119 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics;
-
-use DateTime,
- Nette\Utils\Strings,
- Nette\Diagnostics\Debugger;
-
-/**
- * Diagnostics logger
- *
- * @author Patrik Votoček
- */
-class Logger extends \Nette\Diagnostics\Logger
-{
- /** @var ILoggerStorage */
- private $storage;
-
- /**
- * @param ILoggerStorage
- */
- public function __construct(ILoggerStorage $storage)
- {
- $this->storage = $storage;
- }
-
- /**
- * @param string|array
- * @param string
- */
- public function log($message, $priority = self::INFO)
- {
- $data = array('type' => $priority, 'ip' => $_SERVER['SERVER_ADDR']);
-
- if (is_array($message)) {
- $data['datetime'] = $this->datetimeToIso($message[0]);
- if (isset($message[1])) {
- $data['message'] = $message[1];
- }
- if (isset($message[2])) {
- $data['url'] = substr($message[2], 4);
- }
- if (isset($message[3])) {
- $file = substr($message[3], 5);
- $data['path'] = Debugger::$logDirectory . '/' . $file;
- }
- $data['line'] = implode(' ', $message);
- } else {
- $data['line'] = $message;
- }
-
- $res = parent::log($data['line'], $priority);
-
- $this->storage->save($data);
-
- return $res;
- }
-
- /**
- * @param string
- * @return string
- */
- private function datetimeToIso($date)
- {
- $date = DateTime::createFromFormat('[Y-m-d H:i:s]', $date);
- if ($date instanceof DateTime) {
- return $date->format('c');
- }
- return date('c');
- }
-
- /**
- * @param string
- * @param string
- * @param string|bool password for log file downloader
- * @param string
- */
- public static function register($appId, $appSecret, $password = FALSE, $url = 'http://localhost:50921/api/log.json')
- {
- $dir = Debugger::$logger->directory;
- if (isset($_GET['__getfile'])) {
- @header('X-Frame-Options: ');
- $data = json_decode(base64_decode($_GET['__getfile']), TRUE);
- if ($password === FALSE) {
- die('No password set');
- } elseif (!array_key_exists('password', $data) || !array_key_exists('path', $data)) {
- die('Missing data');
- } elseif ($data['appid'] != $appId || $data['appsecret'] != $appSecret || $data['password'] != $password) {
- die('Invalid credentials');
- } elseif (!file_exists($data['path'])) {
- die('Invalid file');
- } elseif (strncmp(realpath($data['path']), realpath($dir), strlen(realpath($dir))) !== 0) {
- die('Path is not valid log dir');
- }
-
- echo file_get_contents($data['path']);
-
- exit;
- }
-
- $storage = new LoggerStorages\Http($appId, $appSecret, $url);
- $logger = new static($storage);
- $logger->directory = & Debugger::$logger->directory;
- $logger->email = & Debugger::$logger->email;
- $logger->mailer = & Debugger::$logger->mailer;
- static::$emailSnooze = & Logger::$emailSnooze;
-
- Debugger::$logger = $logger;
- }
-}
-
View
65 Nella/Diagnostics/LoggerStorages/Curl.php
@@ -1,65 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics\LoggerStorages;
-
-/**
- * Curl http logger storage
- *
- * @author Patrik Votoček
- */
-class Curl extends \Nette\Object implements \Nella\Diagnostics\ILoggerStorage
-{
- /** @var string */
- private $url;
- /** @var string */
- private $appId;
- /** @var string */
- private $appSecret;
-
- /**
- * @param string
- * @param string
- * @param string
- */
- public function __construct($appId, $appSecret, $url)
- {
- if (!extension_loaded('curl')) {
- throw new \Nette\InvalidStateException('Missing cURL extension');
- }
-
- $this->url = $url;
- $this->appId = $appId;
- $this->appSecret = $appSecret;
- }
-
- /**
- * @param array
- */
- public function save(array $data)
- {
- $headers = array(
- 'appId' => "X-LoggerAuth-AppId: {$this->appId}",
- 'appSecret' => "X-LoggerAuth-AppSecret: {$this->appSecret}",
- );
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, $this->url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_NOBODY, TRUE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_TIMEOUT_MS, 500);
-
- curl_exec($ch);
- }
-}
-
View
63 Nella/Diagnostics/LoggerStorages/Http.php
@@ -1,63 +0,0 @@
-<?php
-/**
- * This file is part of the Nella Framework (http://nellafw.org).
- *
- * Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
- *
- * For the full copyright and license information,
- * please view the file LICENSE.txt that was distributed with this source code.
- */
-
-namespace Nella\Diagnostics\LoggerStorages;
-
-/**
- * Http logger storage
- *
- * @author Patrik Votoček
- */
-class Http extends \Nette\Object implements \Nella\Diagnostics\ILoggerStorage
-{
- /** @var string */
- private $url;
- /** @var string */
- private $appId;
- /** @var string */
- private $appSecret;
-
- /**
- * @param string
- * @param string
- * @param string
- */
- public function __construct($appId, $appSecret, $url)
- {
- if (function_exists('ini_get') && !ini_get('allow_url_fopen')) {
- throw new \Nette\InvalidStateException('allow_url_fopen is not allowed');
- }
-
- $this->url = $url;
- $this->appId = $appId;
- $this->appSecret = $appSecret;
- }
-
- /**
- * @param array
- */
- public function save(array $data)
- {
- $headers = array(
- 'appId' => "X-LoggerAuth-AppId: {$this->appId}",
- 'appSecret' => "X-LoggerAuth-AppSecret: {$this->appSecret}",
- );
- $req = @stream_context_create(array(
- 'http' => array(
- 'header' => "Content-Type: application/x-www-form-urlencoded\r\n".implode("\r\n", $headers),
- 'method' => 'POST',
- 'content' => http_build_query($data),
- )
- ));
- $fp = @fopen($this->url, 'r', FALSE, $req);
- @fclose($fp);
- }
-}
-
View
34 Nella/Diagnostics/composer.json
@@ -1,34 +0,0 @@
-{
- "name": "nella/diagnostics",
- "type": "nette-addon",
- "description": "Remote application log and access log for Nette Framework",
- "keywords": ["debug", "nette", "diagnostics", "nella", "addon", "log", "remote"],
- "homepage": "http://nellafw.org",
- "license": ["BSD-3-Clause", "GPL-2.0+"],
- "authors": [
- {
- "name": "Patrik Votoček",
- "email": "patrik@votocek.cz",
- "homepage": "http://patrik.votocek.cz",
- "role": "Developer"
- },
- {
- "name": "Nella Project",
- "homepage": "http://nella-project.org"
- }
- ],
- "support":{
- "issues":"https://github.com/nella/framework/issues",
- "source":"https://github.com/nella/framework/tree/master/Nella/Diagnostics"
- },
- "autoload": {
- "psr-0": {
- "Nella\\Diagnostics": "./"
- }
- },
- "target-dir": "Nella/Diagnostics",
- "require": {
- "php": ">=5.3.2",
- "nette/nette": "2.0.*"
- }
-}
View
56 Nella/Diagnostics/license.md
@@ -1,56 +0,0 @@
-Licenses
-========
-
-Good news! You may use Nella Framework under the terms of either
-the New BSD License or the GNU General Public License (GPL) version 2 or 3.
-
-The BSD License is recommended for most projects. It is easy to understand and it
-places almost no restrictions on what you can do with the framework. If the GPL
-fits better to your project, you can use the framework under this license.
-
-You don't have to notify anyone which license you are using. You can freely
-use Nella Framework in commercial projects as long as the copyright header
-remains intact.
-
-
-New BSD License
----------------
-
-Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.