mirror of
https://github.com/a2nt/silverstripe-webpack.git
synced 2024-10-22 17:05:31 +02:00
Elemental Rows Impovements
This commit is contained in:
parent
a74ab4b672
commit
1577e974d1
@ -102,22 +102,27 @@ class ElementRows extends DataExtension
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move parent elements
|
// move parent elements
|
||||||
if($this->isList()){
|
if ($this->isList()) {
|
||||||
$tab->push(DropdownField::create(
|
$currEls = $this->owner->getField('Elements')->Elements();
|
||||||
'MoveElementIDToParent',
|
if ($currEls->count()) {
|
||||||
'Move an element from the list to parent',
|
$tab->push(DropdownField::create(
|
||||||
$this->owner->getField('Elements')->Elements()->map('ID', 'Title')
|
'MoveElementIDToParent',
|
||||||
)->setEmptyString('(select an element to move)'));
|
'Move an element from the current list to parent',
|
||||||
|
$currEls->map('ID', 'Title')
|
||||||
|
)->setEmptyString('(select an element to move)'));
|
||||||
|
}
|
||||||
|
|
||||||
$tab->push(DropdownField::create(
|
$parentEls = $this->owner->Parent()->Elements()->exclude('ID', $this->owner->ID);
|
||||||
'MoveElementIDFromParent',
|
if ($parentEls->count()) {
|
||||||
'Move an element from parent to the list',
|
$tab->push(DropdownField::create(
|
||||||
$this->owner->Parent()->Elements()
|
'MoveElementIDFromParent',
|
||||||
->exclude('ID', $this->owner->ID)
|
'Move an element from the parent to the current list',
|
||||||
->map('ID', 'Title')
|
$parentEls->map('ID', 'Title')
|
||||||
)->setEmptyString('(select an element to move)'));
|
)->setEmptyString('(select an element to move)'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$fields->findOrMakeTab('Root.Settings')
|
$fields->findOrMakeTab('Root.Settings')
|
||||||
->push(LiteralField::create(
|
->push(LiteralField::create(
|
||||||
'ClassName',
|
'ClassName',
|
||||||
@ -269,9 +274,10 @@ class ElementRows extends DataExtension
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function MoveElement($moveID, $targetID) {
|
public static function MoveElement($moveID, $targetID)
|
||||||
|
{
|
||||||
$el = BaseElement::get_by_id($moveID);
|
$el = BaseElement::get_by_id($moveID);
|
||||||
if(!$el) {
|
if (!$el) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,14 +294,14 @@ class ElementRows extends DataExtension
|
|||||||
$moveID = $this->owner->getField('MoveElementIDFromParent');
|
$moveID = $this->owner->getField('MoveElementIDFromParent');
|
||||||
$targetID = $moveID ? $this->owner->Elements()->ID : null;
|
$targetID = $moveID ? $this->owner->Elements()->ID : null;
|
||||||
|
|
||||||
if($moveID && $targetID) {
|
if ($moveID && $targetID) {
|
||||||
self::MoveElement($moveID, $targetID);
|
self::MoveElement($moveID, $targetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
$moveID = $this->owner->getField('MoveElementIDToParent');
|
$moveID = $this->owner->getField('MoveElementIDToParent');
|
||||||
$targetID = $moveID ? $this->owner->Parent()->ID : null;
|
$targetID = $moveID ? $this->owner->Parent()->ID : null;
|
||||||
|
|
||||||
if($moveID && $targetID) {
|
if ($moveID && $targetID) {
|
||||||
self::MoveElement($moveID, $targetID);
|
self::MoveElement($moveID, $targetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ use SilverStripe\Core\Cache\FilesystemCacheFactory;
|
|||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\Dev\BuildTask;
|
use SilverStripe\Dev\BuildTask;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Assets\File;
|
use SilverStripe\Assets\File;
|
||||||
|
|
||||||
class TestServer extends BuildTask
|
class TestServer extends BuildTask
|
||||||
@ -24,6 +25,28 @@ class TestServer extends BuildTask
|
|||||||
{
|
{
|
||||||
echo '<style>table{width:100%}table td,table th{border:1px solid #dedede}</style>';
|
echo '<style>table{width:100%}table td,table th{border:1px solid #dedede}</style>';
|
||||||
|
|
||||||
|
echo '<h2>Testing Server</h2>';
|
||||||
|
echo self::success('BASE_PATH: <b>'.BASE_PATH.'</b>');
|
||||||
|
echo self::success('PHP: <b>'.phpversion().'</b>');
|
||||||
|
|
||||||
|
$v = Deprecation::dump_settings()['version'];
|
||||||
|
if ($v) {
|
||||||
|
echo self::success('SilverStipe version: <b>'.$v.'</b>');
|
||||||
|
} else {
|
||||||
|
echo self::success('SilverStipe version unknown: <b>'
|
||||||
|
.(file_exists(BASE_PATH.'/framework') ? '3.x.x' : '4.x.x')
|
||||||
|
.'</b>');
|
||||||
|
}
|
||||||
|
|
||||||
|
echo self::success('Memory limit: <b>'.ini_get('memory_limit').'</b>');
|
||||||
|
|
||||||
|
|
||||||
|
if (is_writable(TEMP_FOLDER)) {
|
||||||
|
echo self::success('TMP (cache) dir <b>'.TEMP_FOLDER.'</b> dir is writable.');
|
||||||
|
} else {
|
||||||
|
echo self::error('TMP (cache) dir <b>'.TEMP_FOLDER.'</b> dir is no writable!');
|
||||||
|
}
|
||||||
|
|
||||||
echo '<h2>Testing Uploads</h2>';
|
echo '<h2>Testing Uploads</h2>';
|
||||||
$maxUpload = ini_get('upload_max_filesize');
|
$maxUpload = ini_get('upload_max_filesize');
|
||||||
$maxPost = ini_get('post_max_size');
|
$maxPost = ini_get('post_max_size');
|
||||||
@ -31,13 +54,13 @@ class TestServer extends BuildTask
|
|||||||
echo self::success('PHP max upload size: '.$maxUpload);
|
echo self::success('PHP max upload size: '.$maxUpload);
|
||||||
echo self::success('PHP max post size: '.$maxPost);
|
echo self::success('PHP max post size: '.$maxPost);
|
||||||
echo self::success('So calculated max upload size: '.self::formatBytes(min(
|
echo self::success('So calculated max upload size: '.self::formatBytes(min(
|
||||||
Convert::memstring2bytes($maxUpload),
|
self::memstring2bytes($maxUpload),
|
||||||
Convert::memstring2bytes($maxPost)
|
self::memstring2bytes($maxPost)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$defaultSizes = Config::inst()->get(Upload_Validator::class, 'default_max_file_size');
|
$defaultSizes = Config::inst()->get(Upload_Validator::class, 'default_max_file_size');
|
||||||
if($defaultSizes) {
|
if ($defaultSizes) {
|
||||||
if(!is_array($defaultSizes)){
|
if (!is_array($defaultSizes)) {
|
||||||
echo self::error('default_max_file_size miss-configuration, plz fix');
|
echo self::error('default_max_file_size miss-configuration, plz fix');
|
||||||
var_dump($defaultSizes);
|
var_dump($defaultSizes);
|
||||||
die();
|
die();
|
||||||
@ -50,6 +73,13 @@ class TestServer extends BuildTask
|
|||||||
}
|
}
|
||||||
echo '</tbody></table>';
|
echo '</tbody></table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_writable(ASSETS_DIR)) {
|
||||||
|
echo self::success('Assets dir <b>'.ASSETS_DIR.'</b> dir is writable.');
|
||||||
|
} else {
|
||||||
|
echo self::error('Assets dir <b>'.ASSETS_DIR.'</b> dir is no writable!');
|
||||||
|
}
|
||||||
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,4 +116,20 @@ class TestServer extends BuildTask
|
|||||||
}
|
}
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function memstring2bytes($memString)
|
||||||
|
{
|
||||||
|
// Remove non-unit characters from the size
|
||||||
|
$unit = preg_replace('/[^bkmgtpezy]/i', '', $memString);
|
||||||
|
// Remove non-numeric characters from the size
|
||||||
|
$size = preg_replace('/[^0-9\.]/', '', $memString);
|
||||||
|
|
||||||
|
if ($unit) {
|
||||||
|
// Find the position of the unit in the ordered string which is the power
|
||||||
|
// of magnitude to multiply a kilobyte by
|
||||||
|
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
return round($size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="form-element__form $ExtraClass">
|
<div class="form-element__form">
|
||||||
<% if $Title && $ShowTitle %>
|
<% if $Title && $ShowTitle %>
|
||||||
<h2 class="form-element__title">$Title</h2>
|
<h2 class="form-element__title">$Title</h2>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
@ -44,10 +44,12 @@ $MetaTags
|
|||||||
<link rel="dns-prefetch" href="https://fonts.gstatic.com" />
|
<link rel="dns-prefetch" href="https://fonts.gstatic.com" />
|
||||||
<link rel="dns-prefetch" href="https://use.fontawesome.com" />
|
<link rel="dns-prefetch" href="https://use.fontawesome.com" />
|
||||||
<link rel="dns-prefetch" href="https://ajax.googleapis.com" />
|
<link rel="dns-prefetch" href="https://ajax.googleapis.com" />
|
||||||
|
<link rel="dns-prefetch" href="https:///www.google-analytics.com" />
|
||||||
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link rel="preconnect" href="https://use.fontawesome.com" crossorigin />
|
<link rel="preconnect" href="https://use.fontawesome.com" crossorigin />
|
||||||
<link rel="preconnect" href="https://ajax.googleapis.com" crossorigin />
|
<link rel="preconnect" href="https://ajax.googleapis.com" crossorigin />
|
||||||
|
<link rel="preconnect" href="https:///www.google-analytics.com" crossorigin />
|
||||||
|
|
||||||
|
|
||||||
<link rel="dns-prefetch" href="https://csi.gstatic.com" />
|
<link rel="dns-prefetch" href="https://csi.gstatic.com" />
|
||||||
|
Loading…
Reference in New Issue
Block a user