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
|
||||
if($this->isList()){
|
||||
$tab->push(DropdownField::create(
|
||||
'MoveElementIDToParent',
|
||||
'Move an element from the list to parent',
|
||||
$this->owner->getField('Elements')->Elements()->map('ID', 'Title')
|
||||
)->setEmptyString('(select an element to move)'));
|
||||
if ($this->isList()) {
|
||||
$currEls = $this->owner->getField('Elements')->Elements();
|
||||
if ($currEls->count()) {
|
||||
$tab->push(DropdownField::create(
|
||||
'MoveElementIDToParent',
|
||||
'Move an element from the current list to parent',
|
||||
$currEls->map('ID', 'Title')
|
||||
)->setEmptyString('(select an element to move)'));
|
||||
}
|
||||
|
||||
$tab->push(DropdownField::create(
|
||||
'MoveElementIDFromParent',
|
||||
'Move an element from parent to the list',
|
||||
$this->owner->Parent()->Elements()
|
||||
->exclude('ID', $this->owner->ID)
|
||||
->map('ID', 'Title')
|
||||
)->setEmptyString('(select an element to move)'));
|
||||
$parentEls = $this->owner->Parent()->Elements()->exclude('ID', $this->owner->ID);
|
||||
if ($parentEls->count()) {
|
||||
$tab->push(DropdownField::create(
|
||||
'MoveElementIDFromParent',
|
||||
'Move an element from the parent to the current list',
|
||||
$parentEls->map('ID', 'Title')
|
||||
)->setEmptyString('(select an element to move)'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$fields->findOrMakeTab('Root.Settings')
|
||||
->push(LiteralField::create(
|
||||
'ClassName',
|
||||
@ -269,9 +274,10 @@ class ElementRows extends DataExtension
|
||||
return $type;
|
||||
}
|
||||
|
||||
public static function MoveElement($moveID, $targetID) {
|
||||
public static function MoveElement($moveID, $targetID)
|
||||
{
|
||||
$el = BaseElement::get_by_id($moveID);
|
||||
if(!$el) {
|
||||
if (!$el) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -288,14 +294,14 @@ class ElementRows extends DataExtension
|
||||
$moveID = $this->owner->getField('MoveElementIDFromParent');
|
||||
$targetID = $moveID ? $this->owner->Elements()->ID : null;
|
||||
|
||||
if($moveID && $targetID) {
|
||||
if ($moveID && $targetID) {
|
||||
self::MoveElement($moveID, $targetID);
|
||||
}
|
||||
|
||||
$moveID = $this->owner->getField('MoveElementIDToParent');
|
||||
$targetID = $moveID ? $this->owner->Parent()->ID : null;
|
||||
|
||||
if($moveID && $targetID) {
|
||||
if ($moveID && $targetID) {
|
||||
self::MoveElement($moveID, $targetID);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use SilverStripe\Core\Cache\FilesystemCacheFactory;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Assets\File;
|
||||
|
||||
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 '<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>';
|
||||
$maxUpload = ini_get('upload_max_filesize');
|
||||
$maxPost = ini_get('post_max_size');
|
||||
@ -31,18 +54,18 @@ class TestServer extends BuildTask
|
||||
echo self::success('PHP max upload size: '.$maxUpload);
|
||||
echo self::success('PHP max post size: '.$maxPost);
|
||||
echo self::success('So calculated max upload size: '.self::formatBytes(min(
|
||||
Convert::memstring2bytes($maxUpload),
|
||||
Convert::memstring2bytes($maxPost)
|
||||
self::memstring2bytes($maxUpload),
|
||||
self::memstring2bytes($maxPost)
|
||||
)));
|
||||
|
||||
$defaultSizes = Config::inst()->get(Upload_Validator::class, 'default_max_file_size');
|
||||
if($defaultSizes) {
|
||||
if(!is_array($defaultSizes)){
|
||||
if ($defaultSizes) {
|
||||
if (!is_array($defaultSizes)) {
|
||||
echo self::error('default_max_file_size miss-configuration, plz fix');
|
||||
var_dump($defaultSizes);
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
echo '<h3>Configured limits:</h3><table style="text-align:center">'
|
||||
.'<thead><tr><th>File</th><th>Size limit</th></tr></thead><tbody>';
|
||||
foreach ($defaultSizes as $k => $size) {
|
||||
@ -50,6 +73,13 @@ class TestServer extends BuildTask
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
@ -86,4 +116,20 @@ class TestServer extends BuildTask
|
||||
}
|
||||
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 %>
|
||||
<h2 class="form-element__title">$Title</h2>
|
||||
<% end_if %>
|
||||
|
@ -44,10 +44,12 @@ $MetaTags
|
||||
<link rel="dns-prefetch" href="https://fonts.gstatic.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:///www.google-analytics.com" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.gstatic.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:///www.google-analytics.com" crossorigin />
|
||||
|
||||
|
||||
<link rel="dns-prefetch" href="https://csi.gstatic.com" />
|
||||
|
Loading…
Reference in New Issue
Block a user