Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleanup & Coding Standard

  • Loading branch information...
commit cd2813729df5dc98f964f95f0c8e7bcf19edff36 1 parent 0216479
@Vrtak-CZ Vrtak-CZ authored
Showing with 952 additions and 1,433 deletions.
  1. +24 −31 app/Api/presenters/ComposerPresenter.php
  2. +32 −36 app/Api/presenters/GithubPresenter.php
  3. +3 −7 app/Manage/forms/AddAddonFormFactory.php
  4. +18 −29 app/Manage/forms/AddVersionForm.php
  5. +24 −28 app/Manage/forms/AddonForm.php
  6. +13 −21 app/Manage/forms/AddonFormFactory.php
  7. +17 −23 app/Manage/forms/EditAddonFormFactory.php
  8. +20 −31 app/Manage/forms/ImportAddonFormFactory.php
  9. +0 −1  app/Manage/forms/ReportFormFactory.php
  10. +20 −28 app/Manage/forms/VersionFormFactory.php
  11. +28 −48 app/Manage/presenters/AddonPresenter.php
  12. +28 −38 app/Manage/presenters/AdminPresenter.php
  13. +3 −11 app/Manage/presenters/BasePresenter.php
  14. +22 −28 app/Manage/presenters/VersionsPresenter.php
  15. +0 −1  app/bootstrap.php
  16. +5 −15 app/components/CategoriesControl.php
  17. +5 −17 app/components/SubMenuControl.php
  18. +2 −11 app/forms/BaseForm.php
  19. +7 −14 app/forms/EditPageFormFactory.php
  20. +3 −18 app/forms/FilterForm.php
  21. +5 −11 app/forms/Form.php
  22. +7 −15 app/forms/ReportFormFactory.php
  23. +0 −3  app/forms/SignInForm.php
  24. +13 −30 app/misc/HttpStreamRequest.php
  25. +1 −8 app/misc/HttpStreamRequestFactory.php
  26. +4 −3 app/misc/Portal.php
  27. +16 −27 app/model/Authenticator.php
  28. +4 −15 app/model/Authorizator.php
  29. +4 −8 app/model/DevelopmentUtils.php
  30. +7 −23 app/model/Entities/Addon.php
  31. +4 −22 app/model/Entities/AddonVersion.php
  32. +3 −12 app/model/Entities/Tag.php
  33. +61 −64 app/model/Facade/AddonManageFacade.php
  34. +3 −13 app/model/IAddonImporter.php
  35. +18 −31 app/model/Importers/GitHub/Repository.php
  36. +7 −7 app/model/Importers/GitHub/RepositoryFactory.php
  37. +22 −45 app/model/Importers/GitHubImporter.php
  38. +0 −11 app/model/Importers/GitHubImporterFactory.php
  39. +14 −20 app/model/Importers/RepositoryImporterManager.php
  40. +0 −7 app/model/PackageRouteHelper.php
  41. +5 −17 app/model/PackageRouteHelperCached.php
  42. +14 −16 app/model/RouterFactory.php
  43. +10 −20 app/model/Table.php
  44. +7 −12 app/model/Tables/AddonDownloads.php
  45. +5 −12 app/model/Tables/AddonReports.php
  46. +37 −40 app/model/Tables/AddonVersions.php
  47. +4 −14 app/model/Tables/AddonVotes.php
  48. +47 −90 app/model/Tables/Addons.php
  49. +10 −16 app/model/Tables/Pages.php
  50. +11 −28 app/model/Tables/Tags.php
  51. +10 −20 app/model/Tables/Users.php
  52. +4 −12 app/model/Tables/VersionDependencies.php
  53. +7 −14 app/model/Utils/Composer.php
  54. +22 −13 app/model/Utils/FormValidators.php
  55. +4 −9 app/model/Utils/Licenses.php
  56. +7 −17 app/model/Utils/Validators.php
  57. +15 −23 app/model/Utils/VersionParser.php
  58. +15 −10 app/model/VendorRouteHelper.php
  59. +4 −11 app/presenters/BaseListPresenter.php
  60. +42 −41 app/presenters/BasePresenter.php
  61. +39 −52 app/presenters/DetailPresenter.php
  62. +15 −9 app/presenters/ErrorPresenter.php
  63. +9 −10 app/presenters/HomepagePresenter.php
  64. +0 −9 app/presenters/ListPresenter.php
  65. +22 −17 app/presenters/PagePresenter.php
  66. +33 −24 app/presenters/SignPresenter.php
  67. +10 −9 app/presenters/SpecialPresenter.php
  68. +2 −7 app/view/HelperLoader.php
  69. +2 −1  app/view/ITextProcessor.php
  70. +7 −18 app/view/TextPreprocessor.php
  71. +8 −2 app/view/TextProcessors/MarkdownProcessor.php
  72. +2 −1  app/view/TextProcessors/Texy/AddonsConverter.php
  73. +42 −26 app/view/TextProcessors/Texy/Convertor.php
  74. +6 −1 app/view/TextProcessors/Texy/Link.php
  75. +8 −1 app/view/TextProcessors/TexyProcessor.php
