Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 97 additions & 230 deletions lib/GaletteAuto/AbstractObject.php

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/GaletteAuto/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ public function load(int $id): bool
return true;
} catch (\Exception $e) {
Analog::log(
'[' . get_class($this) . '] Cannot load car from id `' . $id
. '` | ' . $e->getMessage(),
'[' . static::class . '] Cannot load vehicle #' . $id . ' | ' . $e->getMessage(),
Analog::ERROR
);
return false;
Expand Down
75 changes: 46 additions & 29 deletions lib/GaletteAuto/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

namespace GaletteAuto;

use Galette\Core\Db;

/**
* Automobile Bodies class for galette Auto plugin
*
Expand All @@ -22,53 +20,72 @@ class Body extends AbstractObject
public const string TABLE = 'bodies';
public const string PK = 'id_body';
public const string FIELD = 'body';
public const string NAME = 'bodies';
public const string LIST_ROUTE = 'bodiesList';

/**
* Default constructor
*
* @param Db $zdb Database instance
* @param ?int $id body's id to load. Defaults to null
* Get field label
*/
public function __construct(Db $zdb, ?int $id = null)
public function getFieldLabel(): string
{
parent::__construct(
$zdb,
self::TABLE,
self::PK,
self::FIELD,
self::NAME,
$id
);
return _T('Body', 'auto');
}

/**
* Get field label
* Get list page title
*/
public function getFieldLabel(): string
public function getListTitle(): string
{
return _T('Body', 'auto');
return _T("Bodies list", "auto");
}

/**
* Get property route name
* Get add button text
*/
public function getRouteName(): string
public function getAddText(): string
{
return 'body';
return _T("Add new body", "auto");
}

/**
* Get localized count
*
* @param int $count Count
*/
public function getCountLabel(int $count): string
{
return str_replace(
'%count',
(string)$count,
_Tn('%count body', '%count bodies', $count, 'auto')
);
}

/**
* Get localized count string for object list
* Get removal success message
*
* @param int $count Removed records count
*/
protected function getLocalizedCount(): string
public function getRemovedMessage(int $count): string
{
return _Tn(
'%count body',
'%count bodies',
$this->getCount(),
'auto'
return sprintf(
_Tn('%1$s body has been successfully deleted.', '%1$s bodies have been successfully deleted.', $count, 'auto'),
$count
);
}

/**
* Get message when removal is refused because the record is in use
*/
public function getInUseMessage(): string
{
return _T('This body is used by one or more vehicles, it cannot be deleted.', 'auto');
}

/**
* Get removal error message
*/
public function getRemoveErrorMessage(): string
{
return _T('An error occurred trying to remove body :/', 'auto');
}
}
87 changes: 53 additions & 34 deletions lib/GaletteAuto/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,90 @@

namespace GaletteAuto;

use Galette\Core\Db;

/**
* Automobile Brands class for galette Auto plugin
*
* @category Plugins
* @name AutoBrands
* @author Johan Cwiklinski <johan@x-tnd.be>
* @copyright 2009-2014 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link https://galette.eu
* @since Available since 0.7dev - 2009-03-16
*/
class Brand extends AbstractObject
{
public const string TABLE = 'brands';
public const string PK = 'id_brand';
public const string FIELD = 'brand';
public const string NAME = 'brands';
public const string LIST_ROUTE = 'brandsList';

/**
* Default constructor
* Get field label
*/
public function getFieldLabel(): string
{
return _T('Brand', 'auto');
}

/**
* Get list page title
*/
public function getListTitle(): string
{
return _T("Brands list", "auto");
}

/**
* Get add button text
*/
public function getAddText(): string
{
return _T("Add new brand", "auto");
}

/**
* Get localized count
*
* @param Db $zdb Database instance
* @param ?int $id brand's id to load. Defaults to null
* @param int $count Count
*/
public function __construct(Db $zdb, ?int $id = null)
public function getCountLabel(int $count): string
{
parent::__construct(
$zdb,
self::TABLE,
self::PK,
self::FIELD,
self::NAME,
$id
return str_replace(
'%count',
(string)$count,
_Tn('%count brand', '%count brands', $count, 'auto')
);
}

/**
* Get field label
* Get removal success message
*
* @param int $count Removed records count
*/
public function getFieldLabel(): string
public function getRemovedMessage(int $count): string
{
return _T('Brand', 'auto');
return sprintf(
_Tn('%1$s brand has been successfully deleted.', '%1$s brands have been successfully deleted.', $count, 'auto'),
$count
);
}

/**
* Get property route name
* Get message when removal is refused because the record is in use
*/
public function getRouteName(): string
public function getInUseMessage(): string
{
return 'brand';
return _T('This brand is used by one or more vehicles, it cannot be deleted.', 'auto');
}

/**
* Get removal error message
*/
public function getRemoveErrorMessage(): string
{
return _T('An error occurred trying to remove brand :/', 'auto');
}

/**
* Get localized count string for object list
* Brands have a page listing their models
*/
protected function getLocalizedCount(): string
public function hasDetails(): bool
{
return _Tn(
'%count brand',
'%count brands',
$this->getCount(),
'auto'
);
return true;
}
}
75 changes: 46 additions & 29 deletions lib/GaletteAuto/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

namespace GaletteAuto;

use Galette\Core\Db;

/**
* Automobile Colors class for galette Auto plugin
*
Expand All @@ -22,53 +20,72 @@ class Color extends AbstractObject
public const string TABLE = 'colors';
public const string PK = 'id_color';
public const string FIELD = 'color';
public const string NAME = 'colors';
public const string LIST_ROUTE = 'colorsList';

/**
* Default constructor
*
* @param Db $zdb Database instance
* @param ?int $id state's id to load. Defaults to null
* Get field label
*/
public function __construct(Db $zdb, ?int $id = null)
public function getFieldLabel(): string
{
parent::__construct(
$zdb,
self::TABLE,
self::PK,
self::FIELD,
self::NAME,
$id
);
return _T('Color', 'auto');
}

/**
* Get field label
* Get list page title
*/
public function getFieldLabel(): string
public function getListTitle(): string
{
return _T('Color', 'auto');
return _T("Colors list", "auto");
}

/**
* Get property route name
* Get add button text
*/
public function getRouteName(): string
public function getAddText(): string
{
return 'color';
return _T("Add new color", "auto");
}

/**
* Get localized count
*
* @param int $count Count
*/
public function getCountLabel(int $count): string
{
return str_replace(
'%count',
(string)$count,
_Tn('%count color', '%count colors', $count, 'auto')
);
}

/**
* Get localized count string for object list
* Get removal success message
*
* @param int $count Removed records count
*/
protected function getLocalizedCount(): string
public function getRemovedMessage(int $count): string
{
return _Tn(
'%count color',
'%count colors',
$this->getCount(),
'auto'
return sprintf(
_Tn('%1$s color has been successfully deleted.', '%1$s colors have been successfully deleted.', $count, 'auto'),
$count
);
}

/**
* Get message when removal is refused because the record is in use
*/
public function getInUseMessage(): string
{
return _T('This color is used by one or more vehicles, it cannot be deleted.', 'auto');
}

/**
* Get removal error message
*/
public function getRemoveErrorMessage(): string
{
return _T('An error occurred trying to remove color :/', 'auto');
}
}
Loading
Loading