Skip to content

Commit 5c74a79

Browse files
authored
Merge pull request #41 from 64j/3.1.x
3.1.7
2 parents fa7b523 + 497c1e4 commit 5c74a79

File tree

3 files changed

+41
-40
lines changed

3 files changed

+41
-40
lines changed

assets/plugins/templatesedit/class/templatesedit.class.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ protected function renderTabs(): string
405405
$this->richtexteditorOptions[$this->evo->getConfig('which_editor')]['ta'] = '';
406406
}
407407

408-
foreach ($this->config as $tabName => &$tab) {
408+
foreach ($this->config as $tabName => $tab) {
409409
if ($tab['title'] && $tabName != '#Static') {
410410
$tabContent = $this->renderTab($tab);
411411
if ($tabContent) {
@@ -620,7 +620,7 @@ protected function renderField(string $key, array $data, array $settings = []):
620620
$editor = $this->evo->getConfig('which_editor');
621621
if (!empty($tvOptions)) {
622622
$editor = $tvOptions['editor'] ?? $this->evo->getConfig('which_editor');
623-
};
623+
}
624624
$this->richtexteditorIds[$editor][] = $key;
625625
$this->richtexteditorOptions[$editor][$key] = $tvOptions;
626626
}
@@ -724,7 +724,7 @@ protected function renderField(string $key, array $data, array $settings = []):
724724
]);
725725
$field .= $this->form('input', [
726726
'name' => 'ta',
727-
'value' => !empty($this->doc['content']) ? stripslashes($this->doc['content']) : 'http://',
727+
'value' => !empty($this->doc['content']) ? stripslashes($this->doc['content']) : 'https://',
728728
'class' => $data['class']
729729
]);
730730
}
@@ -898,7 +898,7 @@ protected function renderField(string $key, array $data, array $settings = []):
898898
$editor = $this->evo->getConfig('which_editor');
899899
if (!empty($tvOptions)) {
900900
$editor = $tvOptions['editor'] ?? $this->evo->getConfig('which_editor');
901-
};
901+
}
902902
$this->richtexteditorIds[$editor][] = 'tv' . $data['id'];
903903
$this->richtexteditorOptions[$editor]['tv' . $data['id']] = $tvOptions;
904904
}
@@ -1214,7 +1214,7 @@ public function OnDocFormSave(int $id, string $mode): void
12141214
if (!empty($v['save'])) {
12151215
if (isset($_REQUEST[$k])) {
12161216
if (!empty($v['prepareSave'])) {
1217-
$v = $this->prepare($v['prepareSave'], $_REQUEST[$k]);
1217+
$v = $this->prepare($v['prepareSave'], $_REQUEST[$k], $mode);
12181218
} else {
12191219
$v = $_REQUEST[$k];
12201220
}
@@ -1241,15 +1241,17 @@ public function OnDocFormSave(int $id, string $mode): void
12411241
/**
12421242
* @param string $name
12431243
* @param array $data
1244+
* @param string|null $mode
12441245
* @return array|false|mixed|string
12451246
*/
1246-
protected function prepare(string $name = 'prepare', array $data = [])
1247+
protected function prepare(string $name = 'prepare', array $data = [], string $mode = null)
12471248
{
12481249
if (!empty($name)) {
12491250
$params = [
12501251
'data' => $data,
12511252
'modx' => $this->evo,
1252-
'_MF' => $this
1253+
'_TE' => $this,
1254+
'mode' => $mode
12531255
];
12541256

12551257
if ((is_object($name)) || is_callable($name)) {

assets/plugins/templatesedit/plugin.templatesedit.php

+30-31
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,40 @@
33
die('HACK???');
44
}
55

6+
spl_autoload_register(function ($class) {
7+
if (file_exists($class = __DIR__ . '/class/' . $class . '.class.php')) {
8+
require_once $class;
9+
}
10+
});
11+
612
$e = evolutionCMS()->event;
7-
$templateEditClass = __DIR__ . '/class/templatesedit.class.php';
8-
$templateEditBuilderClass = __DIR__ . '/class/templateseditbuilder.class.php';
9-
10-
if ($e->name == 'OnDocFormTemplateRender') {
11-
global $content;
12-
require_once $templateEditClass;
13-
$e->addOutput(templatesedit::getInstance($content)
14-
->renderTemplate());
15-
}
1613

17-
if ($e->name == 'OnDocFormRender') {
18-
global $content;
19-
require_once $templateEditClass;
20-
$e->addOutput(templatesedit::getInstance($content)
21-
->renderAfterTemplate());
22-
}
14+
switch ($e->name) {
15+
case 'OnDocFormTemplateRender':
16+
global $content;
17+
$e->addOutput(templatesedit::getInstance($content)
18+
->renderTemplate());
19+
break;
2320

24-
if ($e->name == 'OnDocFormSave') {
25-
global $content;
26-
require_once $templateEditClass;
27-
(new templatesedit())->OnDocFormSave((int) $id, (string) $mode);
28-
}
21+
case 'OnDocFormRender':
22+
global $content;
23+
$e->addOutput(templatesedit::getInstance($content)
24+
->renderAfterTemplate());
25+
break;
2926

30-
if ($e->name == 'OnTempFormRender') {
31-
require_once $templateEditBuilderClass;
32-
$e->addOutput((new templateseditbuilder())->renderTemplate());
33-
}
27+
case 'OnDocFormSave':
28+
(new templatesedit())->OnDocFormSave((int) $id, (string) $mode);
29+
break;
3430

35-
if ($e->name == 'OnTempFormSave') {
36-
require_once $templateEditBuilderClass;
37-
(new templateseditbuilder())->saveTemplate();
38-
}
31+
case 'OnTempFormRender':
32+
$e->addOutput((new templateseditbuilder())->renderTemplate());
33+
break;
34+
35+
case 'OnTempFormSave':
36+
(new templateseditbuilder())->saveTemplate();
37+
break;
3938

40-
if ($e->name == 'OnTempFormDelete') {
41-
require_once $templateEditBuilderClass;
42-
(new templateseditbuilder())->deleteTemplate((int) $id);
39+
case 'OnTempFormDelete':
40+
(new templateseditbuilder())->deleteTemplate((int) $id);
41+
break;
4342
}

install/assets/plugins/templatesedit.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Кастомизация полей при редактировании документов
66
*
77
* @category plugin
8-
* @version 3.1.6
8+
* @version 3.1.7
99
* @package evo
1010
* @internal @properties &showTvImage=Show TV thumbnail;list;yes,no;yes &showTvName=Show TV titles;list;yes,no;no &excludeTvCategory=Exclude TV from categories;text
1111
* @internal @events OnDocFormTemplateRender,OnDocFormRender,OnDocFormSave,OnTempFormRender,OnTempFormSave,OnTempFormDelete
@@ -14,4 +14,4 @@
1414
* @author 64j
1515
*/
1616

17-
require MODX_BASE_PATH.'assets/plugins/templatesedit/plugin.templatesedit.php';
17+
require MODX_BASE_PATH.'assets/plugins/templatesedit/plugin.templatesedit.php';

0 commit comments

Comments
 (0)