View
55 app/Api/presenters/ComposerPresenter.php
@@ -2,42 +2,35 @@
namespace NetteAddons\Api;
-use NetteAddons\Model\Addon,
- NetteAddons\Model\AddonVersion,
- NetteAddons\Model\Addons,
- NetteAddons\Model\AddonDownloads,
- NetteAddons\Model\AddonVersions,
- NetteAddons\Model\Utils\Composer;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Addons;
+use NetteAddons\Model\AddonVersion;
+use NetteAddons\Model\AddonVersions;
+use NetteAddons\Model\AddonDownloads;
+use NetteAddons\Model\Utils\Composer;
-
-/**
- * @author Jan Marek
- * @author Jan Tvrdík
- * @author Jan Dolecek <juzna.cz@gmail.com>
- * @author Patrik Votoček
- */
final class ComposerPresenter extends \NetteAddons\BasePresenter
{
- /**
- * @var \NetteAddons\Model\Addons
- * @inject
- */
+ /** @var \NetteAddons\Model\Addons */
public $addons;
- /**
- * @var \NetteAddons\Model\AddonDownloads
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonDownloads */
public $addonDownloads;
- /**
- * @var \NetteAddons\Model\AddonVersions
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonVersions */
public $addonVersions;
+ public function __construct(Addons $addons, AddonDownloads $addonDownloads, AddonVersions $addonVersions)
+ {
+ parent::__construct();
+
+ $this->addons = $addons;
+ $this->addonDownloads = $addonDownloads;
+ $this->addonVersions = $addonVersions;
+ }
+
public function renderPackages()
{
@@ -46,29 +39,29 @@ public function renderPackages()
$packagesJson = Composer::createPackagesJson($addons);
$packagesJson->notify = str_replace(
- 'placeholder', '%package%',
+ 'placeholder',
+ '%package%',
$this->link('//downloadNotify', array('package' => 'placeholder'))
);
$this->sendJson($packagesJson);
}
-
/**
* Called when composer installs a package to increase counters.
*
* @link http://getcomposer.org/doc/05-repositories.md#notify
+ *
* @param string
*/
public function actionDownloadNotify($package)
{
- $post = $this->getRequest()->post;
+ $post = $this->getRequest()->getPost();
if (!isset($post['version'])) {
$this->error('Invalid request.');
}
$version = (string) $post['version'];
-
if (!$addonRow = $this->addons->findOneByComposerFullName($package)) {
$this->error('Package not found.');
}
@@ -81,7 +74,7 @@ public function actionDownloadNotify($package)
));
if (!$versionRow) {
- $this->error("Version of package not found.");
+ $this->error('Version of package not found.');
}
$version = AddonVersion::fromActiveRow($versionRow);
@@ -93,6 +86,6 @@ public function actionDownloadNotify($package)
$this->getHttpRequest()->getHeader('user-agent')
);
- $this->sendJson(array('status' => "success"));
+ $this->sendJson(array('status' => 'success'));
}
}
View
68 app/Api/presenters/GithubPresenter.php
@@ -2,56 +2,52 @@
namespace NetteAddons\Api;
-use Nette\Utils\Json,
- NetteAddons\Model\Addon,
- NetteAddons\Model\Addons,
- NetteAddons\Model\Users,
- NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\GitHubImporter,
- NetteAddons\Model\Importers\RepositoryImporterManager;
-
-
-
-/**
- * GitHub API
- *
- * @author Jan Dolecek <juzna.cz@gmail.com>
- * @author Patrik Votoček
- */
+use Nette\Utils\Json;
+use Nette\Http\IResponse;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Addons;
+use NetteAddons\Model\Users;
+use NetteAddons\Model\Facade\AddonManageFacade;
+use NetteAddons\Model\Importers\GitHubImporter;
+use NetteAddons\Model\Importers\RepositoryImporterManager;
+
+
final class GithubPresenter extends \NetteAddons\BasePresenter
{
- /**
- * @var \NetteAddons\Model\Facade\AddonManageFacade
- * @inject
- */
+ /** @var \NetteAddons\Model\Facade\AddonManageFacade */
public $manager;
- /**
- * @var \NetteAddons\Model\Importers\RepositoryImporterManager
- * @inject
- */
+ /** @var \NetteAddons\Model\Importers\RepositoryImporterManager */
public $importerManager;
- /**
- * @var \NetteAddons\Model\Users
- * @inject
- */
+ /** @var \NetteAddons\Model\Users */
public $users;
- /**
- * @var \NetteAddons\Model\Addons
- * @inject
- */
+ /** @var \NetteAddons\Model\Addons */
public $addons;
+ public function __construct(
+ AddonManageFacade $manager,
+ RepositoryImporterManager $importerManager,
+ Users $users,
+ Addons $addons
+ ) {
+ parent::__construct();
+
+ $this->manager = $manager;
+ $this->importerManager = $importerManager;
+ $this->users = $users;
+ $this->addons = $addons;
+ }
+
/**
* Post receive hook, updates addon info
*/
public function actionPostReceive()
{
- $post = $this->getRequest()->post;
+ $post = $this->getRequest()->getPost();
if (!isset($post['payload'], $post['username'], $post['apiToken'])) {
$this->error('Invalid request.');
}
@@ -61,7 +57,7 @@ public function actionPostReceive()
try {
$payload = Json::decode($post['payload']);
if (!isset($payload->repository->url)) {
- $response->setCode(400); // Bad Request
+ $response->setCode(IResponse::S400_BAD_REQUEST);
$this->sendJson(array(
'status' => 'error',
'message' => 'Missing or invalid payload',
@@ -76,7 +72,7 @@ public function actionPostReceive()
$user = $this->users->findOneByName($username);
if (!$user || $user->apiToken !== $token) {
- $response->setCode(403); // Forbidden
+ $response->setCode(IResponse::S403_FORBIDDEN);
$this->sendJson(array(
'status' => 'error',
'message' => 'Invalid credentials'
@@ -84,7 +80,7 @@ public function actionPostReceive()
}
if (!GitHubImporter::isValid($payload->repository->url)) {
- $response->setCode(400); // Bad Request
+ $response->setCode(IResponse::S400_BAD_REQUEST);
$this->sendJson(array(
'status' => 'error',
'message' => 'Could not parse payload repository URL'
View
10 app/Manage/forms/AddAddonFormFactory.php
@@ -2,21 +2,18 @@
namespace NetteAddons\Manage\Forms;
-use Nette\Utils\Strings,
- Nette\Security\IIdentity;
+use Nette\Utils\Strings;
+use Nette\Security\IIdentity;
/**
* Form for new addon registration. When importing from GitHub, most of the fields should be prefilled.
* The license input won't be visible when composer.json is available.
- *
- * @author Patrik Votoček
*/
class AddAddonFormFactory extends AddonFormFactory
{
-
/**
- * @param IIdentity
+ * @param \Nette\Security\IIdentity
* @param string
* @return AddonForm
*/
@@ -38,5 +35,4 @@ public function create(IIdentity $user, $token)
return $form;
}
-
}
View
47 app/Manage/forms/AddVersionForm.php
@@ -2,20 +2,15 @@
namespace NetteAddons\Manage\Forms;
-use Nette\Security\IIdentity,
- NetteAddons\Model\Addon,
- NetteAddons\Model\AddonVersions,
- NetteAddons\Model\Utils\VersionParser,
- NetteAddons\Model\Utils\Licenses,
- NetteAddons\Model\Utils\FormValidators,
- NetteAddons\Model\Facade\AddonManageFacade;
-
-
-/**
- * Form for addon version creation.
- *
- * @author Patrik Votoček
- */
+use Nette\Security\IIdentity;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\AddonVersions;
+use NetteAddons\Model\Utils\VersionParser;
+use NetteAddons\Model\Utils\Licenses;
+use NetteAddons\Model\Utils\FormValidators;
+use NetteAddons\Model\Facade\AddonManageFacade;
+
+
class AddVersionFormFactory extends \Nette\Object
{
/** @var \NetteAddons\Model\Facade\AddonManageFacade */
@@ -37,16 +32,13 @@ class AddVersionFormFactory extends \Nette\Object
protected $addon;
-
- /**
- * @param \NetteAddons\Model\Facade\AddonManageFacade
- * @param \NetteAddons\Model\Utils\VersionParser
- * @param \NetteAddons\Model\Utils\FormValidators
- * @param \NetteAddons\Model\Utils\Licenses
- * @param \NetteAddons\Model\AddonVersions
- */
- public function __construct(AddonManageFacade $manager, VersionParser $versionParser, FormValidators $validators, Licenses $licenses, AddonVersions $model)
- {
+ public function __construct(
+ AddonManageFacade $manager,
+ VersionParser $versionParser,
+ FormValidators $validators,
+ Licenses $licenses,
+ AddonVersions $model
+ ) {
$this->model = $model;
$this->manager = $manager;
$this->versionParser = $versionParser;
@@ -55,10 +47,9 @@ public function __construct(AddonManageFacade $manager, VersionParser $versionPa
}
-
/**
- * @param Addon
- * @param IIdentity
+ * @param \NetteAddons\Model\Addon
+ * @param \Nette\Security\IIdentity
* @param string
* @return VersionForm
*/
@@ -77,7 +68,6 @@ public function create(Addon $addon, IIdentity $user, $token)
try {
$version = $manager->addVersionFromValues($addon, $values, $user, $versionParser);
-
} catch (\NetteAddons\IOException $e) {
$form['archive']->addError('Uploading file failed.');
return;
@@ -89,7 +79,6 @@ public function create(Addon $addon, IIdentity $user, $token)
} catch (\NetteAddons\DuplicateEntryException $e) {
$form['version']->addError(sprintf("Version '%s' already exists.", $version->version));
}
-
} else {
$manager->storeAddon($values->token, $addon);
}
View
52 app/Manage/forms/AddonForm.php
@@ -2,19 +2,16 @@
namespace NetteAddons\Manage\Forms;
-use NetteAddons\Model,
- NetteAddons\Model\Addon,
- NetteAddons\Model\Tags,
- NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\RepositoryImporterManager,
- NetteAddons\Model\Utils\Licenses,
- NetteAddons\Model\Utils\FormValidators;
-
+use NetteAddons\Model;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Tags;
+use NetteAddons\Model\Facade\AddonManageFacade;
+use NetteAddons\Model\Importers\RepositoryImporterManager;
+use NetteAddons\Model\Utils\Licenses;
+use NetteAddons\Model\Utils\FormValidators;
/**
- * @author Patrik Votoček
- *
* @property \NetteAddons\Model\Addon $addon
*/
class AddonForm extends \NetteAddons\Forms\BaseForm
@@ -41,27 +38,25 @@ class AddonForm extends \NetteAddons\Forms\BaseForm
private $addon;
- /**
- * @param \NetteAddons\Model\Facade\AddonManageFacade
- * @param \NetteAddons\Model\Importers\RepositoryImporterManager
- * @param \NetteAddons\Model\Tags
- * @param \NetteAddons\Model\Utils\FormValidators
- * @param \NetteAddons\Model\Utils\Licenses
- * @param array
- */
- public function __construct(AddonManageFacade $manager, RepositoryImporterManager $importerManager, Tags $tags, FormValidators $validators, Licenses $licenses, array $descriptionFormats = array())
- {
+ public function __construct(
+ AddonManageFacade $manager,
+ RepositoryImporterManager $importerManager,
+ Tags $tags,
+ FormValidators $validators,
+ Licenses $licenses,
+ array $descriptionFormats = array()
+ ) {
$this->manager = $manager;
$this->importerManager = $importerManager;
$this->tags = $tags;
$this->validators = $validators;
$this->licenses = $licenses;
$this->descriptionFormats = $descriptionFormats;
+
parent::__construct();
}
-
protected function buildForm()
{
$this->addText('name', 'Name', NULL, 100)
@@ -69,10 +64,10 @@ protected function buildForm()
$this->addText('composerFullName', 'Composer name', NULL, 100)
->setRequired()
->addRule(self::PATTERN, 'Invalid composer name', FormValidators::COMPOSER_NAME_RE)
- ->addRule($this->validators->isComposerFullNameUnique, 'This composer name has already been taken.');
+ ->addRule(array($this->validators, 'isComposerFullNameUnique'), 'This composer name has already been taken.');
$this->addMultiSelect('defaultLicense', 'Default license', $this->licenses->getLicenses(TRUE))
->setRequired()
- ->addRule($this->validators->isLicenseValid, 'Invalid license identifier.');
+ ->addRule(array($this->validators, 'isLicenseValid'), 'Invalid license identifier.');
$this->addMultiSelect('tags', 'Categories', $this->getCategories())
->setRequired();
$this->addText('repository', 'Repository URL', NULL, 500)
@@ -92,21 +87,21 @@ protected function buildForm()
}
-
/**
* @return array
*/
private function getCategories()
{
$categories = array();
+
foreach ($this->tags->findMainTags() as $tag) {
$categories[$tag->id] = $tag->name;
}
+
return $categories;
}
-
/**
* @return \NetteAddons\Model\Addon
*/
@@ -115,11 +110,11 @@ public function getAddon()
if (!$this->addon) {
$this->addon = new Addon;
}
+
return $this->addon;
}
-
/**
* @param \NetteAddons\Model\Addon
* @return AddonForm
@@ -166,7 +161,6 @@ public function setAddon(Addon $addon)
}
-
/**
* @param bool
* @return \Nette\ArrayHash|array
@@ -174,16 +168,18 @@ public function setAddon(Addon $addon)
public function getValues($asArray = FALSE)
{
$values = parent::getValues($asArray);
+
if (isset($this['repository'])) {
$values['repositoryHosting'] = NULL;
}
+
if (!empty($values['repository'])) {
$values['repository'] = $this->importerManager->normalizeUrl($values['repository']);
if ($this->importerManager->isValid($values['repository'])) {
$values['repositoryHosting'] = $this->importerManager->getIdByUrl($values['repository']);
}
}
+
return $values;
}
-
}
View
34 app/Manage/forms/AddonFormFactory.php
@@ -2,16 +2,14 @@
namespace NetteAddons\Manage\Forms;
-use NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\RepositoryImporterManager,
- NetteAddons\Model\Tags,
- NetteAddons\Model\Utils\FormValidators,
- NetteAddons\Model\Utils\Licenses;
+use NetteAddons\Model\Facade\AddonManageFacade;
+use NetteAddons\Model\Importers\RepositoryImporterManager;
+use NetteAddons\Model\Tags;
+use NetteAddons\Model\Utils\FormValidators;
+use NetteAddons\Model\Utils\Licenses;
/**
- * @author Patrik Votoček
- *
* @property string $token
*/
abstract class AddonFormFactory extends \Nette\Object
@@ -35,16 +33,13 @@
private $descriptionFormats = array();
-
- /**
- * @param \NetteAddons\Model\Facade\AddonManageFacade
- * @param \NetteAddons\Model\Importers\RepositoryImporterManager
- * @param \NetteAddons\Model\Tags
- * @param \NetteAddons\Model\Utils\FormValidators
- * @param \NetteAddons\Model\Utils\Licenses
- */
- public function __construct(AddonManageFacade $manager, RepositoryImporterManager $importerManager, Tags $tags, FormValidators $validators, Licenses $licenses)
- {
+ public function __construct(
+ AddonManageFacade $manager,
+ RepositoryImporterManager $importerManager,
+ Tags $tags,
+ FormValidators $validators,
+ Licenses $licenses
+ ) {
$this->manager = $manager;
$this->importerManager = $importerManager;
$this->tags = $tags;
@@ -53,11 +48,10 @@ public function __construct(AddonManageFacade $manager, RepositoryImporterManage
}
-
/**
* @param string
* @param string
- * @return AddonForm
+ * @return AddonFormFactory
*/
public function addDescriptionFormat($id, $name)
{
@@ -66,7 +60,6 @@ public function addDescriptionFormat($id, $name)
}
-
/**
* @return AddonForm
*/
@@ -81,5 +74,4 @@ protected function createForm()
$this->descriptionFormats
);
}
-
}
View
40 app/Manage/forms/EditAddonFormFactory.php
@@ -2,21 +2,19 @@
namespace NetteAddons\Manage\Forms;
-use NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\RepositoryImporterManager,
- NetteAddons\Model\Tags,
- NetteAddons\Model\Utils\FormValidators,
- NetteAddons\Model\Utils\Licenses,
- NetteAddons\Model\Addons,
- NetteAddons\Model\Addon;
+use NetteAddons\Model\Facade\AddonManageFacade;
+use NetteAddons\Model\Importers\RepositoryImporterManager;
+use NetteAddons\Model\Tags;
+use NetteAddons\Model\Utils\FormValidators;
+use NetteAddons\Model\Utils\Licenses;
+use NetteAddons\Model\Addons;
+use NetteAddons\Model\Addon;
/**
* Form for new addon registration. When importing from GitHub, most of the fields should be prefilled.
* The license input won't be visible when composer.json is available.
*
- * @author Patrik Votoček
- *
* @property string $token
*/
class EditAddonFormFactory extends AddonFormFactory
@@ -25,25 +23,22 @@ class EditAddonFormFactory extends AddonFormFactory
private $model;
-
- /**
- * @param \NetteAddons\Model\Facade\AddonManageFacade
- * @param \NetteAddons\Model\Importers\RepositoryImporterManager
- * @param \NetteAddons\Model\Tags
- * @param \NetteAddons\Model\Utils\FormValidators
- * @param \NetteAddons\Model\Utils\Licenses
- * @param \NetteAddons\Model\Addons
- */
- public function __construct(AddonManageFacade $manager, RepositoryImporterManager $importerManager, Tags $tags, FormValidators $validators, Licenses $licenses, Addons $model)
- {
+ public function __construct(
+ AddonManageFacade $manager,
+ RepositoryImporterManager $importerManager,
+ Tags $tags,
+ FormValidators $validators,
+ Licenses $licenses,
+ Addons $model
+ ) {
parent::__construct($manager, $importerManager, $tags, $validators, $licenses);
+
$this->model = $model;
}
-
/**
- * @param Addon
+ * @param \NetteAddons\Model\Addon
* @return AddonForm
*/
public function create(Addon $addon)
@@ -66,5 +61,4 @@ public function create(Addon $addon)
return $form;
}
-
}
View
51 app/Manage/forms/ImportAddonFormFactory.php
@@ -2,18 +2,16 @@
namespace NetteAddons\Manage\Forms;
-use Nette,
- Nette\Utils\Strings,
- Nette\Forms\IControl,
- Nette\Security\IIdentity,
- NetteAddons\Forms\Form,
- NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\RepositoryImporterManager,
- NetteAddons\Model\Utils\Validators;
-
-/**
- * @author Patrik Votoček
- */
+use Nette\Diagnostics\Debugger;
+use Nette\Utils\Strings;
+use Nette\Forms\IControl;
+use Nette\Security\IIdentity;
+use NetteAddons\Forms\Form;
+use NetteAddons\Model\Facade\AddonManageFacade;
+use NetteAddons\Model\Importers\RepositoryImporterManager;
+use NetteAddons\Model\Utils\Validators;
+
+
class ImportAddonFormFactory extends \Nette\Object
{
/** @var \NetteAddons\Model\Facade\AddonManageFacade */
@@ -26,22 +24,21 @@ class ImportAddonFormFactory extends \Nette\Object
private $validators;
-
- /**
- * @param \NetteAddons\Model\Facade\AddonManageFacade
- * @param \NetteAddons\Model\Importers\RepositoryImporterManager
- * @param \NetteAddons\Model\Utils\Validators
- */
- public function __construct(AddonManageFacade $manager, RepositoryImporterManager $importers, Validators $validators)
- {
+ public function __construct(
+ AddonManageFacade $manager,
+ RepositoryImporterManager $importers,
+ Validators $validators
+ ) {
$this->manager = $manager;
$this->importerManager = $importers;
$this->validators = $validators;
}
-
-
+ /**
+ * @param \Nette\Security\IIdentity
+ * @return \NetteAddons\Forms\Form
+ */
public function create(IIdentity $user)
{
$form = new Form;
@@ -67,7 +64,6 @@ public function create(IIdentity $user)
try {
$importer = $importerManager->createFromUrl($values->url);
-
} catch (\NetteAddons\NotSupportedException $e) {
$form['url']->addError(
'Sorry, we currently support only repositories from ' . $importerManager->getNames() . '.'
@@ -84,23 +80,19 @@ public function create(IIdentity $user)
}
$manager->storeAddon($values->token, $addon);
-
} catch (\NetteAddons\Utils\HttpException $e) {
if ($e->getCode() === 404) {
$form['url']->addError("Repository with URL '{$values->url}' does not exist.");
-
} else {
$importerName = $importer::getName();
$form['url']->addError("Importing failed because '$importerName' returned error #" . $e->getCode() . '.');
}
-
} catch (\NetteAddons\IOException $e) {
if ($e->getCode() === 404) {
$form['url']->addError("Repository with URL '{$values->url}' does not exist.");
-
} else {
$form['url']->addError('Importing failed. Try again later.');
- Nette\Diagnostics\Debugger::log($e, Nette\Diagnostics\Debugger::WARNING);
+ Debugger::log($e, Debugger::WARNING);
}
}
};
@@ -109,7 +101,6 @@ public function create(IIdentity $user)
}
-
/**
* @param \Nette\Forms\IControl
* @return bool
@@ -120,7 +111,6 @@ public function validateRepositoryUrlSupported(IControl $control)
}
-
/**
* @param \Nette\Forms\IControl
* @return bool
@@ -129,5 +119,4 @@ public function validateRepositoryUrl(IControl $control)
{
return $this->importerManager->isValid($control->getValue());
}
-
}
View
1  app/Manage/forms/ReportFormFactory.php
@@ -41,7 +41,6 @@ public function create(IIdentity $user)
$form->addSubmit('sub', 'Zap');
-
$model = $this->reports;
$form->onSuccess[] = function(Form $form) use($model, $user) {
$values = $form->getValues();
View
48 app/Manage/forms/VersionFormFactory.php
@@ -2,54 +2,45 @@
namespace NetteAddons\Manage\Forms;
-use Nette\Utils\Strings,
- Nette\Forms\Controls\UploadControl,
- NetteAddons\Model\Addon,
- NetteAddons\Model\Utils\Licenses,
- NetteAddons\Model\Utils\FormValidators;
+use Nette\Utils\Strings;
+use Nette\Forms\Controls\UploadControl;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Utils\Licenses;
+use NetteAddons\Model\Utils\FormValidators;
-
-/**
- * @author Patrik Votoček
- */
class VersionForm extends \NetteAddons\Forms\BaseForm
{
- /** @var FormValidators */
+ /** @var \NetteAddons\Model\Utils\FormValidators */
private $validators;
- /** @var Licenses */
+ /** @var \NetteAddons\Model\Utils\Licenses */
private $licenses;
- /** @var Addon */
+ /** @var \NetteAddons\Model\Addon */
private $addon;
- /**
- * @param FormValidators
- * @param Licenses
- * @param Addon
- */
public function __construct(FormValidators $validators, Licenses $licenses, Addon $addon)
{
$this->validators = $validators;
$this->licenses = $licenses;
$this->addon = $addon;
+
parent::__construct();
}
-
protected function buildForm()
{
$this->addText('version', 'Version', NULL, 100)
->setRequired()
- ->addRule($this->validators->isVersionValid, 'Invalid version.');
+ ->addRule(array($this->validators, 'isVersionValid'), 'Invalid version.');
$this->addMultiSelect('license', 'License', $this->licenses->getLicenses(TRUE))
->setAttribute('class', 'chzn-select')
->setRequired()
- ->addRule($this->validators->isLicenseValid, 'Invalid license identifier.');
+ ->addRule(array($this->validators, 'isLicenseValid'), 'Invalid license identifier.');
$providers = array(
'link' => 'Provide link to distribution archive.',
@@ -57,20 +48,23 @@ protected function buildForm()
);
$this->addSelect('how', 'How would you like to provide source codes?', $providers)
->setRequired()
- ->addCondition(self::EQUAL, 'link')->toggle('xlink')->endCondition()
- ->addCondition(self::EQUAL, 'upload')->toggle('xupload')->endCondition();
+ ->addCondition(self::EQUAL, 'link')
+ ->toggle('xlink')
+ ->endCondition()
+ ->addCondition(self::EQUAL, 'upload')
+ ->toggle('xupload');
$this->addText('archiveLink', 'Link to ZIP archive')
->setOption('id', 'xlink')
->addConditionOn($this['how'], self::EQUAL, 'link')
- ->addRule(self::FILLED)
- ->addRule(self::URL);
+ ->addRule(self::FILLED)
+ ->addRule(self::URL);
$this->addUpload('archive', 'Archive')
->setOption('id', 'xupload')
->addConditionOn($this['how'], self::EQUAL, 'upload')
- ->addRule(self::FILLED)
- ->addRule($this->isArchiveValid, 'Only ZIP files are allowed.');
+ ->addRule(self::FILLED)
+ ->addRule(array($this, 'isArchiveValid'), 'Only ZIP files are allowed.');
$license = $this->addon->defaultLicense;
if (is_string($license)) {
@@ -82,7 +76,6 @@ protected function buildForm()
}
-
/**
* @param \Nette\Forms\Controls\UploadControl
* @return bool
@@ -91,5 +84,4 @@ public function isArchiveValid(UploadControl $control)
{
return Strings::endsWith($control->value->name, '.zip');
}
-
}
View
76 app/Manage/presenters/AddonPresenter.php
@@ -2,44 +2,44 @@
namespace NetteAddons\Manage;
-use NetteAddons\Forms\Form,
- NetteAddons\Model\Utils\Validators;
+use NetteAddons\Forms\Form;
+use NetteAddons\Model\Utils\Validators;
+use NetteAddons\Manage\Forms\AddAddonFormFactory;
+use NetteAddons\Manage\Forms\EditAddonFormFactory;
+use NetteAddons\Manage\Forms\ImportAddonFormFactory;
-/**
- * @author Patrik Votoček
- */
final class AddonPresenter extends BasePresenter
{
- /**
- * @var Forms\AddAddonFormFactory
- * @inject
- */
+ /** @var Forms\AddAddonFormFactory */
public $addAddonForm;
- /**
- * @var Forms\EditAddonFormFactory
- * @inject
- */
+ /** @var Forms\EditAddonFormFactory */
public $editAddonForm;
- /**
- * @var Forms\ImportAddonFormFactory
- * @inject
- */
+ /** @var Forms\ImportAddonFormFactory */
public $importAddonForm;
- /**
- * @var \NetteAddons\Model\Utils\Validators
- * @inject
- */
+ /** @var \NetteAddons\Model\Utils\Validators */
public $validators;
+ public function __construct(
+ AddAddonFormFactory $addAddonFormFactory,
+ EditAddonFormFactory $editAddonFormFactory,
+ ImportAddonFormFactory $importAddonFormFactory,
+ Validators $validators
+ ) {
+ parent::__construct();
+
+ $this->addAddonForm = $addAddonFormFactory;
+ $this->editAddonForm = $editAddonFormFactory;
+ $this->importAddonForm = $importAddonFormFactory;
+ $this->validators = $validators;
+ }
+
/**
- * Creates a new form for addon information.
- *
* @return Forms\AddonForm
*/
protected function createComponentAddAddonForm()
@@ -50,16 +50,13 @@ protected function createComponentAddAddonForm()
$form->setAddon($this->addon);
}
- $form->onSuccess[] = $this->addAddonFormSubmitted;
+ $form->onSuccess[] = array($this, 'addAddonFormSubmitted');
return $form;
}
-
/**
- * Handles the new addon form submission.
- *
* @param Forms\AddonForm
*/
public function addAddonFormSubmitted(Forms\AddonForm $form)
@@ -73,7 +70,6 @@ public function addAddonFormSubmitted(Forms\AddonForm $form)
if ($imported) {
$this->redirect(':Manage:Versions:import');
-
} else {
$this->flashMessage('Addon created. Now it\'s time to add the first version.');
$this->redirect(':Manage:Versions:add');
@@ -82,23 +78,21 @@ public function addAddonFormSubmitted(Forms\AddonForm $form)
}
-
/**
- * @return Form
+ * @return \NetteAddons\Forms\Form
*/
protected function createComponentImportAddonForm()
{
$form = $this->importAddonForm->create($this->getUser()->getIdentity());
- $form->onSuccess[] = $this->importAddonFormSubmitted;
+ $form->onSuccess[] = array($this, 'importAddonFormSubmitted');
return $form;
}
-
/**
- * @param Form
+ * @param \NetteAddons\Forms\Form
*/
public function importAddonFormSubmitted(Form $form)
{
@@ -112,17 +106,12 @@ public function importAddonFormSubmitted(Form $form)
}
-
public function renderAdd()
{
$this->template->full = empty($this->token);
}
-
- /**
- * Finish the addon creation
- */
public function actionFinish()
{
if (!$this->addon) {
@@ -145,7 +134,6 @@ public function actionFinish()
}
-
/**
* @return Forms\AddonForm
*/
@@ -157,13 +145,12 @@ protected function createComponentEditAddonForm()
$form = $this->editAddonForm->create($this->addon);
- $form->onSuccess[] = $this->editAddonFormSubmitted;
+ $form->onSuccess[] = array($this, 'editAddonFormSubmitted');
return $form;
}
-
/**
* @param Forms\AddonForm
*/
@@ -178,7 +165,6 @@ public function editAddonFormSubmitted(Forms\AddonForm $form)
}
-
/**
* @param int
*/
@@ -191,7 +177,6 @@ public function actionEdit($addonId)
}
-
/**
* @param int
*/
@@ -201,7 +186,6 @@ public function renderEdit($addonId)
}
-
/**
* @secured
* @param int
@@ -224,7 +208,6 @@ public function handleDelete($addonId, $real = FALSE)
}
-
/**
* @secured
* @param int
@@ -244,7 +227,6 @@ public function handleRestore($addonId)
}
-
/**
* @param int
*/
@@ -257,7 +239,6 @@ public function actionDelete($addonId)
}
-
/**
* @param int
*/
@@ -266,5 +247,4 @@ public function renderDelete($addonId)
$this->template->addon = $this->addon;
$this->template->newest = !$this->validators->isComposerFullNameUnique($this->addon->composerFullName);
}
-
}
View
66 app/Manage/presenters/AdminPresenter.php
@@ -2,42 +2,42 @@
namespace NetteAddons\Manage;
-use NetteAddons\Forms\Form,
- NetteAddons\Model\Addons,
- NetteAddons\Model\AddonVotes,
- NetteAddons\Model\AddonReports;
+use Nette\Http\IResponse;
+use NetteAddons\Forms\Form;
+use NetteAddons\Model\Addons;
+use NetteAddons\Model\AddonVotes;
+use NetteAddons\Model\AddonReports;
-/**
- * @author Patrik Votoček
- */
final class AdminPresenter extends \NetteAddons\BasePresenter
{
- /**
- * @var \NetteAddons\Model\Addons
- * @inject
- */
+ /** @var \NetteAddons\Model\Addons */
public $addons;
- /**
- * @var \NetteAddons\Model\AddonVotes
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonVotes */
public $addonVotes;
- /**
- * @var \NetteAddons\Model\AddonReports
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonReports */
public $reports;
- /**
- * @var Forms\ReportFormFactory
- * @inject
- */
+ /** @var \NetteAddons\Manage\Forms\ReportFormFactory */
public $reportForm;
+ public function __construct(
+ Addons $addons,
+ AddonVotes $addonVotes,
+ AddonReports $addonReports,
+ Forms\ReportFormFactory $reportFormFactory
+ ) {
+ parent::__construct();
+
+ $this->addons = $addons;
+ $this->addonVotes = $addonVotes;
+ $this->reports = $addonReports;
+ $this->reportForm = $reportFormFactory;
+ }
+
/**
* @param \Nette\Application\UI\PresenterComponentReflection
@@ -49,20 +49,18 @@ public function checkRequirements($element)
$this->flashMessage('Please sign in to continue.');
$this->redirect(':Sign:in', $this->storeRequest());
} elseif (!$this->user->isInRole('moderators') && !$this->user->isInRole('administrators')) {
- $this->error('This section is only for admins and moderators.', 403);
+ $this->error('This section is only for admins and moderators.', IResponse::S403_FORBIDDEN);
}
}
-
protected function beforeRender()
{
parent::beforeRender();
- $this->template->addonVotes = callback($this->addonVotes, 'calculatePopularity');
+ $this->template->addonVotes = array($this->addonVotes, 'calculatePopularity');
}
-
public function actionDeleted()
{
if (!$this->auth->isAllowed('addon', 'delete')) {
@@ -71,37 +69,32 @@ public function actionDeleted()
}
-
public function renderDeleted()
{
$this->template->addons = $this->addons->findDeleted();
}
-
public function renderReports()
{
$this->template->reports = $this->reports->findAll()->order('reportedAt DESC');
}
-
/**
- * @return Form
+ * @return \NetteAddons\Forms\Form
*/
protected function createComponentReportForm()
{
$form = $this->reportForm->create($this->getUser()->getIdentity());
- $form->onSuccess[] = $this->reportFormSubmitted;
+ $form->onSuccess[] = array($this, 'reportFormSubmitted');
return $form;
}
-
-
/**
- * @param Form
+ * @param \NetteAddons\Forms\Form
*/
public function reportFormSubmitted(Form $form)
{
@@ -112,7 +105,6 @@ public function reportFormSubmitted(Form $form)
}
-
/**
* @param int
*/
@@ -127,7 +119,6 @@ public function actionReport($id)
}
-
/**
* @param int
*/
@@ -135,5 +126,4 @@ public function renderReport($id)
{
$this->template->report = $this->reports->find($id);
}
-
}
View
14 app/Manage/presenters/BasePresenter.php
@@ -2,16 +2,9 @@
namespace NetteAddons\Manage;
-use Nette\Utils\Strings,
- NetteAddons\Model\Addon,
- NetteAddons\Model\Addons,
- NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\RepositoryImporterManager;
+use NetteAddons\Model\Addon;
-/**
- * @author Patrik Votoček
- */
abstract class BasePresenter extends \NetteAddons\BasePresenter
{
/**
@@ -48,7 +41,6 @@
protected $addon;
-
/**
* @param \Nette\Application\UI\PresenterComponentReflection
*/
@@ -61,7 +53,6 @@ public function checkRequirements($element)
}
-
protected function startup()
{
parent::startup();
@@ -72,13 +63,14 @@ protected function startup()
if ($this->token) {
$this->addon = $this->manager->restoreAddon($this->token);
-
} elseif ($this->addonId) {
$deleted = $this->auth->isAllowed('addon', 'delete');
$row = $this->addons->find($this->addonId, $deleted);
+
if (!$row) {
$this->error('Addon not found.');
}
+
$this->addon = Addon::fromActiveRow($row);
}
View
50 app/Manage/presenters/VersionsPresenter.php
@@ -2,34 +2,35 @@
namespace NetteAddons\Manage;
-use NetteAddons\Model\Users,
- NetteAddons\Model\AddonVersions;
+use NetteAddons\Manage\Forms\AddVersionFormFactory;
+use NetteAddons\Model\Users;
+use NetteAddons\Model\AddonVersions;
-/**
- * @author Patrik Votoček
- */
final class VersionsPresenter extends BasePresenter
{
- /**
- * @var Forms\AddVersionFormFactory
- * @inject
- */
+ /** @var \NetteAddons\Manage\Forms\AddVersionFormFactory */
public $addVersionForm;
- /**
- * @var \NetteAddons\Model\AddonVersions
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonVersions */
public $versions;
- /**
- * @var \NetteAddons\Model\Users
- * @inject
- */
+ /** @var \NetteAddons\Model\Users */
public $users;
+ public function __construct(
+ AddVersionFormFactory $addVersionFormFactory,
+ AddonVersions $addonVersions,
+ Users $users
+ ) {
+ parent::__construct();
+
+ $this->addVersionForm = $addVersionFormFactory;
+ $this->versions = $addonVersions;
+ $this->users = $users;
+ }
+
/**
* @return Forms\VersionForm
@@ -38,15 +39,14 @@ protected function createComponentAddVersionForm()
{
$form = $this->addVersionForm->create($this->addon, $this->getUser()->getIdentity(), $this->token);
- $form->onSuccess[] = $this->addVersionFormSubmitted;
+ $form->onSuccess[] = array($this, 'addVersionFormSubmitted');
return $form;
}
-
/**
- * @param Forms\VersionForm
+ * @param \NetteAddons\Manage\Forms\VersionForm
*/
public function addVersionFormSubmitted(Forms\VersionForm $form)
{
@@ -65,7 +65,6 @@ public function addVersionFormSubmitted(Forms\VersionForm $form)
}
-
public function actionAdd()
{
if (!$this->addon) {
@@ -74,14 +73,12 @@ public function actionAdd()
}
-
public function renderAdd()
{
$this->template->addon = $this->addon;
}
-
public function actionImport()
{
if (!$this->addon) {
@@ -96,14 +93,12 @@ public function actionImport()
$this->manager->importVersions($this->addon, $importer, $this->getUser()->identity);
$this->manager->storeAddon($this->token, $this->addon);
$this->redirect(':Manage:Addon:finish');
-
} catch (\NetteAddons\NotSupportedException $e) {
$this->error();
}
}
-
/**
* @param int
*/
@@ -118,10 +113,8 @@ public function actionCheck($addonId)
try {
$importer = $this->importerManager->createFromUrl($this->addon->repository);
$result = $this->manager->updateVersions($this->addon, $importer, $owner);
-
} catch (\NetteAddons\NotSupportedException $e) {
$this->error();
-
} catch (\NetteAddons\IOException $e) {
$this->flashMessage('Version importing failed. Try again later.', 'error');
$this->redirect(':Detail:', $this->addon->id);
@@ -134,10 +127,12 @@ public function actionCheck($addonId)
foreach ($result['new'] as $version) {
$this->versions->add($version);
}
+
foreach ($result['conflicted'] as $conflict) {
$conflict['b']->id = $conflict['a']->id;
$this->versions->update($conflict['b']);
}
+
$this->flashMessage('Versions have been updated.');
} catch (\PDOException $e) {
$this->flashMessage('Version importing failed. Try again later.', 'error');
@@ -146,5 +141,4 @@ public function actionCheck($addonId)
$this->redirect(':Detail:', $this->addon->id);
}
-
}
View
1  app/bootstrap.php
@@ -2,7 +2,6 @@
namespace NetteAddons;
-use Nette\Application\Routers\Route;
use Nette\Configurator;
// Load Nette Framework or autoloader generated by Composer
View
20 app/components/CategoriesControl.php
@@ -2,33 +2,24 @@
namespace NetteAddons\Components;
-use Nette,
- NetteAddons\Model\Tags;
+use Nette;
+use NetteAddons\Model\Tags;
-
-/**
- * @author Patrik Votoček
- */
-class CategoriesControl extends Nette\Application\UI\Control
+class CategoriesControl extends \Nette\Application\UI\Control
{
-
- /** @var \NetteAddons\Model\Tags */
+ /** * @var \NetteAddons\Model\Tags */
private $tags;
-
- /**
- * @param \NetteAddons\Model\Tags
- */
public function __construct(Tags $tags)
{
parent::__construct();
+
$this->tags = $tags;
}
-
public function render()
{
$this->template->categories = $this->tags->findMainTagsWithAddons();
@@ -37,5 +28,4 @@ public function render()
$this->template->setFile(__DIR__ . '/Categories.latte');
$this->template->render();
}
-
}
View
22 app/components/SubMenuControl.php
@@ -2,17 +2,11 @@
namespace NetteAddons\Components;
-use Nette,
- NetteAddons\Model\Addon,
- NetteAddons\Model\Authorizator;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Authorizator;
-
-/**
- * @author Filip Procházka <filip@prochazka.su>
- * @author Patrik Votoček
- */
-class SubMenuControl extends Nette\Application\UI\Control
+class SubMenuControl extends \Nette\Application\UI\Control
{
/** @var \NetteAddons\Model\Authorizator */
@@ -25,20 +19,17 @@ class SubMenuControl extends Nette\Application\UI\Control
private $page;
-
- /**
- * @param \NetteAddons\Model\Authorizator $auth
- */
public function __construct(Authorizator $auth)
{
parent::__construct();
+
$this->auth = $auth;
}
-
/**
* @param \NetteAddons\Model\Addon
+ * @return SubMenuControl
*/
public function setAddon(Addon $addon)
{
@@ -47,7 +38,6 @@ public function setAddon(Addon $addon)
}
-
/**
* @param \Nette\Database\Table\ActiveRow|string
* @return SubMenuControl
@@ -59,7 +49,6 @@ public function setPage($page)
}
-
public function render()
{
$this->template->auth = $this->auth;
@@ -73,5 +62,4 @@ public function render()
$this->template->setFile(__DIR__ . '/SubMenu.latte');
$this->template->render();
}
-
}
View
13 app/forms/BaseForm.php
@@ -2,27 +2,18 @@
namespace NetteAddons\Forms;
-use Nette\ComponentModel\IContainer;
-
-/**
- * Base class for all forms.
- *
- * Handles the form rendering using form templates.
- */
abstract class BaseForm extends Form
{
- public function __construct(IContainer $parent = NULL, $name = NULL)
+ public function __construct()
{
- parent::__construct($parent, $name);
+ parent::__construct();
$this->buildForm();
}
/**
- * Abstract function which handles the form creation.
- * @abstract
* @return void
*/
protected abstract function buildForm();
View
21 app/forms/EditPageFormFactory.php
@@ -2,24 +2,17 @@
namespace NetteAddons\Forms;
-use Nette\Security\IIdentity,
- Nette\Database\Table\ActiveRow,
- NetteAddons\Model\Pages;
+use Nette\Security\IIdentity;
+use Nette\Database\Table\ActiveRow;
+use NetteAddons\Model\Pages;
-/**
- * @author Patrik Votoček
- */
class EditPageFormFactory extends \Nette\Object
{
-
- /** @var Pages */
+ /** @var \NetteAddons\Model\Pages */
private $pages;
- /**
- * @param Pages
- */
public function __construct(Pages $pages)
{
$this->pages = $pages;
@@ -27,13 +20,14 @@ public function __construct(Pages $pages)
/**
- * @param ActiveRow
- * @param IIdentity
+ * @param \Nette\Database\Table\ActiveRow
+ * @param \Nette\Security\IIdentity
* @return Form
*/
public function create(ActiveRow $page, IIdentity $user)
{
$form = new Form;
+
$form->addText('name', 'Name')
->setRequired()
->setAttribute('class', 'text input-half');
@@ -56,5 +50,4 @@ public function create(ActiveRow $page, IIdentity $user)
return $form;
}
-
}
View
21 app/forms/FilterForm.php
@@ -2,16 +2,11 @@
namespace NetteAddons\Forms;
-use NetteAddons\Model,
- Nette\Application\UI\Form;
+use NetteAddons\Model\Tags;
-/**
- * @author Patrik Votoček
- */
class FilterForm extends BaseForm
{
-
/** @var \NetteAddons\Model\Tags */
private $tags;
@@ -19,20 +14,14 @@ class FilterForm extends BaseForm
private $tagsPairs;
-
- /**
- * @param Model\Tags
- */
- public function __construct(Model\Tags $tags)
+ public function __construct(Tags $tags)
{
$this->tags = $tags;
+
parent::__construct();
}
- /**
- * @return \Nette\Application\UI\Form
- */
protected function buildForm()
{
$this->tagsPairs = $this->tags->findMainTags()->fetchPairs('slug', 'name');
@@ -45,7 +34,6 @@ protected function buildForm()
}
-
/**
* @param string
* @return FilterForm
@@ -57,7 +45,6 @@ public function setSearch($search)
}
-
/**
* @param string
* @return FilterForm
@@ -69,7 +56,6 @@ public function setCategory($category)
}
-
/**
* @return string
*/
@@ -78,5 +64,4 @@ public function getCategory()
$value = $this['category']->getValue();
return $value ? $this->tagsPairs[$value] : NULL;
}
-
}
View
16 app/forms/Form.php
@@ -2,23 +2,17 @@
namespace NetteAddons\Forms;
-use Nette,
- Nette\ComponentModel\IContainer;
+use Nette\Forms\Rendering\DefaultFormRenderer;
-/**
- * Base class for all forms.
- *
- * Handles the form rendering using form templates.
- */
-class Form extends Nette\Application\UI\Form
+class Form extends \Nette\Application\UI\Form
{
- public function __construct(IContainer $parent = NULL, $name = NULL)
+ public function __construct()
{
- parent::__construct($parent, $name);
+ parent::__construct();
$renderer = $this->getRenderer();
- if ($renderer instanceof \Nette\Forms\Rendering\DefaultFormRenderer) {
+ if ($renderer instanceof DefaultFormRenderer) {
$renderer->wrappers['form']['container'] = 'div class=form';
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class=controls';
View
22 app/forms/ReportFormFactory.php
@@ -2,24 +2,17 @@
namespace NetteAddons\Forms;
-use Nette\Security\IIdentity,
- NetteAddons\Model\Addon,
- NetteAddons\Model\AddonReports;
+use Nette\Security\IIdentity;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\AddonReports;
-/**
- * @author Patrik Votoček
- */
class ReportFormFactory extends \Nette\Object
{
-
- /** @var AddonReports */
+ /** @var \NetteAddons\Model\AddonReports */
private $reports;
- /**
- * @param AddonReports
- */
public function __construct(AddonReports $reports)
{
$this->reports = $reports;
@@ -27,8 +20,8 @@ public function __construct(AddonReports $reports)
/**
- * @param Addon
- * @param IIdentity
+ * @param \NetteAddons\Model\Addon
+ * @param \Nette\Security\IIdentity
* @return Form
*/
public function create(Addon $addon, IIdentity $user)
@@ -43,10 +36,9 @@ public function create(Addon $addon, IIdentity $user)
$model = $this->reports;
$form->onSuccess[] = function(Form $form) use($model, $addon, $user) {
$values = $form->getValues();
- $model->saveReport($user->getId(), $addon->id, $values['message']);
+ $model->saveReport($user->getId(), $addon->id, $values->message);
};
return $form;
}
-
}
View
3  app/forms/SignInForm.php
@@ -3,10 +3,8 @@
namespace NetteAddons\Forms;
-
class SignInForm extends BaseForm
{
-
protected function buildForm()
{
$this->addText('username', 'Username:')
@@ -19,5 +17,4 @@ protected function buildForm()
$this->addSubmit('login', 'Login');
}
-
}
View
43 app/misc/HttpStreamRequest.php
@@ -2,19 +2,13 @@
namespace NetteAddons\Utils;
-use Nette,
- Nette\Utils\Strings;
-
+use Nette\Utils\Strings;
/**
- * @author Michael Moravec
- * @author Patrik Votoček
- * @author Jan Tvrdík
- *
* @property-read array $headers
*/
-class HttpStreamRequest extends Nette\FreezableObject
+class HttpStreamRequest extends \Nette\FreezableObject
{
/** regexp's for parsing */
const HEADER_REGEXP = '~(?P<header>.*?)\:\s(?P<value>.*)~',
@@ -43,10 +37,9 @@ public function __construct($url)
}
-
/**
- * @param string
- * @param mixed
+ * @param string
+ * @param mixed
* @return HttpStreamRequest
*/
public function setOption($name, $value)
@@ -57,9 +50,8 @@ public function setOption($name, $value)
}
-
/**
- * @param int
+ * @param int
* @return HttpStreamRequest
*/
public function removeOption($name)
@@ -71,8 +63,8 @@ public function removeOption($name)
/**
- * @param string
- * @param string
+ * @param string
+ * @param string
* @return HttpStreamRequest
*/
public function addHeader($name, $value)
@@ -83,11 +75,10 @@ public function addHeader($name, $value)