forked from directus/directus
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
430ea13
commit b704bf9
Showing
1,220 changed files
with
2,443 additions
and
1,680 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
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
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
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 |
---|---|---|
|
@@ -13,5 +13,7 @@ public function up() | |
'null' => true, | ||
'default' => null, | ||
]); | ||
|
||
$table->save(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -13,5 +13,7 @@ public function up() | |
'null' => true, | ||
'default' => null | ||
]); | ||
|
||
$table->save(); | ||
} | ||
} |
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
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
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 |
---|---|---|
|
@@ -11,5 +11,7 @@ public function up() | |
$table->changeColumn('value', 'text', [ | ||
'null' => true | ||
]); | ||
|
||
$table->save(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,7 +16,5 @@ public function up() | |
], | ||
['collection' => 'directus_files', 'field' => 'duration'] | ||
)); | ||
|
||
|
||
} | ||
} |
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
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
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
110 changes: 110 additions & 0 deletions
110
migrations/upgrades/20200108122313_add_asset_url_naming_setting.php
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,110 @@ | ||
<?php | ||
|
||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class AddAssetURLNamingSetting extends AbstractMigration | ||
{ | ||
public function change() | ||
{ | ||
$fieldsTable = $this->table('directus_fields'); | ||
$settingsTable = $this->table('directus_settings'); | ||
|
||
if (!$this->checkFieldExist('directus_settings', 'asset_url_naming')) { | ||
$fieldsTable->insert([ | ||
'collection' => 'directus_settings', | ||
'field' => 'asset_url_naming', | ||
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING, | ||
'interface' => 'dropdown', | ||
'locked' => 1, | ||
'sort' => 32, | ||
'width' => 'half', | ||
'note' => 'Thumbnail URL convention', | ||
'options' => json_encode([ | ||
'choices' => [ | ||
'private_hash' => 'Private Hash (Obfuscated)', | ||
'filename_download' => 'File Name (Readable)' | ||
] | ||
]) | ||
])->save(); | ||
} | ||
|
||
if ($this->checkFieldExist('directus_settings', 'file_mimetype_whitelist')) { | ||
$this->execute(\Directus\phinx_update( | ||
$this->getAdapter(), | ||
'directus_fields', | ||
[ | ||
'sort' => 33 | ||
], | ||
['collection' => 'directus_settings', 'field' => 'file_mimetype_whitelist'] | ||
)); | ||
} | ||
|
||
if ($this->checkFieldExist('directus_settings', 'asset_whitelist')) { | ||
$this->execute(\Directus\phinx_update( | ||
$this->getAdapter(), | ||
'directus_fields', | ||
[ | ||
'sort' => 34 | ||
], | ||
['collection' => 'directus_settings', 'field' => 'asset_whitelist'] | ||
)); | ||
} | ||
|
||
if ($this->checkFieldExist('directus_settings', 'asset_whitelist_system')) { | ||
$this->execute(\Directus\phinx_update( | ||
$this->getAdapter(), | ||
'directus_fields', | ||
[ | ||
'sort' => 35 | ||
], | ||
['collection' => 'directus_settings', 'field' => 'asset_whitelist_system'] | ||
)); | ||
} | ||
|
||
if ($this->checkFieldExist('directus_settings', 'youtube_api_key')) { | ||
$this->execute(\Directus\phinx_update( | ||
$this->getAdapter(), | ||
'directus_fields', | ||
[ | ||
'sort' => 36 | ||
], | ||
['collection' => 'directus_settings', 'field' => 'youtube_api_key'] | ||
)); | ||
} | ||
|
||
// ------------------------------------------------------------------------- | ||
// Add new setting fields | ||
// ------------------------------------------------------------------------- | ||
$newSettings = [ | ||
[ | ||
'key' => 'asset_url_naming', | ||
'value' => 'private_hash' | ||
], | ||
]; | ||
|
||
foreach ($newSettings as $setting) { | ||
if ($this->hasSetting($setting['key']) == false) { | ||
$settingsTable->insert($setting); | ||
} | ||
} | ||
|
||
// ------------------------------------------------------------------------- | ||
// Save the changes | ||
// ------------------------------------------------------------------------- | ||
$fieldsTable->save(); | ||
$settingsTable->save(); | ||
} | ||
|
||
public function checkFieldExist($collection, $field) | ||
{ | ||
$checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $field); | ||
return $this->query($checkSql)->fetch(); | ||
} | ||
|
||
public function hasSetting($field) | ||
{ | ||
$checkSql = sprintf('SELECT 1 FROM `directus_settings` WHERE `key` = "%s"', $field); | ||
return $this->query($checkSql)->fetch(); | ||
} | ||
} |
Oops, something went wrong.