Skip to content

Commit

Permalink
Merge pull request #42 from 64j/3.1.x
Browse files Browse the repository at this point in the history
3.1.8
  • Loading branch information
64j authored Mar 8, 2022
2 parents 5c74a79 + f5435ea commit c1a1121
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 38 deletions.
33 changes: 27 additions & 6 deletions assets/plugins/templatesedit/class/templatesedit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,7 @@ protected function setDefaults(): void

$this->doc['syncsite'] = 1;

$this->defaultFields = require_once $this->basePath . 'configs/fields.php';

if (file_exists($this->basePath . 'configs/custom_fields.php')) {
$this->defaultFields += require_once $this->basePath . 'configs/custom_fields.php';
}
$this->defaultFields = $this->getDefaultFields();
}

/**
Expand All @@ -275,6 +271,30 @@ protected function getTemplateId(): int
return (int) $this->doc['template'];
}

/**
* @return array
*/
protected function getDefaultFields(): array
{
$this->defaultFields = require_once $this->basePath . 'configs/fields.php';

if (version_compare($this->evo->getConfig('settings_version'), '3.1.0') >= 0) {
$position = array_search('donthit', array_keys($this->defaultFields));
$fieldsBefore = array_slice($this->defaultFields, 0, $position);
$fieldsAfter = array_slice($this->defaultFields, $position + 1);
$addedFields = [
'hide_from_tree' => $this->defaultFields['donthit']
];
$this->defaultFields = $fieldsBefore + $addedFields + $fieldsAfter;
}

if (file_exists($this->basePath . 'configs/custom_fields.php')) {
$this->defaultFields += require_once $this->basePath . 'configs/custom_fields.php';
}

return $this->defaultFields;
}

