Skip to content

Commit

Permalink
added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshnik committed Mar 27, 2024
1 parent 7e07a62 commit d1bec33
Show file tree
Hide file tree
Showing 121 changed files with 29,310 additions and 35 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
config.core.php
/core/components/extrafields/vendor/
_build/resolvers/symlinks.php
_build/resolvers/symlinks.php
/node_modules/
pass.txt
4 changes: 4 additions & 0 deletions assets/components/extrafields/css/mgr/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ a.ef-btn.disabled, fieldset[disabled] a.ef-btn { pointer-events: none }
background: #fff;
padding: 15px;
}
#modx-resource-main-left .modx3-resource-panel {
padding: 0;
margin: 0;
}

/* Fields */
.ef-hidden-time .ux-datetime-time { display: none }
Expand Down
11 changes: 6 additions & 5 deletions assets/components/extrafields/js/mgr/misc/combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,18 @@ ExtraFields.combo.Types = function(config) {
[_('ef_field_type_xdatetime'),'xdatetime'],
[_('ef_field_type_readonly'),'readonly'],
[_('ef_field_type_hidden'),'hidden'],
[_('ef_field_type_xtype'),'efxtype']
[_('ef_field_type_xtype'),'ef-xtype']
];

if (MODx.loadRTE) data.splice(2,0,[_('ef_field_type_richtext'),'richtext']);

var ace = (typeof(MODx.ux) != 'undefined' && typeof(MODx.ux.Ace) == 'function') ? 1 : 0;
if (ace) data.splice(2,0,[_('ef_field_type_texteditor'), 'modx-texteditor']);
if (ace) data.splice(3,0,[_('ef_field_type_texteditor'), 'modx-texteditor']);

if (typeof ColorPicker == 'object') {
data.splice(-4,0,['ColorPicker','colorpicker']);
}
// TODO
// if (typeof ColorPicker == 'object') {
// data.splice(-4,0,['ColorPicker','colorpicker']);
// }

if (!Ext.isEmpty(ExtraFields.config.pageblocks?.apiKey)) {
data.splice(-4,0,[_('ef_field_type_gallery'),'pb-gallery']);
Expand Down
54 changes: 47 additions & 7 deletions assets/components/extrafields/js/mgr/misc/xtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ExtraFields.utils.getXtype = function (field) {
id: Ext.id(),
anchor: '100%',
width: '100%',
allowBlank: !+field.required,
allowBlank: !field.required,
description: '<b>[[*' + field.field_name + ']]</b>',
listeners: {
afterrender: function(el) {
Expand All @@ -32,7 +32,7 @@ ExtraFields.utils.getXtype = function (field) {
xtype.xtype = 'textarea';
xtype.listeners.render = function (el) {
ExtraFields.utils.renderRTE(el);
}
};
break;

case 'modx-texteditor':
Expand Down Expand Up @@ -66,7 +66,7 @@ ExtraFields.utils.getXtype = function (field) {
if (!Ext.isEmpty(values)) {
el.setValue(values.split('||'));
}
}
};
break;

case 'resourcelist':
Expand Down Expand Up @@ -100,6 +100,8 @@ ExtraFields.utils.getXtype = function (field) {
break;

case 'numberfield':
case 'price':
xtype.xtype = 'numberfield';
xtype.inputType = 'number';
xtype.cls = 'x-form-text';
if(!field.number_allownegative) {
Expand Down Expand Up @@ -197,7 +199,7 @@ ExtraFields.utils.getXtype = function (field) {
change: (el) => {
ExtraFields.utils.updateImage(el.id, el.getValue());
}
}
};
break;

case 'file':
Expand Down Expand Up @@ -252,7 +254,7 @@ ExtraFields.utils.getXtype = function (field) {
el.container.dom.querySelector('.clr-field').style.color = el.value;
},500);
}
}
};
break;

