partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 4838dab7e6e3c5d94b1eab9bc787845bdfdc2d05
parent 157c19b50d695653cadc70aee3b4061496caf847
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri, 19 Jun 2015 15:16:54 +0200

Merge branch 'sf2migration' into sf2migration-dunglas

Conflicts:
	app/AppKernel.php
	composer.json
	composer.lock

Diffstat:
Mapp/SymfonyRequirements.php | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
Mapp/check.php | 148+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Mapp/config/routing.yml | 10++++++++++
Mscripts/UpdateCategoryPathCache.php | 4++--
Asrc/PartKeepr/DoctrineReflectionBundle/Controller/DoctrineRESTTreeController.php | 9+++++++++
Msrc/PartKeepr/DoctrineReflectionBundle/Resources/views/model.js.twig | 2+-
Asrc/PartKeepr/FootprintBundle/Controller/FootprintCategoryController.php | 24++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Controller/FootprintController.php | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/DependencyInjection/Configuration.php | 29+++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/DependencyInjection/PartKeeprFootprintExtension.php | 28++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/Footprint.php | 202+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintAttachment.php | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintCategory.php | 31+++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintCategoryManager.php | 43+++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintCategoryService.php | 10++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintImage.php | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintManager.php | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/FootprintService.php | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Entity/Repository/FootprintCategoryRepository.php | 9+++++++++
Asrc/PartKeepr/FootprintBundle/PartKeeprFootprintBundle.php | 9+++++++++
Asrc/PartKeepr/FootprintBundle/Resources/config/services.xml | 16++++++++++++++++
Asrc/PartKeepr/FootprintBundle/Resources/views/Default/index.html.twig | 1+
Asrc/PartKeepr/FootprintBundle/Tests/Controller/DefaultControllerTest.php | 17+++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js | 6+-----
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditor.js | 103-------------------------------------------------------------------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditorComponent.js | 20--------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutGrid.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintStorageLocations.js | 111-------------------------------------------------------------------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingExecutor.js | 38--------------------------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditor.js | 186-------------------------------------------------------------------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditorComponent.js | 20--------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationGrid.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingWindow.js | 155-------------------------------------------------------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectAttachmentGrid.js | 2+-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/StockReport/AbstractStockHistoryGrid.js | 4++--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/RemoteImageField.js | 23+++++++----------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/StorageLocationComboBox.js | 2+-
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/AbstractCategory.js | 5-----
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/Distributor.js | 18------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/Footprint.js | 17-----------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/FootprintAttachment.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/FootprintCategory.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/Manufacturer.js | 19-------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/ManufacturerICLogo.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/Part.js | 61-------------------------------------------------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PartAttachment.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PartCategory.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PartDistributor.js | 20--------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PartManufacturer.js | 14--------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PartParameter.js | 14--------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PartUnit.js | 14--------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingPageBasicLayout.js | 21---------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingPrintingJobConfiguration.js | 20--------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingRenderer.js | 11-----------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingResponse.js | 7-------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingType.js | 11-----------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/Project.js | 21---------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectAttachment.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectPart.js | 23-----------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectReport.js | 22----------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectReportList.js | 22----------------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/SiPrefix.js | 11-----------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/StatisticSample.js | 9---------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/StockEntry.js | 16----------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/StorageLocation.js | 14--------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemInformationRecord.js | 15---------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemNotice.js | 17-----------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/Unit.js | 14--------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/User.js | 13-------------
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Models/UserPreference.js | 10----------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js | 23++++++++++++++++-------
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 9---------
Asrc/PartKeepr/PartBundle/Controller/DefaultController.php | 19+++++++++++++++++++
Asrc/PartKeepr/PartBundle/DependencyInjection/Configuration.php | 29+++++++++++++++++++++++++++++
Asrc/PartKeepr/PartBundle/DependencyInjection/PartKeeprPartExtension.php | 28++++++++++++++++++++++++++++
Asrc/PartKeepr/PartBundle/Entity/PartCategory.php | 29+++++++++++++++++++++++++++++
Asrc/PartKeepr/PartBundle/Entity/PartCategoryManager.php | 43+++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/PartBundle/Entity/PartCategoryService.php | 10++++++++++
Asrc/PartKeepr/PartBundle/Entity/Repository/PartCategoryRepository.php | 10++++++++++
Asrc/PartKeepr/PartBundle/PartKeeprPartBundle.php | 9+++++++++
Asrc/PartKeepr/PartBundle/Resources/config/services.xml | 16++++++++++++++++
Asrc/PartKeepr/PartBundle/Resources/views/Default/index.html.twig | 1+
Asrc/PartKeepr/PartBundle/Tests/Controller/DefaultControllerTest.php | 13+++++++++++++
Msrc/PartKeepr/SiPrefixBundle/Controller/DefaultController.php | 4++--
Dsrc/PartKeepr/UnitBundle/Tests/Controller/DefaultControllerTest.php | 13-------------
Msrc/backend/PartKeepr/Category/AbstractCategory.php | 29++++++++++++++++++-----------
Dsrc/backend/PartKeepr/Footprint/Footprint.php | 193-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Footprint/FootprintAttachment.php | 103-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Footprint/FootprintImage.php | 52----------------------------------------------------
Dsrc/backend/PartKeepr/Footprint/FootprintManager.php | 158-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Footprint/FootprintService.php | 96-------------------------------------------------------------------------------
Msrc/backend/PartKeepr/FootprintAttachment/FootprintAttachmentManager.php | 2+-
Msrc/backend/PartKeepr/FootprintAttachment/FootprintAttachmentService.php | 4++--
Dsrc/backend/PartKeepr/FootprintCategory/FootprintCategory.php | 18------------------
Dsrc/backend/PartKeepr/FootprintCategory/FootprintCategoryManager.php | 43-------------------------------------------
Dsrc/backend/PartKeepr/FootprintCategory/FootprintCategoryService.php | 10----------
Msrc/backend/PartKeepr/Part/Part.php | 20++++++++++++--------
Msrc/backend/PartKeepr/Part/PartManager.php | 6+++---
Msrc/backend/PartKeepr/Part/PartService.php | 4++--
Dsrc/backend/PartKeepr/PartCategory/PartCategory.php | 18------------------
Dsrc/backend/PartKeepr/PartCategory/PartCategoryManager.php | 43-------------------------------------------
Dsrc/backend/PartKeepr/PartCategory/PartCategoryService.php | 10----------
Msrc/backend/PartKeepr/PartKeepr.php | 4++--
Msrc/backend/PartKeepr/Setup/FootprintSetup.php | 12++++++------
Msrc/backend/PartKeepr/Setup/Migration/PartDB/FootprintMigration.php | 6+++---
Msrc/backend/PartKeepr/Setup/Migration/PartDB/PartCategoryMigration.php | 4++--
Msrc/backend/PartKeepr/Setup/Migration/PartDB/PartMigration.php | 4++--
Msrc/backend/PartKeepr/Setup/PartCategorySetup.php | 4++--
Msrc/backend/PartKeepr/Statistic/StatisticService.php | 2+-
Msrc/backend/PartKeepr/Statistic/StatisticSnapshotManager.php | 2+-
Mtesting/SetupDatabase.php | 2+-
Mtests/Part/PartServiceTest.php | 2+-
Mtests/bootstrap.php | 2+-
113 files changed, 1452 insertions(+), 2147 deletions(-)