/**
* @return array
*/
Expand Down Expand Up @@ -629,6 +649,7 @@ protected function renderField(string $key, array $data, array $settings = []):
case 'published':
case 'richtext':
case 'donthit':
case 'hide_from_tree':
case 'searchable':
case 'cacheable':
case 'syncsite':
Expand All @@ -638,7 +659,7 @@ protected function renderField(string $key, array $data, array $settings = []):
$rowClass .= ' form-row-checkbox';
$labelFor .= 'check';
$value = empty($this->doc[$key]) ? 0 : 1;
if ($key == 'donthit' || $key == 'hidemenu') {
if ($key == 'donthit' || $key == 'hide_from_tree' || $key == 'hidemenu') {
$checked = !$value ? 'checked' : '';
} else {
$checked = $value ? 'checked' : '';
Expand Down
10 changes: 10 additions & 0 deletions assets/plugins/templatesedit/class/templateseditbuilder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ protected function getDefaultFields(): array
{
$this->defaultFields = require_once $this->basePath . 'configs/fields.php';

if (version_compare($this->evo->getConfig('settings_version'), '3.1.0') >= 0) {
$position = array_search('donthit', array_keys($this->defaultFields));
$fieldsBefore = array_slice($this->defaultFields, 0, $position);
$fieldsAfter = array_slice($this->defaultFields, $position + 1);
$addedFields = [
'hide_from_tree' => $this->defaultFields['donthit']
];
$this->defaultFields = $fieldsBefore + $addedFields + $fieldsAfter;
}

if (file_exists($this->basePath . 'configs/custom_fields.php')) {
$this->defaultFields += require_once $this->basePath . 'configs/custom_fields.php';
}
Expand Down
3 changes: 3 additions & 0 deletions assets/plugins/templatesedit/lang/en.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return require 'english.php';
3 changes: 3 additions & 0 deletions assets/plugins/templatesedit/lang/es.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return require 'spanish.php';
3 changes: 3 additions & 0 deletions assets/plugins/templatesedit/lang/nl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return require 'nederlands-utf8.php';
3 changes: 3 additions & 0 deletions assets/plugins/templatesedit/lang/ru.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return require 'russian-UTF8.php';
6 changes: 3 additions & 3 deletions assets/plugins/templatesedit/tpl/b_field.tpl.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="col-12 b-field b-item b-draggable<?= $data['rowClass'] ?>" title="<?= $data['title'] ?>" data-name="<?= $data['name'] ?>" data-title="<?= $data['title'] ?>" data-type="<?= $data['type'] ?>" data-category="<?= $data['category'] ?>"<?= $data['attr'] ?>>
<div class="col-12 b-field b-item b-draggable<?= $data['rowClass'] ?? '' ?>" title="<?= $data['title'] ?? '' ?>" data-name="<?= $data['name'] ?? '' ?>" data-title="<?= $data['title'] ?? '' ?>" data-type="<?= $data['type'] ?? '' ?>" data-category="<?= $data['category'] ?? 0 ?>"<?= $data['attr'] ?? '' ?>>
<div class="row align-items-center">
<div class="col-auto"><i class="fa fa-bars b-move"></i></div>
<div class="col b-field-name"><?= $data['name'] ?></div>
<div class="col b-field-name"><?= $data['name'] ?? '' ?></div>
<div class="col-auto"><i class="fa fa-cog b-btn-settings"></i></div>
<div class="col-auto"><i class="fa fa-minus-circle text-danger b-btn-del"></i></div>
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions assets/plugins/templatesedit/tpl/b_field_category.tpl.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="col-12 b-category b-item b-draggable" data-name="category:<?= $data['name'] ?>" data-title="<?= $data['title'] ?>" data-id="<?= $data['name'] ?>">
<div class="col-12 b-category b-item b-draggable" data-name="category:<?= $data['name'] ?? '' ?>" data-title="<?= $data['title'] ?? '' ?>" data-id="<?= $data['name'] ?? '' ?>">
<div class="row b-category-title">
<div class="col-auto"><i class="fa fa-bars b-move"></i></div>
<div class="col b-field-name"><?= $data['title'] ?></div>
<div class="col b-field-name"><?= $data['title'] ?? '' ?></div>
<div class="col-auto"><i class="fa fa-minus-circle text-danger b-btn-del"></i></div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion assets/plugins/templatesedit/tpl/builder.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</div>
<textarea name="templatesedit_builder_data" id="templatesedit_builder_data" rows="15" style="display: none"><?= $data['config'] ?></textarea>
<script src="<?= MODX_BASE_URL ?>assets/plugins/templatesedit/js/Sortable.min.js"></script>
<script src="<?= MODX_BASE_URL ?>assets/plugins/templatesedit/js/TemplatesEditBuilder.js?v=3.1.6"></script>
<script src="<?= MODX_BASE_URL ?>assets/plugins/templatesedit/js/TemplatesEditBuilder.js?v=3.1.8"></script>
<script>
new TemplatesEditBuilder(document.getElementById('builder'), {
dataEl: document.getElementById('templatesedit_builder_data'),
Expand Down
2 changes: 1 addition & 1 deletion assets/plugins/templatesedit/tpl/button.tpl.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button type="button" class="btn" <?= $data['attr'] ?>><?= $data['value'] ?></button>
<button type="button" class="btn" <?= $data['attr'] ?? '' ?>><?= $data['value'] ?? '' ?></button>
6 changes: 3 additions & 3 deletions assets/plugins/templatesedit/tpl/datalist.tpl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<datalist id="datalist<?= $data['id'] ?>">
<?= $data['options'] ?>
<datalist id="datalist<?= $data['id'] ?? '' ?>">
<?= $data['options'] ?? '' ?>
</datalist>
<script>document.mutate.tv<?= $data['id'] ?>.setAttribute('list', 'datalist<?= $data['id'] ?>');</script>
<script>document.mutate.tv<?= $data['id'] ?? '' ?>.setAttribute('list', 'datalist<?= $data['id'] ?? '' ?>');</script>
8 changes: 4 additions & 4 deletions assets/plugins/templatesedit/tpl/date.tpl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<input id="<?= $data['id'] ?>" class="<?= $data['class'] ?> DatePicker unstyled" name="<?= $data['name'] ?>" value="<?= $data['value'] ?>" onblur="documentDirty=true;" placeholder="<?= $data['placeholder'] ?>" <?= $data['disabled'] ?> />
<input id="<?= $data['id'] ?? '' ?>" class="<?= $data['class'] ?? '' ?> DatePicker unstyled" name="<?= $data['name'] ?? '' ?>" value="<?= $data['value'] ?? '' ?>" onblur="documentDirty=true;" placeholder="<?= $data['placeholder'] ?? '' ?>" <?= $data['disabled'] ?? '' ?> />
<span class="input-group-append">
<a class="btn text-danger" href="javascript:;" onclick="document.mutate.<?= $data['name'] ?>.value=''; documentDirty=true; return true;">
<i class="<?= $data['icon'] ?>" title="<?= $data['icon.title'] ?>"></i>
<a class="btn text-danger" href="javascript:;" onclick="document.mutate.<?= $data['name'] ?? '' ?>.value=''; documentDirty=true; return true;">
<i class="<?= $data['icon'] ?? '' ?>" title="<?= $data['icon.title'] ?? '' ?>"></i>
</a>
</span>
</span>
2 changes: 1 addition & 1 deletion assets/plugins/templatesedit/tpl/element.tpl.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<<?= (isset($data['tag']) ? $data['tag'] : 'div') ?><?= (isset($data['id']) ? ' id="' . $data['id'] . '"' : '') ?> class="<?= (isset($data['class']) ? $data['class'] : '') ?>" <?= (isset($data['attr']) ? $data['attr'] : '') ?>><?= (isset($data['content']) ? $data['content'] : '') ?></<?= (isset($data['tag']) ? $data['tag'] : 'div') ?>>
<<?= $data['tag'] ?? 'div' ?> id="<?= $data['id'] ?? '' ?>" class="<?= $data['class'] ?? '' ?>" <?= $data['attr'] ?? '' ?>><?= $data['content'] ?? '' ?></<?= $data['tag'] ?? 'div' ?>>
2 changes: 1 addition & 1 deletion assets/plugins/templatesedit/tpl/input.tpl.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<input type="<?= $data['type'] ?>" id="<?= $data['id'] ?>" class="<?= $data['class'] ?>" name="<?= $data['name'] ?>" maxlength="<?= $data['maxlength'] ?>" value="<?= $data['value'] ?>" onchange="<?= $data['onchange'] ?>" <?= $data['attr'] ?> />
<input type="<?= $data['type'] ?? 'text' ?>" id="<?= $data['id'] ?? '' ?>" class="<?= $data['class'] ?? '' ?>" name="<?= $data['name'] ?? '' ?>" maxlength="<?= $data['maxlength'] ?? '' ?>" value="<?= $data['value'] ?? '' ?>" onchange="<?= $data['onchange'] ?? '' ?>" <?= $data['attr'] ?? '' ?> />
2 changes: 1 addition & 1 deletion assets/plugins/templatesedit/tpl/option.tpl.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<option value="<?= $data['value'] ?>" <?= $data['selected'] ?>><?= $data['title'] ?></option>
<option value="<?= $data['value'] ?? '' ?>" <?= $data['selected'] ?? '' ?>><?= $data['title'] ?? '' ?></option>
6 changes: 3 additions & 3 deletions assets/plugins/templatesedit/tpl/select.tpl.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<select id="<?= $data['id'] ?>" class="<?= $data['class'] ?>" name="<?= $data['name'] ?>" onchange="<?= $data['onchange'] ?>">
<?= $data['options'] ?>
</select>
<select id="<?= $data['id'] ?? '' ?>" class="<?= $data['class'] ?? '' ?>" name="<?= $data['name'] ?? '' ?>" onchange="<?= $data['onchange'] ?? '' ?>">
<?= $data['options'] ?? '' ?>
</select>
12 changes: 6 additions & 6 deletions assets/plugins/templatesedit/tpl/tab.tpl.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- tab<?= $data['name'] ?> -->
<div class="tab-page" id="tab<?= $data['name'] ?>">
<h2 class="tab"><?= $data['title'] ?></h2>
<script><?= $data['tabsObject'] ?>.addTabPage(document.getElementById('tab<?= $data['name'] ?>'));</script>
<?= isset($data['content']) ? $data['content'] : '' ?>
<!-- tab<?= $data['name'] ?? '' ?> -->
<div class="tab-page" id="tab<?= $data['name'] ?? '' ?>">
<h2 class="tab"><?= $data['title'] ?? '' ?></h2>
<script><?= $data['tabsObject'] ?? '' ?>.addTabPage(document.getElementById('tab<?= $data['name'] ?? '' ?>'));</script>
<?= $data['content'] ?? '' ?>
</div>
<!-- end #tab<?= $data['name'] ?> -->
<!-- end #tab<?= $data['name'] ?? '' ?> -->
2 changes: 1 addition & 1 deletion assets/plugins/templatesedit/tpl/textarea.tpl.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<textarea id="<?= $data['id'] ?>" class="<?= $data['class'] ?>" name="<?= $data['name'] ?>" rows="<?= $data['rows'] ?>" wrap="soft" onchange="documentDirty=true;"><?= $data['value'] ?></textarea>
<textarea id="<?= $data['id'] ?? '' ?>" class="<?= $data['class'] ?? '' ?>" name="<?= $data['name'] ?? '' ?>" rows="<?= $data['rows'] ?? '' ?>" wrap="soft" onchange="documentDirty=true;"><?= $data['value'] ?? '' ?></textarea>
6 changes: 3 additions & 3 deletions assets/plugins/templatesedit/tpl/thumb.tpl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="col-12">
<div id="image_for_<?= $data['name'] ?>" class="image_for_field" data-image="<?= $data['value'] ?>" onclick="BrowseServer('<?= $data['name'] ?>')" style="background-image: url('<?= $data['value'] ?>');"></div>
<script>document.getElementById('<?= $data['name'] ?>').addEventListener('change', renderTvImageCheck, false);</script>
</div>
<div id="image_for_<?= $data['name'] ?? '' ?>" class="image_for_field" data-image="<?= $data['value'] ?? '' ?>" onclick="BrowseServer('<?= $data['name'] ?? '' ?>')" style="background-image: url('<?= $data['value'] ?>');"></div>
<script>document.getElementById('<?= $data['name'] ?? '' ?>').addEventListener('change', renderTvImageCheck, false);</script>
</div>
2 changes: 1 addition & 1 deletion install/assets/plugins/templatesedit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Кастомизация полей при редактировании документов
*
* @category plugin
* @version 3.1.7
* @version 3.1.8
* @package evo
* @internal @properties &showTvImage=Show TV thumbnail;list;yes,no;yes &showTvName=Show TV titles;list;yes,no;no &excludeTvCategory=Exclude TV from categories;text
* @internal @events OnDocFormTemplateRender,OnDocFormRender,OnDocFormSave,OnTempFormRender,OnTempFormSave,OnTempFormDelete
Expand Down

0 comments on commit c1a1121

Please sign in to comment.