|
|
@@ -159,7 +159,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
if($this->id) $this->field = $this->fields->get($this->id);
|
|
|
|
if($this->id) $this->field = $this->fields->get($this->id);
|
|
|
|
if(!$this->field) $this->field = new Field();
|
|
|
|
if(!$this->field) $this->field = new Field();
|
|
|
|
|
|
|
|
|
|
|
|
return parent::init();
|
|
|
|
parent::init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@@ -405,6 +405,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$button->showInHeader();
|
|
|
|
$button->showInHeader();
|
|
|
|
$out .= $button->render();
|
|
|
|
$out .= $button->render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldButton $button */
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button->id = 'tags_button';
|
|
|
|
$button->id = 'tags_button';
|
|
|
|
$button->href = './tags/';
|
|
|
|
$button->href = './tags/';
|
|
|
@@ -412,6 +413,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$button->value = $this->labels['manage-tags'];
|
|
|
|
$button->value = $this->labels['manage-tags'];
|
|
|
|
$out .= $button->render();
|
|
|
|
$out .= $button->render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldButton $button */
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button->id = 'import_button';
|
|
|
|
$button->id = 'import_button';
|
|
|
|
$button->href = "./import/";
|
|
|
|
$button->href = "./import/";
|
|
|
@@ -420,6 +422,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$button->setSecondary();
|
|
|
|
$button->setSecondary();
|
|
|
|
$out .= $button->render();
|
|
|
|
$out .= $button->render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldButton $button */
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button->id = 'export_button';
|
|
|
|
$button->id = 'export_button';
|
|
|
|
$button->href = "./export/";
|
|
|
|
$button->href = "./export/";
|
|
|
@@ -494,8 +497,10 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$value = array();
|
|
|
|
$value = array();
|
|
|
|
foreach($fields as $field) {
|
|
|
|
foreach($fields as $field) {
|
|
|
|
/** @var Field $field */
|
|
|
|
/** @var Field $field */
|
|
|
|
|
|
|
|
/** @var Fieldtype $fieldtype */
|
|
|
|
|
|
|
|
$fieldtype = $field->type;
|
|
|
|
if($field->flags & Field::flagSystem && !in_array($field->name, array('title', 'email'))) continue;
|
|
|
|
if($field->flags & Field::flagSystem && !in_array($field->name, array('title', 'email'))) continue;
|
|
|
|
$f->addOption($field->name, "**$field->name**|$field->label|{$field->type->shortName}|" . $field->getTags(', '));
|
|
|
|
$f->addOption($field->name, "**$field->name**|$field->label|{$fieldtype->shortName}|" . $field->getTags(', '));
|
|
|
|
if($field->hasTag($editTag)) $value[] = $field->name;
|
|
|
|
if($field->hasTag($editTag)) $value[] = $field->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$f->attr('value', $value);
|
|
|
|
$f->attr('value', $value);
|
|
|
@@ -855,6 +860,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
protected function buildEditFormAlert() {
|
|
|
|
protected function buildEditFormAlert() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$modules = $this->wire()->modules;
|
|
|
|
|
|
|
|
|
|
|
|
$this->field->type->getDatabaseSchema($this->field); // may add to trackGets, so we include it (i.e. FieldtypeFile and fileSchema)
|
|
|
|
$this->field->type->getDatabaseSchema($this->field); // may add to trackGets, so we include it (i.e. FieldtypeFile and fileSchema)
|
|
|
|
$gets = $this->field->trackGets();
|
|
|
|
$gets = $this->field->trackGets();
|
|
|
|
$xkeys = array();
|
|
|
|
$xkeys = array();
|
|
|
@@ -912,25 +919,28 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldWrapper $form */
|
|
|
|
$form = $this->wire(new InputfieldWrapper());
|
|
|
|
$form = $this->wire(new InputfieldWrapper());
|
|
|
|
$form->attr('class', 'WireTab');
|
|
|
|
$form->attr('class', 'WireTab');
|
|
|
|
$form->attr('id', 'alert');
|
|
|
|
$form->attr('id', 'alert');
|
|
|
|
$form->attr('title', $this->_x('Alert', 'tab'));
|
|
|
|
$form->attr('title', $this->_x('Alert', 'tab'));
|
|
|
|
|
|
|
|
|
|
|
|
if(count($xkeys)) {
|
|
|
|
if(count($xkeys)) {
|
|
|
|
$f = $this->wire('modules')->get('InputfieldCheckboxes');
|
|
|
|
/** @var InputfieldCheckboxes $f */
|
|
|
|
|
|
|
|
$f = $modules->get('InputfieldCheckboxes');
|
|
|
|
$f->attr('name', '_remove_keys');
|
|
|
|
$f->attr('name', '_remove_keys');
|
|
|
|
$f->label = $this->_('Unknown Properties');
|
|
|
|
$f->label = $this->_('Unknown Properties');
|
|
|
|
$f->description = $this->_('The following properties were found with this field with zero accesses during configuration. Sometimes this can indicate that the properties are no longer in use. Check the box next to each property you want to remove. If you are not sure, there is no harm in just leaving them there.');
|
|
|
|
$f->description = $this->_('The following properties were found with this field with zero accesses during configuration. Sometimes this can indicate that the properties are no longer in use. Check the box next to each property you want to remove. If you are not sure, there is no harm in just leaving them there.');
|
|
|
|
$f->icon = 'exclamation-triangle';
|
|
|
|
$f->icon = 'exclamation-triangle';
|
|
|
|
foreach($xkeys as $key) $f->addOption($key);
|
|
|
|
foreach($xkeys as $key) $f->addOption($key);
|
|
|
|
$this->wire('session')->set($this, '_remove_keys', $xkeys);
|
|
|
|
$this->wire()->session->set($this, '_remove_keys', $xkeys);
|
|
|
|
$form->add($f);
|
|
|
|
$form->add($f);
|
|
|
|
$this->error($checkLabel . $this->_('Potential unknown properties found in this field. Please see the "Alert" tab.'));
|
|
|
|
$this->error($checkLabel . $this->_('Potential unknown properties found in this field. Please see the "Alert" tab.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($numRows) {
|
|
|
|
if($numRows) {
|
|
|
|
$f = $this->wire('modules')->get('InputfieldCheckbox');
|
|
|
|
/** @var InputfieldCheckbox $f */
|
|
|
|
|
|
|
|
$f = $modules->get('InputfieldCheckbox');
|
|
|
|
$f->attr('name', '_remove_rows');
|
|
|
|
$f->attr('name', '_remove_rows');
|
|
|
|
$f->label = sprintf($this->_('Remove %d orphaned table rows?'), $numRows);
|
|
|
|
$f->label = sprintf($this->_('Remove %d orphaned table rows?'), $numRows);
|
|
|
|
$f->description = $this->_('We found rows of data in the table for this field that do not match up with any page, or match pages that do not have this field.');
|
|
|
|
$f->description = $this->_('We found rows of data in the table for this field that do not match up with any page, or match pages that do not have this field.');
|
|
|
@@ -953,9 +963,9 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->fieldgroup) return;
|
|
|
|
if(!$this->fieldgroup) return;
|
|
|
|
|
|
|
|
|
|
|
|
$fieldOriginal = $this->wire('fields')->get($this->field->id);
|
|
|
|
$fieldOriginal = $this->wire()->fields->get($this->field->id);
|
|
|
|
$context = $this->fieldgroup->getFieldContextArray($this->field->id, $this->contextNamespace);
|
|
|
|
$context = $this->fieldgroup->getFieldContextArray($this->field->id, $this->contextNamespace);
|
|
|
|
$languages = $this->wire('languages');
|
|
|
|
$languages = $this->wire()->languages;
|
|
|
|
|
|
|
|
|
|
|
|
foreach($context as $key => $value) {
|
|
|
|
foreach($context as $key => $value) {
|
|
|
|
|
|
|
|
|
|
|
@@ -988,7 +998,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
protected function renderContextSelect() {
|
|
|
|
protected function renderContextSelect() {
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->field->id) return '';
|
|
|
|
if(!$this->field->id) return '';
|
|
|
|
if($this->fieldgroup && $this->wire('input')->get('modal')) {
|
|
|
|
if($this->fieldgroup && $this->wire()->input->get('modal')) {
|
|
|
|
return "<input type='hidden' name='fieldgroup_id' value='{$this->fieldgroup->id}' />";
|
|
|
|
return "<input type='hidden' name='fieldgroup_id' value='{$this->fieldgroup->id}' />";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -1002,6 +1012,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
"<option value=''>$contextLabel</option>";
|
|
|
|
"<option value=''>$contextLabel</option>";
|
|
|
|
|
|
|
|
|
|
|
|
foreach($fieldgroups->sort('name') as $fieldgroup) {
|
|
|
|
foreach($fieldgroups->sort('name') as $fieldgroup) {
|
|
|
|
|
|
|
|
/** @var Fieldgroup $fieldgroup */
|
|
|
|
$selected = $this->fieldgroup && $this->fieldgroup->id == $fieldgroup->id ? " selected='selected'" : '';
|
|
|
|
$selected = $this->fieldgroup && $this->fieldgroup->id == $fieldgroup->id ? " selected='selected'" : '';
|
|
|
|
$out .= "<option$selected value='{$fieldgroup->id}'>{$fieldgroup->name}</option>";
|
|
|
|
$out .= "<option$selected value='{$fieldgroup->id}'>{$fieldgroup->name}</option>";
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1128,17 +1139,20 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$form->add($field);
|
|
|
|
$form->add($field);
|
|
|
|
|
|
|
|
|
|
|
|
if($this->fieldgroup) {
|
|
|
|
if($this->fieldgroup) {
|
|
|
|
|
|
|
|
/** @var InputfieldHidden $field */
|
|
|
|
$field = $modules->get('InputfieldHidden');
|
|
|
|
$field = $modules->get('InputfieldHidden');
|
|
|
|
$field->attr('name', 'fieldgroup_id');
|
|
|
|
$field->attr('name', 'fieldgroup_id');
|
|
|
|
$field->attr('value', $this->fieldgroup->id);
|
|
|
|
$field->attr('value', $this->fieldgroup->id);
|
|
|
|
$form->add($field);
|
|
|
|
$form->add($field);
|
|
|
|
if($this->contextNamespace) {
|
|
|
|
if($this->contextNamespace) {
|
|
|
|
|
|
|
|
/** @var InputfieldHidden $field */
|
|
|
|
$field = $modules->get('InputfieldHidden');
|
|
|
|
$field = $modules->get('InputfieldHidden');
|
|
|
|
$field->attr('name', '_context_namespace');
|
|
|
|
$field->attr('name', '_context_namespace');
|
|
|
|
$field->attr('value', $this->contextNamespace);
|
|
|
|
$field->attr('value', $this->contextNamespace);
|
|
|
|
$form->add($field);
|
|
|
|
$form->add($field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($this->contextLabel) {
|
|
|
|
if($this->contextLabel) {
|
|
|
|
|
|
|
|
/** @var InputfieldHidden $field */
|
|
|
|
$field = $modules->get('InputfieldHidden');
|
|
|
|
$field = $modules->get('InputfieldHidden');
|
|
|
|
$field->attr('name', '_context_label');
|
|
|
|
$field->attr('name', '_context_label');
|
|
|
|
$field->attr('value', $this->contextLabel);
|
|
|
|
$field->attr('value', $this->contextLabel);
|
|
|
@@ -1390,7 +1404,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
$fieldtypeNames = $this->field->type->getConfigAllowContext($this->field);
|
|
|
|
$fieldtypeNames = $this->field->type->getConfigAllowContext($this->field);
|
|
|
|
if(!is_array($fieldtypeNames)) $fieldtypeNames = array();
|
|
|
|
if(!is_array($fieldtypeNames)) $fieldtypeNames = array();
|
|
|
|
$dummyPage = $this->wire('pages')->get("/"); // only using this to satisfy param requirement
|
|
|
|
$dummyPage = $this->wire()->pages->get("/"); // only using this to satisfy param requirement
|
|
|
|
$inputfield = $this->field->getInputfield($dummyPage);
|
|
|
|
$inputfield = $this->field->getInputfield($dummyPage);
|
|
|
|
$inputfieldNames = $inputfield ? $inputfield->getConfigAllowContext($this->field) : array();
|
|
|
|
$inputfieldNames = $inputfield ? $inputfield->getConfigAllowContext($this->field) : array();
|
|
|
|
if(!is_array($inputfieldNames)) $inputfieldNames = array();
|
|
|
|
if(!is_array($inputfieldNames)) $inputfieldNames = array();
|
|
|
@@ -1404,10 +1418,13 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$tabInputfield = $form->getChildByName($tabName);
|
|
|
|
$tabInputfield = $form->getChildByName($tabName);
|
|
|
|
if(!$tabInputfield) continue;
|
|
|
|
if(!$tabInputfield) continue;
|
|
|
|
foreach($tabInputfield->getAll() as $f) {
|
|
|
|
foreach($tabInputfield->getAll() as $f) {
|
|
|
|
|
|
|
|
/** @var Inputfield $f */
|
|
|
|
$name = $f->name;
|
|
|
|
$name = $f->name;
|
|
|
|
if(strpos($name, '_') === 0) continue;
|
|
|
|
if(strpos($name, '_') === 0) continue;
|
|
|
|
if(in_array($name, $exclusions) || strpos($name, 'theme') === 0) continue;
|
|
|
|
if(in_array($name, $exclusions) || strpos($name, 'theme') === 0) continue;
|
|
|
|
if($f instanceof InputfieldWrapper || $f instanceof InputfieldMarkup || $f instanceof InputfieldHidden) continue;
|
|
|
|
if($f instanceof InputfieldMarkup) continue;
|
|
|
|
|
|
|
|
if($f instanceof InputfieldWrapper) continue;
|
|
|
|
|
|
|
|
if($f instanceof InputfieldHidden) continue;
|
|
|
|
$typeName = str_replace('Inputfield', '', $f->className());
|
|
|
|
$typeName = str_replace('Inputfield', '', $f->className());
|
|
|
|
$settingLabel = str_replace('|', ' ', "$tabLabel $f->label");
|
|
|
|
$settingLabel = str_replace('|', ' ', "$tabLabel $f->label");
|
|
|
|
$label = $settingLabel .
|
|
|
|
$label = $settingLabel .
|
|
|
@@ -1440,6 +1457,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$tab = null;
|
|
|
|
$tab = null;
|
|
|
|
|
|
|
|
|
|
|
|
foreach($customFields as $field) {
|
|
|
|
foreach($customFields as $field) {
|
|
|
|
|
|
|
|
/** @var Inputfield|InputfieldWrapper $field */
|
|
|
|
// skip over wrappers if they don't have fields in them
|
|
|
|
// skip over wrappers if they don't have fields in them
|
|
|
|
if($field instanceof InputfieldWrapper && !count($field->children)) continue;
|
|
|
|
if($field instanceof InputfieldWrapper && !count($field->children)) continue;
|
|
|
|
//if(!$this->fieldgroup) $field->attr('class', 'WireTab');
|
|
|
|
//if(!$this->fieldgroup) $field->attr('class', 'WireTab');
|
|
|
@@ -1460,21 +1478,26 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function buildEditFormFrontEdit($tab) {
|
|
|
|
protected function buildEditFormFrontEdit($tab) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$modules = $this->wire()->modules;
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->field) return;
|
|
|
|
if(!$this->field) return;
|
|
|
|
$cls = __NAMESPACE__ . "\\FieldtypeFieldsetOpen";
|
|
|
|
$cls = __NAMESPACE__ . "\\FieldtypeFieldsetOpen";
|
|
|
|
if($this->field->type instanceof $cls) return;
|
|
|
|
if($this->field->type instanceof $cls) return;
|
|
|
|
|
|
|
|
|
|
|
|
$fieldset = $this->wire('modules')->get('InputfieldFieldset');
|
|
|
|
/** @var InputfieldFieldset $fieldset */
|
|
|
|
|
|
|
|
$fieldset = $modules->get('InputfieldFieldset');
|
|
|
|
$fieldset->label = $this->_('Front-end editing');
|
|
|
|
$fieldset->label = $this->_('Front-end editing');
|
|
|
|
$fieldset->icon = 'edit';
|
|
|
|
$fieldset->icon = 'edit';
|
|
|
|
$fieldset->attr('id', 'front-end-editing');
|
|
|
|
$fieldset->attr('id', 'front-end-editing');
|
|
|
|
$fieldset->collapsed = Inputfield::collapsedYes;
|
|
|
|
$fieldset->collapsed = Inputfield::collapsedYes;
|
|
|
|
$tab->add($fieldset);
|
|
|
|
$tab->add($fieldset);
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->wire('modules')->isInstalled('PageFrontEdit')) {
|
|
|
|
if(!$modules->isInstalled('PageFrontEdit')) {
|
|
|
|
$f = $this->wire('modules')->get('InputfieldMarkup');
|
|
|
|
/** @var InputfieldMarkup $f */
|
|
|
|
|
|
|
|
$f = $modules->get('InputfieldMarkup');
|
|
|
|
$fieldset->add($f);
|
|
|
|
$fieldset->add($f);
|
|
|
|
$button = $this->wire('modules')->get('InputfieldButton');
|
|
|
|
/** @var InputfieldButton $button */
|
|
|
|
|
|
|
|
$button = $modules->get('InputfieldButton');
|
|
|
|
$button->href = $this->wire('config')->urls->admin . "module/installConfirm?name=PageFrontEdit";
|
|
|
|
$button->href = $this->wire('config')->urls->admin . "module/installConfirm?name=PageFrontEdit";
|
|
|
|
$button->value = $this->_('Install');
|
|
|
|
$button->value = $this->_('Install');
|
|
|
|
$button->icon = 'sign-in';
|
|
|
|
$button->icon = 'sign-in';
|
|
|
@@ -1484,9 +1507,10 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$file = $this->wire('config')->paths->PageFrontEdit . 'PageFrontEditConfig.php';
|
|
|
|
$file = $this->wire()->config->paths('PageFrontEdit') . 'PageFrontEditConfig.php';
|
|
|
|
/** @noinspection PhpIncludeInspection */
|
|
|
|
/** @noinspection PhpIncludeInspection */
|
|
|
|
include_once($file);
|
|
|
|
include_once($file);
|
|
|
|
|
|
|
|
/** @var PageFrontEditConfig $moduleConfig */
|
|
|
|
$moduleConfig = $this->wire(new PageFrontEditConfig());
|
|
|
|
$moduleConfig = $this->wire(new PageFrontEditConfig());
|
|
|
|
$moduleConfig->fieldHelpInputfields($fieldset, $this->field);
|
|
|
|
$moduleConfig->fieldHelpInputfields($fieldset, $this->field);
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1527,12 +1551,13 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function ___buildEditFormBasics() {
|
|
|
|
protected function ___buildEditFormBasics() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$modules = $this->wire()->modules;
|
|
|
|
|
|
|
|
$fields = $this->wire()->fields;
|
|
|
|
|
|
|
|
$languages = $this->wire()->languages;
|
|
|
|
|
|
|
|
$config = $this->wire()->config;
|
|
|
|
|
|
|
|
|
|
|
|
$isNew = !$this->field || !$this->field->id;
|
|
|
|
$isNew = !$this->field || !$this->field->id;
|
|
|
|
|
|
|
|
|
|
|
|
/** @var Fields $fields */
|
|
|
|
|
|
|
|
$fields = $this->wire('fields');
|
|
|
|
|
|
|
|
/** @var Languages|null $languages */
|
|
|
|
|
|
|
|
$languages = $this->wire('languages');
|
|
|
|
|
|
|
|
$languageFields = array();
|
|
|
|
$languageFields = array();
|
|
|
|
$adminTheme = $this->wire()->adminTheme;
|
|
|
|
$adminTheme = $this->wire()->adminTheme;
|
|
|
|
$legacyTheme = !$adminTheme || in_array($adminTheme->className(), array('AdminThemeDefault', 'AdminThemeReno'));
|
|
|
|
$legacyTheme = !$adminTheme || in_array($adminTheme->className(), array('AdminThemeDefault', 'AdminThemeReno'));
|
|
|
@@ -1544,7 +1569,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$form->attr('title', $this->_x('Basics', 'tab'));
|
|
|
|
$form->attr('title', $this->_x('Basics', 'tab'));
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldPageTitle $field */
|
|
|
|
/** @var InputfieldPageTitle $field */
|
|
|
|
$field = $this->modules->get('InputfieldPageTitle');
|
|
|
|
$field = $modules->get('InputfieldPageTitle');
|
|
|
|
$field->attr('id+name', 'field_label');
|
|
|
|
$field->attr('id+name', 'field_label');
|
|
|
|
$field->label = $this->labels['label'];
|
|
|
|
$field->label = $this->labels['label'];
|
|
|
|
$field->attr('value', $this->field->label);
|
|
|
|
$field->attr('value', $this->field->label);
|
|
|
@@ -1564,7 +1589,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
/** @var InputfieldName $field */
|
|
|
|
/** @var InputfieldName $field */
|
|
|
|
$field = $this->modules->get('InputfieldName');
|
|
|
|
$field = $modules->get('InputfieldName');
|
|
|
|
$field->attr('name', 'name');
|
|
|
|
$field->attr('name', 'name');
|
|
|
|
$field->attr('value', $this->field->name);
|
|
|
|
$field->attr('value', $this->field->name);
|
|
|
|
$field->description = '';
|
|
|
|
$field->description = '';
|
|
|
@@ -1578,7 +1603,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$form->add($field);
|
|
|
|
$form->add($field);
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldSelect $field */
|
|
|
|
/** @var InputfieldSelect $field */
|
|
|
|
$field = $this->modules->get('InputfieldSelect');
|
|
|
|
$field = $modules->get('InputfieldSelect');
|
|
|
|
$field->label = $this->labels['type'];
|
|
|
|
$field->label = $this->labels['type'];
|
|
|
|
$field->attr('name', 'type');
|
|
|
|
$field->attr('name', 'type');
|
|
|
|
$field->required = true;
|
|
|
|
$field->required = true;
|
|
|
@@ -1604,7 +1629,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$fieldtypeLabels[$label] = $fieldtype;
|
|
|
|
$fieldtypeLabels[$label] = $fieldtype;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ksort($fieldtypeLabels);
|
|
|
|
ksort($fieldtypeLabels);
|
|
|
|
$advanced = $this->wire('config')->advanced;
|
|
|
|
$advanced = $config->advanced;
|
|
|
|
foreach($fieldtypeLabels as $label => $fieldtype) {
|
|
|
|
foreach($fieldtypeLabels as $label => $fieldtype) {
|
|
|
|
if(!$advanced && $fieldtype->isAdvanced() && $this->field->name != 'title'
|
|
|
|
if(!$advanced && $fieldtype->isAdvanced() && $this->field->name != 'title'
|
|
|
|
&& $field->value != $fieldtype->className()) continue;
|
|
|
|
&& $field->value != $fieldtype->className()) continue;
|
|
|
@@ -1617,7 +1642,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
if($isNew) {
|
|
|
|
if($isNew) {
|
|
|
|
$names = array();
|
|
|
|
$names = array();
|
|
|
|
foreach($fields as $f) {
|
|
|
|
foreach($fields as $f) {
|
|
|
|
if(($f->flags & Field::flagSystem) && !$this->wire('config')->advanced) continue;
|
|
|
|
/** @var Field $f */
|
|
|
|
|
|
|
|
if(($f->flags & Field::flagSystem) && !$config->advanced) continue;
|
|
|
|
if(strpos($f->name, '_END')) continue;
|
|
|
|
if(strpos($f->name, '_END')) continue;
|
|
|
|
$names['_' . $f->name] = $f->name;
|
|
|
|
$names['_' . $f->name] = $f->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1635,7 +1661,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldTextarea $field */
|
|
|
|
/** @var InputfieldTextarea $field */
|
|
|
|
$field = $this->modules->get('InputfieldTextarea');
|
|
|
|
$field = $modules->get('InputfieldTextarea');
|
|
|
|
$field->label = $this->_x('Description', 'textarea input'); // Label for the 'field description' textarea input
|
|
|
|
$field->label = $this->_x('Description', 'textarea input'); // Label for the 'field description' textarea input
|
|
|
|
$field->attr('name', 'description');
|
|
|
|
$field->attr('name', 'description');
|
|
|
|
$field->attr('value', $this->field->description);
|
|
|
|
$field->attr('value', $this->field->description);
|
|
|
@@ -1647,7 +1673,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$form->add($field);
|
|
|
|
$form->add($field);
|
|
|
|
$languageFields[] = $field;
|
|
|
|
$languageFields[] = $field;
|
|
|
|
|
|
|
|
|
|
|
|
$field = $this->modules->get('InputfieldTextarea');
|
|
|
|
/** @var InputfieldTextarea $field */
|
|
|
|
|
|
|
|
$field = $modules->get('InputfieldTextarea');
|
|
|
|
$field->label = $this->_x('Notes', 'textarea input'); // Label for the 'field description' textarea input
|
|
|
|
$field->label = $this->_x('Notes', 'textarea input'); // Label for the 'field description' textarea input
|
|
|
|
$field->attr('name', 'notes');
|
|
|
|
$field->attr('name', 'notes');
|
|
|
|
$field->attr('value', $this->field->notes);
|
|
|
|
$field->attr('value', $this->field->notes);
|
|
|
@@ -1660,7 +1687,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$languageFields[] = $field;
|
|
|
|
$languageFields[] = $field;
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldText $field */
|
|
|
|
/** @var InputfieldText $field */
|
|
|
|
$field = $this->modules->get('InputfieldText');
|
|
|
|
$field = $modules->get('InputfieldText');
|
|
|
|
$field->label = $this->_('Label for tab');
|
|
|
|
$field->label = $this->_('Label for tab');
|
|
|
|
$field->attr('name', 'tabLabel');
|
|
|
|
$field->attr('name', 'tabLabel');
|
|
|
|
$field->attr('value', (string) $this->field->get('tabLabel'));
|
|
|
|
$field->attr('value', (string) $this->field->get('tabLabel'));
|
|
|
@@ -1677,13 +1704,14 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$name = $field->name;
|
|
|
|
$name = $field->name;
|
|
|
|
if($name == 'field_label') $name = 'label';
|
|
|
|
if($name == 'field_label') $name = 'label';
|
|
|
|
foreach($languages as $language) {
|
|
|
|
foreach($languages as $language) {
|
|
|
|
if($language->isDefault) continue;
|
|
|
|
/** @var Language $language */
|
|
|
|
|
|
|
|
if($language->isDefault()) continue;
|
|
|
|
$field->set("value{$language->id}", $this->field->get("$name{$language->id}"));
|
|
|
|
$field->set("value{$language->id}", $this->field->get("$name{$language->id}"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldIcon $field */
|
|
|
|
/** @var InputfieldIcon $field */
|
|
|
|
$field = $this->modules->get("InputfieldIcon");
|
|
|
|
$field = $modules->get("InputfieldIcon");
|
|
|
|
$field->attr('name', 'icon');
|
|
|
|
$field->attr('name', 'icon');
|
|
|
|
$field->attr('value', $this->field->icon);
|
|
|
|
$field->attr('value', $this->field->icon);
|
|
|
|
$field->icon = 'puzzle-piece';
|
|
|
|
$field->icon = 'puzzle-piece';
|
|
|
@@ -1693,7 +1721,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$form->add($field);
|
|
|
|
$form->add($field);
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldMarkup $field */
|
|
|
|
/** @var InputfieldMarkup $field */
|
|
|
|
$field = $this->modules->get('InputfieldMarkup');
|
|
|
|
$field = $modules->get('InputfieldMarkup');
|
|
|
|
$field->attr('name', '_usage_table');
|
|
|
|
$field->attr('name', '_usage_table');
|
|
|
|
$field->label = $this->_('Usage');
|
|
|
|
$field->label = $this->_('Usage');
|
|
|
|
$field->icon = 'search';
|
|
|
|
$field->icon = 'search';
|
|
|
@@ -2020,14 +2048,17 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function ___executeSave() {
|
|
|
|
public function ___executeSave() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$input = $this->wire()->input;
|
|
|
|
|
|
|
|
$session = $this->wire()->session;
|
|
|
|
|
|
|
|
$sanitizer = $this->wire()->sanitizer;
|
|
|
|
$form = $this->buildEditForm();
|
|
|
|
$form = $this->buildEditForm();
|
|
|
|
|
|
|
|
|
|
|
|
if($this->input->get('reloadInputfieldAjax') === 'Inputfield_overrides_table') {
|
|
|
|
if($this->input->get('reloadInputfieldAjax') === 'Inputfield_overrides_table') {
|
|
|
|
return $form->render();
|
|
|
|
return $form->render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->input->post('submit_save_field')) {
|
|
|
|
if(!$form->isSubmitted('submit_save_field')) {
|
|
|
|
$this->session->redirect("./");
|
|
|
|
$session->redirect("./");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($this->fieldgroup) {
|
|
|
|
if($this->fieldgroup) {
|
|
|
@@ -2037,26 +2068,26 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
$isNew = !$this->field->id;
|
|
|
|
$isNew = !$this->field->id;
|
|
|
|
|
|
|
|
|
|
|
|
if($this->input->post('delete') && $this->input->post('delete') == $this->field->id && $this->field->numFieldgroups() == 0) {
|
|
|
|
if($input->post('delete') && $input->post('delete') == $this->field->id && $this->field->numFieldgroups() == 0) {
|
|
|
|
$this->session->CSRF->validate();
|
|
|
|
$session->CSRF->validate();
|
|
|
|
$this->session->message($this->_('Deleted field') . " - {$this->field->name}"); // Message after deleting a field, followed by field name
|
|
|
|
$session->message($this->_('Deleted field') . " - {$this->field->name}"); // Message after deleting a field, followed by field name
|
|
|
|
$this->fields->delete($this->field);
|
|
|
|
$this->fields->delete($this->field);
|
|
|
|
$this->fieldDeleted($this->field);
|
|
|
|
$this->fieldDeleted($this->field);
|
|
|
|
$this->session->redirect("./");
|
|
|
|
$session->redirect("./");
|
|
|
|
return '';
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($isNew) {
|
|
|
|
if($isNew) {
|
|
|
|
// when adding new field, make sure name is valid
|
|
|
|
// when adding new field, make sure name is valid
|
|
|
|
$name = $this->wire('input')->post('name');
|
|
|
|
$name = $input->post('name');
|
|
|
|
$name = $this->wire('sanitizer')->fieldName($name);
|
|
|
|
$name = $sanitizer->fieldName($name);
|
|
|
|
if(!$this->isAllowedName($name)) return $this->wire('session')->redirect('./add');
|
|
|
|
if(!$this->isAllowedName($name)) $session->location('./add');
|
|
|
|
$type = $this->wire('input')->post('type');
|
|
|
|
$type = (string) $input->post('type');
|
|
|
|
// check for clone option on create
|
|
|
|
// check for clone option on create
|
|
|
|
if(strpos($type, '_') === 0) {
|
|
|
|
if(strpos($type, '_') === 0) {
|
|
|
|
// clone existing field option is existing field name with "_" prepended
|
|
|
|
// clone existing field option is existing field name with "_" prepended
|
|
|
|
$cloneFieldName = $this->wire('sanitizer')->fieldName(substr($type, 1));
|
|
|
|
$cloneFieldName = $sanitizer->fieldName(substr($type, 1));
|
|
|
|
$cloneField = $this->wire('fields')->get($cloneFieldName);
|
|
|
|
$cloneField = $this->wire()->fields->get($cloneFieldName);
|
|
|
|
if($cloneField) {
|
|
|
|
if($cloneField) {
|
|
|
|
$this->field = $this->cloneField($cloneField, $name);
|
|
|
|
$this->field = $this->cloneField($cloneField, $name);
|
|
|
|
if(!$this->field) throw new WireException("Error cloning $cloneFieldName");
|
|
|
|
if(!$this->field) throw new WireException("Error cloning $cloneFieldName");
|
|
|
@@ -2065,7 +2096,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$this->form->processInput($this->input->post);
|
|
|
|
$form->processInput($input->post);
|
|
|
|
$this->saveInputfields($this->form);
|
|
|
|
$this->saveInputfields($this->form);
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
$this->error($e->getMessage());
|
|
|
@@ -2082,21 +2113,21 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
} else if($isNew) {
|
|
|
|
} else if($isNew) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$this->field->save();
|
|
|
|
$this->field->save();
|
|
|
|
$this->session->message($this->_('Added Field') . " - {$this->field->name}");
|
|
|
|
$session->message($this->_('Added Field') . " - {$this->field->name}");
|
|
|
|
$this->fieldAdded($this->field);
|
|
|
|
$this->fieldAdded($this->field);
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
if(!$this->field->id) $this->session->redirect("./");
|
|
|
|
if(!$this->field->id) $session->redirect("./");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$redirectURL = "edit?id={$this->field->id}";
|
|
|
|
$redirectURL = "edit?id={$this->field->id}";
|
|
|
|
if(!$this->wire('input')->get('modal')) $redirectURL .= "#fieldtypeConfig";
|
|
|
|
if(!$input->get('modal')) $redirectURL .= "#fieldtypeConfig";
|
|
|
|
$this->session->redirect($redirectURL);
|
|
|
|
$session->redirect($redirectURL);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
$removeKeys = $this->wire('input')->post('_remove_keys');
|
|
|
|
$removeKeys = $input->post('_remove_keys');
|
|
|
|
if($removeKeys && count($removeKeys)) {
|
|
|
|
if($removeKeys && count($removeKeys)) {
|
|
|
|
$_removeKeys = $this->wire('session')->get($this, '_remove_keys');
|
|
|
|
$_removeKeys = $session->get($this, '_remove_keys');
|
|
|
|
foreach($removeKeys as $xkey) {
|
|
|
|
foreach($removeKeys as $xkey) {
|
|
|
|
if(!in_array($xkey, $_removeKeys)) continue; // validate via session
|
|
|
|
if(!in_array($xkey, $_removeKeys)) continue; // validate via session
|
|
|
|
$this->field->remove($xkey);
|
|
|
|
$this->field->remove($xkey);
|
|
|
@@ -2104,7 +2135,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($this->input->post('_remove_rows') == $this->field->id) {
|
|
|
|
if($input->post('_remove_rows') == $this->field->id) {
|
|
|
|
$table = $this->field->getTable();
|
|
|
|
$table = $this->field->getTable();
|
|
|
|
$sql = "DELETE $table FROM $table LEFT JOIN pages ON $table.pages_id=pages.id WHERE pages.id IS NULL ";
|
|
|
|
$sql = "DELETE $table FROM $table LEFT JOIN pages ON $table.pages_id=pages.id WHERE pages.id IS NULL ";
|
|
|
|
$templatesWithoutField = $this->getTemplatesWithoutField($this->field);
|
|
|
|
$templatesWithoutField = $this->getTemplatesWithoutField($this->field);
|
|
|
@@ -2117,34 +2148,32 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
if($cnt) $this->message($this->field->name . ": " . sprintf($this->_('Deleted %d orphaned rows'), $cnt));
|
|
|
|
if($cnt) $this->message($this->field->name . ": " . sprintf($this->_('Deleted %d orphaned rows'), $cnt));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->session->remove($this, 'optimize');
|
|
|
|
$session->remove($this, 'optimize');
|
|
|
|
if($this->input->post('_optimize')) $this->session->set($this, 'optimize', $this->field->id);
|
|
|
|
if($input->post('_optimize')) $session->set($this, 'optimize', $this->field->id);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$this->field->save();
|
|
|
|
$this->field->save();
|
|
|
|
$this->message($this->_('Saved Field') . " - {$this->field->name}");
|
|
|
|
$this->message($this->_('Saved Field') . " - {$this->field->name}");
|
|
|
|
$this->saveRemoveOverrides();
|
|
|
|
$this->saveRemoveOverrides();
|
|
|
|
$this->fieldSaved($this->field);
|
|
|
|
$this->fieldSaved($this->field);
|
|
|
|
$select = $this->form->get("type");
|
|
|
|
$select = $form->get("type");
|
|
|
|
if($this->field->type->className() != $select->value) {
|
|
|
|
if($this->field->type->className() != $select->value) {
|
|
|
|
$this->session->redirect("changeType?id={$this->field->id}&type={$select->value}");
|
|
|
|
$session->location("changeType?id={$this->field->id}&type={$select->value}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$cloneField = $this->form->get('_clone_field');
|
|
|
|
$cloneField = $form->get('_clone_field');
|
|
|
|
$cloneName = $cloneField ? $cloneField->attr('value') : '';
|
|
|
|
$cloneName = $cloneField ? $cloneField->attr('value') : '';
|
|
|
|
if($cloneName) {
|
|
|
|
if($cloneName) {
|
|
|
|
$clone = $this->cloneField($this->field, $cloneName);
|
|
|
|
$clone = $this->cloneField($this->field, $cloneName);
|
|
|
|
if($clone && $clone->id) {
|
|
|
|
if($clone && $clone->id) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$this->fields->save($clone);
|
|
|
|
$this->fields->save($clone);
|
|
|
|
if(!count($errors)) {
|
|
|
|
$this->fieldAdded($clone);
|
|
|
|
$this->fieldAdded($clone);
|
|
|
|
$session->message($this->_('You are now editing the field you cloned.'));
|
|
|
|
$this->wire('session')->message($this->_('You are now editing the field you cloned.'));
|
|
|
|
$session->location("./edit?id=$clone->id#basics");
|
|
|
|
$this->wire('session')->redirect("./edit?id=$clone->id#basics");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
} catch(\Exception $e) {
|
|
|
|
$errors[] = $e->getMessage();
|
|
|
|
$errors[] = $e->getMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -2157,11 +2186,11 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
foreach($errors as $error) {
|
|
|
|
foreach($errors as $error) {
|
|
|
|
$this->error($error);
|
|
|
|
$this->error($error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($isNew) return $this->executeAdd();
|
|
|
|
// if($isNew) return $this->executeAdd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($this->wire('input')->post('_send_templates_changed') == 'changed') {
|
|
|
|
if($input->post('_send_templates_changed') === 'changed') {
|
|
|
|
$sendTemplates = $this->form->get('send_templates');
|
|
|
|
$sendTemplates = $form->get('send_templates');
|
|
|
|
$value = $sendTemplates->attr('value');
|
|
|
|
$value = $sendTemplates->attr('value');
|
|
|
|
$valuePrevious = $sendTemplates->_valuePrevious;
|
|
|
|
$valuePrevious = $sendTemplates->_valuePrevious;
|
|
|
|
if($value != $valuePrevious) {
|
|
|
|
if($value != $valuePrevious) {
|
|
|
@@ -2177,18 +2206,18 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
// $this->message("Remove from template " . $this->wire('templates')->get($templateID));
|
|
|
|
// $this->message("Remove from template " . $this->wire('templates')->get($templateID));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(count($templateIDs)) {
|
|
|
|
if(count($templateIDs)) {
|
|
|
|
$this->wire('session')->redirect("./send-templates?id={$this->field->id}&templates=" . implode(',', $templateIDs));
|
|
|
|
$session->location("./send-templates?id={$this->field->id}&templates=" . implode(',', $templateIDs));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($this->listAfterSave) {
|
|
|
|
if($this->listAfterSave) {
|
|
|
|
$this->session->redirect("./");
|
|
|
|
$session->location("./");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$url = "edit?id={$this->field->id}";
|
|
|
|
$url = "edit?id={$this->field->id}";
|
|
|
|
if($this->wire('input')->post("_optimize")) $url .= '#alert';
|
|
|
|
if($input->post("_optimize")) $url .= '#alert';
|
|
|
|
$this->session->redirect($url);
|
|
|
|
$session->location($url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
return '';
|
|
|
@@ -2321,11 +2350,13 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function saveInputfields(InputfieldWrapper $wrapper) {
|
|
|
|
protected function saveInputfields(InputfieldWrapper $wrapper) {
|
|
|
|
|
|
|
|
|
|
|
|
/** @var Languages $languages */
|
|
|
|
$languages = $this->wire()->languages;
|
|
|
|
$languages = $this->wire('languages');
|
|
|
|
|
|
|
|
$sanitizer = $this->wire()->sanitizer;
|
|
|
|
$sanitizer = $this->wire()->sanitizer;
|
|
|
|
|
|
|
|
$input = $this->wire()->input;
|
|
|
|
|
|
|
|
$config = $this->wire()->config;
|
|
|
|
|
|
|
|
|
|
|
|
foreach($wrapper->children() as $inputfield) {
|
|
|
|
foreach($wrapper->children() as $inputfield) {
|
|
|
|
|
|
|
|
/** @var Inputfield|InputfieldWrapper $inputfield */
|
|
|
|
|
|
|
|
|
|
|
|
if($inputfield instanceof InputfieldWrapper && count($inputfield->children())) {
|
|
|
|
if($inputfield instanceof InputfieldWrapper && count($inputfield->children())) {
|
|
|
|
$this->saveInputfields($inputfield);
|
|
|
|
$this->saveInputfields($inputfield);
|
|
|
@@ -2339,25 +2370,34 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
// see /core/Fieldtype.php for the inputfields that initiate the autojoin and global flags
|
|
|
|
// see /core/Fieldtype.php for the inputfields that initiate the autojoin and global flags
|
|
|
|
if($name == 'autojoin') {
|
|
|
|
if($name == 'autojoin') {
|
|
|
|
if(!$this->input->post('autojoin')) $this->field->flags = $this->field->flags & ~Field::flagAutojoin;
|
|
|
|
if(!$input->post('autojoin')) {
|
|
|
|
else $this->field->flags = $this->field->flags | Field::flagAutojoin;
|
|
|
|
$this->field->flags = $this->field->flags & ~Field::flagAutojoin;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagAutojoin;
|
|
|
|
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
} else if($name == 'global') {
|
|
|
|
} else if($name == 'global') {
|
|
|
|
if(!$this->input->post('global')) $this->field->flags = $this->field->flags & ~Field::flagGlobal;
|
|
|
|
if(!$input->post('global')) {
|
|
|
|
else $this->field->flags = $this->field->flags | Field::flagGlobal;
|
|
|
|
$this->field->flags = $this->field->flags & ~Field::flagGlobal;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagGlobal;
|
|
|
|
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if($name == 'system' && $this->config->advanced) {
|
|
|
|
} else if($name == 'system' && $config->advanced) {
|
|
|
|
if(!$this->input->post('system')) {
|
|
|
|
if(!$input->post('system')) {
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagSystemOverride;
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagSystemOverride;
|
|
|
|
$this->field->flags = $this->field->flags & ~Field::flagSystem;
|
|
|
|
$this->field->flags = $this->field->flags & ~Field::flagSystem;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagSystem;
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagSystem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if($name == 'permanent' && $this->config->advanced) {
|
|
|
|
} else if($name == 'permanent' && $config->advanced) {
|
|
|
|
if(!$this->input->post('permanent')) $this->field->flags = $this->field->flags & ~Field::flagPermanent;
|
|
|
|
if(!$input->post('permanent')) {
|
|
|
|
else $this->field->flags = $this->field->flags | Field::flagPermanent;
|
|
|
|
$this->field->flags = $this->field->flags & ~Field::flagPermanent;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->field->flags = $this->field->flags | Field::flagPermanent;
|
|
|
|
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -2397,9 +2437,9 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
if($this->field->useRoles) {
|
|
|
|
if($this->field->useRoles) {
|
|
|
|
// access control active for this field
|
|
|
|
// access control active for this field
|
|
|
|
$this->field->viewRoles = $this->wire('input')->post('viewRoles');
|
|
|
|
$this->field->viewRoles = $input->post('viewRoles');
|
|
|
|
$this->field->editRoles = $this->wire('input')->post('editRoles');
|
|
|
|
$this->field->editRoles = $input->post('editRoles');
|
|
|
|
$accessFlags = $this->wire('input')->post('_accessFlags');
|
|
|
|
$accessFlags = $input->post('_accessFlags');
|
|
|
|
if(!is_array($accessFlags)) $accessFlags = array();
|
|
|
|
if(!is_array($accessFlags)) $accessFlags = array();
|
|
|
|
$flags = $this->field->flags;
|
|
|
|
$flags = $this->field->flags;
|
|
|
|
if(in_array(Field::flagAccessAPI, $accessFlags)) {
|
|
|
|
if(in_array(Field::flagAccessAPI, $accessFlags)) {
|
|
|
@@ -2423,6 +2463,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function checkInputfieldDependencySetting(Inputfield $inputfield) {
|
|
|
|
protected function checkInputfieldDependencySetting(Inputfield $inputfield) {
|
|
|
|
|
|
|
|
$fields = $this->wire()->fields;
|
|
|
|
|
|
|
|
|
|
|
|
$label = sprintf($this->_('Error in setting “%s”'), $inputfield->getSetting('label'));
|
|
|
|
$label = sprintf($this->_('Error in setting “%s”'), $inputfield->getSetting('label'));
|
|
|
|
$value = $inputfield->attr('value');
|
|
|
|
$value = $inputfield->attr('value');
|
|
|
|
$valueLabel = ' ' . sprintf($this->_('(you specified “%s”)'), $value);
|
|
|
|
$valueLabel = ' ' . sprintf($this->_('(you specified “%s”)'), $value);
|
|
|
@@ -2437,7 +2479,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
foreach($selector->fields() as $f) {
|
|
|
|
foreach($selector->fields() as $f) {
|
|
|
|
if(strpos($f, '.')) continue;
|
|
|
|
if(strpos($f, '.')) continue;
|
|
|
|
if(!strlen($selector->value())) continue;
|
|
|
|
if(!strlen($selector->value())) continue;
|
|
|
|
$f = $this->wire('fields')->get($f);
|
|
|
|
/** @var Field $f */
|
|
|
|
|
|
|
|
$f = $fields->get($f);
|
|
|
|
if(!$f || !$f->type instanceof FieldtypePage) continue;
|
|
|
|
if(!$f || !$f->type instanceof FieldtypePage) continue;
|
|
|
|
$v = implode('', $selector->values());
|
|
|
|
$v = implode('', $selector->values());
|
|
|
|
if(ctype_digit("$v")) continue; // validates
|
|
|
|
if(ctype_digit("$v")) continue; // validates
|
|
|
@@ -2452,7 +2495,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function saveRemoveOverrides() {
|
|
|
|
protected function saveRemoveOverrides() {
|
|
|
|
|
|
|
|
|
|
|
|
$removeContext = $this->wire('input')->post('_remove_context');
|
|
|
|
$removeContext = $this->wire()->input->post('_remove_context');
|
|
|
|
if(empty($removeContext)) return;
|
|
|
|
if(empty($removeContext)) return;
|
|
|
|
|
|
|
|
|
|
|
|
$contextArrays = array();
|
|
|
|
$contextArrays = array();
|
|
|
@@ -2474,11 +2517,13 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
if(isset($fieldgroups[$fieldgroupID])) {
|
|
|
|
if(isset($fieldgroups[$fieldgroupID])) {
|
|
|
|
$fieldgroup = $fieldgroups[$fieldgroupID];
|
|
|
|
$fieldgroup = $fieldgroups[$fieldgroupID];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$fieldgroup = $this->wire('fieldgroups')->get((int) $fieldgroupID);
|
|
|
|
$fieldgroup = $this->wire()->fieldgroups->get((int) $fieldgroupID);
|
|
|
|
if(!$fieldgroup) continue;
|
|
|
|
if(!$fieldgroup) continue;
|
|
|
|
$fieldgroups[$fieldgroup->id] = $fieldgroup;
|
|
|
|
$fieldgroups[$fieldgroup->id] = $fieldgroup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var Fieldgroup $fieldgroup */
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($contextArrays[$fieldgroup->id])) {
|
|
|
|
if(isset($contextArrays[$fieldgroup->id])) {
|
|
|
|
// use previously loaded version
|
|
|
|
// use previously loaded version
|
|
|
|
$contextArray = $contextArrays[$fieldgroup->id];
|
|
|
|
$contextArray = $contextArrays[$fieldgroup->id];
|
|
|
@@ -2525,34 +2570,39 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function ___executeChangeType() {
|
|
|
|
public function ___executeChangeType() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$input = $this->wire()->input;
|
|
|
|
|
|
|
|
$modules = $this->wire()->modules;
|
|
|
|
|
|
|
|
$session = $this->wire()->session;
|
|
|
|
|
|
|
|
$sanitizer = $this->wire()->sanitizer;
|
|
|
|
|
|
|
|
|
|
|
|
$this->buildEditForm();
|
|
|
|
$this->buildEditForm();
|
|
|
|
|
|
|
|
|
|
|
|
$this->headline(sprintf($this->_('Change type for field: %s'), $this->field->name)); // Page headline when changing type
|
|
|
|
$this->headline(sprintf($this->_('Change type for field: %s'), $this->field->name)); // Page headline when changing type
|
|
|
|
$this->wire('breadcrumbs')
|
|
|
|
$this->breadcrumb('./', $this->labels['fields']);
|
|
|
|
->add(new Breadcrumb('./', $this->labels['fields']))
|
|
|
|
$this->breadcrumb("./edit?id={$this->field->id}", $this->field->name);
|
|
|
|
->add(new Breadcrumb("./edit?id={$this->field->id}", $this->field->name));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->input->get('type')) $this->session->redirect('./');
|
|
|
|
if(!$input->get('type')) $session->location('./');
|
|
|
|
$newType = $this->wire('sanitizer')->name($this->input->get('type'));
|
|
|
|
$newType = $sanitizer->name($input->get('type'));
|
|
|
|
$newType = $this->wire('fieldtypes')->get($newType);
|
|
|
|
$newType = $this->wire()->fieldtypes->get($newType);
|
|
|
|
if(!$newType) $this->session->redirect('./');
|
|
|
|
if(!$newType) $session->location('./');
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldForm $form */
|
|
|
|
/** @var InputfieldForm $form */
|
|
|
|
$form = $this->modules->get("InputfieldForm");
|
|
|
|
$form = $modules->get("InputfieldForm");
|
|
|
|
$form->attr('method', 'post');
|
|
|
|
$form->attr('method', 'post');
|
|
|
|
$form->attr('action', 'saveChangeType');
|
|
|
|
$form->attr('action', 'saveChangeType');
|
|
|
|
$form->head = sprintf($this->_('Change field type from "%1$s" to "%2$s"'), $this->field->type->longName, $newType->longName);
|
|
|
|
$form->head = sprintf($this->_('Change field type from "%1$s" to "%2$s"'), $this->field->type->longName, $newType->longName);
|
|
|
|
$form->description = $this->_("Please note that changing the field type alters the database schema. If the new fieldtype is not compatible with the old, or if it contains a significantly different schema, it is possible for data loss to occur. As a result, you are advised to backup the database before completing a field type change."); // Change field type description
|
|
|
|
$form->description = $this->_("Please note that changing the field type alters the database schema. If the new fieldtype is not compatible with the old, or if it contains a significantly different schema, it is possible for data loss to occur. As a result, you are advised to backup the database before completing a field type change."); // Change field type description
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldCheckbox $f */
|
|
|
|
/** @var InputfieldCheckbox $f */
|
|
|
|
$f = $this->modules->get("InputfieldCheckbox");
|
|
|
|
$f = $modules->get("InputfieldCheckbox");
|
|
|
|
$f->attr('name', 'confirm_type');
|
|
|
|
$f->attr('name', 'confirm_type');
|
|
|
|
$f->attr('value', $newType->className());
|
|
|
|
$f->attr('value', $newType->className());
|
|
|
|
$f->label = $this->_("Confirm field type change");
|
|
|
|
$f->label = $this->_("Confirm field type change");
|
|
|
|
$f->description = $this->_("If you are sure you want to change the field type, check the box below and submit this form."); // Confirm change description
|
|
|
|
$f->description = $this->_("If you are sure you want to change the field type, check the box below and submit this form."); // Confirm change description
|
|
|
|
$form->append($f);
|
|
|
|
$form->append($f);
|
|
|
|
|
|
|
|
|
|
|
|
$f = $this->modules->get("InputfieldCheckbox");
|
|
|
|
/** @var InputfieldCheckbox $f */
|
|
|
|
|
|
|
|
$f = $modules->get("InputfieldCheckbox");
|
|
|
|
$f->attr('name', 'keep_settings');
|
|
|
|
$f->attr('name', 'keep_settings');
|
|
|
|
$f->label = $this->_('Keep field settings?');
|
|
|
|
$f->label = $this->_('Keep field settings?');
|
|
|
|
$f->description = $this->_('Check this box to retain all the custom settings for this field (from the Details and Input tabs). This is desirable if the new field type has the same or similar configuration properties to the old field type. However, it can also result in unnecessary or redundant configuration data taking up space in the field. You can always analyze this later from: Advanced > Check field data.'); // Keep field settings description
|
|
|
|
$f->description = $this->_('Check this box to retain all the custom settings for this field (from the Details and Input tabs). This is desirable if the new field type has the same or similar configuration properties to the old field type. However, it can also result in unnecessary or redundant configuration data taking up space in the field. You can always analyze this later from: Advanced > Check field data.'); // Keep field settings description
|
|
|
@@ -2561,13 +2611,13 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$form->append($f);
|
|
|
|
$form->append($f);
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldHidden $f */
|
|
|
|
/** @var InputfieldHidden $f */
|
|
|
|
$f = $this->modules->get("InputfieldHidden");
|
|
|
|
$f = $modules->get("InputfieldHidden");
|
|
|
|
$f->attr('name', 'id');
|
|
|
|
$f->attr('name', 'id');
|
|
|
|
$f->attr('value', $this->field->id);
|
|
|
|
$f->attr('value', $this->field->id);
|
|
|
|
$form->append($f);
|
|
|
|
$form->append($f);
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldSubmit $field */
|
|
|
|
/** @var InputfieldSubmit $field */
|
|
|
|
$field = $this->modules->get('InputfieldSubmit');
|
|
|
|
$field = $modules->get('InputfieldSubmit');
|
|
|
|
$field->attr('name', 'submit_change_field_type');
|
|
|
|
$field->attr('name', 'submit_change_field_type');
|
|
|
|
$form->append($field);
|
|
|
|
$form->append($field);
|
|
|
|
|
|
|
|
|
|
|
@@ -2623,7 +2673,6 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
/** @var ProcessFieldExportImport $o */
|
|
|
|
/** @var ProcessFieldExportImport $o */
|
|
|
|
$o = $this->wire(new ProcessFieldExportImport());
|
|
|
|
$o = $this->wire(new ProcessFieldExportImport());
|
|
|
|
/** @var InputfieldForm $form */
|
|
|
|
|
|
|
|
$form = $o->buildImport();
|
|
|
|
$form = $o->buildImport();
|
|
|
|
|
|
|
|
|
|
|
|
return $form->render();
|
|
|
|
return $form->render();
|
|
|
@@ -2643,7 +2692,6 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
require(dirname(__FILE__) . '/ProcessFieldExportImport.php');
|
|
|
|
require(dirname(__FILE__) . '/ProcessFieldExportImport.php');
|
|
|
|
/** @var ProcessFieldExportImport $o */
|
|
|
|
/** @var ProcessFieldExportImport $o */
|
|
|
|
$o = $this->wire(new ProcessFieldExportImport());
|
|
|
|
$o = $this->wire(new ProcessFieldExportImport());
|
|
|
|
/** @var InputfieldForm $form */
|
|
|
|
|
|
|
|
$form = $o->buildExport();
|
|
|
|
$form = $o->buildExport();
|
|
|
|
|
|
|
|
|
|
|
|
return $form->render();
|
|
|
|
return $form->render();
|
|
|
@@ -2658,17 +2706,22 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function ___executeSendTemplates() {
|
|
|
|
public function ___executeSendTemplates() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$modules = $this->wire()->modules;
|
|
|
|
|
|
|
|
$templates = $this->wire()->templates;
|
|
|
|
|
|
|
|
$input = $this->wire()->input;
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->field || !$this->field->id) throw new WireException('No field specified');
|
|
|
|
if(!$this->field || !$this->field->id) throw new WireException('No field specified');
|
|
|
|
$templateIDs = $this->wire('input')->get('templates');
|
|
|
|
$templateIDs = $input->get('templates');
|
|
|
|
if(!strlen($templateIDs)) throw new WireException("No templates specified");
|
|
|
|
if(!strlen($templateIDs)) throw new WireException("No templates specified");
|
|
|
|
$templateIDs = explode(',', $templateIDs);
|
|
|
|
$templateIDs = explode(',', $templateIDs);
|
|
|
|
|
|
|
|
|
|
|
|
$form = $this->wire('modules')->get('InputfieldForm');
|
|
|
|
/** @var InputfieldForm $form */
|
|
|
|
|
|
|
|
$form = $modules->get('InputfieldForm');
|
|
|
|
$form->attr('action', "./send-templates-save?id={$this->field->id}");
|
|
|
|
$form->attr('action', "./send-templates-save?id={$this->field->id}");
|
|
|
|
|
|
|
|
|
|
|
|
$fields = array($this->field);
|
|
|
|
$fields = array($this->field);
|
|
|
|
if($this->field->type instanceof FieldtypeFieldsetOpen) {
|
|
|
|
if($this->field->type instanceof FieldtypeFieldsetOpen) {
|
|
|
|
$fieldsetClose = $this->wire('fields')->get($this->field->name . '_END');
|
|
|
|
$fieldsetClose = $this->wire()->fields->get($this->field->name . '_END');
|
|
|
|
if($fieldsetClose) $fields[] = $fieldsetClose;
|
|
|
|
if($fieldsetClose) $fields[] = $fieldsetClose;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -2676,19 +2729,21 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
$templateID = (int) $templateID;
|
|
|
|
$templateID = (int) $templateID;
|
|
|
|
if(!$templateID) continue;
|
|
|
|
if(!$templateID) continue;
|
|
|
|
$template = $this->wire('templates')->get(abs($templateID));
|
|
|
|
|
|
|
|
|
|
|
|
$template = $templates->get(abs($templateID));
|
|
|
|
if(!$template) continue;
|
|
|
|
if(!$template) continue;
|
|
|
|
|
|
|
|
|
|
|
|
if($templateID < 0) {
|
|
|
|
if($templateID < 0) {
|
|
|
|
// remove from template
|
|
|
|
// remove from template
|
|
|
|
|
|
|
|
|
|
|
|
$f = $this->wire('modules')->get('InputfieldCheckbox');
|
|
|
|
/** @var InputfieldCheckbox $f */
|
|
|
|
|
|
|
|
$f = $modules->get('InputfieldCheckbox');
|
|
|
|
$f->attr('name', "remove_{$this->field->id}_template_$template->id");
|
|
|
|
$f->attr('name', "remove_{$this->field->id}_template_$template->id");
|
|
|
|
$f->attr('value', $this->field->id);
|
|
|
|
$f->attr('value', $this->field->id);
|
|
|
|
$f->icon = 'minus-circle';
|
|
|
|
$f->icon = 'minus-circle';
|
|
|
|
$f->label = sprintf($this->_('Remove field "%1$s" from template "%2$s"'), $this->field->name, $template->name);
|
|
|
|
$f->label = sprintf($this->_('Remove field "%1$s" from template "%2$s"'), $this->field->name, $template->name);
|
|
|
|
$f->label2 = sprintf($this->_('Confirm removal of field "%1$s" from template "%2$s"'), $this->field->name, $template->name);
|
|
|
|
$f->label2 = sprintf($this->_('Confirm removal of field "%1$s" from template "%2$s"'), $this->field->name, $template->name);
|
|
|
|
$numRows = $this->wire('fields')->getNumRows($this->field, array('template' => $template));
|
|
|
|
$numRows = $this->wire()->fields->getNumRows($this->field, array('template' => $template));
|
|
|
|
if($numRows) {
|
|
|
|
if($numRows) {
|
|
|
|
$f->description = $this->_('WARNING: This will result in data associated with the field being permanently deleted.') . ' '; // Warning for field deletion
|
|
|
|
$f->description = $this->_('WARNING: This will result in data associated with the field being permanently deleted.') . ' '; // Warning for field deletion
|
|
|
|
$f->notes = sprintf($this->_n('This will also delete %d row of data.', 'This will also delete %d rows of data.', $numRows), $numRows); // Notes for field deletion
|
|
|
|
$f->notes = sprintf($this->_n('This will also delete %d row of data.', 'This will also delete %d rows of data.', $numRows), $numRows); // Notes for field deletion
|
|
|
@@ -2705,7 +2760,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
foreach($fields as $field) {
|
|
|
|
foreach($fields as $field) {
|
|
|
|
|
|
|
|
|
|
|
|
$f = $this->wire('modules')->get('InputfieldSelect');
|
|
|
|
/** @var InputfieldSelect $f */
|
|
|
|
|
|
|
|
$f = $modules->get('InputfieldSelect');
|
|
|
|
$f->attr('name', "add_{$field->id}_template_$templateID");
|
|
|
|
$f->attr('name', "add_{$field->id}_template_$templateID");
|
|
|
|
$f->label = sprintf($this->_('Template: %s'), $template->name);
|
|
|
|
$f->label = sprintf($this->_('Template: %s'), $template->name);
|
|
|
|
$f->label = sprintf($this->_('Add field "%1$s" to template "%2$s"'), $field->name, $template->name);
|
|
|
|
$f->label = sprintf($this->_('Add field "%1$s" to template "%2$s"'), $field->name, $template->name);
|
|
|
@@ -2735,7 +2791,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$f = $this->wire('modules')->get('InputfieldSubmit');
|
|
|
|
/** @var InputfieldSubmit $f */
|
|
|
|
|
|
|
|
$f = $modules->get('InputfieldSubmit');
|
|
|
|
$form->add($f);
|
|
|
|
$form->add($f);
|
|
|
|
|
|
|
|
|
|
|
|
$this->headline($this->_('Add or remove from template(s)'));
|
|
|
|
$this->headline($this->_('Add or remove from template(s)'));
|
|
|
@@ -2753,15 +2810,18 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
public function ___executeSendTemplatesSave() {
|
|
|
|
public function ___executeSendTemplatesSave() {
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->field || !$this->field->id) throw new WireException('No field specified');
|
|
|
|
if(!$this->field || !$this->field->id) throw new WireException('No field specified');
|
|
|
|
/** @var Session $session */
|
|
|
|
|
|
|
|
$session = $this->wire('session');
|
|
|
|
$session = $this->wire()->session;
|
|
|
|
$session->CSRF->validate();
|
|
|
|
$session->CSRF->validate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$input = $this->wire()->input;
|
|
|
|
|
|
|
|
$templates = $this->wire()->templates;
|
|
|
|
|
|
|
|
|
|
|
|
$changedTemplates = array();
|
|
|
|
$changedTemplates = array();
|
|
|
|
$isFieldset = false;
|
|
|
|
$isFieldset = false;
|
|
|
|
$fields = array($this->field);
|
|
|
|
$fields = array($this->field);
|
|
|
|
if($this->field->type instanceof FieldtypeFieldsetOpen) {
|
|
|
|
if($this->field->type instanceof FieldtypeFieldsetOpen) {
|
|
|
|
$fieldsetClose = $this->wire('fields')->get($this->field->name . '_END');
|
|
|
|
$fieldsetClose = $this->wire()->fields->get($this->field->name . '_END');
|
|
|
|
if($fieldsetClose) {
|
|
|
|
if($fieldsetClose) {
|
|
|
|
$fields[] = $fieldsetClose;
|
|
|
|
$fields[] = $fieldsetClose;
|
|
|
|
$isFieldset = true;
|
|
|
|
$isFieldset = true;
|
|
|
@@ -2769,7 +2829,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// first handle additions, since it's possible for removals to take a long time or remote chance of timeout
|
|
|
|
// first handle additions, since it's possible for removals to take a long time or remote chance of timeout
|
|
|
|
foreach($this->wire('templates') as $template) {
|
|
|
|
foreach($templates as $template) {
|
|
|
|
$templateChanged = false;
|
|
|
|
$templateChanged = false;
|
|
|
|
|
|
|
|
|
|
|
|
foreach($fields as $key => $field) {
|
|
|
|
foreach($fields as $key => $field) {
|
|
|
@@ -2778,7 +2838,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
// there is also the corresponding FieldtypeFieldsetClose
|
|
|
|
// there is also the corresponding FieldtypeFieldsetClose
|
|
|
|
$isFieldsetEnd = $isFieldset && $key > 0;
|
|
|
|
$isFieldsetEnd = $isFieldset && $key > 0;
|
|
|
|
|
|
|
|
|
|
|
|
$addFieldID = $this->wire('input')->post("add_{$field->id}_template_$template->id");
|
|
|
|
$addFieldID = $input->post("add_{$field->id}_template_$template->id");
|
|
|
|
if(!$addFieldID) continue;
|
|
|
|
if(!$addFieldID) continue;
|
|
|
|
if(!$this->allowFieldInTemplate($field, $template)) continue;
|
|
|
|
if(!$this->allowFieldInTemplate($field, $template)) continue;
|
|
|
|
if($isFieldsetEnd && $template->fieldgroup->hasField($field)) continue;
|
|
|
|
if($isFieldsetEnd && $template->fieldgroup->hasField($field)) continue;
|
|
|
@@ -2826,13 +2886,13 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// next handle removals
|
|
|
|
// next handle removals
|
|
|
|
foreach($this->wire('templates') as $template) {
|
|
|
|
foreach($templates as $template) {
|
|
|
|
$removeFieldID = (int) $this->wire('input')->post("remove_{$this->field->id}_template_$template->id");
|
|
|
|
$removeFieldID = (int) $input->post("remove_{$this->field->id}_template_$template->id");
|
|
|
|
$templateChanged = false;
|
|
|
|
$templateChanged = false;
|
|
|
|
if($removeFieldID && $removeFieldID === (int) $this->field->id) {
|
|
|
|
if($removeFieldID && $removeFieldID === (int) $this->field->id) {
|
|
|
|
$template->fieldgroup->remove($this->field);
|
|
|
|
$template->fieldgroup->remove($this->field);
|
|
|
|
if($this->field->type instanceof FieldtypeFieldsetOpen) {
|
|
|
|
if($this->field->type instanceof FieldtypeFieldsetOpen) {
|
|
|
|
$fieldsetClose = $this->wire('fields')->get($this->field->name . '_END');
|
|
|
|
$fieldsetClose = $this->wire()->fields->get($this->field->name . '_END');
|
|
|
|
if($fieldsetClose) $template->fieldgroup->remove($fieldsetClose);
|
|
|
|
if($fieldsetClose) $template->fieldgroup->remove($fieldsetClose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@@ -2850,7 +2910,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
if($templateChanged) $template->save();
|
|
|
|
if($templateChanged) $template->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->wire('session')->redirect("./edit?id={$this->field->id}");
|
|
|
|
$session->location("./edit?id={$this->field->id}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@@ -2864,15 +2924,16 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function getContextChanges(InputfieldWrapper $form, Field $field, Fieldgroup $fieldgroup) {
|
|
|
|
protected function getContextChanges(InputfieldWrapper $form, Field $field, Fieldgroup $fieldgroup) {
|
|
|
|
|
|
|
|
|
|
|
|
if(!$fieldgroup) return array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$contextArray = $fieldgroup->getFieldContextArray($field->id, $this->contextNamespace);
|
|
|
|
$contextArray = $fieldgroup->getFieldContextArray($field->id, $this->contextNamespace);
|
|
|
|
if(!count($contextArray)) return array();
|
|
|
|
if(!count($contextArray)) return array();
|
|
|
|
|
|
|
|
|
|
|
|
$fieldOriginal = $this->wire('fields')->get($field->id);
|
|
|
|
$fieldOriginal = $this->wire()->fields->get($field->id);
|
|
|
|
$changes = array();
|
|
|
|
$changes = array();
|
|
|
|
// $isInContext = $this->fieldgroup || $this->contextNamespace;
|
|
|
|
// $isInContext = $this->fieldgroup || $this->contextNamespace;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$roles = $this->wire()->roles;
|
|
|
|
|
|
|
|
$languages = $this->wire()->languages;
|
|
|
|
|
|
|
|
|
|
|
|
$labels = array(
|
|
|
|
$labels = array(
|
|
|
|
'on' => $this->_('On'),
|
|
|
|
'on' => $this->_('On'),
|
|
|
|
'off' => $this->_('Off'),
|
|
|
|
'off' => $this->_('Off'),
|
|
|
@@ -2941,7 +3002,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
if(is_array($value) && ($key == 'viewRoles' || $key == 'editRoles')) {
|
|
|
|
if(is_array($value) && ($key == 'viewRoles' || $key == 'editRoles')) {
|
|
|
|
foreach($value as $k => $v) {
|
|
|
|
foreach($value as $k => $v) {
|
|
|
|
$v = $this->wire('roles')->get((int) $v);
|
|
|
|
$v = $roles->get((int) $v);
|
|
|
|
$roleName = $v->name == 'guest' ? $labels['all'] : $v->name;
|
|
|
|
$roleName = $v->name == 'guest' ? $labels['all'] : $v->name;
|
|
|
|
if($v) $value[$k] = $roleName;
|
|
|
|
if($v) $value[$k] = $roleName;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -2949,7 +3010,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
|
|
|
|
|
|
|
|
if(is_array($originalValue) && ($key == 'viewRoles' || $key == 'editRoles')) {
|
|
|
|
if(is_array($originalValue) && ($key == 'viewRoles' || $key == 'editRoles')) {
|
|
|
|
foreach($originalValue as $k => $v) {
|
|
|
|
foreach($originalValue as $k => $v) {
|
|
|
|
$v = $this->wire('roles')->get((int) $v);
|
|
|
|
$v = $roles->get((int) $v);
|
|
|
|
$roleName = $v->name == 'guest' ? $labels['all'] : $v->name;
|
|
|
|
$roleName = $v->name == 'guest' ? $labels['all'] : $v->name;
|
|
|
|
if($v) $originalValue[$k] = $roleName;
|
|
|
|
if($v) $originalValue[$k] = $roleName;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -2997,8 +3058,8 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if($this->wire('languages') && preg_match('/^(label|description|notes)(\d+)$/', $key, $matches)) {
|
|
|
|
} else if($languages && preg_match('/^(label|description|notes)(\d+)$/', $key, $matches)) {
|
|
|
|
$label = ucfirst($matches[1]) . ' (' . $this->wire('languages')->get((int) $matches[2])->get('title|name') . ')';
|
|
|
|
$label = ucfirst($matches[1]) . ' (' . $languages->get((int) $matches[2])->get('title|name') . ')';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$label = $key;
|
|
|
|
$label = $key;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -3025,8 +3086,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function search($text, array $options = array()) {
|
|
|
|
public function search($text, array $options = array()) {
|
|
|
|
|
|
|
|
|
|
|
|
/** @var Languages $languages */
|
|
|
|
$languages = $this->wire()->langauges;
|
|
|
|
$languages = $this->wire('langauges');
|
|
|
|
|
|
|
|
$page = $this->getProcessPage();
|
|
|
|
$page = $this->getProcessPage();
|
|
|
|
|
|
|
|
|
|
|
|
$result = array(
|
|
|
|
$result = array(
|
|
|
@@ -3052,7 +3112,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
$property = isset($options['property']) ? $options['property'] : '';
|
|
|
|
$property = isset($options['property']) ? $options['property'] : '';
|
|
|
|
$cnt = 0;
|
|
|
|
$cnt = 0;
|
|
|
|
|
|
|
|
|
|
|
|
foreach($this->wire('fields') as $item) {
|
|
|
|
foreach($this->wire()->fields as $item) {
|
|
|
|
/** @var Field $item */
|
|
|
|
/** @var Field $item */
|
|
|
|
if(!$item->type) continue;
|
|
|
|
if(!$item->type) continue;
|
|
|
|
|
|
|
|
|
|
|
@@ -3073,7 +3133,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($property == 'settings' || $property == 'data') {
|
|
|
|
if($property == 'settings' || $property == 'data') {
|
|
|
|
foreach($item->getArray() as $k => $v) {
|
|
|
|
foreach($item->getArray() as $v) {
|
|
|
|
$search[] = (string) $v;
|
|
|
|
$search[] = (string) $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(!in_array($property, $result['properties'])) {
|
|
|
|
} else if(!in_array($property, $result['properties'])) {
|
|
|
@@ -3117,7 +3177,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
* URL to redirect to after non-authenticated user is logged-in, or false if module does not support
|
|
|
|
* URL to redirect to after non-authenticated user is logged-in, or false if module does not support
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param Page $page
|
|
|
|
* @param Page $page
|
|
|
|
* @return bool|string
|
|
|
|
* @return string
|
|
|
|
* @sine 3.0.167
|
|
|
|
* @sine 3.0.167
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@@ -3199,8 +3259,9 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
public function getModuleConfigInputfields(array $data) {
|
|
|
|
public function getModuleConfigInputfields(array $data) {
|
|
|
|
|
|
|
|
|
|
|
|
$fields = $this->wire(new InputfieldWrapper());
|
|
|
|
$fields = $this->wire(new InputfieldWrapper());
|
|
|
|
$modules = $this->wire('modules');
|
|
|
|
$modules = $this->wire()->modules;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var InputfieldCheckbox $field */
|
|
|
|
$field = $modules->get("InputfieldCheckbox");
|
|
|
|
$field = $modules->get("InputfieldCheckbox");
|
|
|
|
$field->attr('name', 'listAfterSave');
|
|
|
|
$field->attr('name', 'listAfterSave');
|
|
|
|
$field->attr('value', 1);
|
|
|
|
$field->attr('value', 1);
|
|
|
@@ -3275,7 +3336,6 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function ___allowFieldInTemplate(Field $field, Template $template) {
|
|
|
|
public function ___allowFieldInTemplate(Field $field, Template $template) {
|
|
|
|
if($field && $template) {}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -3287,14 +3347,14 @@ class ProcessField extends Process implements ConfigurableModule {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function ___upgrade($fromVersion, $toVersion) {
|
|
|
|
public function ___upgrade($fromVersion, $toVersion) {
|
|
|
|
$collapsedTags = $this->wire('modules')->getConfig($this, 'collapsedTags');
|
|
|
|
$collapsedTags = $this->wire()->modules->getConfig($this, 'collapsedTags');
|
|
|
|
if(!is_array($collapsedTags)) {
|
|
|
|
if(!is_array($collapsedTags)) {
|
|
|
|
$collapsedTags = array();
|
|
|
|
$collapsedTags = array();
|
|
|
|
foreach($this->wire('fields')->getTags() as $tag) {
|
|
|
|
foreach($this->wire()->fields->getTags() as $tag) {
|
|
|
|
$c = substr($tag, 0, 1);
|
|
|
|
$c = substr($tag, 0, 1);
|
|
|
|
if($c === '-' || $c === '_') $collapsedTags[] = $tag;
|
|
|
|
if($c === '-' || $c === '_') $collapsedTags[] = $tag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->wire('modules')->saveConfig($this, 'collapsedTags', $collapsedTags);
|
|
|
|
$this->wire()->modules->saveConfig($this, 'collapsedTags', $collapsedTags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|