diff --git a/app/SymfonyRequirements.php b/app/SymfonyRequirements.php @@ -41,25 +41,25 @@ class Requirement /** * Constructor that initializes the requirement. * - * @param Boolean $fulfilled Whether the requirement is fulfilled + * @param bool $fulfilled Whether the requirement is fulfilled * @param string $testMessage The message for testing the requirement * @param string $helpHtml The help text formatted in HTML for resolving the problem * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement + * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement */ public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) { - $this->fulfilled = (Boolean) $fulfilled; + $this->fulfilled = (bool) $fulfilled; $this->testMessage = (string) $testMessage; $this->helpHtml = (string) $helpHtml; $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; - $this->optional = (Boolean) $optional; + $this->optional = (bool) $optional; } /** * Returns whether the requirement is fulfilled. * - * @return Boolean true if fulfilled, otherwise false + * @return bool true if fulfilled, otherwise false */ public function isFulfilled() { @@ -99,7 +99,7 @@ class Requirement /** * Returns whether this is only an optional recommendation and not a mandatory requirement. * - * @return Boolean true if optional, false if mandatory + * @return bool true if optional, false if mandatory */ public function isOptional() { @@ -117,16 +117,16 @@ class PhpIniRequirement extends Requirement /** * Constructor that initializes the requirement. * - * @param string $cfgName The configuration name used for ini_get() - * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, - * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) - * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement + * @param string $cfgName The configuration name used for ini_get() + * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, + * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) + * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement */ public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) { @@ -193,7 +193,7 @@ class RequirementCollection implements IteratorAggregate /** * Adds a mandatory requirement. * - * @param Boolean $fulfilled Whether the requirement is fulfilled + * @param bool $fulfilled Whether the requirement is fulfilled * @param string $testMessage The message for testing the requirement * @param string $helpHtml The help text formatted in HTML for resolving the problem * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) @@ -206,7 +206,7 @@ class RequirementCollection implements IteratorAggregate /** * Adds an optional recommendation. * - * @param Boolean $fulfilled Whether the recommendation is fulfilled + * @param bool $fulfilled Whether the recommendation is fulfilled * @param string $testMessage The message for testing the recommendation * @param string $helpHtml The help text formatted in HTML for resolving the problem * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) @@ -219,15 +219,15 @@ class RequirementCollection implements IteratorAggregate /** * Adds a mandatory requirement in form of a php.ini configuration. * - * @param string $cfgName The configuration name used for ini_get() - * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, - * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) - * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param string $cfgName The configuration name used for ini_get() + * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, + * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) + * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) */ public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) { @@ -237,15 +237,15 @@ class RequirementCollection implements IteratorAggregate /** * Adds an optional recommendation in form of a php.ini configuration. * - * @param string $cfgName The configuration name used for ini_get() - * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, - * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) - * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param string $cfgName The configuration name used for ini_get() + * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, + * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) + * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) */ public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) { @@ -343,7 +343,7 @@ class RequirementCollection implements IteratorAggregate /** * Returns whether a php.ini configuration is not correct. * - * @return Boolean php.ini configuration problem? + * @return bool php.ini configuration problem? */ public function hasPhpIniConfigIssue() { @@ -405,22 +405,24 @@ class SymfonyRequirements extends RequirementCollection $this->addRequirement( is_dir(__DIR__.'/../vendor/composer'), 'Vendor libraries must be installed', - 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' . + 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '. 'Then run "<strong>php composer.phar install</strong>" to install them.' ); - $baseDir = basename(__DIR__); + $cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache'; $this->addRequirement( - is_writable(__DIR__.'/cache'), - "$baseDir/cache/ directory must be writable", - "Change the permissions of the \"<strong>$baseDir/cache/</strong>\" directory so that the web server can write into it." + is_writable($cacheDir), + 'app/cache/ or var/cache/ directory must be writable', + 'Change the permissions of either "<strong>app/cache/</strong>" or "<strong>var/cache/</strong>" directory so that the web server can write into it.' ); + $logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs'; + $this->addRequirement( - is_writable(__DIR__.'/logs'), - "$baseDir/logs/ directory must be writable", - "Change the permissions of the \"<strong>$baseDir/logs/</strong>\" directory so that the web server can write into it." + is_writable($logsDir), + 'app/logs/ or var/logs/ directory must be writable', + 'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.' ); $this->addPhpIniRequirement( @@ -438,8 +440,8 @@ class SymfonyRequirements extends RequirementCollection } $this->addRequirement( - isset($timezones[date_default_timezone_get()]), - sprintf('Configured default timezone "%s" must be supported by your installation of PHP', date_default_timezone_get()), + isset($timezones[@date_default_timezone_get()]), + sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), 'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.' ); } @@ -528,6 +530,16 @@ class SymfonyRequirements extends RequirementCollection 'Install the <strong>PCRE</strong> extension (version 8.0+).' ); + if (extension_loaded('mbstring')) { + $this->addPhpIniRequirement( + 'mbstring.func_overload', + create_function('$cfgValue', 'return (int) $cfgValue === 0;'), + true, + 'string functions should not be overloaded', + 'Set "<strong>mbstring.func_overload</strong>" to <strong>0</strong> in php.ini<a href="#phpini">*</a> to disable function overloading by the mbstring extension.' + ); + } + /* optional recommendations follow */ if (file_exists(__DIR__.'/../vendor/composer')) { @@ -611,6 +623,12 @@ class SymfonyRequirements extends RequirementCollection 'Install and enable the <strong>XML</strong> extension.' ); + $this->addRecommendation( + function_exists('filter_var'), + 'filter_var() should be available', + 'Install and enable the <strong>filter</strong> extension.' + ); + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { $this->addRecommendation( function_exists('posix_isatty'), @@ -667,6 +685,8 @@ class SymfonyRequirements extends RequirementCollection || (extension_loaded('apc') && ini_get('apc.enabled')) || + (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) + || (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) || (extension_loaded('xcache') && ini_get('xcache.cacher')) @@ -677,9 +697,17 @@ class SymfonyRequirements extends RequirementCollection $this->addRecommendation( $accelerator, 'a PHP accelerator should be installed', - 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).' + 'Install and/or enable a <strong>PHP accelerator</strong> (highly recommended).' ); + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $this->addRecommendation( + $this->getRealpathCacheSize() > 1000, + 'realpath_cache_size should be above 1024 in php.ini', + 'Set "<strong>realpath_cache_size</strong>" to e.g. "<strong>1024</strong>" in php.ini<a href="#phpini">*</a> to improve performance on windows.' + ); + } + $this->addPhpIniRecommendation('short_open_tag', false); $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); @@ -697,10 +725,34 @@ class SymfonyRequirements extends RequirementCollection if (class_exists('PDO')) { $drivers = PDO::getAvailableDrivers(); $this->addRecommendation( - count($drivers), + count($drivers) > 0, sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 'Install <strong>PDO drivers</strong> (mandatory for Doctrine).' ); } } + + /** + * Loads realpath_cache_size from php.ini and converts it to int. + * + * (e.g. 16k is converted to 16384 int) + * + * @return int + */ + protected function getRealpathCacheSize() + { + $size = ini_get('realpath_cache_size'); + $size = trim($size); + $unit = strtolower(substr($size, -1, 1)); + switch ($unit) { + case 'g': + return $size * 1024 * 1024 * 1024; + case 'm': + return $size * 1024 * 1024; + case 'k': + return $size * 1024; + default: + return (int) $size; + } + } } diff --git a/app/check.php b/app/check.php @@ -2,61 +2,141 @@ require_once dirname(__FILE__).'/SymfonyRequirements.php'; +$lineSize = 70; $symfonyRequirements = new SymfonyRequirements(); - $iniPath = $symfonyRequirements->getPhpIniConfigPath(); -echo "********************************\n"; -echo "* *\n"; -echo "* Symfony requirements check *\n"; -echo "* *\n"; -echo "********************************\n\n"; - -echo $iniPath ? sprintf("* Configuration file used by PHP: %s\n\n", $iniPath) : "* WARNING: No configuration file (php.ini) used by PHP!\n\n"; +echo_title('Symfony2 Requirements Checker'); -echo "** ATTENTION **\n"; -echo "* The PHP CLI can use a different php.ini file\n"; -echo "* than the one used with your web server.\n"; -if ('\\' == DIRECTORY_SEPARATOR) { - echo "* (especially on the Windows platform)\n"; +echo '> PHP is using the following php.ini file:'.PHP_EOL; +if ($iniPath) { + echo_style('green', ' '.$iniPath); +} else { + echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!'); } -echo "* To be on the safe side, please also launch the requirements check\n"; -echo "* from your web server using the web/config.php script.\n"; -echo_title('Mandatory requirements'); +echo PHP_EOL.PHP_EOL; + +echo '> Checking Symfony requirements:'.PHP_EOL.' '; -$checkPassed = true; +$messages = array(); foreach ($symfonyRequirements->getRequirements() as $req) { /** @var $req Requirement */ - echo_requirement($req); - if (!$req->isFulfilled()) { - $checkPassed = false; + if ($helpText = get_error_message($req, $lineSize)) { + echo_style('red', 'E'); + $messages['error'][] = $helpText; + } else { + echo_style('green', '.'); } } -echo_title('Optional recommendations'); +$checkPassed = empty($messages['error']); foreach ($symfonyRequirements->getRecommendations() as $req) { - echo_requirement($req); + if ($helpText = get_error_message($req, $lineSize)) { + echo_style('yellow', 'W'); + $messages['warning'][] = $helpText; + } else { + echo_style('green', '.'); + } +} + +if ($checkPassed) { + echo_block('success', 'OK', 'Your system is ready to run Symfony2 projects', true); +} else { + echo_block('error', 'ERROR', 'Your system is not ready to run Symfony2 projects', true); + + echo_title('Fix the following mandatory requirements', 'red'); + + foreach ($messages['error'] as $helpText) { + echo ' * '.$helpText.PHP_EOL; + } } +if (!empty($messages['warning'])) { + echo_title('Optional recommendations to improve your setup', 'yellow'); + + foreach ($messages['warning'] as $helpText) { + echo ' * '.$helpText.PHP_EOL; + } +} + +echo PHP_EOL; +echo_style('title', 'Note'); +echo ' The command console could use a different php.ini file'.PHP_EOL; +echo_style('title', '~~~~'); +echo ' than the one used with your web server. To be on the'.PHP_EOL; +echo ' safe side, please check the requirements from your web'.PHP_EOL; +echo ' server using the '; +echo_style('yellow', 'web/config.php'); +echo ' script.'.PHP_EOL; +echo PHP_EOL; + exit($checkPassed ? 0 : 1); -/** - * Prints a Requirement instance - */ -function echo_requirement(Requirement $requirement) +function get_error_message(Requirement $requirement, $lineSize) { - $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR'); - echo ' ' . str_pad($result, 9); - echo $requirement->getTestMessage() . "\n"; - - if (!$requirement->isFulfilled()) { - echo sprintf(" %s\n\n", $requirement->getHelpText()); + if ($requirement->isFulfilled()) { + return; } + + $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL; + $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL; + + return $errorMessage; } -function echo_title($title) +function echo_title($title, $style = null) { - echo "\n** $title **\n\n"; + $style = $style ?: 'title'; + + echo PHP_EOL; + echo_style($style, $title.PHP_EOL); + echo_style($style, str_repeat('~', strlen($title)).PHP_EOL); + echo PHP_EOL; +} + +function echo_style($style, $message) +{ + // ANSI color codes + $styles = array( + 'reset' => "\033[0m", + 'red' => "\033[31m", + 'green' => "\033[32m", + 'yellow' => "\033[33m", + 'error' => "\033[37;41m", + 'success' => "\033[37;42m", + 'title' => "\033[34m", + ); + $supports = has_color_support(); + + echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : ''); +} + +function echo_block($style, $title, $message) +{ + $message = ' '.trim($message).' '; + $width = strlen($message); + + echo PHP_EOL.PHP_EOL; + + echo_style($style, str_repeat(' ', $width).PHP_EOL); + echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL); + echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL); + echo_style($style, str_repeat(' ', $width).PHP_EOL); +} + +function has_color_support() +{ + static $support; + + if (null === $support) { + if (DIRECTORY_SEPARATOR == '\\') { + $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); + } else { + $support = function_exists('posix_isatty') && @posix_isatty(STDOUT); + } + } + + return $support; } diff --git a/app/config/routing.yml b/app/config/routing.yml @@ -1,3 +1,13 @@ +part_keepr_part: + resource: "@PartKeeprPartBundle/Controller/" + type: annotation + prefix: / + +part_keepr_footprint: + resource: "@PartKeeprFootprintBundle/Controller/" + type: annotation + prefix: / + part_keepr_unit: resource: "@PartKeeprUnitBundle/Controller/" type: annotation diff --git a/scripts/UpdateCategoryPathCache.php b/scripts/UpdateCategoryPathCache.php @@ -7,9 +7,9 @@ namespace PartKeepr\Scripts; use PartKeepr\PartKeepr, - PartKeepr\PartCategory\PartCategoryManager, + \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\Util\Configuration, - PartKeepr\FootprintCategory\FootprintCategoryManager; + \PartKeepr\FootprintBundle\Entity\FootprintCategoryManager; include("../src/backend/PartKeepr/PartKeepr.php"); diff --git a/src/PartKeepr/DoctrineReflectionBundle/Controller/DoctrineRESTTreeController.php b/src/PartKeepr/DoctrineReflectionBundle/Controller/DoctrineRESTTreeController.php @@ -0,0 +1,8 @@ +<?php +namespace PartKeepr\DoctrineReflectionBundle\Controller; + + +class DoctrineRESTTreeController +{ + +}+ \ No newline at end of file diff --git a/src/PartKeepr/DoctrineReflectionBundle/Resources/views/model.js.twig b/src/PartKeepr/DoctrineReflectionBundle/Resources/views/model.js.twig @@ -23,6 +23,6 @@ Ext.define('{{ className }}', { proxy: { type: "PartKeeprREST", - url: '{{ uri|raw }}' + url: '{% if uri == "" %}undefined:{{ className }}{% else %}{{ uri|raw }}{% endif %}' } }); \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Controller/FootprintCategoryController.php b/src/PartKeepr/FootprintBundle/Controller/FootprintCategoryController.php @@ -0,0 +1,23 @@ +<?php +namespace PartKeepr\FootprintBundle\Controller; + + +use DoctrineExtensions\NestedSet\Config; +use FOS\RestBundle\Controller\FOSRestController; +use Symfony\Component\Routing\Annotation\Route; + +class FootprintCategoryController extends FOSRestController +{ + /** + * @Route("/FootprintCategory/getAll", defaults={"method" = "get","_format" = "json"}) + */ + public function getAllAction() + { + $repository = $this->get("doctrine")->getEntityManager()->getRepository('PartKeepr\FootprintBundle\Entity\FootprintCategory'); + + var_dump($repository->verify()); + $repository->recover(); + $this->get("doctrine")->getEntityManager()->flush(); + return $repository->childrenHierarchy(); + } +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Controller/FootprintController.php b/src/PartKeepr/FootprintBundle/Controller/FootprintController.php @@ -0,0 +1,87 @@ +<?php + +namespace PartKeepr\FootprintBundle\Controller; + +use FOS\RestBundle\Request\ParamFetcher; +use PartKeepr\DoctrineReflectionBundle\Controller\DoctrineRESTQueryController; +use Sensio\Bundle\FrameworkExtraBundle\Configuration as Routing; +use JMS\Serializer\Annotation as JMS; +use Nelmio\ApiDocBundle\Annotation\ApiDoc; +use FOS\RestBundle\Controller\Annotations\View; +use Symfony\Component\HttpFoundation\Request; + +class FootprintController extends DoctrineRESTQueryController +{ + protected $targetEntity = "PartKeepr\\FootprintBundle\\Entity\\Footprint"; + + /** + * Retrieves footprint + * + * @Routing\Route("/footprint", defaults={"method" = "get","_format" = "json"}) + * @Routing\Method({"GET"}) + * @ApiDoc(section="footprint",output="array<PartKeepr\FootprintBundle\Entity\Footprint>") + * + * @View() + * + * {@inheritdoc} + */ + public function listAction(ParamFetcher $paramFetcher) + { + return parent::listAction($paramFetcher); + } + + /** + * Retrieves a single footprint + * + * @Routing\Route("/footprint/{id}", defaults={"method" = "get","_format" = "json"}) + * @Routing\Method({"GET"}) + * @ApiDoc(section="footprint",output="PartKeepr\FootprintBundle\Entity\Footprint") + * @View() + */ + public function getAction($id) + { + return parent::getAction($id); + } + + /** + * Saves a single footprint + * + * @Routing\Route("/footprint/{id}", defaults={"_format" = "json"}) + * @Routing\Method({"PUT"}) + * @ApiDoc(section="footprint",input="PartKeepr\FootprintBundle\Entity\Footprint",output="PartKeepr\FootprintBundle\Entity\Footprint") + * + * @View() + */ + public function putAction(Request $request, $id) + { + return parent::putAction($request, $id); + } + + /** + * Creates a single footprint + * + * @Routing\Route("/footprint", defaults={"_format" = "json"}) + * @Routing\Method({"POST"}) + * @ApiDoc(section="footprint",input="PartKeepr\FootprintBundle\Entity\Footprint",output="PartKeepr\FootprintBundle\Entity\Footprint") + * + * @View() + */ + public function postAction(Request $request) + { + return parent::postAction($request); + } + + /** + * Deletes a single footprint + * + * @Routing\Route("/footprint/{id}", defaults={"_format" = "json"}) + * @Routing\Method({"DELETE"}) + * @ApiDoc(section="footprint") + * + * @View() + */ + public function deleteAction($id) + { + return parent::deleteAction($id); + } +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/DependencyInjection/Configuration.php b/src/PartKeepr/FootprintBundle/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +<?php + +namespace PartKeepr\FootprintBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +/** + * This is the class that validates and merges configuration from your app/config files + * + * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} + */ +class Configuration implements ConfigurationInterface +{ + /** + * {@inheritdoc} + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('part_keepr_footprint'); + + // Here you should define the parameters that are allowed to + // configure your bundle. See the documentation linked above for + // more information on that topic. + + return $treeBuilder; + } +} diff --git a/src/PartKeepr/FootprintBundle/DependencyInjection/PartKeeprFootprintExtension.php b/src/PartKeepr/FootprintBundle/DependencyInjection/PartKeeprFootprintExtension.php @@ -0,0 +1,28 @@ +<?php + +namespace PartKeepr\FootprintBundle\DependencyInjection; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Loader; + +/** + * This is the class that loads and manages your bundle configuration + * + * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} + */ +class PartKeeprFootprintExtension extends Extension +{ + /** + * {@inheritdoc} + */ + public function load(array $configs, ContainerBuilder $container) + { + $configuration = new Configuration(); + $config = $this->processConfiguration($configuration, $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/PartKeepr/FootprintBundle/Entity/Footprint.php b/src/PartKeepr/FootprintBundle/Entity/Footprint.php @@ -0,0 +1,202 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; +use JMS\Serializer\Annotation\ExclusionPolicy; +use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; +use PartKeepr\Util\Deserializable; + +use PartKeepr\Util\Serializable; +use PartKeepr\FootprintBundle\Entity\FootprintCategory; +use PartKeepr\Util\BaseEntity; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity + * @TargetService(uri="/footprint") + * @ExclusionPolicy("none") + */ + +class Footprint extends BaseEntity implements Serializable, Deserializable { + /** + * Holds the footprint name + * @ORM\Column(length=64,unique=true) + * @var string + */ + private $name; + + /** + * Holds the footprint description + * @ORM\Column(type="text",nullable=true) + * @var string + */ + private $description; + + /** + * The category of the footprint + * @ORM\ManyToOne(targetEntity="PartKeepr\FootprintBundle\Entity\FootprintCategory") + * @var Category + */ + private $category; + + /** + * Holds the footprint image + * @ORM\OneToOne(targetEntity="PartKeepr\FootprintBundle\Entity\FootprintImage",mappedBy="footprint",cascade={"persist", "remove"}) + * + * @var FootprintImage + */ + private $image; + + /** + * Holds the footprint attachments + * @ORM\OneToMany(targetEntity="PartKeepr\FootprintBundle\Entity\FootprintAttachment",mappedBy="footprint",cascade={"persist", "remove"}) + * + * @var FootprintAttachment + */ + private $attachments; + + /** + * Constructs a new Footprint entity + */ + public function __construct () { + $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Sets the name of this footprint + * + * @param string $name The footprint name + */ + public function setName ($name) { + $this->name = $name; + } + + /** + * Returns the name of this footprint + * @return string The name of this footprint + */ + public function getName () { + return $this->name; + } + + /** + * Sets the description of this footprint + * @param string $description The description + */ + public function setDescription ($description) { + $this->description = $description; + } + + /** + * Returns the description of this footprint + * @return string The description + */ + public function getDescription () { + return $this->description; + } + + /** + * Sets the category for this footprint + * +*@param \PartKeepr\FootprintBundle\Entity\FootprintCategory $category The category + */ + public function setCategory (FootprintCategory $category) { + $this->category = $category; + } + + /** + * Returns the category of this footprint + * @return FootprintCategory The footprint category + */ + public function getCategory () { + return $this->category; + } + + /** + * Sets the footprint image + * @param FootprintImage $image The footprint image + */ + public function setImage (FootprintImage $image) { + $this->image = $image; + $image->setFootprint($this); + } + + /** + * Returns the footprint image + * @return FootprintImage The footprint image + */ + public function getImage () { + return $this->image; + } + + /** + * Returns the attachments for this footprint + * @return ArrayCollection The attachments + */ + public function getAttachments () { + return $this->attachments; + } + + /** + * Serializes the footprint + * @return array the serialized footprint + */ + public function serialize () { + return array( + "id" => $this->getId(), + "name" => $this->getName(), + "description" => $this->getDescription(), + "image_id" => is_object($this->getImage()) ? $this->getImage()->getId() : null, + "category" => is_object($this->getCategory()) ? $this->getCategory()->getId() : null, + "attachments" => $this->serializeChildren($this->getAttachments()) + ); + } + + /** + * Deserializes the footprint + * @param array $parameters The array with the parameters to set + */ + public function deserialize (array $parameters) { + foreach ($parameters as $key => $value) { + switch ($key) { + case "name": + $this->setName($value); + break; + case "description": + $this->setDescription($value); + break; + case "image_id": + if ($value == "") { + echo "/** Breaking because of empty value */"; + break; } + + try { + $image = FootprintImage::loadById($value); + $this->setImage($image); + } catch (\Exception $e) { + if ($this->getImage()) { + // Image was not found, maybe a temporary image? + $this->getImage()->replaceFromTemporaryFile($value); + } else { + $image = FootprintImage::createFromTemporaryFile($value); + $this->setImage($image); + } + } + + break; + case "category": + try { + $category = FootprintCategory::loadById($value); + $this->setCategory($category); + } catch (\Exception $e) { + // Category was not found, do not change category. + } + break; + case "attachments": + $this->deserializeChildren($value, $this->getAttachments(), "PartKeepr\Footprint\FootprintAttachment"); + foreach ($this->getAttachments() as $attachment) { + $attachment->setFootprint($this); + } + break; + } + } + } +} diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintAttachment.php b/src/PartKeepr/FootprintBundle/Entity/FootprintAttachment.php @@ -0,0 +1,103 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\Util\Deserializable, + PartKeepr\Util\Serializable, + PartKeepr\UploadedFile\UploadedFile, + Doctrine\ORM\Mapping as ORM; + +/** + * Holds a footprint attachment + * @ORM\Entity + **/ +class FootprintAttachment extends UploadedFile implements Serializable, Deserializable { + /** + * The description of this attachment + * @ORM\Column(type="text") + * @var string + */ + private $description; + + /** + * Creates a new footprint attachment + */ + public function __construct () { + parent::__construct(); + $this->setType("FootprintAttachment"); + } + /** + * The footprint object + * @ORM\ManyToOne(targetEntity="PartKeepr\FootprintBundle\Entity\Footprint",inversedBy="attachments") + * + * @var Footprint + */ + private $footprint = null; + + /** + * Sets the footprint + * @param Footprint $footprint The footprint to set + */ + public function setFootprint (Footprint $footprint) { + $this->footprint = $footprint; + } + + /** + * Returns the footprint + * @return Footprint the footprint + */ + public function getFootprint () { + return $this->footprint; + } + + /** + * Sets the description for this attachment + * @param string $description The attachment description + */ + public function setDescription ($description) { + $this->description = $description; + } + + /** + * Returns the description for this attachment + * @return string The description + */ + public function getDescription () { + return $this->description; + } + + /** + * + * Serializes this footprint attachment + * @return array The serialized footprint attachment + */ + public function serialize () { + return array( + "id" => $this->getId(), + "footprint_id" => $this->getFootprint()->getId(), + "originalFilename" => $this->getOriginalFilename(), + "mimetype" => $this->getMimetype(), + "extension" => $this->getExtension(), + "size" => $this->getSize(), + "description" => $this->getDescription()); + } + + /** + * Deserializes the footprint attachment + * @param array $parameters The array with the parameters to set + */ + public function deserialize (array $parameters) { + if (array_key_exists("id", $parameters)) { + if (substr($parameters["id"], 0, 4) === "TMP:") { + $this->replaceFromTemporaryFile($parameters["id"]); + } + } + + foreach ($parameters as $key => $value) { + switch ($key) { + case "description": + $this->setDescription($value); + break; + } + } + } +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintCategory.php b/src/PartKeepr/FootprintBundle/Entity/FootprintCategory.php @@ -0,0 +1,30 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\Category\AbstractCategory, + Doctrine\ORM\Mapping as ORM, + Doctrine\ORM\Mapping\Table, + Doctrine\ORM\Mapping\Index; +use Gedmo\Mapping\Annotation as Gedmo; + +/** + * @ORM\Entity(repositoryClass="PartKeepr\FootprintBundle\Entity\Repository\FootprintCategoryRepository") + * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) + * The entity for our footprint categories + * + */ +class FootprintCategory extends AbstractCategory { + /** + * @ORM\ManyToOne(targetEntity="FootprintCategory", inversedBy="children") + * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE") + * + * @Gedmo\TreeParent + * @var int + */ + private $parent; + + /** + * @ORM\OneToMany(targetEntity="FootprintCategory", mappedBy="parent") + */ + private $children; +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintCategoryManager.php b/src/PartKeepr/FootprintBundle/Entity/FootprintCategoryManager.php @@ -0,0 +1,42 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\Category\AbstractCategoryManager; +use DoctrineExtensions\NestedSet\NodeWrapper; +use PartKeepr\Util\SerializableException; +use PartKeepr\PartKeepr; + +class FootprintCategoryManager extends AbstractCategoryManager { + protected $categoryClass = "PartKeepr\FootprintBundle\Entity\FootprintCategory"; + + /** + * Deletes the given category ID. + * @param $id int The category id to delete + * @throws CategoryNotFoundException If the category wasn't found + */ + public function deleteCategory ($id) { + $category = $this->getCategory($id); + + try { + + if ($category->hasChildren()) { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains other categories."), $category->getNode()->getName())); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains other categories. Please move the categories or delete them first."), $category->getNode()->getName())); + + throw $exception; + } + + parent::deleteCategory($id); + } catch (\PDOException $e) { + if ($e->getCode() == "23000") { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains footprints."), $category->getNode()->getName())); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains footprints. Please move the footprints to another category."), $category->getNode()->getName())); + + throw $exception; + } else { + throw $e; + } + } + } + +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintCategoryService.php b/src/PartKeepr/FootprintBundle/Entity/FootprintCategoryService.php @@ -0,0 +1,9 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\Category\AbstractCategoryService; + +class FootprintCategoryService extends AbstractCategoryService { + protected $categoryManagerClass = "PartKeepr\FootprintBundle\Entity\FootprintCategoryManager"; + protected $categoryClass = "PartKeepr\FootprintBundle\Entity\FootprintCategory"; +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintImage.php b/src/PartKeepr/FootprintBundle/Entity/FootprintImage.php @@ -0,0 +1,52 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\Util\Serializable, + PartKeepr\Image\Image, + Doctrine\ORM\Mapping as ORM; + +/** + * Holds a footprint image + * @ORM\Entity + **/ +class FootprintImage extends Image implements Serializable { + /** + * The footprint object + * @ORM\OneToOne(targetEntity="PartKeepr\FootprintBundle\Entity\Footprint",inversedBy="image") + * + * @var Footprint + */ + private $footprint = null; + + /** + * Creates a new IC logo instance + */ + public function __construct () { + parent::__construct(Image::IMAGE_FOOTPRINT); + } + + /** + * Sets the footprint + * @param Footprint $footprint The footprint to set + */ + public function setFootprint (Footprint $footprint) { + $this->footprint = $footprint; + } + + /** + * Returns the footprint + * @return Footprint the footprint + */ + public function getFootprint () { + return $this->footprint; + } + + /** + * + * Serializes this ic logo + * @return array The serialized ic logo + */ + public function serialize () { + return array("id" => $this->getId(), "footprint_id" => $this->getFootprint()->getId()); + } +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintManager.php b/src/PartKeepr/FootprintBundle/Entity/FootprintManager.php @@ -0,0 +1,158 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\Util\Singleton, + PartKeepr\Util\SerializableException, + \PartKeepr\FootprintBundle\Entity\Footprint, + PartKeepr\PartKeepr, + PartKeepr\Util\Exceptions\EntityNotFoundException; + +class FootprintManager extends Singleton { + /** + * Returns a list of footprints. + * + * @param int $start Start of the list, default 0 + * @param int $limit Number of users to list, default 10 + * @param string $sort The field to sort by, default "name" + * @param string $dir The direction to sort (ASC or DESC), default ASC + * @param string $filter A string to filter the footprint's name by, default empty + */ + public function getFootprints ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { + + $qb = PartKeepr::getEM()->createQueryBuilder(); + $qb->select("f.id, f.name, f.description, im.id AS image_id, ca.id AS category")->from("PartKeepr\Footprint\Footprint","f") + ->leftJoin("f.image", "im") + ->leftJoin("f.category", "ca"); + + if ($filter != "") { + $qb = $qb->where("LOWER(f.name) LIKE :filter"); + $qb->setParameter("filter", "%".strtolower($filter)."%"); + } + + if ($limit > -1) { + $qb->setMaxResults($limit); + $qb->setFirstResult($start); + } + + $qb->orderBy("f.".$sort, $dir); + + $query = $qb->getQuery(); + + $result = $query->getResult(); + + $totalQueryBuilder = PartKeepr::getEM()->createQueryBuilder(); + $totalQueryBuilder->select("COUNT(f.id)")->from("PartKeepr\Footprint\Footprint","f")->leftJoin("f.image", "im"); + + + + if ($filter != "") { + $totalQueryBuilder = $totalQueryBuilder->where("LOWER(f.name) LIKE :filter"); + $totalQueryBuilder->setParameter("filter", "%".strtolower($filter)."%"); + } + + $totalQuery = $totalQueryBuilder->getQuery(); + + return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); + } + + /** + * Creates a new footprint + * + * @param string $footprint The footprint's name + * @throws \PartKeepr\Util\SerializableException + * @throws PDOException + */ + public function addFootprint ($name) { + $fp = new Footprint(); + $fp->setName($name); + + // @todo Port the UniqueEntityValidator from Symfony2 to here. + try { + PartKeepr::getEM()->persist($fp); + PartKeepr::getEM()->flush(); + } catch (\PDOException $e) { + if ($e->getCode() == "23000") { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s already exists!"), $name)); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to add the footprint %s, but a footprint with the same name already exists."), $name)); + + throw $exception; + } else { + throw $e; + } + } + + return $fp; + } + + /** + * Deletes the footprint with the given id. + * + * @param int $id The footprint id to delete + * @throws \PartKeepr\Util\SerializableException + */ + public function deleteFootprint ($id) { + $footprint = Footprint::loadById($id); + + try { + PartKeepr::getEM()->remove($footprint); + PartKeepr::getEM()->flush(); + } catch (\PDOException $e) { + if ($e->getCode() == "23000") { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s is in use by some parts!"), $footprint->getName())); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the footprint %s, but there are parts which use this footprint."), $footprint->getName())); + + throw $exception; + } + } + } + + /** + * Loads a footprint by id + * @param int $id The footprint id + */ + public function getFootprint ($id) { + return Footprint::loadById($id); + } + + /** + * Finds or creates a footprint by name. + * + * @param mixed $footprint Either the ID or the footprint's name to find + */ + public function getOrCreateFootprint ($footprint) { + try { + $footprint = Footprint::loadById($footprint); + return $footprint; + } catch (EntityNotFoundException $e) {} + + $dql = "SELECT f FROM PartKeepr\Footprint\Footprint f WHERE f.name = :name"; + $query = PartKeepr::getEM()->createQuery($dql); + $query->setParameter("name", $footprint); + + try { + $footprint = $query->getSingleResult(); + return $footprint; + } catch (\Exception $e) {} + + $fp = new Footprint(); + $fp->setName($footprint); + + PartKeepr::getEM()->persist($fp); + + return $fp; + } + + /** + * Retrieves a distributor by its name. + * + * @param string $name The name of the distributor to retrieve + * @throws Doctrine\ORM\NoResultException If the distributor was not found + */ + public function getFootprintByName ($name) { + $dql = "SELECT fp FROM PartKeepr\Footprint\Footprint fp WHERE fp.name = :name"; + $query = PartKeepr::getEM()->createQuery($dql); + $query->setParameter("name", $name); + + return $query->getSingleResult(); + } +} diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintService.php b/src/PartKeepr/FootprintBundle/Entity/FootprintService.php @@ -0,0 +1,96 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity; + +use PartKeepr\TempImage\TempImage, + \PartKeepr\FootprintBundle\Entity\FootprintCategory, + PartKeepr\Service\Service, + PartKeepr\Service\RestfulService, + PartKeepr\PartKeepr, + \PartKeepr\FootprintBundle\Entity\FootprintManager; + +class FootprintService extends Service implements RestfulService { + /** + * (non-PHPdoc) + * @see PartKeepr\Service.RestfulService::get() + */ + public function get () { + if ($this->hasParameter("id")) { + return array("data" => FootprintManager::getInstance()->getFootprint($this->getParameter("id"))->serialize()); + } else { + if ($this->hasParameter("sort")) { + $tmp = json_decode($this->getParameter("sort"), true); + + $aSortParams = $tmp[0]; + } else { + $aSortParams = array( + "property" => "name", + "direction" => "ASC"); + } + return FootprintManager::getInstance()->getFootprints( + $this->getParameter("start", $this->getParameter("start", 0)), + $this->getParameter("limit", $this->getParameter("limit", 25)), + $this->getParameter("sortby", $aSortParams["property"]), + $this->getParameter("dir", $aSortParams["direction"]), + $this->getParameter("query", "")); + } + } + + /** + * (non-PHPdoc) + * @see PartKeepr\Service.RestfulService::create() + */ + public function create () { + $this->requireParameter("name"); + + $footprint = new Footprint(); + $footprint->deserialize($this->getParameters()); + + PartKeepr::getEM()->persist($footprint); + + PartKeepr::getEM()->flush(); + + return array("data" => $footprint->serialize()); + } + + /** + * (non-PHPdoc) + * @see PartKeepr\Service.RestfulService::update() + */ + public function update () { + $this->requireParameter("id"); + $this->requireParameter("name"); + $footprint = Footprint::loadById($this->getParameter("id")); + + $footprint->deserialize($this->getParameters()); + + PartKeepr::getEM()->flush(); + + return array("data" => $footprint->serialize()); + + } + + /** + * (non-PHPdoc) + * @see PartKeepr\Service.RestfulService::destroy() + */ + public function destroy () { + $this->requireParameter("id"); + + FootprintManager::getInstance()->deleteFootprint($this->getParameter("id")); + + return array("data" => null); + } + + public function moveFootprint () { + $this->requireParameter("targetCategory"); + $this->requireParameter("id"); + + $footprint = Footprint::loadById($this->getParameter("id")); + $category = FootprintCategory::loadById($this->getParameter("targetCategory")); + + $footprint->setCategory($category); + + PartKeepr::getEM()->flush(); + } + +} diff --git a/src/PartKeepr/FootprintBundle/Entity/Repository/FootprintCategoryRepository.php b/src/PartKeepr/FootprintBundle/Entity/Repository/FootprintCategoryRepository.php @@ -0,0 +1,8 @@ +<?php +namespace PartKeepr\FootprintBundle\Entity\Repository; + +use Gedmo\Tree\Entity\Repository\NestedTreeRepository; + +class FootprintCategoryRepository extends NestedTreeRepository +{ +}+ \ No newline at end of file diff --git a/src/PartKeepr/FootprintBundle/PartKeeprFootprintBundle.php b/src/PartKeepr/FootprintBundle/PartKeeprFootprintBundle.php @@ -0,0 +1,9 @@ +<?php + +namespace PartKeepr\FootprintBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class PartKeeprFootprintBundle extends Bundle +{ +} diff --git a/src/PartKeepr/FootprintBundle/Resources/config/services.xml b/src/PartKeepr/FootprintBundle/Resources/config/services.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" ?> + +<container xmlns="http://symfony.com/schema/dic/services" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + + <!-- + <services> + <service id="part_keepr_footprint.example" class="PartKeepr\FootprintBundle\Example"> + <argument type="service" id="service_id" /> + <argument>plain_value</argument> + <argument>%parameter_name%</argument> + </service> + </services> + --> +</container> diff --git a/src/PartKeepr/FootprintBundle/Resources/views/Default/index.html.twig b/src/PartKeepr/FootprintBundle/Resources/views/Default/index.html.twig @@ -0,0 +1 @@ +Hello {{ name }}! diff --git a/src/PartKeepr/FootprintBundle/Tests/Controller/DefaultControllerTest.php b/src/PartKeepr/FootprintBundle/Tests/Controller/DefaultControllerTest.php @@ -0,0 +1,17 @@ +<?php + +namespace PartKeepr\FootprintBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +class DefaultControllerTest extends WebTestCase +{ + public function testIndex() + { + $client = static::createClient(); + + $crawler = $client->request('GET', '/hello/Fabien'); + + $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0); + } +} diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js @@ -4,10 +4,9 @@ Ext.define('PartKeepr.FootprintEditorComponent', { navigationClass: 'PartKeepr.FootprintTree', editorClass: 'PartKeepr.FootprintEditor', newItemText: i18n("New Footprint"), - model: 'PartKeepr.Footprint', + model: 'PartKeepr.FootprintBundle.Entity.Footprint', initComponent: function () { this.createStore({ - proxy: PartKeepr.getRESTProxy("Footprint"), sorters: [{ property: 'name', direction:'ASC' @@ -15,7 +14,6 @@ Ext.define('PartKeepr.FootprintEditorComponent', { }); this.callParent(); - }, deleteRecord: function (r) { var editor = this.findEditor(r.get("id")); @@ -34,7 +32,5 @@ Ext.define('PartKeepr.FootprintEditorComponent', { }, this)); call.doCall(); - - } }); \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditor.js @@ -1,102 +0,0 @@ -Ext.define('PartKeepr.Printing.PageBasicLayoutEditor', { - extend: 'PartKeepr.Editor', - alias: 'widget.Printing.PageBasicLayoutEditor', - saveText: i18n("Save Label Layout"), - - layout: 'column', - - initComponent: function () { - this.items = [{ - columnWidth: 1, - minWidth: 500, - layout: 'anchor', - xtype: 'container', - margin: '0 5 0 0', - items: [{ - xtype: 'textfield', - name: 'name', - anchor: '100%', - labelWidth: 130, - fieldLabel: i18n("Layout Name") - }, - { - xtype: 'textfield', - name: 'comment', - anchor: '100%', - labelWidth: 130, - fieldLabel: i18n("Comment") - }, - { - xtype: 'textfield', - name: 'paperSize', - anchor: '100%', - labelWidth: 130, - fieldLabel: i18n("Paper Sheet Size") - }, - { - xtype: 'checkbox', - hideEmptyLabel: false, - fieldLabel: i18n("Portrait Sheet"), - labelWidth: 130, - name: 'paperPortrait' - }, - { - xtype: 'numberfield', - fieldLabel: i18n("Number of Columns"), - labelWidth: 130, - minValue: 1, - allowDecimals: false, - name: 'columnCount' - }, - { - xtype: 'numberfield', - fieldLabel: i18n("Number of Rows"), - labelWidth: 130, - minValue: 1, - allowDecimals: false, - name: 'rowCount' - }, - { - xtype: 'numberfield', - fieldLabel: i18n("Cell Width"), - boxLabel: "mm", - labelWidth: 130, - minValue: 0, - name: 'cellWidthInMM' - }, - { - xtype: 'numberfield', - fieldLabel: i18n("Cell Height"), - boxLabel: "mm", - labelWidth: 130, - minValue: 0, - name: 'cellHeightInMM' - }, - { - xtype: 'numberfield', - fieldLabel: i18n("X Position of top left"), - boxLabel: "mm", - labelWidth: 130, - minValue: 0, - name: 'topLeftXInMM' - }, - { - xtype: 'numberfield', - fieldLabel: i18n("Y Position of top left"), - boxLabel: "mm", - labelWidth: 130, - minValue: 0, - name: 'topLeftYInMM' - } - ]} - ]; - - this.on("startEdit", this.onStartEdit, this); - this.callParent(); - }, - onStartEdit: function () { - this.store.getProxy().extraParams.PageBasicLayout = this.record.get("id"); - this.store.load(); - } - -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditorComponent.js @@ -1,19 +0,0 @@ -Ext.define('PartKeepr.Printing.PageBasicLayoutEditorComponent', { - extend: 'PartKeepr.EditorComponent', - alias: 'widget.Printing.PageBasicLayoutEditorComponent', - navigationClass: 'PartKeepr.Printing.PageBasicLayoutGrid', - editorClass: 'PartKeepr.Printing.PageBasicLayoutEditor', - newItemText: i18n("New Label Layout"), - model: 'PartKeepr.Printing.PageBasicLayout', - initComponent: function () { - this.createStore({ - sorters: [{ - proxy: PartKeepr.getRESTProxy("Printing.PageBasicLayout"), - property: 'name', - direction:'ASC' - }] - }); - - this.callParent(); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutGrid.js @@ -1,14 +0,0 @@ -Ext.define('PartKeepr.Printing.PageBasicLayoutGrid', { - extend: 'PartKeepr.EditorGrid', - alias: 'widget.Printing.PageBasicLayoutGrid', - - automaticPageSize: true, - - columns: [ - {header: i18n("Label Layout"), dataIndex: 'name', flex: 1} - ], - addButtonText: i18n("Add Label Layout"), - addButtonIcon: 'resources/fugue-icons/icons/wooden-box--plus.png', - deleteButtonText: i18n("Delete Label Layout"), - deleteButtonIcon: 'resources/fugue-icons/icons/wooden-box--minus.png' -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintStorageLocations.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintStorageLocations.js @@ -1,110 +0,0 @@ -/** - * Represents the printing view for the storage locations - */ -Ext.define('PartKeepr.PrintStorageLocations', { - extend: 'Ext.panel.Panel', - alias: 'widget.PrintStorageLocations', - - bodyStyle: 'background:#DBDBDB;padding: 5px', - border: false, - - defaults: { - bodyStyle: 'padding:10px' - }, - - layout: 'border', - - initComponent: function () { - this.createStores(); - - this.printExecutor = Ext.create('PartKeepr.PrintingExecutor'); - - this.upperGridEditing = Ext.create('Ext.grid.plugin.CellEditing', { - clicksToEdit: 1 - }); - - this.locationList = Ext.create("PartKeepr.BaseGrid", { - selModel: { - mode: 'MULTI' - }, - selType: 'checkboxmodel', - flex: 1, - columns: [{ - header: i18n("Storage location name"), dataIndex: 'name', - flex: 1 - }], - store: this.storeStorageLocation, - plugins: [ this.upperGridEditing ] - }); - - this.editing = Ext.create('Ext.grid.plugin.CellEditing', { - clicksToEdit: 1 - }); - - this.printIt = Ext.create('Ext.button.Button', { - text: i18n("Print"), - width: 160, - listeners: { - scope: this, - click: this.onPrintClick - } - - }); - - this.items = [ - { - title: i18n("Choose locations to print label for"), - split: true, - minHeight: 300, - height: 300, - bodyStyle: 'background:#DBDBDB;padding: 10px;', - layout: { - type: 'vbox', - align : 'stretch', - pack : 'start' - }, - region: 'north', - items: [ - this.locationList, - { - layout: { - type: 'hbox', - pack: 'start' - }, - margins: { - top: 10 - }, - border: false, - bodyStyle: 'background:#DBDBDB', - items: [ this.printIt] - } - ] - }]; - - this.callParent(); - }, - onPrintClick: function () { - selection = this.locationList.getSelectionModel().getSelection(); - var ids = new Array(); - for (var i=0;i<selection.length;i++) { - ids.push(selection[i].get("id")); - } - - var val = Ext.create("PartKeepr.PrintingWindow"); - val.setObjectType('PartKeepr\\StorageLocation\\StorageLocation'); - val.setObjectIds(ids); - val.show(); - }, - /** - * Creates the store used in this view. - */ - createStores: function () { - var config = { - autoLoad: true, - model: "PartKeepr.StorageLocation", - pageSize: -1 - }; - - this.storeStorageLocation = Ext.create('Ext.data.Store', config); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingExecutor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingExecutor.js @@ -1,38 +0,0 @@ -/** - * This class is responsible for executing a printing request and showing the - * response from the server. - */ -Ext.define('PartKeepr.PrintingExecutor', { - constructor: function () { - }, - /** - * Send the print request to the server and get the incoming response. - * Afterwards the requested file will be opened. - * - * @param configId The ID of the configuration to use for printing. - * @param objectType The object type (full path) the ids are from - * @param ids The ids of the objects which should be printed. - */ - executePrint: function (configId, objectType, ids, target) { - if (configId===null){ - Ext.Msg.alert(i18n("Error"),i18n("No Layout selected for printing. Please select a layout and try again.")); - return; - } - - var call = new PartKeepr.ServiceCall( - "Printing", - "startExport"); - call.setParameter("objectType",objectType); - call.setParameter("configuration",configId); - call.setParameter("target",target); - call.setParameter("ids",ids.join(",")); - - call.setHandler(Ext.bind(this.onPrintingFinished, this, [target === null], true )); - call.doCall(); - }, - onPrintingFinished: function(reply, downloadDirectly) { - if (downloadDirectly ) { - window.open('file.php?id=' + reply.fileid + '&type=Print'); - } - } -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditor.js @@ -1,185 +0,0 @@ -Ext.define('PartKeepr.Printing.PrintingJobConfigurationEditor', { - extend: 'PartKeepr.Editor', - alias: 'widget.Printing.PrintingJobConfigurationEditor', - saveText: i18n("Save Configuration"), - - layout: 'column', - inSetRecordPhase: false, - - initComponent: function () { - this.createStores(); - - this.layoutSelector = Ext.create('Ext.form.field.ComboBox',{ - store: this.layoutStore, - name: 'pageLayout', - valueField: 'id', - displayField: 'name', - fieldLabel: i18n("Basic Page Layout"), - allowBlank: false, - labelWidth: 130 - } ); - - this.rendererSelector = Ext.create('Ext.form.field.ComboBox',{ - store: this.rendererStore, - name: 'exportRenderer', - valueField: 'id', - displayField: 'name', - fieldLabel: i18n("Renderer"), - allowBlank: false, - labelWidth: 130, - listeners: { - scope: this, - change: function (field, newValue) { - if (newValue){ - this.onChangeRenderer( newValue ); - } - } - } - } ); - - this.typeSelector = Ext.create('Ext.form.field.ComboBox',{ - store: this.typeStore, - name: 'objectType', - valueField: 'id', - displayField: 'name', - fieldLabel: i18n("Datatype"), - allowBlank: false, - labelWidth: 130 - } ); - - - this.items = [{ - columnWidth: 1, - minWidth: 500, - layout: 'anchor', - xtype: 'container', - margin: '0 5 0 0', - items: [{ - xtype: 'textfield', - name: 'name', - anchor: '100%', - labelWidth: 130, - fieldLabel: i18n("Name") - }, - { - xtype: 'textfield', - name: 'comment', - anchor: '100%', - labelWidth: 130, - fieldLabel: i18n("Comment") - }, - this.rendererSelector, - this.layoutSelector, - this.typeSelector, - { - xtype: 'textarea', - name: 'rendererConfiguration', - anchor: '100%', - labelWidth: 130, - fieldLabel: i18n("Additional Configuration") - } - ]} - ]; - - - this.on("startEdit", this.onStartEdit, this); - this.callParent(); - }, - editItem: function (record) { - this.inSetRecordPhase = true; - - // FIXME: How can a base method can be called in Javascript? - this.record = record; - this.getForm().loadRecord(this.record); - this.show(); - if (this.record.get("name") !== "") { - this._setTitle(this.record.get("name")); - } - - this.change = false; - this.fireEvent("startEdit", this); - - this.inSetRecordPhase = false; - }, - onChangeRenderer: function( renderer ) { - this.typeStore.getProxy().extraParams.renderer = renderer; - this.typeStore.load(); - if (!this.inSetRecordPhase) - this.typeSelector.clearValue(); - - var call = new PartKeepr.ServiceCall( - "Printing", - "getNeededParameters"); - call.setParameter("renderer",renderer); - - call.setHandler(Ext.bind(this.onReceivedNeededParameters, this)); - call.doCall(); - }, - onReceivedNeededParameters: function (data) { - var needPageBasicLayout = data.data.indexOf('PartKeepr\\Printing\\PageBasicLayout\\PageBasicLayout') != -1; - - if (needPageBasicLayout) { - this.layoutSelector.show(); - } else { - this.layoutSelector.hide(); - this.layoutSelector.clearValue(); - } - }, - onStartEdit: function () { - this.store.getProxy().extraParams.PrintingJobConfiguration = this.record.get("id"); - this.store.load(); - }, - createStores: function() { - this.layoutStore = Ext.create("Ext.data.Store", { - autoLoad: true, - model: 'PartKeepr.Printing.PageBasicLayout', - pageSize: -1 - }); - - this.typeStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.PrintingType', - proxy: { - type: 'ajax', - reader: { - type: 'json', - root: 'response.data' - }, - url : 'service.php', - extraParams: { - "service": "Printing", - "call": "getAvailableTypes", - "renderer": "" - }, - headers: { - session :PartKeepr.getApplication().getSession() - } - }, - autoLoad: false - }); - - - this.rendererStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.PrintingRenderer', - proxy: { - type: 'ajax', - reader: { - type: 'json', - root: 'response.data' - }, - url : 'service.php', - extraParams: { - "service": "Printing", - "call": "getAvailableRenderer" - }, - headers: { - session :PartKeepr.getApplication().getSession() - } - }, - autoLoad: true - }); - - - - - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditorComponent.js @@ -1,19 +0,0 @@ -Ext.define('PartKeepr.Printing.PrintingJobConfigurationEditorComponent', { - extend: 'PartKeepr.EditorComponent', - alias: 'widget.Printing.PrintingJobConfigurationEditorComponent', - navigationClass: 'PartKeepr.Printing.PrintingJobConfigurationGrid', - editorClass: 'PartKeepr.Printing.PrintingJobConfigurationEditor', - newItemText: i18n("New Label Layout"), - model: 'PartKeepr.Printing.PrintingJobConfiguration', - initComponent: function () { - this.createStore({ - sorters: [{ - proxy: PartKeepr.getRESTProxy("Printing.PrintingJobConfiguration"), - property: 'name', - direction:'ASC' - }] - }); - - this.callParent(); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationGrid.js @@ -1,14 +0,0 @@ -Ext.define('PartKeepr.Printing.PrintingJobConfigurationGrid', { - extend: 'PartKeepr.EditorGrid', - alias: 'widget.Printing.PrintingJobConfigurationGrid', - - automaticPageSize: true, - - columns: [ - {header: i18n("Printing Configuration"), dataIndex: 'name', flex: 1} - ], - addButtonText: i18n("Add Configuration"), - addButtonIcon: 'resources/fugue-icons/icons/wooden-box--plus.png', - deleteButtonText: i18n("Delete Configuration"), - deleteButtonIcon: 'resources/fugue-icons/icons/wooden-box--minus.png' -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Printing/PrintingWindow.js @@ -1,155 +0,0 @@ -/** - * The PrintingWindow can be used to configure a printing in more - * detail and execute the printing request with the right configuration. - */ -Ext.define('PartKeepr.PrintingWindow', { - extend: 'Ext.window.Window', - - constrainHeader: true, - layout: { - type: 'vbox', - align: 'left' - }, - buttonAlign:'center', - - width: 400, - minWidth: 400, - minHeight: 50, - height: 150, - - modal: true, - - context: "", - - executeText: i18n("Print"), - cancelText: i18n("Cancel"), - - title: i18n("Printing ..."), - - /** - * Creates the part editor and put it into the window. - */ - initComponent: function () { - this.objectType = null; - this.objectIds = null; - - this.configurationStore = Ext.create("Ext.data.Store", { - autoLoad: true, - model: 'PartKeepr.Printing.PrintingJobConfiguration', - pageSize: -1 - }); - - this.targetStore = Ext.create("Ext.data.Store", { - autoLoad: true, - model: 'PartKeepr.User', - pageSize: -1, - remoteFilter: true, - filters: [{ - property: 'lastSeenMax', - value: '60' - },{ - property: 'hideCurrentUser', - value: '1' - }], - listeners: { - scope: this, - load: function( xstore , record , option ) { - xstore.add({ id : '-1', username: i18n('Download as file') }, true); - } - } - }); - - this.configurationSelector = Ext.create('Ext.form.field.ComboBox',{ - store: this.configurationStore, - valueField: 'id', - displayField: 'name', - fieldLabel: i18n("Choose Configuration"), - allowBlank: false, - labelWidth: 140 - } ); - - - this.targetSelector = Ext.create('Ext.form.field.ComboBox',{ - store: this.targetStore, - valueField: 'id', - displayField: 'username', - fieldLabel: i18n("Choose Target"), - allowBlank: false, - labelWidth: 140 - } ); - this.items = [ this.configurationSelector, this.targetSelector ]; - - this.executeButton = Ext.create("Ext.button.Button", { - text: this.executeText, - icon: 'resources/fugue-icons/icons/disk.png', - handler: Ext.bind(this.onExecute, this) - }); - - this.cancelButton = Ext.create("Ext.button.Button", { - text: this.cancelText, - icon: 'resources/silkicons/cancel.png', - handler: Ext.bind(this.onCancel, this) - }); - - this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", { - enableOverflow: true, - defaults: {minWidth: 100}, - dock: 'bottom', - ui: 'footer', - pack: 'start', - items: [ this.executeButton, this.cancelButton ] - }); - - this.buttons = [ this.bottomToolbar ]; - - this.callParent(); - }, - /** - * Set the object type. They will be passed - * to the server later on. - */ - setObjectType: function( objectType ) { - this.objectType = objectType; - this.configurationStore.filter('objectType', objectType ); - this.loadLastUsed(); - }, - /** - * Sets the window context to store last used values for this context. - * Context needs to be a string, which identifies it. - */ - setContext: function( context ) { - this.context = context; - this.loadLastUsed(); - }, - loadLastUsed: function() { - var context = this.context.length > 0 ? this.context : this.objectType; - this.configurationSelector.setValue( PartKeepr.getApplication().getUserPreference("partkeepr.printing.lastUsedConfiguration."+context),'' ); - this.targetSelector.setValue( PartKeepr.getApplication().getUserPreference("partkeepr.printing.lastUsedTarget."+context),'' ); - }, - /** - * Set the ids of the objects which should be printed/exported - */ - setObjectIds: function( ids ) { - this.objectIds = ids; - }, - onCancel: function () { - this.close(); - }, - onExecute: function () { - executor = Ext.create('PartKeepr.PrintingExecutor'); - if (this.objectIds===null || this.objectType===null){ - Ext.Msg.alert(i18n("Error"),i18n("Unable to handle request: Missing data! This is a Bug, please report it!")); - } - config = this.configurationSelector.getValue(); - target = this.targetSelector.getValue() == -1 ? null : this.targetSelector.getValue(); - if (config!==null){ - executor.executePrint( config, this.objectType, this.objectIds, target); - if (this.objectType!==null){ - PartKeepr.getApplication().setUserPreference("partkeepr.printing.lastUsedConfiguration."+this.context, this.configurationSelector.getValue() ); - PartKeepr.getApplication().setUserPreference("partkeepr.printing.lastUsedTarget."+this.context, this.targetSelector.getValue() ); - } - - this.close(); - } - } -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectAttachmentGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectAttachmentGrid.js @@ -2,5 +2,5 @@ Ext.define('PartKeepr.FootprintAttachmentGrid', { extend: 'PartKeepr.AttachmentGrid', alias: 'widget.FootprintAttachmentGrid', - model: "PartKeepr.FootprintAttachment" + model: "PartKeepr.FootprintBundle.Entity.FootprintAttachment" }); \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StockReport/AbstractStockHistoryGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StockReport/AbstractStockHistoryGrid.js @@ -66,7 +66,7 @@ Ext.define('PartKeepr.AbstractStockHistoryGrid', { } }]; }, - model: 'PartKeepr.StockEntry', + model: 'PartKeepr.Stock.StockEntry', /** * Initializes the stock history grid. */ @@ -80,7 +80,7 @@ Ext.define('PartKeepr.AbstractStockHistoryGrid', { remoteFilter: true, remoteSort: true, proxy: PartKeepr.getRESTProxy("Stock"), - model: 'PartKeepr.StockEntry', + model: this.model, sorters: [{ property: 'dateTime', direction:'DESC' diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/RemoteImageField.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/RemoteImageField.js @@ -49,31 +49,22 @@ Ext.define('PartKeepr.RemoteImageField', { onRender: function() { var me = this; - me.onLabelableRender(); + /** + * @todo what did we use this for? + */ - me.addChildEls('imgEl'); + //me.onLabelableRender(); + //me.addChildEls('imgEl'); me.callParent(arguments); }, - /*onRender: function () { - var me = this, - renderSelectors = me.renderSelectors; - - Ext.applyIf(renderSelectors, me.getLabelableSelectors()); - - Ext.applyIf(renderSelectors, { - imgEl: 'img.remoteimagefield' - }); - - me.callParent(arguments); - },*/ /** * Applies the image URL to the element after rendering */ afterRender: function () { - this.imgEl.dom.src = this.getImageURL(); + //this.imgEl.dom.src = this.getImageURL(); - this.imgEl.on("click", this.onClick, this); + //this.imgEl.on("click", this.onClick, this); }, onClick: function () { var j = Ext.create("PartKeepr.FileUploadDialog", { imageUpload: true }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/StorageLocationComboBox.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/StorageLocationComboBox.js @@ -18,7 +18,7 @@ Ext.define("PartKeepr.StorageLocationComboBox",{ initComponent: function () { this.store = Ext.create("Ext.data.Store", { - model: 'PartKeepr.StorageLocation', + model: 'PartKeepr.StorageLocation.StorageLocation', proxy: PartKeepr.getRESTProxy("StorageLocation"), pageSize: -1, autoLoad: true diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/AbstractCategory.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/AbstractCategory.js @@ -1,5 +0,0 @@ -Ext.define("PartKeepr.AbstractCategory", { - extend: "Ext.data.Model", - isCategory: true -}); - diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Distributor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Distributor.js @@ -1,18 +0,0 @@ -Ext.define("PartKeepr.Distributor", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'url', type: 'string'}, - { name: 'comment', type: 'string'}, - { name: 'address', type: 'string'}, - { name: 'phone', type: 'string'}, - { name: 'fax', type: 'string'}, - { name: 'email', type: 'string'}, - { name: 'skuurl', type: 'string'} - ], - proxy: PartKeepr.getRESTProxy("Distributor"), - getRecordName: function () { - return this.get("name"); - } -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Footprint.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Footprint.js @@ -1,17 +0,0 @@ -Ext.define("PartKeepr.Footprint", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string' }, - { name: 'text', type: 'string' }, - { name: 'description', type: 'string' }, - // image_id needs to be a string because we need to be able to push TMP:<id> back - { name: 'image_id', type: 'string' }, - { name: 'category', type: 'int' } - ], - hasMany: {model: 'PartKeepr.FootprintAttachment', name: 'attachments'}, - proxy: PartKeepr.getRESTProxy("Footprint"), - getRecordName: function () { - return this.get("name"); - } -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/FootprintAttachment.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/FootprintAttachment.js @@ -1,14 +0,0 @@ -Ext.define("PartKeepr.FootprintAttachment", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'string' }, - { name: 'originalFilename', type: 'string' }, - { name: 'footprint_id', type: 'int' }, - { name: 'mimetype', type: 'string' }, - { name: 'extension', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'size', type: 'string' } - ], - belongsTo: { type: 'belongsTo', model: 'PartKeepr.Footprint', primaryKey: 'id', foreignKey: 'footprint_id'}, - proxy: PartKeepr.getRESTProxy("FootprintAttachment") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/FootprintCategory.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/FootprintCategory.js @@ -1,15 +0,0 @@ -Ext.define("PartKeepr.FootprintCategory", { - extend: "PartKeepr.AbstractCategory", - fields: [ - { name: 'id', type: 'int' }, - { name: 'name', type: 'string' }, - { name: 'text', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'parent', type: 'int' } - ], - proxy: PartKeepr.getRESTProxy("FootprintCategory"), - getRecordName: function () { - return this.get("name"); - } -}); - diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Manufacturer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Manufacturer.js @@ -1,18 +0,0 @@ -Ext.define("PartKeepr.Manufacturer", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'url', type: 'string'}, - { name: 'comment', type: 'string'}, - { name: 'address', type: 'string'}, - { name: 'phone', type: 'string'}, - { name: 'fax', type: 'string'}, - { name: 'email', type: 'string'} - ], - hasMany: {model: 'PartKeepr.ManufacturerICLogo', name: 'iclogos'}, - proxy: PartKeepr.getRESTProxy("Manufacturer"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ManufacturerICLogo.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ManufacturerICLogo.js @@ -1,14 +0,0 @@ -Ext.define("PartKeepr.ManufacturerICLogo", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'string' }, - { name: 'originalFilename', type: 'string' }, - { name: 'footprint_id', type: 'int' }, - { name: 'mimetype', type: 'string' }, - { name: 'extension', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'size', type: 'string' } - ], - belongsTo: { type: 'belongsTo', model: 'PartKeepr.Manufacturer', primaryKey: 'id', foreignKey: 'manufacturer_id'}, - proxy: PartKeepr.getRESTProxy("ManufacturerICLogo") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Part.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Part.js @@ -1,61 +0,0 @@ -Ext.define("PartKeepr.Part", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'category', type: 'int'}, - { name: 'footprint', type: 'int'}, - { name: 'storageLocation', type: 'int'}, - { name: 'partUnit', type: 'int'}, - { name: 'averagePrice', type: 'float'}, - { name: 'name', type: 'string'}, - { name: 'description', type: 'string'}, - { name: 'comment', type: 'string'}, - { name: 'status', type: 'string'}, - { name: 'stockLevel', type: 'int'}, - { name: 'minStockLevel', type: 'int'}, - { name: 'createDate', type: 'date'}, - { name: 'needsReview', type: 'boolean'}, - { name: 'partCondition', type: 'string'}, - - // Various things that don't belong to the part, but are transmitted anyways to make handling easier - { name: 'initialStockLevel', type: 'int'}, - { name: 'initialStockLevelUser', type: 'int'}, - { name: 'initialStockLevelPrice', type: 'float'}, - { name: 'initialStockLevelPricePerItem', type: 'boolean'}, - { name: 'partUnitName', type: 'string'}, - { name: 'partUnitShortName', type: 'string'}, - - { name: 'footprintName', type: 'string'}, - { name: 'storageLocationName',type: 'string'}, - { name: 'categoryName', type: 'string'}, - { name: 'categoryPath', type: 'string'}, - { name: 'projects', type: 'string'}, - { name: 'internalPartNumber', type: 'string'}, - { name: 'attachmentCount', type: 'int'}, - { - name: 'partUnitDefault', - type: 'boolean', - convert: function (val) { - if (val === "true" || val === "1" || val === true) - { return true; } - else { return false; } - } - } - - ], - belongsTo: [ - { model: 'PartKeepr.StorageLocation', primaryKey: 'id', foreignKey: 'storageLocation'}, - { model: 'PartKeepr.Footprint', primaryKey: 'id', foreignKey: 'footprint'}, - { model: 'PartKeepr.PartCategory', primaryKey: 'id', foreignKey: 'category'} - ], - hasMany: [ - { model: 'PartKeepr.PartDistributor', name: 'distributors'}, - { model: 'PartKeepr.PartManufacturer', name: 'manufacturers'}, - { model: 'PartKeepr.PartParameter', name: 'parameters'}, - { model: 'PartKeepr.PartAttachment', name: 'attachments'} - ], - proxy: PartKeepr.getRESTProxy("Part"), - getRecordName: function () { - return this.get("name"); - } -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartAttachment.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartAttachment.js @@ -1,15 +0,0 @@ -Ext.define("PartKeepr.PartAttachment", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'string' }, - { name: 'originalFilename', type: 'string' }, - { name: 'footprint_id', type: 'int' }, - { name: 'mimetype', type: 'string' }, - { name: 'image', type: 'boolean' }, - { name: 'extension', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'size', type: 'string' } - ], - belongsTo: { type: 'belongsTo', model: 'PartKeepr.Part', primaryKey: 'id', foreignKey: 'part_id'}, - proxy: PartKeepr.getRESTProxy("PartAttachment") -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartCategory.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartCategory.js @@ -1,15 +0,0 @@ -Ext.define("PartKeepr.PartCategory", { - extend: "PartKeepr.AbstractCategory", - fields: [ - { name: 'id', type: 'int' }, - { name: 'name', type: 'string' }, - { name: 'text', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'parent', type: 'int' } - ], - proxy: PartKeepr.getRESTProxy("PartCategory"), - getRecordName: function () { - return this.get("name"); - } -}); - diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartDistributor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartDistributor.js @@ -1,20 +0,0 @@ -Ext.define("PartKeepr.PartDistributor", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'part_id', type: 'int' }, - { name: 'part_name', type: 'string' }, - { name: 'distributor_id', type: 'int' }, - { name: 'distributor_name', type: 'string' }, - { name: 'price', type: 'float' }, - { name: 'orderNumber', type: 'string' }, - { name: 'packagingUnit', type: 'int'}, - { name: 'sku', type: 'string' }, - - // Virtual field for the packagePrice. - { name: 'packagePrice', type: 'float' } - ], - belongsTo: [{ type: 'belongsTo', model: 'PartKeepr.Part', primaryKey: 'id', foreignKey: 'part_id'}, - { type: 'belongsTo', model: 'PartKeepr.Distributor', primaryKey: 'id', foreignKey: 'distributor_id'}], - proxy: PartKeepr.getRESTProxy("PartDistributor") -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartManufacturer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartManufacturer.js @@ -1,14 +0,0 @@ -Ext.define("PartKeepr.PartManufacturer", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'part_id', type: 'int' }, - { name: 'part_name', type: 'string' }, - { name: 'manufacturer_id', type: 'int' }, - { name: 'manufacturer_name', type: 'string' }, - { name: 'partNumber', type: 'string' } - ], - belongsTo: [{ type: 'belongsTo', model: 'PartKeepr.Part', primaryKey: 'id', foreignKey: 'part_id'}, - { type: 'belongsTo', model: 'PartKeepr.Manufacturer', primaryKey: 'id', foreignKey: 'manufacturer_id'}], - proxy: PartKeepr.getRESTProxy("PartManufacturer") -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartParameter.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartParameter.js @@ -1,14 +0,0 @@ -Ext.define("PartKeepr.PartParameter", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'part_id', type: 'int' }, - { name: 'name', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'unit_id', type: 'int' }, - { name: 'siprefix_id', type: 'int' }, - { name: 'value', type: 'float' }, - { name: 'prefixedValue' } - ], - proxy: PartKeepr.getRESTProxy("PartParameter") -}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartUnit.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PartUnit.js @@ -1,13 +0,0 @@ -Ext.define("PartKeepr.PartUnit", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'shortName', type: 'string'}, - { name: 'default', type: 'bool'} - ], - proxy: PartKeepr.getRESTProxy("PartUnit"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingPageBasicLayout.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingPageBasicLayout.js @@ -1,20 +0,0 @@ -Ext.define("PartKeepr.Printing.PageBasicLayout", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'comment', type: 'string'}, - { name: 'columnCount', type: 'int'}, - { name: 'rowCount', type: 'int'}, - { name: 'paperSize', type: 'string'}, - { name: 'paperPortrait', type: 'boolean'}, - { name: 'cellWidthInMM', type: 'float'}, - { name: 'cellHeightInMM', type: 'float'}, - { name: 'topLeftXInMM', type: 'float'}, - { name: 'topLeftYInMM', type: 'float'} - ], - proxy: PartKeepr.getRESTProxy("Printing.PageBasicLayout"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingPrintingJobConfiguration.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingPrintingJobConfiguration.js @@ -1,19 +0,0 @@ -Ext.define("PartKeepr.Printing.PrintingJobConfiguration", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'comment', type: 'string'}, - { name: 'objectType', type: 'string'}, - { name: 'exportRenderer', type: 'string'}, - { name: 'pageLayout', type: 'int'}, - { name: 'rendererConfiguration', type: 'string'} - ], - belongsTo: [ - { model: 'PartKeepr.Printing.PageBasicLayout', primaryKey: 'id', foreignKey: 'pageLayout'} - ], - proxy: PartKeepr.getRESTProxy("Printing.PrintingJobConfiguration"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingRenderer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingRenderer.js @@ -1,10 +0,0 @@ -Ext.define("PartKeepr.PrintingRenderer", { - extend: "Ext.data.Model", - fields: [ - { name: 'id', type: 'string'}, - { name: 'name', type: 'string'} - ], - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingResponse.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingResponse.js @@ -1,6 +0,0 @@ -Ext.define("PartKeepr.PrintingResponse", { - extend: "Ext.data.Model", - fields: [ - { name: 'fileid', type: 'string'} - ] -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingType.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/PrintingType.js @@ -1,10 +0,0 @@ -Ext.define("PartKeepr.PrintingType", { - extend: "Ext.data.Model", - fields: [ - { name: 'id', type: 'string'}, - { name: 'name', type: 'string'} - ], - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Project.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Project.js @@ -1,20 +0,0 @@ -/** - * Represents a project - */ -Ext.define("PartKeepr.Project", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'description', type: 'string'}, - { name: 'user_id', type: 'int'} - ], - hasMany: [ - { model: 'PartKeepr.ProjectPart', name: 'parts'}, - { model: 'PartKeepr.ProjectAttachment', name: 'attachments' } - ], - proxy: PartKeepr.getRESTProxy("Project"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectAttachment.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectAttachment.js @@ -1,14 +0,0 @@ -Ext.define("PartKeepr.ProjectAttachment", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'string' }, - { name: 'originalFilename', type: 'string' }, - { name: 'project_id', type: 'int' }, - { name: 'mimetype', type: 'string' }, - { name: 'extension', type: 'string' }, - { name: 'description', type: 'string' }, - { name: 'size', type: 'string' } - ], - belongsTo: { type: 'belongsTo', model: 'PartKeepr.Project', primaryKey: 'id', foreignKey: 'project_id'}, - proxy: PartKeepr.getRESTProxy("ProjectAttachment") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectPart.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectPart.js @@ -1,22 +0,0 @@ -/** - * Represents a project part - */ -Ext.define("PartKeepr.ProjectPart", { - extend: "Ext.data.Model", - fields: [ - { - id: 'id', - name: 'id', - type: 'int' - }, - { name: 'project_id', type: 'int'}, - { name: 'part_id', type: 'int'}, - { name: 'part_name', type: 'string'}, - { name: 'quantity', type: 'int'}, - { name: 'remarks', type: 'string'} - - ], - belongsTo: { type: 'belongsTo', model: 'PartKeepr.Project', primaryKey: 'id', foreignKey: 'project_id'}, - belongsTo: { type: 'belongsTo', model: 'PartKeepr.Part', primaryKey: 'id', foreignKey: 'part_id'}, - proxy: PartKeepr.getRESTProxy("ProjectPart") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectReport.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectReport.js @@ -1,21 +0,0 @@ -/** - * Represents a project report - */ -Ext.define("PartKeepr.ProjectReport", { - extend: "Ext.data.Model", - fields: [ - { name: 'quantity', type: 'int'}, - { name: 'storageLocation_name', type: 'string'}, - { name: 'available', type: 'int'}, - { name: 'missing', type: 'int'}, - { name: 'distributor_order_number', type: 'string'}, - { name: 'sum_order', type: 'float'}, - { name: 'sum', type: 'float'}, - { name: 'projects', type: 'string'}, - { name: 'remarks', type: 'string'} - ], - hasMany: [ - { model: 'PartKeepr.Part', name: 'part'} - ], - proxy: PartKeepr.getRESTProxy("ProjectReport") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectReportList.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/ProjectReportList.js @@ -1,21 +0,0 @@ -/** - * Represents a project report list - */ -Ext.define("PartKeepr.ProjectReportList", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'description', type: 'string'}, - { name: 'user_id', type: 'int'}, - { name: 'amount', type: 'int', defaultValue: 1 } - ], - hasMany: [ - { model: 'PartKeepr.ProjectPart', name: 'parts'}, - { model: 'PartKeepr.ProjectAttachment', name: 'attachments' } - ], - proxy: PartKeepr.getRESTProxy("Project"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SiPrefix.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SiPrefix.js @@ -1,10 +0,0 @@ -Ext.define("PartKeepr.SiPrefix", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'prefix', type: 'string'}, - { name: 'symbol', type: 'string'}, - { name: 'power', type: 'int'} - ], - proxy: PartKeepr.getRESTProxy("SiPrefix") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/StatisticSample.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/StatisticSample.js @@ -1,8 +0,0 @@ -Ext.define("PartKeepr.StatisticSample", { - extend: "Ext.data.Model", - fields: [ - { name: 'start', type: 'date', dateFormat: 'Y-m-d H:i:s'}, - { name: 'parts', type: 'int', useNull: true }, - { name: 'categories', type: 'int', useNull: true } - ] -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/StockEntry.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/StockEntry.js @@ -1,15 +0,0 @@ -Ext.define("PartKeepr.StockEntry", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'username', type: 'string'}, - { name: 'user_id', type: 'int'}, - { name: 'dateTime', type: 'date'}, - { name: 'stockLevel', type: 'int'}, - { name: 'storageLocation_name', type: 'string'}, - { name: 'direction', type: 'string'}, - { name: 'part_name', type: 'string'}, - { name: 'price', type: 'float'}, - { name: 'comment', type: 'string'} - ] -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/StorageLocation.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/StorageLocation.js @@ -1,13 +0,0 @@ -Ext.define("PartKeepr.StorageLocation", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - // image_id needs to be a string because we need to be able to push TMP:<id> back - { name: 'image_id', type: 'string' } - ], - proxy: PartKeepr.getRESTProxy("StorageLocation"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemInformationRecord.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemInformationRecord.js @@ -1,14 +0,0 @@ -/** - * Defines a system information record - */ -Ext.define("PartKeepr.SystemInformationRecord", { - extend: "Ext.data.Model", - fields: [ - /* Defines the name of the property */ - { name: 'name', type: 'string' }, - /* Defines the value of the property */ - { name: 'value', type: 'string' }, - /* Defines the category of the property */ - { name: 'category', type: 'string' } - ] -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemNotice.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/SystemNotice.js @@ -1,16 +0,0 @@ -/** - * Represents a system notice - */ -Ext.define("PartKeepr.SystemNotice", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'date', type: 'date', dateFormat: 'Y-m-d H:i:s'}, - { name: 'title', type: 'string'}, - { name: 'description', type: 'string'} - ], - proxy: PartKeepr.getRESTProxy("SystemNotice"), - getRecordName: function () { - return this.get("title"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Unit.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/Unit.js @@ -1,13 +0,0 @@ -Ext.define("PartKeepr.Unit", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'name', type: 'string'}, - { name: 'symbol', type: 'string'} - ], - hasMany: { model: 'PartKeepr.SiPrefix', name: 'prefixes'}, - proxy: PartKeepr.getRESTProxy("Unit"), - getRecordName: function () { - return this.get("name"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/User.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/User.js @@ -1,12 +0,0 @@ -Ext.define("PartKeepr.User", { - extend: "Ext.data.Model", - fields: [ - { id: 'id', name: 'id', type: 'int' }, - { name: 'username', type: 'string'}, - { name: 'password', type: 'string'} - ], - proxy: PartKeepr.getRESTProxy("User"), - getRecordName: function () { - return this.get("username"); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Models/UserPreference.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Models/UserPreference.js @@ -1,9 +0,0 @@ -Ext.define("PartKeepr.UserPreference", { - extend: "Ext.data.Model", - fields: [ - { name: 'key', type: 'string'}, - { name: 'value'}, - { name: 'user_id', type: 'int'} - ], - proxy: PartKeepr.getRESTProxy("UserPreference") -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js b/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js @@ -51,8 +51,17 @@ Ext.application({ * enables the menu bar and creates the stores+loads them. */ onLogin: function () { + var j = new Ext.create("PartKeepr.FootprintEditorComponent"); + + var k = new Ext.create("Ext.Window", { + items: j + }); + + k.show(); + return; this.createGlobalStores(); - + + if (window.parameters.userPreferences) { PartKeepr.getApplication().setInitialUserPreferences(window.parameters.userPreferences); } @@ -226,7 +235,7 @@ Ext.application({ createGlobalStores: function () { this.footprintStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.Footprint.Footprint', + model: 'PartKeepr.FootprintBundle.Entity.Footprint', pageSize: -1, autoLoad: false }); @@ -254,28 +263,28 @@ Ext.application({ this.partUnitStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.PartUnit.PartUnit', + model: 'PartKeepr.Part.PartUnit', pageSize: -1, autoLoad: false }); this.unitStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.Unit', + model: 'PartKeepr.UnitBundle.Entity.Unit', pageSize: -1, autoLoad: false }); this.userStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.User', + model: 'PartKeepr.AuthBundle.Entity.User.User', pageSize: -1, autoLoad: false }); this.tipOfTheDayStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.TipOfTheDay', + model: 'PartKeepr.TipOfTheDay.TipOfTheDay', pageSize: -1, autoLoad: true, listeners: { @@ -286,7 +295,7 @@ Ext.application({ this.userPreferenceStore = Ext.create("Ext.data.Store", { - model: 'PartKeepr.UserPreference', + model: 'PartKeepr.UserPreference.UserPreference', pageSize: -1, autoLoad: false, listeners: { diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -55,9 +55,6 @@ '@PartKeeprFrontendBundle/Resources/public/js/Data/RestProxy.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Statusbar.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Auth/LoginDialog.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PrintingExecutor.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PrintingWindow.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PrintStorageLocations.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartImageDisplay.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartsManager.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/Editor/PartEditorWindow.js' @@ -79,8 +76,6 @@ '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/ProjectAttachmentGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Editor/EditorGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Distributor/DistributorGrid.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationGrid.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartsGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Manufacturer/ManufacturerGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/PartUnit/PartUnitGrid.js' @@ -124,8 +119,6 @@ '@PartKeeprFrontendBundle/Resources/public/js/Components/ContextMenu/CharPickerMenu.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Editor/Editor.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Distributor/DistributorEditor.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditor.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditor.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/Editor/PartEditor.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Manufacturer/ManufacturerEditor.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/PartUnit/PartUnitEditor.js' @@ -137,8 +130,6 @@ '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/ProjectEditor.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Editor/EditorComponent.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Distributor/DistributorEditorComponent.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PageBasicLayoutEditorComponent.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Printing/PrintingJobConfigurationEditorComponent.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Manufacturer/ManufacturerEditorComponent.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/PartUnit/PartUnitEditorComponent.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Unit/UnitEditorComponent.js' diff --git a/src/PartKeepr/PartBundle/Controller/DefaultController.php b/src/PartKeepr/PartBundle/Controller/DefaultController.php @@ -0,0 +1,19 @@ +<?php + +namespace PartKeepr\PartBundle\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; + +class DefaultController extends Controller +{ + /** + * @Route("/hello/{name}") + * @Template() + */ + public function indexAction($name) + { + return array('name' => $name); + } +} diff --git a/src/PartKeepr/PartBundle/DependencyInjection/Configuration.php b/src/PartKeepr/PartBundle/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +<?php + +namespace PartKeepr\PartBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +/** + * This is the class that validates and merges configuration from your app/config files + * + * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} + */ +class Configuration implements ConfigurationInterface +{ + /** + * {@inheritdoc} + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('part_keepr_part'); + + // Here you should define the parameters that are allowed to + // configure your bundle. See the documentation linked above for + // more information on that topic. + + return $treeBuilder; + } +} diff --git a/src/PartKeepr/PartBundle/DependencyInjection/PartKeeprPartExtension.php b/src/PartKeepr/PartBundle/DependencyInjection/PartKeeprPartExtension.php @@ -0,0 +1,28 @@ +<?php + +namespace PartKeepr\PartBundle\DependencyInjection; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Loader; + +/** + * This is the class that loads and manages your bundle configuration + * + * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} + */ +class PartKeeprPartExtension extends Extension +{ + /** + * {@inheritdoc} + */ + public function load(array $configs, ContainerBuilder $container) + { + $configuration = new Configuration(); + $config = $this->processConfiguration($configuration, $configs); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/PartKeepr/PartBundle/Entity/PartCategory.php b/src/PartKeepr/PartBundle/Entity/PartCategory.php @@ -0,0 +1,28 @@ +<?php +namespace PartKeepr\PartBundle\Entity; + +use PartKeepr\Category\AbstractCategory, + Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; + +/** + * @ORM\Entity(repositoryClass="PartKeepr\PartBundle\Entity\Repository\PartCategoryRepository") + * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) + * The entity for our part categories + * + */ +class PartCategory extends AbstractCategory { + /** + * @ORM\ManyToOne(targetEntity="PartCategory", inversedBy="children") + * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE") + * + * @Gedmo\TreeParent + * @var int + */ + private $parent; + + /** + * @ORM\OneToMany(targetEntity="PartCategory", mappedBy="parent") + */ + private $children; +}+ \ No newline at end of file diff --git a/src/PartKeepr/PartBundle/Entity/PartCategoryManager.php b/src/PartKeepr/PartBundle/Entity/PartCategoryManager.php @@ -0,0 +1,42 @@ +<?php +namespace PartKeepr\PartBundle\Entity; + +use PartKeepr\Category\AbstractCategoryManager; +use DoctrineExtensions\NestedSet\NodeWrapper; +use PartKeepr\Util\SerializableException; +use PartKeepr\PartKeepr; + +class PartCategoryManager extends AbstractCategoryManager { + protected $categoryClass = "PartKeepr\PartBundle\Entity\PartCategory"; + + /** + * Deletes the given category ID. + * @param $id int The category id to delete + * @throws CategoryNotFoundException If the category wasn't found + */ + public function deleteCategory ($id) { + $category = $this->getCategory($id); + + try { + + if ($category->hasChildren()) { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains other categories."), $category->getNode()->getName())); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains other categories. Please move the categories or delete them first."), $category->getNode()->getName())); + + throw $exception; + } + + parent::deleteCategory($id); + } catch (\PDOException $e) { + if ($e->getCode() == "23000") { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains parts."), $category->getNode()->getName())); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains parts. Please move the parts to another category."), $category->getNode()->getName())); + + throw $exception; + } else { + throw $e; + } + } + } + +}+ \ No newline at end of file diff --git a/src/PartKeepr/PartBundle/Entity/PartCategoryService.php b/src/PartKeepr/PartBundle/Entity/PartCategoryService.php @@ -0,0 +1,9 @@ +<?php +namespace PartKeepr\PartBundle\Entity; + +use PartKeepr\Category\AbstractCategoryService; + +class PartCategoryService extends AbstractCategoryService { + protected $categoryManagerClass = "PartKeepr\PartBundle\Entity\PartCategoryManager"; + protected $categoryClass = "PartKeepr\PartBundle\Entity\PartCategory"; +}+ \ No newline at end of file diff --git a/src/PartKeepr/PartBundle/Entity/Repository/PartCategoryRepository.php b/src/PartKeepr/PartBundle/Entity/Repository/PartCategoryRepository.php @@ -0,0 +1,9 @@ +<?php +namespace PartKeepr\PartBundle\Entity\Repository; + +use Gedmo\Tree\Entity\Repository\NestedTreeRepository; + +class PartCategoryRepository extends NestedTreeRepository +{ + +}+ \ No newline at end of file diff --git a/src/PartKeepr/PartBundle/PartKeeprPartBundle.php b/src/PartKeepr/PartBundle/PartKeeprPartBundle.php @@ -0,0 +1,9 @@ +<?php + +namespace PartKeepr\PartBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class PartKeeprPartBundle extends Bundle +{ +} diff --git a/src/PartKeepr/PartBundle/Resources/config/services.xml b/src/PartKeepr/PartBundle/Resources/config/services.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" ?> + +<container xmlns="http://symfony.com/schema/dic/services" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + + <!-- + <services> + <service id="part_keepr_part.example" class="PartKeepr\PartBundle\Example"> + <argument type="service" id="service_id" /> + <argument>plain_value</argument> + <argument>%parameter_name%</argument> + </service> + </services> + --> +</container> diff --git a/src/PartKeepr/PartBundle/Resources/views/Default/index.html.twig b/src/PartKeepr/PartBundle/Resources/views/Default/index.html.twig @@ -0,0 +1 @@ +Hello {{ name }}! diff --git a/src/PartKeepr/PartBundle/Tests/Controller/DefaultControllerTest.php b/src/PartKeepr/PartBundle/Tests/Controller/DefaultControllerTest.php @@ -0,0 +1,13 @@ +<?php + +namespace PartKeepr\PartBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +class DefaultControllerTest extends WebTestCase +{ + public function testIndex() + { + + } +} diff --git a/src/PartKeepr/SiPrefixBundle/Controller/DefaultController.php b/src/PartKeepr/SiPrefixBundle/Controller/DefaultController.php @@ -11,6 +11,8 @@ use FOS\RestBundle\Controller\Annotations\View; class DefaultController extends DoctrineRESTQueryController { + protected $targetEntity = "PartKeepr\\SiPrefixBundle\\Entity\\SiPrefix"; + /** * Retrieves SI Prefixes in the database * @@ -24,8 +26,6 @@ class DefaultController extends DoctrineRESTQueryController */ public function listAction(ParamFetcher $paramFetcher) { - $this->setTargetEntity("PartKeepr\\SiPrefixBundle\\Entity\\SiPrefix"); - return parent::listAction($paramFetcher); } } \ No newline at end of file diff --git a/src/PartKeepr/UnitBundle/Tests/Controller/DefaultControllerTest.php b/src/PartKeepr/UnitBundle/Tests/Controller/DefaultControllerTest.php @@ -1,13 +0,0 @@ -<?php - -namespace PartKeepr\UnitBundle\Tests\Controller; - -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - -class DefaultControllerTest extends WebTestCase -{ - public function testIndex() - { - - } -} diff --git a/src/backend/PartKeepr/Category/AbstractCategory.php b/src/backend/PartKeepr/Category/AbstractCategory.php @@ -3,10 +3,11 @@ namespace PartKeepr\Category; use PartKeepr\Util\BaseEntity; use PartKeepr\Util\Serializable; -use DoctrineExtensions\NestedSet\Node, - Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; +use Doctrine\ORM\Mapping as ORM; /** + * @Gedmo\Tree(type="nested") * @ORM\MappedSuperclass * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) * @@ -15,10 +16,11 @@ use DoctrineExtensions\NestedSet\Node, * * If you are interested on how NestedSets work, please read http://en.wikipedia.org/wiki/Nested_set_model */ -class AbstractCategory extends BaseEntity implements Node, Serializable { +class AbstractCategory extends BaseEntity { /** * The "left" property of the nested set * @ORM\Column(type="integer") + * @Gedmo\TreeLeft * @var integer */ private $lft; @@ -26,6 +28,7 @@ class AbstractCategory extends BaseEntity implements Node, Serializable { /** * The "right" property of the nested set * @ORM\Column(type="integer") + * @Gedmo\TreeRight * @var integer */ private $rgt; @@ -44,14 +47,18 @@ class AbstractCategory extends BaseEntity implements Node, Serializable { */ private $description; - /** - * Holds the parent node ID. Note that this - * is not a persistant value, but rather calculated - * or set on the fly. - * @var int - */ - private $parent; - + /** + * @Gedmo\TreeRoot + * @ORM\Column(type="integer", nullable=true) + */ + private $root; + + /** + * @Gedmo\TreeLevel + * @ORM\Column(name="lvl", type="integer") + */ + private $level; + /** * Holds the category path. * diff --git a/src/backend/PartKeepr/Footprint/Footprint.php b/src/backend/PartKeepr/Footprint/Footprint.php @@ -1,193 +0,0 @@ -<?php -namespace PartKeepr\Footprint; -use PartKeepr\Util\Deserializable; - -use PartKeepr\Util\Serializable; -use PartKeepr\FootprintCategory\FootprintCategory; -use PartKeepr\Util\BaseEntity; -use Doctrine\ORM\Mapping as ORM; - -/** @ORM\Entity */ - -class Footprint extends BaseEntity implements Serializable, Deserializable { - /** - * Holds the footprint name - * @ORM\Column(length=64,unique=true) - * @var string - */ - private $name; - - /** - * Holds the footprint description - * @ORM\Column(type="text",nullable=true) - * @var string - */ - private $description; - - /** - * The category of the footprint - * @ORM\ManyToOne(targetEntity="PartKeepr\FootprintCategory\FootprintCategory") - * @var Category - */ - private $category; - - /** - * Holds the footprint image - * @ORM\OneToOne(targetEntity="PartKeepr\Footprint\FootprintImage",mappedBy="footprint",cascade={"persist", "remove"}) - * @var FootprintImage - */ - private $image; - - /** - * Holds the footprint attachments - * @ORM\OneToMany(targetEntity="PartKeepr\Footprint\FootprintAttachment",mappedBy="footprint",cascade={"persist", "remove"}) - * @var FootprintAttachment - */ - private $attachments; - - /** - * Constructs a new Footprint entity - */ - public function __construct () { - $this->attachments = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * Sets the name of this footprint - * - * @param string $name The footprint name - */ - public function setName ($name) { - $this->name = $name; - } - - /** - * Returns the name of this footprint - * @return string The name of this footprint - */ - public function getName () { - return $this->name; - } - - /** - * Sets the description of this footprint - * @param string $description The description - */ - public function setDescription ($description) { - $this->description = $description; - } - - /** - * Returns the description of this footprint - * @return string The description - */ - public function getDescription () { - return $this->description; - } - - /** - * Sets the category for this footprint - * @param \PartKeepr\FootprintCategory\FootprintCategory $category The category - */ - public function setCategory (FootprintCategory $category) { - $this->category = $category; - } - - /** - * Returns the category of this footprint - * @return FootprintCategory The footprint category - */ - public function getCategory () { - return $this->category; - } - - /** - * Sets the footprint image - * @param FootprintImage $image The footprint image - */ - public function setImage (FootprintImage $image) { - $this->image = $image; - $image->setFootprint($this); - } - - /** - * Returns the footprint image - * @return FootprintImage The footprint image - */ - public function getImage () { - return $this->image; - } - - /** - * Returns the attachments for this footprint - * @return ArrayCollection The attachments - */ - public function getAttachments () { - return $this->attachments; - } - - /** - * Serializes the footprint - * @return array the serialized footprint - */ - public function serialize () { - return array( - "id" => $this->getId(), - "name" => $this->getName(), - "description" => $this->getDescription(), - "image_id" => is_object($this->getImage()) ? $this->getImage()->getId() : null, - "category" => is_object($this->getCategory()) ? $this->getCategory()->getId() : null, - "attachments" => $this->serializeChildren($this->getAttachments()) - ); - } - - /** - * Deserializes the footprint - * @param array $parameters The array with the parameters to set - */ - public function deserialize (array $parameters) { - foreach ($parameters as $key => $value) { - switch ($key) { - case "name": - $this->setName($value); - break; - case "description": - $this->setDescription($value); - break; - case "image_id": - if ($value == "") { - echo "/** Breaking because of empty value */"; - break; } - - try { - $image = FootprintImage::loadById($value); - $this->setImage($image); - } catch (\Exception $e) { - if ($this->getImage()) { - // Image was not found, maybe a temporary image? - $this->getImage()->replaceFromTemporaryFile($value); - } else { - $image = FootprintImage::createFromTemporaryFile($value); - $this->setImage($image); - } - } - - break; - case "category": - try { - $category = FootprintCategory::loadById($value); - $this->setCategory($category); - } catch (\Exception $e) { - // Category was not found, do not change category. - } - break; - case "attachments": - $this->deserializeChildren($value, $this->getAttachments(), "PartKeepr\Footprint\FootprintAttachment"); - foreach ($this->getAttachments() as $attachment) { - $attachment->setFootprint($this); - } - break; - } - } - } -} diff --git a/src/backend/PartKeepr/Footprint/FootprintAttachment.php b/src/backend/PartKeepr/Footprint/FootprintAttachment.php @@ -1,102 +0,0 @@ -<?php -namespace PartKeepr\Footprint; - -use PartKeepr\Util\Deserializable, - PartKeepr\Util\Serializable, - PartKeepr\UploadedFile\UploadedFile, - Doctrine\ORM\Mapping as ORM; - -/** - * Holds a footprint attachment - * @ORM\Entity - **/ -class FootprintAttachment extends UploadedFile implements Serializable, Deserializable { - /** - * The description of this attachment - * @ORM\Column(type="text") - * @var string - */ - private $description; - - /** - * Creates a new footprint attachment - */ - public function __construct () { - parent::__construct(); - $this->setType("FootprintAttachment"); - } - /** - * The footprint object - * @ORM\ManyToOne(targetEntity="PartKeepr\Footprint\Footprint",inversedBy="attachments") - * @var Footprint - */ - private $footprint = null; - - /** - * Sets the footprint - * @param Footprint $footprint The footprint to set - */ - public function setFootprint (Footprint $footprint) { - $this->footprint = $footprint; - } - - /** - * Returns the footprint - * @return Footprint the footprint - */ - public function getFootprint () { - return $this->footprint; - } - - /** - * Sets the description for this attachment - * @param string $description The attachment description - */ - public function setDescription ($description) { - $this->description = $description; - } - - /** - * Returns the description for this attachment - * @return string The description - */ - public function getDescription () { - return $this->description; - } - - /** - * - * Serializes this footprint attachment - * @return array The serialized footprint attachment - */ - public function serialize () { - return array( - "id" => $this->getId(), - "footprint_id" => $this->getFootprint()->getId(), - "originalFilename" => $this->getOriginalFilename(), - "mimetype" => $this->getMimetype(), - "extension" => $this->getExtension(), - "size" => $this->getSize(), - "description" => $this->getDescription()); - } - - /** - * Deserializes the footprint attachment - * @param array $parameters The array with the parameters to set - */ - public function deserialize (array $parameters) { - if (array_key_exists("id", $parameters)) { - if (substr($parameters["id"], 0, 4) === "TMP:") { - $this->replaceFromTemporaryFile($parameters["id"]); - } - } - - foreach ($parameters as $key => $value) { - switch ($key) { - case "description": - $this->setDescription($value); - break; - } - } - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Footprint/FootprintImage.php b/src/backend/PartKeepr/Footprint/FootprintImage.php @@ -1,51 +0,0 @@ -<?php -namespace PartKeepr\Footprint; - -use PartKeepr\Util\Serializable, - PartKeepr\Image\Image, - Doctrine\ORM\Mapping as ORM; - -/** - * Holds a footprint image - * @ORM\Entity - **/ -class FootprintImage extends Image implements Serializable { - /** - * The footprint object - * @ORM\OneToOne(targetEntity="PartKeepr\Footprint\Footprint",inversedBy="image") - * @var Footprint - */ - private $footprint = null; - - /** - * Creates a new IC logo instance - */ - public function __construct () { - parent::__construct(Image::IMAGE_FOOTPRINT); - } - - /** - * Sets the footprint - * @param Footprint $footprint The footprint to set - */ - public function setFootprint (Footprint $footprint) { - $this->footprint = $footprint; - } - - /** - * Returns the footprint - * @return Footprint the footprint - */ - public function getFootprint () { - return $this->footprint; - } - - /** - * - * Serializes this ic logo - * @return array The serialized ic logo - */ - public function serialize () { - return array("id" => $this->getId(), "footprint_id" => $this->getFootprint()->getId()); - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Footprint/FootprintManager.php b/src/backend/PartKeepr/Footprint/FootprintManager.php @@ -1,158 +0,0 @@ -<?php -namespace PartKeepr\Footprint; - -use PartKeepr\Util\Singleton, - PartKeepr\Util\SerializableException, - PartKeepr\Footprint\Footprint, - PartKeepr\PartKeepr, - PartKeepr\Util\Exceptions\EntityNotFoundException; - -class FootprintManager extends Singleton { - /** - * Returns a list of footprints. - * - * @param int $start Start of the list, default 0 - * @param int $limit Number of users to list, default 10 - * @param string $sort The field to sort by, default "name" - * @param string $dir The direction to sort (ASC or DESC), default ASC - * @param string $filter A string to filter the footprint's name by, default empty - */ - public function getFootprints ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { - - $qb = PartKeepr::getEM()->createQueryBuilder(); - $qb->select("f.id, f.name, f.description, im.id AS image_id, ca.id AS category")->from("PartKeepr\Footprint\Footprint","f") - ->leftJoin("f.image", "im") - ->leftJoin("f.category", "ca"); - - if ($filter != "") { - $qb = $qb->where("LOWER(f.name) LIKE :filter"); - $qb->setParameter("filter", "%".strtolower($filter)."%"); - } - - if ($limit > -1) { - $qb->setMaxResults($limit); - $qb->setFirstResult($start); - } - - $qb->orderBy("f.".$sort, $dir); - - $query = $qb->getQuery(); - - $result = $query->getResult(); - - $totalQueryBuilder = PartKeepr::getEM()->createQueryBuilder(); - $totalQueryBuilder->select("COUNT(f.id)")->from("PartKeepr\Footprint\Footprint","f")->leftJoin("f.image", "im"); - - - - if ($filter != "") { - $totalQueryBuilder = $totalQueryBuilder->where("LOWER(f.name) LIKE :filter"); - $totalQueryBuilder->setParameter("filter", "%".strtolower($filter)."%"); - } - - $totalQuery = $totalQueryBuilder->getQuery(); - - return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); - } - - /** - * Creates a new footprint - * - * @param string $footprint The footprint's name - * @throws \PartKeepr\Util\SerializableException - * @throws PDOException - */ - public function addFootprint ($name) { - $fp = new Footprint(); - $fp->setName($name); - - // @todo Port the UniqueEntityValidator from Symfony2 to here. - try { - PartKeepr::getEM()->persist($fp); - PartKeepr::getEM()->flush(); - } catch (\PDOException $e) { - if ($e->getCode() == "23000") { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s already exists!"), $name)); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to add the footprint %s, but a footprint with the same name already exists."), $name)); - - throw $exception; - } else { - throw $e; - } - } - - return $fp; - } - - /** - * Deletes the footprint with the given id. - * - * @param int $id The footprint id to delete - * @throws \PartKeepr\Util\SerializableException - */ - public function deleteFootprint ($id) { - $footprint = Footprint::loadById($id); - - try { - PartKeepr::getEM()->remove($footprint); - PartKeepr::getEM()->flush(); - } catch (\PDOException $e) { - if ($e->getCode() == "23000") { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s is in use by some parts!"), $footprint->getName())); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the footprint %s, but there are parts which use this footprint."), $footprint->getName())); - - throw $exception; - } - } - } - - /** - * Loads a footprint by id - * @param int $id The footprint id - */ - public function getFootprint ($id) { - return Footprint::loadById($id); - } - - /** - * Finds or creates a footprint by name. - * - * @param mixed $footprint Either the ID or the footprint's name to find - */ - public function getOrCreateFootprint ($footprint) { - try { - $footprint = Footprint::loadById($footprint); - return $footprint; - } catch (EntityNotFoundException $e) {} - - $dql = "SELECT f FROM PartKeepr\Footprint\Footprint f WHERE f.name = :name"; - $query = PartKeepr::getEM()->createQuery($dql); - $query->setParameter("name", $footprint); - - try { - $footprint = $query->getSingleResult(); - return $footprint; - } catch (\Exception $e) {} - - $fp = new Footprint(); - $fp->setName($footprint); - - PartKeepr::getEM()->persist($fp); - - return $fp; - } - - /** - * Retrieves a distributor by its name. - * - * @param string $name The name of the distributor to retrieve - * @throws Doctrine\ORM\NoResultException If the distributor was not found - */ - public function getFootprintByName ($name) { - $dql = "SELECT fp FROM PartKeepr\Footprint\Footprint fp WHERE fp.name = :name"; - $query = PartKeepr::getEM()->createQuery($dql); - $query->setParameter("name", $name); - - return $query->getSingleResult(); - } -} diff --git a/src/backend/PartKeepr/Footprint/FootprintService.php b/src/backend/PartKeepr/Footprint/FootprintService.php @@ -1,96 +0,0 @@ -<?php -namespace PartKeepr\Footprint; - -use PartKeepr\TempImage\TempImage, - PartKeepr\FootprintCategory\FootprintCategory, - PartKeepr\Service\Service, - PartKeepr\Service\RestfulService, - PartKeepr\PartKeepr, - PartKeepr\Footprint\FootprintManager; - -class FootprintService extends Service implements RestfulService { - /** - * (non-PHPdoc) - * @see PartKeepr\Service.RestfulService::get() - */ - public function get () { - if ($this->hasParameter("id")) { - return array("data" => FootprintManager::getInstance()->getFootprint($this->getParameter("id"))->serialize()); - } else { - if ($this->hasParameter("sort")) { - $tmp = json_decode($this->getParameter("sort"), true); - - $aSortParams = $tmp[0]; - } else { - $aSortParams = array( - "property" => "name", - "direction" => "ASC"); - } - return FootprintManager::getInstance()->getFootprints( - $this->getParameter("start", $this->getParameter("start", 0)), - $this->getParameter("limit", $this->getParameter("limit", 25)), - $this->getParameter("sortby", $aSortParams["property"]), - $this->getParameter("dir", $aSortParams["direction"]), - $this->getParameter("query", "")); - } - } - - /** - * (non-PHPdoc) - * @see PartKeepr\Service.RestfulService::create() - */ - public function create () { - $this->requireParameter("name"); - - $footprint = new Footprint(); - $footprint->deserialize($this->getParameters()); - - PartKeepr::getEM()->persist($footprint); - - PartKeepr::getEM()->flush(); - - return array("data" => $footprint->serialize()); - } - - /** - * (non-PHPdoc) - * @see PartKeepr\Service.RestfulService::update() - */ - public function update () { - $this->requireParameter("id"); - $this->requireParameter("name"); - $footprint = Footprint::loadById($this->getParameter("id")); - - $footprint->deserialize($this->getParameters()); - - PartKeepr::getEM()->flush(); - - return array("data" => $footprint->serialize()); - - } - - /** - * (non-PHPdoc) - * @see PartKeepr\Service.RestfulService::destroy() - */ - public function destroy () { - $this->requireParameter("id"); - - FootprintManager::getInstance()->deleteFootprint($this->getParameter("id")); - - return array("data" => null); - } - - public function moveFootprint () { - $this->requireParameter("targetCategory"); - $this->requireParameter("id"); - - $footprint = Footprint::loadById($this->getParameter("id")); - $category = FootprintCategory::loadById($this->getParameter("targetCategory")); - - $footprint->setCategory($category); - - PartKeepr::getEM()->flush(); - } - -} diff --git a/src/backend/PartKeepr/FootprintAttachment/FootprintAttachmentManager.php b/src/backend/PartKeepr/FootprintAttachment/FootprintAttachmentManager.php @@ -2,7 +2,7 @@ namespace PartKeepr\FootprintAttachment; use PartKeepr\Util\Singleton, - PartKeepr\Footprint\Footprint, + \PartKeepr\FootprintBundle\Entity\Footprint, PartKeepr\PartKeepr; class FootprintAttachmentManager extends Singleton { diff --git a/src/backend/PartKeepr/FootprintAttachment/FootprintAttachmentService.php b/src/backend/PartKeepr/FootprintAttachment/FootprintAttachmentService.php @@ -1,12 +1,12 @@ <?php namespace PartKeepr\FootprintAttachment; -use PartKeepr\Footprint\FootprintAttachment, +use \PartKeepr\FootprintBundle\Entity\FootprintAttachment, PartKeepr\UploadedFile\TempUploadedFile, PartKeepr\Service\RestfulService, PartKeepr\Service\Service, PartKeepr\PartKeepr, - PartKeepr\Footprint\Footprint, + \PartKeepr\FootprintBundle\Entity\Footprint, PartKeepr\Session\SessionManager; class FootprintAttachmentService extends Service implements RestfulService { diff --git a/src/backend/PartKeepr/FootprintCategory/FootprintCategory.php b/src/backend/PartKeepr/FootprintCategory/FootprintCategory.php @@ -1,17 +0,0 @@ -<?php -namespace PartKeepr\FootprintCategory; - -use PartKeepr\Category\AbstractCategory, - Doctrine\ORM\Mapping as ORM, - Doctrine\ORM\Mapping\Table, - Doctrine\ORM\Mapping\Index; - -/** - * @ORM\Entity - * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) - * The entity for our footprint categories - * - */ -class FootprintCategory extends AbstractCategory { - -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/FootprintCategory/FootprintCategoryManager.php b/src/backend/PartKeepr/FootprintCategory/FootprintCategoryManager.php @@ -1,42 +0,0 @@ -<?php -namespace PartKeepr\FootprintCategory; - -use PartKeepr\Category\AbstractCategoryManager; -use DoctrineExtensions\NestedSet\NodeWrapper; -use PartKeepr\Util\SerializableException; -use PartKeepr\PartKeepr; - -class FootprintCategoryManager extends AbstractCategoryManager { - protected $categoryClass = "PartKeepr\FootprintCategory\FootprintCategory"; - - /** - * Deletes the given category ID. - * @param $id int The category id to delete - * @throws CategoryNotFoundException If the category wasn't found - */ - public function deleteCategory ($id) { - $category = $this->getCategory($id); - - try { - - if ($category->hasChildren()) { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains other categories."), $category->getNode()->getName())); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains other categories. Please move the categories or delete them first."), $category->getNode()->getName())); - - throw $exception; - } - - parent::deleteCategory($id); - } catch (\PDOException $e) { - if ($e->getCode() == "23000") { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains footprints."), $category->getNode()->getName())); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains footprints. Please move the footprints to another category."), $category->getNode()->getName())); - - throw $exception; - } else { - throw $e; - } - } - } - -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/FootprintCategory/FootprintCategoryService.php b/src/backend/PartKeepr/FootprintCategory/FootprintCategoryService.php @@ -1,9 +0,0 @@ -<?php -namespace PartKeepr\FootprintCategory; - -use PartKeepr\Category\AbstractCategoryService; - -class FootprintCategoryService extends AbstractCategoryService { - protected $categoryManagerClass = "PartKeepr\FootprintCategory\FootprintCategoryManager"; - protected $categoryClass = "PartKeepr\FootprintCategory\FootprintCategory"; -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Part/Part.php b/src/backend/PartKeepr/Part/Part.php @@ -2,10 +2,10 @@ namespace PartKeepr\Part; use PartKeepr\StorageLocation\StorageLocation, - PartKeepr\Footprint\Footprint, - PartKeepr\PartCategory\PartCategoryManager, + \PartKeepr\FootprintBundle\Entity\Footprint, + \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\Util\Deserializable, - PartKeepr\PartCategory\PartCategory, + \PartKeepr\PartBundle\Entity\PartCategory, PartKeepr\Util\Serializable, PartKeepr\Util\BaseEntity, PartKeepr\PartKeepr, @@ -24,7 +24,7 @@ use PartKeepr\StorageLocation\StorageLocation, class Part extends BaseEntity implements Serializable, Deserializable { /** * The category of the part - * @ORM\ManyToOne(targetEntity="PartKeepr\PartCategory\PartCategory") + * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\PartCategory") * @var Category */ private $category; @@ -45,7 +45,8 @@ class Part extends BaseEntity implements Serializable, Deserializable { /** * The footprint of this part - * @ORM\ManyToOne(targetEntity="PartKeepr\Footprint\Footprint") + * @ORM\ManyToOne(targetEntity="PartKeepr\FootprintBundle\Entity\Footprint") + * * @var Footprint */ private $footprint; @@ -327,7 +328,8 @@ class Part extends BaseEntity implements Serializable, Deserializable { /** * Sets the category for this part - * @param \PartKeepr\PartCategory\PartCategory $category The category + * +*@param \PartKeepr\PartBundle\Entity\PartCategory $category The category */ public function setCategory (PartCategory $category) { $this->category = $category; @@ -335,7 +337,8 @@ class Part extends BaseEntity implements Serializable, Deserializable { /** * Returns the assigned category - * @return \PartKeepr\PartCategory\PartCategory + * +*@return \PartKeepr\PartBundle\Entity\PartCategory */ public function getCategory () { return $this->category; @@ -359,7 +362,8 @@ class Part extends BaseEntity implements Serializable, Deserializable { /** * Sets the footprint for this part - * @param \PartKeepr\Footprint\Footprint $footprint The footprint to set + * +*@param \PartKeepr\FootprintBundle\Entity\Footprint $footprint The footprint to set */ public function setFootprint (Footprint $footprint = null) { $this->footprint = $footprint; diff --git a/src/backend/PartKeepr/Part/PartManager.php b/src/backend/PartKeepr/Part/PartManager.php @@ -19,13 +19,13 @@ use PartKeepr\UploadedFile\TempUploadedFile, PartKeepr\PartUnit\PartUnitManager, PartKeepr\Distributor\Distributor, PartKeepr\Manufacturer\Manufacturer, - PartKeepr\Footprint\FootprintManager, + \PartKeepr\FootprintBundle\Entity\FootprintManager, PartKeepr\Session\SessionManager, PartKeepr\Stock\StockEntry, PartKeepr\Util\Singleton, - PartKeepr\Footprint\Footprint, + \PartKeepr\FootprintBundle\Entity\Footprint, PartKeepr\PartKeepr, - PartKeepr\PartCategory\PartCategoryManager, + \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\Manufacturer\ManufacturerManager; class PartManager extends AbstractManager { diff --git a/src/backend/PartKeepr/Part/PartService.php b/src/backend/PartKeepr/Part/PartService.php @@ -3,8 +3,8 @@ namespace PartKeepr\Part; use PartKeepr\AuthBundle\Entity\User\User; use PartKeepr\Manager\ManagerFilter; -use PartKeepr\PartCategory\PartCategory; -use PartKeepr\PartCategory\PartCategoryManager; +use \PartKeepr\PartBundle\Entity\PartCategory; +use \PartKeepr\PartBundle\Entity\PartCategoryManager; use PartKeepr\PartKeepr; use PartKeepr\Service\RestfulService; use PartKeepr\Service\Service; diff --git a/src/backend/PartKeepr/PartCategory/PartCategory.php b/src/backend/PartKeepr/PartCategory/PartCategory.php @@ -1,17 +0,0 @@ -<?php -namespace PartKeepr\PartCategory; - -use PartKeepr\Category\AbstractCategory, - Doctrine\ORM\Mapping as ORM, - Doctrine\ORM\Mapping\Table, - Doctrine\ORM\Mapping\Index; - -/** - * @ORM\Entity - * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) - * The entity for our part categories - * - */ -class PartCategory extends AbstractCategory { - -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/PartCategory/PartCategoryManager.php b/src/backend/PartKeepr/PartCategory/PartCategoryManager.php @@ -1,42 +0,0 @@ -<?php -namespace PartKeepr\PartCategory; - -use PartKeepr\Category\AbstractCategoryManager; -use DoctrineExtensions\NestedSet\NodeWrapper; -use PartKeepr\Util\SerializableException; -use PartKeepr\PartKeepr; - -class PartCategoryManager extends AbstractCategoryManager { - protected $categoryClass = "PartKeepr\PartCategory\PartCategory"; - - /** - * Deletes the given category ID. - * @param $id int The category id to delete - * @throws CategoryNotFoundException If the category wasn't found - */ - public function deleteCategory ($id) { - $category = $this->getCategory($id); - - try { - - if ($category->hasChildren()) { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains other categories."), $category->getNode()->getName())); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains other categories. Please move the categories or delete them first."), $category->getNode()->getName())); - - throw $exception; - } - - parent::deleteCategory($id); - } catch (\PDOException $e) { - if ($e->getCode() == "23000") { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains parts."), $category->getNode()->getName())); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains parts. Please move the parts to another category."), $category->getNode()->getName())); - - throw $exception; - } else { - throw $e; - } - } - } - -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/PartCategory/PartCategoryService.php b/src/backend/PartKeepr/PartCategory/PartCategoryService.php @@ -1,9 +0,0 @@ -<?php -namespace PartKeepr\PartCategory; - -use PartKeepr\Category\AbstractCategoryService; - -class PartCategoryService extends AbstractCategoryService { - protected $categoryManagerClass = "PartKeepr\PartCategory\PartCategoryManager"; - protected $categoryClass = "PartKeepr\PartCategory\PartCategory"; -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/PartKeepr.php b/src/backend/PartKeepr/PartKeepr.php @@ -157,7 +157,7 @@ class PartKeepr { 'PartKeepr\Footprint\Footprint', 'PartKeepr\Footprint\FootprintImage', 'PartKeepr\Footprint\FootprintAttachment', - 'PartKeepr\FootprintCategory\FootprintCategory', + 'PartKeepr\FootprintBundle\Entity\FootprintCategory', 'PartKeepr\Part\Part', 'PartKeepr\Part\PartUnit', @@ -165,7 +165,7 @@ class PartKeepr { 'PartKeepr\Part\PartDistributor', 'PartKeepr\Part\PartImage', 'PartKeepr\Part\PartAttachment', - 'PartKeepr\PartCategory\PartCategory', + 'PartKeepr\PartBundle\Entity\PartCategory', 'PartKeepr\Printing\PageBasicLayout\PageBasicLayout', 'PartKeepr\Printing\PrintingJob\PrintingJob', diff --git a/src/backend/PartKeepr/Setup/FootprintSetup.php b/src/backend/PartKeepr/Setup/FootprintSetup.php @@ -1,12 +1,12 @@ <?php namespace PartKeepr\Setup; -use PartKeepr\Footprint\FootprintManager, - PartKeepr\FootprintCategory\FootprintCategoryManager, - PartKeepr\FootprintCategory\FootprintCategory, - PartKeepr\Footprint\Footprint, - PartKeepr\Footprint\FootprintImage, - PartKeepr\Footprint\FootprintAttachment, +use \PartKeepr\FootprintBundle\Entity\FootprintManager, + \PartKeepr\FootprintBundle\Entity\FootprintCategoryManager, + \PartKeepr\FootprintBundle\Entity\FootprintCategory, + \PartKeepr\FootprintBundle\Entity\Footprint, + \PartKeepr\FootprintBundle\Entity\FootprintImage, + \PartKeepr\FootprintBundle\Entity\FootprintAttachment, PartKeepr\PartKeepr, PartKeepr\Setup\Setup; diff --git a/src/backend/PartKeepr/Setup/Migration/PartDB/FootprintMigration.php b/src/backend/PartKeepr/Setup/Migration/PartDB/FootprintMigration.php @@ -2,9 +2,9 @@ namespace PartKeepr\Setup\Migration\PartDB; use PartKeepr\PartKeepr, - PartKeepr\Footprint\Footprint, - PartKeepr\Footprint\FootprintManager, - PartKeepr\FootprintCategory\FootprintCategoryManager, + \PartKeepr\FootprintBundle\Entity\Footprint, + \PartKeepr\FootprintBundle\Entity\FootprintManager, + \PartKeepr\FootprintBundle\Entity\FootprintCategoryManager, PartKeepr\Setup\FootprintSetup; class FootprintMigration extends FootprintSetup { diff --git a/src/backend/PartKeepr/Setup/Migration/PartDB/PartCategoryMigration.php b/src/backend/PartKeepr/Setup/Migration/PartDB/PartCategoryMigration.php @@ -2,8 +2,8 @@ namespace PartKeepr\Setup\Migration\PartDB; use PartKeepr\PartKeepr, - PartKeepr\PartCategory\PartCategory, - PartKeepr\PartCategory\PartCategoryManager, + \PartKeepr\PartBundle\Entity\PartCategory, + \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\Setup\AbstractSetup; class PartCategoryMigration extends AbstractSetup { diff --git a/src/backend/PartKeepr/Setup/Migration/PartDB/PartMigration.php b/src/backend/PartKeepr/Setup/Migration/PartDB/PartMigration.php @@ -8,8 +8,8 @@ use PartKeepr\PartKeepr, PartKeepr\Part\PartManager, PartKeepr\Stock\StockEntry, PartKeepr\Distributor\DistributorManager, - PartKeepr\PartCategory\PartCategoryManager, - PartKeepr\Footprint\FootprintManager, + \PartKeepr\PartBundle\Entity\PartCategoryManager, + \PartKeepr\FootprintBundle\Entity\FootprintManager, PartKeepr\PartUnit\PartUnitManager, PartKeepr\StorageLocation\StorageLocationManager, PartKeepr\Setup\AbstractSetup; diff --git a/src/backend/PartKeepr/Setup/PartCategorySetup.php b/src/backend/PartKeepr/Setup/PartCategorySetup.php @@ -2,8 +2,8 @@ namespace PartKeepr\Setup; use PartKeepr\PartKeepr, - PartKeepr\PartCategory\PartCategoryManager, - PartKeepr\PartCategory\PartCategory; + \PartKeepr\PartBundle\Entity\PartCategoryManager, + \PartKeepr\PartBundle\Entity\PartCategory; class PartCategorySetup extends AbstractSetup { /** diff --git a/src/backend/PartKeepr/Statistic/StatisticService.php b/src/backend/PartKeepr/Statistic/StatisticService.php @@ -5,7 +5,7 @@ use PartKeepr\Part\PartUnit, PartKeepr\Service\Service, PartKeepr\PartKeepr, PartKeepr\Part\PartManager, - PartKeepr\PartCategory\PartCategoryManager, + \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\PartUnit\PartUnitManager; class StatisticService extends Service { diff --git a/src/backend/PartKeepr/Statistic/StatisticSnapshotManager.php b/src/backend/PartKeepr/Statistic/StatisticSnapshotManager.php @@ -6,7 +6,7 @@ use PartKeepr\Util\Singleton, PartKeepr\Part\PartManager, PartKeepr\PartUnit\PartUnitManager, PartKeepr\PartKeepr, - PartKeepr\PartCategory\PartCategoryManager, + \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\PartUnit\Exceptions\PartUnitNotFoundException; class StatisticSnapshotManager extends Singleton { diff --git a/testing/SetupDatabase.php b/testing/SetupDatabase.php @@ -4,7 +4,7 @@ namespace PartKeepr\Testing; use PartKeepr\PartKeepr, PartKeepr\Setup\Migration\PartDB\PartDBMigration, PartKeepr\Util\Configuration, - PartKeepr\PartCategory\PartCategoryManager; + \PartKeepr\PartBundle\Entity\PartCategoryManager; use PartKeepr\Setup\Setup; diff --git a/tests/Part/PartServiceTest.php b/tests/Part/PartServiceTest.php @@ -3,7 +3,7 @@ namespace PartKeepr\Tests\Part; use PartKeepr\Distributor\DistributorService; -use PartKeepr\PartCategory\PartCategoryManager, +use \PartKeepr\PartBundle\Entity\PartCategoryManager, PartKeepr\Part\PartService, PartKeepr\PartKeepr, PartKeepr\Part\Part, diff --git a/tests/bootstrap.php b/tests/bootstrap.php @@ -2,7 +2,7 @@ namespace PartKeepr\Tests; use PartKeepr\AuthBundle\Entity\User\User; -use PartKeepr\PartCategory\PartCategoryManager; +use \PartKeepr\PartBundle\Entity\PartCategoryManager; use PartKeepr\PartKeepr; include(dirname(__DIR__). "/src/backend/PartKeepr/PartKeepr.php");