Skip to content

Commit

Permalink
Allow snippet/chunk tags in options for the dropdown field [#104]
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-H committed Oct 3, 2017
1 parent ac59f4f commit 2b9c571
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions _bootstrap/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
foreach ($objectContainers as $oC) {
$manager->createObjectContainer($oC);
}
$manager->addField('cgSetting', 'process_options');
echo "Done.";

// Refresh the cache
Expand Down
1 change: 1 addition & 0 deletions _build/resolvers/tables.resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
$manager->alterField('cgGroup', 'description', array());

$manager->addField('cgSetting', 'source');
$manager->addField('cgSetting', 'process_options');

$modx->setLogLevel($loglevel);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ ClientConfig.grid.Settings = function(config) {
{name: 'group', type: 'int'},
{name: 'group_label', type: 'string'},
{name: 'sortorder', type: 'int'},
{name: 'options', type: 'object'}
{name: 'options', type: 'object'},
{name: 'process_options', type: 'bool'}
],

// Visible Columns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ ClientConfig.window.Setting = function(config) {
select: {fn: function(field, record) {
if (record.data.xtype == 'modx-combo') {
Ext.getCmp(config.id + '-options').show();
Ext.getCmp(config.id + '-process_options').show();
} else {
Ext.getCmp(config.id + '-options').hide();
Ext.getCmp(config.id + '-process_options').hide();
}
if (['modx-panel-tv-image', 'modx-panel-tv-file'].indexOf(record.data.xtype) !== -1) {
Ext.getCmp(config.id + '-source').show();
Expand All @@ -96,6 +98,12 @@ ClientConfig.window.Setting = function(config) {
description: _('clientconfig.options.desc'),
anchor: '100%',
hidden: (config.record && (config.record.xtype === 'modx-combo')) ? false : true
},{
xtype: 'checkbox',
id: config.id + '-process_options',
name: 'process_options',
boxLabel: _('clientconfig.process_options'),
anchor: '100%'
},{
xtype: 'modx-combo-source',
id: config.id + '-source',
Expand Down
6 changes: 6 additions & 0 deletions core/components/clientconfig/controllers/home.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public function process(array $scriptProperties = array()) {
$googleFontsApiKey = $this->modx->getOption('clientconfig.google_fonts_api_key', null, '');
$sa['xtype'] = empty($googleFontsApiKey) ? 'textfield' : $sa['xtype'];
}
elseif ($sa['xtype'] === 'modx-combo' && $setting->get('process_options')) {
$inputOpts = $setting->get('options');
$this->modx->getParser();
$this->modx->parser->processElementTags('', $inputOpts, true, true);
$sa['options'] = $inputOpts;
}
$grp['items'][] = $sa;
}
$tabs[] = $grp;
Expand Down
1 change: 1 addition & 0 deletions core/components/clientconfig/docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
+++++++++++++++++++++++++
- ClientConfig can now (optionally) manage settings for different contexts [#4/#112]
- Media fields (image/file) now prefix the media source url [#124]
- Allow snippet/chunk tags in options for the dropdown field [#104]
- Updated minimum requirements to PHP 5.5.0 and MODX 2.5.2.
- Added separate clientconfig.categories lexicon for the vertical tabs interface [#91]

Expand Down
3 changes: 2 additions & 1 deletion core/components/clientconfig/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@
$_lang['clientconfig.choose_context'] = 'Choose Context';
$_lang['clientconfig.global_values'] = 'Global';
$_lang['clientconfig.config_for_context'] = 'Configuration for [[+context]]';
$_lang['clientconfig.categories'] = 'Categories';
$_lang['clientconfig.categories'] = 'Categories';
$_lang['clientconfig.process_options'] = 'Process tags in options';
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'default' => '',
'group' => 0,
'options' => '',
'process_options' => 0,
'source' => 0,
),
'fieldMeta' =>
Expand Down Expand Up @@ -96,6 +97,14 @@
'null' => true,
'default' => '',
),
'process_options' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
'phptype' => 'boolean',
'null' => false,
'default' => 0,
),
'source' =>
array (
'dbtype' => 'int',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field key="default" dbtype="mediumtext" phptype="string" null="false" default="" />
<field key="group" dbtype="int" precision="11" phptype="int" null="true" default="0" />
<field key="options" dbtype="mediumtext" phptype="string" null="true" default="" />
<field key="process_options" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="source" dbtype="int" precision="11" phptype="int" null="true" default="0" />

<aggregate alias="Group" class="cgGroup" cardinality="one" local="group" foreign="id" owner="foreign" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function beforeSet() {

/* Set is_required checkbox */
$this->setCheckbox('is_required', true);
$this->setCheckbox('process_options', true);
return parent::beforeSet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function beforeSet() {
}

$this->setCheckbox('is_required', true);
$this->setCheckbox('process_options', true);
return parent::beforeSet();
}

Expand Down

0 comments on commit 2b9c571

Please sign in to comment.