case 'pb-gallery':
Expand All @@ -268,6 +270,44 @@ ExtraFields.utils.getXtype = function (field) {
delete xtype.listeners;
break;

case 'pb-panel-video':
xtype.model_id = ExtraFields.object.id || 0;
xtype.source = field.source;
xtype.source_path = field.source_path || '/';
xtype.allowedFileTypes = ExtraFields.config.media_source[field.source].allowedFileTypes || '';
xtype.openTo = field.openTo || '/';
xtype.panel_help = field.help;
field.help = '';
xtype.listeners = {
afterrender: function(el) {
setTimeout(function(){
let input = document.getElementById(el.id + '-input');

if (Ext.isEmpty(input.value) && !Ext.isEmpty(field.default)) {
let image = new Image();
image.src = MODx.config.base_url + field.default;
image.onload = function() {
input.value = field.default;
let info = document.getElementById(el.id + '-info');
if (info) {
info.value = JSON.stringify({
"url": field.default,
"width": image.width,
"height": image.height,
"title": field.default.split('/').pop()
});
}
let preview = Ext.getCmp(el.id + '-preview');
if (preview) {
preview.update(PageBlocks.utils.previewImage(field.default));
}
};
}
}, 500);
}
};
break;

case 'pb-table':
xtype.model_type = ExtraFields.object.class_key;
xtype.model_id = ExtraFields.object.id;
Expand All @@ -282,7 +322,7 @@ ExtraFields.utils.getXtype = function (field) {
xtype.readOnly = true;
break;

case 'efxtype':
case 'ef-xtype':
xtype.xtype = field.xtype;
xtype.hiddenName = field.field_name;

Expand Down Expand Up @@ -327,7 +367,7 @@ ExtraFields.utils.getXtype = function (field) {
width:'100%',
items: items,
cls: classes.join(' '),
}
};

if (ExtraFields.config.modxversion === '3') {
xtype = {
Expand Down
2 changes: 1 addition & 1 deletion core/components/extrafields/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$_lang['ef_field_dir'] = 'Sorting direction';
$_lang['ef_field_areas'] = 'Areas';
$_lang['ef_field_index'] = 'Index';
$_lang['ef_field_active'] = 'Actively';
$_lang['ef_field_active'] = 'Active';

$_lang['ef_combo_empty'] = 'Click to select';
$_lang['ef_settings'] = 'Field settings';
Expand Down
10 changes: 5 additions & 5 deletions core/components/extrafields/lexicon/en/field.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$_lang['ef_field_type_textfield'] = 'Text field';
$_lang['ef_field_type_textarea'] = 'Text area';
$_lang['ef_field_type_textarea'] = 'Textarea';
$_lang['ef_field_type_richtext'] = 'Text editor';
//$_lang['ef_field_type_editorjs'] = 'EditorJs';
$_lang['ef_field_type_texteditor'] = 'ACE';
Expand All @@ -10,17 +10,17 @@
$_lang['ef_field_type_resourcelist'] = 'Resource list';
//$_lang['ef_field_type_readyblocks'] = 'Готовые блоки';
$_lang['ef_field_type_combo_boolean'] = 'Yes/No list';
$_lang['ef_field_type_price'] = 'Numeric field (price)';
$_lang['ef_field_type_price'] = 'Price field';
$_lang['ef_field_type_numberfield'] = 'Numeric field';
$_lang['ef_field_type_xcheckbox'] = 'Flag';
$_lang['ef_field_type_checkboxgroup'] = 'Flag group';
$_lang['ef_field_type_xcheckbox'] = 'Checkbox';
$_lang['ef_field_type_checkboxgroup'] = 'Checkbox group';
$_lang['ef_field_type_radiogroup'] = 'Radio button';
$_lang['ef_field_type_file'] = 'File';
$_lang['ef_field_type_image'] = 'Image';
$_lang['ef_field_type_gallery'] = 'Gallery';
$_lang['ef_field_type_video'] = 'Video';
//$_lang['ef_field_type_button'] = 'Кнопка';
$_lang['ef_field_type_xdatetime'] = 'Date';
$_lang['ef_field_type_xdatetime'] = 'DateTime';
//$_lang['ef_field_type_timefield'] = 'Время';
$_lang['ef_field_type_table'] = 'Table';
//$_lang['ef_field_type_colorpalette'] = 'Цветовая палитра';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function prepareRow(xPDOObject $object)
$array = $object->toArray();
$array['actions'] = [];

$fieldType = str_replace(['pb-panel-', 'pb-', 'modx-'], '', $array['field_type']);
$fieldType = str_replace(['pb-panel-', 'pb-', 'modx-', 'ef-'], '', $array['field_type']);
$fieldType = str_replace('-', '_', $fieldType);
$array['type_lexicon'] = $this->modx->lexicon('ef_field_type_' . $fieldType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class OnBeforeUserFormSave extends Event

public function run()
{
$this->modx->log(1, print_r($this->scriptProperties['mode'],1));
if ($this->scriptProperties['mode'] == 'new') return;

/** @var \modUser $user */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public function run()
if (!$resource) {
return true;
}
$data = json_encode($resource->toArray(),1);
$data = $resource->toArray();
$data['class_key'] = $resource->_class;
$data = json_encode($data,1);

$this->extrafields->loadRichTextEditor();
$tabs = json_encode($this->getTabs(),1);
Expand Down
2 changes: 1 addition & 1 deletion core/components/extrafields/src/Events/OnDocFormSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function run()

$fields = $this->getFields();
foreach ($fields as $field) {
unset($resource->_fields[$field['name']]);
unset($resource->_fields[$field['field_name']]);
}
}
}
4 changes: 2 additions & 2 deletions core/components/extrafields/src/Events/OnMODXInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public function run()

$rows = [
[
'className' => $this->modxversion === 3 ? \MODX\Revolution\modResource::class : \modResource::class,
'className' => $this->modxversion === '3' ? \MODX\Revolution\modResource::class : \modResource::class,
'fields' => $this->getFields()
], [
'className' => $this->modxversion === 3 ? \MODX\Revolution\modUserProfile::class : \modUserProfile::class,
'className' => $this->modxversion === '3' ? \MODX\Revolution\modUserProfile::class : \modUserProfile::class,
'fields' => $this->getFields('modUserProfile')
], [
'className' => \pbBlockValue::class,
Expand Down
24 changes: 15 additions & 9 deletions core/components/extrafields/src/Processors/HelpProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@ trait HelpProcessor
'dbtype' => 'text',
'phptype' => 'string',
],
'pb-panel-video' => [
'dbtype' => 'text',
'phptype' => 'string',
],
'richtext' => [
'dbtype' => 'mediumtext',
'phptype' => 'string',
],
'pb-gallery' => [
'dbtype' => 'mediumtext',
'phptype' => 'string',
],
'modx-texteditor' => [
'dbtype' => 'mediumtext',
'phptype' => 'string',
],
'listbox-multiple' => [
'dbtype' => 'text',
'phptype' => 'string',
],
'numberfield' => [
'dbtype' => 'int',
'precision' => '1',
Expand Down Expand Up @@ -51,9 +63,9 @@ trait HelpProcessor
'default' => 0,
],
'xdatetime' => [
'dbtype' => 'date',
'precision' => null,
'phptype' => 'date',
'dbtype' => 'int',
'precision' => 20,
'phptype' => 'timestamp',
],
];

Expand All @@ -66,8 +78,6 @@ trait HelpProcessor
public function createTableColumn($object)
{
if ($sql = $this->getSQL($object)) {
$this->modx->log(1, print_r($object->toArray(),1));
$this->modx->log(1, print_r($sql,1));
$this->modx->exec($sql);
}
}
Expand All @@ -80,8 +90,6 @@ public function createTableColumn($object)
public function updateTableColumn($object)
{
if ($sql = $this->getSQL($object, 'update')) {
$this->modx->log(1, print_r($object->toArray(),1));
$this->modx->log(1, print_r($sql,1));
$this->modx->exec($sql);
}
}
Expand All @@ -94,8 +102,6 @@ public function updateTableColumn($object)
public function removeTableColumn($object)
{
if ($sql = $this->getSQL($object, 'remove')) {
$this->modx->log(1, print_r($object->toArray(),1));
$this->modx->log(1, print_r($sql,1));
$this->modx->exec($sql);
}
}
Expand Down
Loading

0 comments on commit d1bec33

Please sign in to comment.