generated from silverstripe/silverstripe-module
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
181 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
{ | ||
"name": "dynamic/silverstripe-elemental-locations", | ||
"description": "A locations block for Silverstripe. Display one or more locations on a map.", | ||
"license": "BSD-3-Clause", | ||
"type": "silverstripe-vendormodule", | ||
"keywords": [ | ||
"silverstripe", | ||
"CMS" | ||
], | ||
"license": "BSD-3-Clause", | ||
"require": { | ||
"dnadesign/silverstripe-elemental": "^4.8", | ||
"dnadesign/silverstripe-elemental": "^5", | ||
"silverstripe/linkfield": "^4.0", | ||
"symbiote/silverstripe-addressable": "^5.0" | ||
}, | ||
"require-dev": { | ||
"silverstripe/recipe-testing": "^2", | ||
"squizlabs/php_codesniffer": "^3.0" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"Dynamic\\Elements\\Locations\\": "src/", | ||
"Dynamic\\Elements\\Blog\\Locations\\": "tests/" | ||
"Dynamic\\Elements\\\\Locations\\Test\\": "tests/" | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.x-dev" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\Locations\Admin; | ||
|
||
use SilverStripe\Admin\ModelAdmin; | ||
use Dynamic\Elements\Locations\Model\Location; | ||
use Dynamic\Elements\Locations\Model\LocationCategory; | ||
|
||
/** | ||
* Class \Dynamic\Elements\Locations\Admin\LocationsAdmin | ||
* | ||
*/ | ||
class LocationsAdmin extends ModelAdmin | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private static $managed_models = [ | ||
Location::class, | ||
LocationCategory::class, | ||
]; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $menu_title = 'Locations'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $url_segment = 'locations'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\Locations\Model; | ||
|
||
use SilverStripe\ORM\DataObject; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\LinkField\Models\Link; | ||
use SilverStripe\LinkField\Form\MultiLinkField; | ||
|
||
/** | ||
* Class \Dynamic\Elements\Locations\Model\Location | ||
* | ||
* @property string $Title | ||
* @property string $Phone | ||
* @property string $Email | ||
* @property string $Fax | ||
* @method DataList|Link[] Links() | ||
* @method ManyManyList|LocationCategory[] Categories() | ||
*/ | ||
class Location extends DataObject | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'Location'; | ||
|
||
/** | ||
* @var string | ||
* @config | ||
*/ | ||
private static string $singular_name = 'Location'; | ||
|
||
/** | ||
* @var string | ||
* @config | ||
*/ | ||
private static string $plural_name = 'Locations'; | ||
|
||
/** | ||
* @var string | ||
* @config | ||
*/ | ||
private static string $description = 'A Location for use with the Locations Element'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $db = [ | ||
'Title' => 'Varchar(255)', | ||
'Phone' => 'Varchar(40)', | ||
'Email' => 'Varchar(255)', | ||
'Fax' => 'Varchar(45)', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $has_many = [ | ||
'Links' => Link::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $many_many = [ | ||
'Categories' => LocationCategory::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $owns = [ | ||
'Links', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
public function getCMSFields() | ||
{ | ||
$this->beforeUpdateCMSFields(function (FieldList $fields) { | ||
$fields->removeByName(['Links']); | ||
|
||
$fields->addFieldsToTab( | ||
'Root.Main', | ||
[ | ||
MultiLinkField::create('Links'), | ||
] | ||
); | ||
}); | ||
|
||
return parent::getCMSFields(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\Locations\Model; | ||
|
||
use SilverStripe\ORM\DataObject; | ||
|
||
/** | ||
* Class \Dynamic\Elements\Locations\Model\LocationCategory | ||
* | ||
* @property string $Title | ||
* @method ManyManyList|Location[] Locations() | ||
*/ | ||
class LocationCategory extends DataObject | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'LocationCategory'; | ||
|
||
/** | ||
* @var string | ||
* @config | ||
*/ | ||
private static string $singular_name = 'Category'; | ||
|
||
/** | ||
* @var string | ||
* @config | ||
*/ | ||
private static string $plural_name = 'Categories'; | ||
|
||
/** | ||
* @var string | ||
* @config | ||
*/ | ||
private static string $description = 'A category to use with Location records'; | ||
|
||
private static $db = [ | ||
'Title' => 'Varchar(255)', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $belongs_many_many = [ | ||
'Locations' => Location::class, | ||
]; | ||
} |