diff --git a/core/lexicon/en/template.inc.php b/core/lexicon/en/template.inc.php
index 940e84ef80a..30bb35ece74 100644
--- a/core/lexicon/en/template.inc.php
+++ b/core/lexicon/en/template.inc.php
@@ -26,6 +26,7 @@
$_lang['template_err_duplicate'] = 'An error occured while duplicating the template.';
$_lang['template_err_ae'] = 'A template already exists with the name "[[+name]]".';
$_lang['template_err_in_use'] = 'This template is in use. Please set the documents using the template to another template. Documents using this template:
';
+$_lang['template_err_invalid_name'] = 'Template name is invalid.';
$_lang['template_err_locked'] = 'Template is locked from editing.';
$_lang['template_err_nf'] = 'Template not found!';
$_lang['template_err_ns'] = 'Template not specified.';
diff --git a/core/model/modx/mysql/modchunk.map.inc.php b/core/model/modx/mysql/modchunk.map.inc.php
index 48afd97a6eb..8772a9a054e 100644
--- a/core/model/modx/mysql/modchunk.map.inc.php
+++ b/core/model/modx/mysql/modchunk.map.inc.php
@@ -8,11 +8,11 @@
'version' => '1.1',
'table' => 'site_htmlsnippets',
'extends' => 'modElement',
- 'tableMeta' =>
+ 'tableMeta' =>
array (
'engine' => 'InnoDB',
),
- 'fields' =>
+ 'fields' =>
array (
'name' => '',
'description' => 'Chunk',
@@ -25,9 +25,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'name' =>
+ 'name' =>
array (
'dbtype' => 'varchar',
'precision' => '50',
@@ -36,7 +36,7 @@
'default' => '',
'index' => 'unique',
),
- 'description' =>
+ 'description' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -44,7 +44,7 @@
'null' => false,
'default' => 'Chunk',
),
- 'editor_type' =>
+ 'editor_type' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -52,7 +52,7 @@
'null' => false,
'default' => 0,
),
- 'category' =>
+ 'category' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -61,7 +61,7 @@
'default' => 0,
'index' => 'fk',
),
- 'cache_type' =>
+ 'cache_type' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -69,12 +69,12 @@
'null' => false,
'default' => 0,
),
- 'snippet' =>
+ 'snippet' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -84,13 +84,13 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -100,7 +100,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -109,21 +109,21 @@
'default' => '',
),
),
- 'fieldAliases' =>
+ 'fieldAliases' =>
array (
'content' => 'snippet',
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'name' =>
+ 'name' =>
array (
'alias' => 'name',
'primary' => false,
'unique' => true,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'name' =>
+ 'name' =>
array (
'length' => '',
'collation' => 'A',
@@ -131,15 +131,15 @@
),
),
),
- 'category' =>
+ 'category' =>
array (
'alias' => 'category',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'category' =>
+ 'category' =>
array (
'length' => '',
'collation' => 'A',
@@ -147,15 +147,15 @@
),
),
),
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -163,15 +163,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -180,27 +180,27 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modChunk',
),
),
),
),
- 'aggregates' =>
+ 'aggregates' =>
array (
- 'Category' =>
+ 'Category' =>
array (
'class' => 'modCategory',
'key' => 'id',
@@ -210,16 +210,16 @@
'owner' => 'foreign',
),
),
- 'validation' =>
+ 'validation' =>
array (
- 'rules' =>
+ 'rules' =>
array (
- 'name' =>
+ 'name' =>
array (
- 'invalid' =>
+ 'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'chunk_err_invalid_name',
),
),
diff --git a/core/model/modx/mysql/modplugin.map.inc.php b/core/model/modx/mysql/modplugin.map.inc.php
index eacfab87dc5..5e57fb6fb5f 100644
--- a/core/model/modx/mysql/modplugin.map.inc.php
+++ b/core/model/modx/mysql/modplugin.map.inc.php
@@ -8,11 +8,11 @@
'version' => '1.1',
'table' => 'site_plugins',
'extends' => 'modScript',
- 'tableMeta' =>
+ 'tableMeta' =>
array (
'engine' => 'InnoDB',
),
- 'fields' =>
+ 'fields' =>
array (
'cache_type' => 0,
'plugincode' => '',
@@ -23,9 +23,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'cache_type' =>
+ 'cache_type' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -33,14 +33,14 @@
'null' => false,
'default' => 0,
),
- 'plugincode' =>
+ 'plugincode' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
'null' => false,
'default' => '',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -50,13 +50,13 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'disabled' =>
+ 'disabled' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -66,7 +66,7 @@
'default' => 0,
'index' => 'index',
),
- 'moduleguid' =>
+ 'moduleguid' =>
array (
'dbtype' => 'varchar',
'precision' => '32',
@@ -75,7 +75,7 @@
'default' => '',
'index' => 'fk',
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -85,7 +85,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -94,21 +94,21 @@
'default' => '',
),
),
- 'fieldAliases' =>
+ 'fieldAliases' =>
array (
'content' => 'plugincode',
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -116,15 +116,15 @@
),
),
),
- 'disabled' =>
+ 'disabled' =>
array (
'alias' => 'disabled',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'disabled' =>
+ 'disabled' =>
array (
'length' => '',
'collation' => 'A',
@@ -132,15 +132,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -149,24 +149,24 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modPlugin',
),
),
),
- 'PluginEvents' =>
+ 'PluginEvents' =>
array (
'class' => 'modPluginEvent',
'local' => 'id',
@@ -175,16 +175,16 @@
'owner' => 'local',
),
),
- 'validation' =>
+ 'validation' =>
array (
- 'rules' =>
+ 'rules' =>
array (
- 'name' =>
+ 'name' =>
array (
- 'invalid' =>
+ 'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9_-\\x7f-\\xff\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x7f-\xff-_\s]+(? 'plugin_err_invalid_name',
),
),
diff --git a/core/model/modx/mysql/modsnippet.map.inc.php b/core/model/modx/mysql/modsnippet.map.inc.php
index 92dfd62c07d..1a3cb4ff438 100644
--- a/core/model/modx/mysql/modsnippet.map.inc.php
+++ b/core/model/modx/mysql/modsnippet.map.inc.php
@@ -8,11 +8,11 @@
'version' => '1.1',
'table' => 'site_snippets',
'extends' => 'modScript',
- 'tableMeta' =>
+ 'tableMeta' =>
array (
'engine' => 'InnoDB',
),
- 'fields' =>
+ 'fields' =>
array (
'cache_type' => 0,
'snippet' => NULL,
@@ -22,9 +22,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'cache_type' =>
+ 'cache_type' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -32,12 +32,12 @@
'null' => false,
'default' => 0,
),
- 'snippet' =>
+ 'snippet' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -47,13 +47,13 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'moduleguid' =>
+ 'moduleguid' =>
array (
'dbtype' => 'varchar',
'precision' => '32',
@@ -62,7 +62,7 @@
'default' => '',
'index' => 'fk',
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -72,7 +72,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -81,21 +81,21 @@
'default' => '',
),
),
- 'fieldAliases' =>
+ 'fieldAliases' =>
array (
'content' => 'snippet',
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -103,15 +103,15 @@
),
),
),
- 'moduleguid' =>
+ 'moduleguid' =>
array (
'alias' => 'moduleguid',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'moduleguid' =>
+ 'moduleguid' =>
array (
'length' => '',
'collation' => 'A',
@@ -119,15 +119,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -136,34 +136,34 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modSnippet',
),
),
),
),
- 'validation' =>
+ 'validation' =>
array (
- 'rules' =>
+ 'rules' =>
array (
- 'name' =>
+ 'name' =>
array (
- 'invalid' =>
+ 'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'snippet_err_invalid_name',
),
),
diff --git a/core/model/modx/mysql/modtemplate.map.inc.php b/core/model/modx/mysql/modtemplate.map.inc.php
index a9b0e9c1466..688c48442af 100644
--- a/core/model/modx/mysql/modtemplate.map.inc.php
+++ b/core/model/modx/mysql/modtemplate.map.inc.php
@@ -8,11 +8,11 @@
'version' => '1.1',
'table' => 'site_templates',
'extends' => 'modElement',
- 'tableMeta' =>
+ 'tableMeta' =>
array (
'engine' => 'InnoDB',
),
- 'fields' =>
+ 'fields' =>
array (
'templatename' => '',
'description' => 'Template',
@@ -26,9 +26,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'templatename' =>
+ 'templatename' =>
array (
'dbtype' => 'varchar',
'precision' => '50',
@@ -37,7 +37,7 @@
'default' => '',
'index' => 'unique',
),
- 'description' =>
+ 'description' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -45,7 +45,7 @@
'null' => false,
'default' => 'Template',
),
- 'editor_type' =>
+ 'editor_type' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -53,7 +53,7 @@
'null' => false,
'default' => 0,
),
- 'category' =>
+ 'category' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -62,7 +62,7 @@
'default' => 0,
'index' => 'fk',
),
- 'icon' =>
+ 'icon' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -70,7 +70,7 @@
'null' => false,
'default' => '',
),
- 'template_type' =>
+ 'template_type' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -78,14 +78,14 @@
'null' => false,
'default' => 0,
),
- 'content' =>
+ 'content' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
'null' => false,
'default' => '',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -95,13 +95,13 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -111,7 +111,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -120,17 +120,17 @@
'default' => '',
),
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'templatename' =>
+ 'templatename' =>
array (
'alias' => 'templatename',
'primary' => false,
'unique' => true,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'templatename' =>
+ 'templatename' =>
array (
'length' => '',
'collation' => 'A',
@@ -138,15 +138,15 @@
),
),
),
- 'category' =>
+ 'category' =>
array (
'alias' => 'category',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'category' =>
+ 'category' =>
array (
'length' => '',
'collation' => 'A',
@@ -154,15 +154,15 @@
),
),
),
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -170,15 +170,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -187,24 +187,24 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modTemplate',
),
),
),
- 'TemplateVarTemplates' =>
+ 'TemplateVarTemplates' =>
array (
'class' => 'modTemplateVarTemplate',
'local' => 'id',
@@ -213,9 +213,9 @@
'owner' => 'local',
),
),
- 'aggregates' =>
+ 'aggregates' =>
array (
- 'Category' =>
+ 'Category' =>
array (
'class' => 'modCategory',
'local' => 'category',
@@ -223,7 +223,7 @@
'cardinality' => 'one',
'owner' => 'foreign',
),
- 'Resources' =>
+ 'Resources' =>
array (
'class' => 'modResource',
'local' => 'id',
@@ -232,4 +232,19 @@
'owner' => 'local',
),
),
+ 'validation' =>
+ array (
+ 'rules' =>
+ array (
+ 'templatename' =>
+ array (
+ 'invalid' =>
+ array (
+ 'type' => 'preg_match',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'template_err_invalid_name',
+ ),
+ ),
+ ),
+ ),
);
diff --git a/core/model/modx/mysql/modtemplatevar.map.inc.php b/core/model/modx/mysql/modtemplatevar.map.inc.php
index 9fd41d789b0..3bd1b7c891b 100644
--- a/core/model/modx/mysql/modtemplatevar.map.inc.php
+++ b/core/model/modx/mysql/modtemplatevar.map.inc.php
@@ -8,11 +8,11 @@
'version' => '1.1',
'table' => 'site_tmplvars',
'extends' => 'modElement',
- 'tableMeta' =>
+ 'tableMeta' =>
array (
'engine' => 'InnoDB',
),
- 'fields' =>
+ 'fields' =>
array (
'type' => '',
'name' => '',
@@ -31,9 +31,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'type' =>
+ 'type' =>
array (
'dbtype' => 'varchar',
'precision' => '20',
@@ -41,7 +41,7 @@
'null' => false,
'default' => '',
),
- 'name' =>
+ 'name' =>
array (
'dbtype' => 'varchar',
'precision' => '50',
@@ -50,7 +50,7 @@
'default' => '',
'index' => 'unique',
),
- 'caption' =>
+ 'caption' =>
array (
'dbtype' => 'varchar',
'precision' => '80',
@@ -58,7 +58,7 @@
'null' => false,
'default' => '',
),
- 'description' =>
+ 'description' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -66,7 +66,7 @@
'null' => false,
'default' => '',
),
- 'editor_type' =>
+ 'editor_type' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -74,7 +74,7 @@
'null' => false,
'default' => 0,
),
- 'category' =>
+ 'category' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -83,7 +83,7 @@
'default' => 0,
'index' => 'fk',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -93,12 +93,12 @@
'default' => 0,
'index' => 'index',
),
- 'elements' =>
+ 'elements' =>
array (
'dbtype' => 'text',
'phptype' => 'string',
),
- 'rank' =>
+ 'rank' =>
array (
'dbtype' => 'int',
'precision' => '11',
@@ -107,7 +107,7 @@
'default' => 0,
'index' => 'index',
),
- 'display' =>
+ 'display' =>
array (
'dbtype' => 'varchar',
'precision' => '20',
@@ -115,30 +115,30 @@
'null' => false,
'default' => '',
),
- 'default_text' =>
+ 'default_text' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'input_properties' =>
+ 'input_properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'output_properties' =>
+ 'output_properties' =>
array (
'dbtype' => 'text',
'phptype' => 'array',
'null' => true,
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -148,7 +148,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'varchar',
'precision' => '191',
@@ -157,21 +157,21 @@
'default' => '',
),
),
- 'fieldAliases' =>
+ 'fieldAliases' =>
array (
'content' => 'default_text',
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'name' =>
+ 'name' =>
array (
'alias' => 'name',
'primary' => false,
'unique' => true,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'name' =>
+ 'name' =>
array (
'length' => '',
'collation' => 'A',
@@ -179,15 +179,15 @@
),
),
),
- 'category' =>
+ 'category' =>
array (
'alias' => 'category',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'category' =>
+ 'category' =>
array (
'length' => '',
'collation' => 'A',
@@ -195,15 +195,15 @@
),
),
),
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -211,15 +211,15 @@
),
),
),
- 'rank' =>
+ 'rank' =>
array (
'alias' => 'rank',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'rank' =>
+ 'rank' =>
array (
'length' => '',
'collation' => 'A',
@@ -227,15 +227,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -244,24 +244,24 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modTemplateVar',
),
),
),
- 'TemplateVarTemplates' =>
+ 'TemplateVarTemplates' =>
array (
'class' => 'modTemplateVarTemplate',
'local' => 'id',
@@ -269,7 +269,7 @@
'cardinality' => 'many',
'owner' => 'local',
),
- 'TemplateVarResources' =>
+ 'TemplateVarResources' =>
array (
'class' => 'modTemplateVarResource',
'local' => 'id',
@@ -277,7 +277,7 @@
'cardinality' => 'many',
'owner' => 'local',
),
- 'TemplateVarResourceGroups' =>
+ 'TemplateVarResourceGroups' =>
array (
'class' => 'modTemplateVarResourceGroup',
'local' => 'id',
@@ -286,9 +286,9 @@
'owner' => 'local',
),
),
- 'aggregates' =>
+ 'aggregates' =>
array (
- 'Category' =>
+ 'Category' =>
array (
'class' => 'modCategory',
'local' => 'category',
@@ -297,19 +297,19 @@
'owner' => 'foreign',
),
),
- 'validation' =>
+ 'validation' =>
array (
- 'rules' =>
+ 'rules' =>
array (
- 'name' =>
+ 'name' =>
array (
- 'invalid' =>
+ 'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'tv_err_invalid_name',
),
- 'reserved' =>
+ 'reserved' =>
array (
'type' => 'preg_match',
'rule' => '/^(?!(id|type|contentType|pagetitle|longtitle|description|alias|alias_visible|link_attributes|published|pub_date|unpub_date|parent|isfolder|introtext|content|richtext|template|menuindex|searchable|cacheable|createdby|createdon|editedby|editedon|deleted|deletedby|deletedon|publishedon|publishedby|menutitle|donthit|privateweb|privatemgr|content_dispo|hidemenu|class_key|context_key|content_type|uri|uri_override|hide_children_in_tree|show_in_tree|properties)$)/',
diff --git a/core/model/modx/processors/element/create.class.php b/core/model/modx/processors/element/create.class.php
index 203cba57c92..b405e7ac061 100644
--- a/core/model/modx/processors/element/create.class.php
+++ b/core/model/modx/processors/element/create.class.php
@@ -34,11 +34,11 @@ public function cleanup() {
* @return boolean
*/
public function beforeSave() {
- $name = $this->getProperty('name');
-
+ $nameField = $this->classKey === 'modTemplate' ? 'templatename' : 'name';
+ $name = $this->getProperty($nameField,'');
/* verify element with that name does not already exist */
if ($this->alreadyExists($name)) {
- $this->addFieldError('name',$this->modx->lexicon($this->objectType.'_err_ae',array(
+ $this->addFieldError($nameField,$this->modx->lexicon($this->objectType.'_err_ae',array(
'name' => $name,
)));
}
diff --git a/core/model/modx/processors/element/update.class.php b/core/model/modx/processors/element/update.class.php
index 119c4026fcf..e15d3086b80 100644
--- a/core/model/modx/processors/element/update.class.php
+++ b/core/model/modx/processors/element/update.class.php
@@ -82,6 +82,8 @@ public function afterSave() {
}
public function cleanup() {
- return $this->success('',array_merge($this->object->get(array('id', 'name', 'description', 'locked', 'category', 'content')), array('previous_category' => $this->previousCategory)));
+ $fields = array('id', 'description', 'locked', 'category', 'content');
+ array_push($fields,($this->classKey == 'modTemplate' ? 'templatename' : 'name'));
+ return $this->success('',array_merge($this->object->get($fields), array('previous_category' => $this->previousCategory)));
}
}
diff --git a/core/model/modx/sqlsrv/modchunk.map.inc.php b/core/model/modx/sqlsrv/modchunk.map.inc.php
index 6444f72e2e8..c6891992160 100644
--- a/core/model/modx/sqlsrv/modchunk.map.inc.php
+++ b/core/model/modx/sqlsrv/modchunk.map.inc.php
@@ -8,7 +8,7 @@
'version' => '1.1',
'table' => 'site_htmlsnippets',
'extends' => 'modElement',
- 'fields' =>
+ 'fields' =>
array (
'name' => '',
'description' => 'Chunk',
@@ -21,9 +21,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'name' =>
+ 'name' =>
array (
'dbtype' => 'nvarchar',
'precision' => '50',
@@ -32,7 +32,7 @@
'default' => '',
'index' => 'unique',
),
- 'description' =>
+ 'description' =>
array (
'dbtype' => 'nvarchar',
'precision' => '255',
@@ -40,14 +40,14 @@
'null' => false,
'default' => 'Chunk',
),
- 'editor_type' =>
+ 'editor_type' =>
array (
'dbtype' => 'int',
'phptype' => 'integer',
'null' => false,
'default' => 0,
),
- 'category' =>
+ 'category' =>
array (
'dbtype' => 'int',
'phptype' => 'integer',
@@ -55,7 +55,7 @@
'default' => 0,
'index' => 'fk',
),
- 'cache_type' =>
+ 'cache_type' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -63,13 +63,13 @@
'null' => false,
'default' => 0,
),
- 'snippet' =>
+ 'snippet' =>
array (
'dbtype' => 'nvarchar',
'precision' => 'max',
'phptype' => 'string',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -77,14 +77,14 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'nvarchar',
'precision' => 'max',
'phptype' => 'array',
'null' => true,
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -92,7 +92,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'nvarchar',
'precision' => '255',
@@ -101,21 +101,21 @@
'default' => '',
),
),
- 'fieldAliases' =>
+ 'fieldAliases' =>
array (
'content' => 'snippet',
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'name' =>
+ 'name' =>
array (
'alias' => 'name',
'primary' => false,
'unique' => true,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'name' =>
+ 'name' =>
array (
'length' => '',
'collation' => 'A',
@@ -123,15 +123,15 @@
),
),
),
- 'category' =>
+ 'category' =>
array (
'alias' => 'category',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'category' =>
+ 'category' =>
array (
'length' => '',
'collation' => 'A',
@@ -139,15 +139,15 @@
),
),
),
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -155,15 +155,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -172,27 +172,27 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modChunk',
),
),
),
),
- 'aggregates' =>
+ 'aggregates' =>
array (
- 'Category' =>
+ 'Category' =>
array (
'class' => 'modCategory',
'key' => 'id',
@@ -202,16 +202,16 @@
'owner' => 'foreign',
),
),
- 'validation' =>
+ 'validation' =>
array (
- 'rules' =>
+ 'rules' =>
array (
- 'name' =>
+ 'name' =>
array (
- 'invalid' =>
+ 'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'chunk_err_invalid_name',
),
),
diff --git a/core/model/modx/sqlsrv/modplugin.map.inc.php b/core/model/modx/sqlsrv/modplugin.map.inc.php
index ef9bcb9688b..5b8ab56361d 100644
--- a/core/model/modx/sqlsrv/modplugin.map.inc.php
+++ b/core/model/modx/sqlsrv/modplugin.map.inc.php
@@ -8,7 +8,7 @@
'version' => '1.1',
'table' => 'site_plugins',
'extends' => 'modScript',
- 'fields' =>
+ 'fields' =>
array (
'cache_type' => 0,
'plugincode' => '',
@@ -19,9 +19,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'cache_type' =>
+ 'cache_type' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
@@ -29,7 +29,7 @@
'null' => false,
'default' => 0,
),
- 'plugincode' =>
+ 'plugincode' =>
array (
'dbtype' => 'nvarchar',
'precision' => 'max',
@@ -37,7 +37,7 @@
'null' => false,
'default' => '',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -45,14 +45,14 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'nvarchar',
'precision' => 'max',
'phptype' => 'array',
'null' => true,
),
- 'disabled' =>
+ 'disabled' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -60,7 +60,7 @@
'default' => 0,
'index' => 'index',
),
- 'moduleguid' =>
+ 'moduleguid' =>
array (
'dbtype' => 'nvarchar',
'precision' => '32',
@@ -69,7 +69,7 @@
'default' => '',
'index' => 'fk',
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -77,7 +77,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'nvarchar',
'precision' => '255',
@@ -86,21 +86,21 @@
'default' => '',
),
),
- 'fieldAliases' =>
+ 'fieldAliases' =>
array (
'content' => 'plugincode',
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -108,15 +108,15 @@
),
),
),
- 'disabled' =>
+ 'disabled' =>
array (
'alias' => 'disabled',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'disabled' =>
+ 'disabled' =>
array (
'length' => '',
'collation' => 'A',
@@ -125,24 +125,24 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modPlugin',
),
),
),
- 'PluginEvents' =>
+ 'PluginEvents' =>
array (
'class' => 'modPluginEvent',
'local' => 'id',
@@ -151,16 +151,16 @@
'owner' => 'local',
),
),
- 'validation' =>
+ 'validation' =>
array (
- 'rules' =>
+ 'rules' =>
array (
- 'name' =>
+ 'name' =>
array (
- 'invalid' =>
+ 'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9_-\\x7f-\\xff\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'plugin_err_invalid_name',
),
),
diff --git a/core/model/modx/sqlsrv/modsnippet.map.inc.php b/core/model/modx/sqlsrv/modsnippet.map.inc.php
index 15b23b762f1..223bba4f5dc 100644
--- a/core/model/modx/sqlsrv/modsnippet.map.inc.php
+++ b/core/model/modx/sqlsrv/modsnippet.map.inc.php
@@ -141,7 +141,7 @@
'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'snippet_err_invalid_name',
),
),
diff --git a/core/model/modx/sqlsrv/modtemplate.map.inc.php b/core/model/modx/sqlsrv/modtemplate.map.inc.php
index 62db00620ea..89544029c98 100644
--- a/core/model/modx/sqlsrv/modtemplate.map.inc.php
+++ b/core/model/modx/sqlsrv/modtemplate.map.inc.php
@@ -8,7 +8,7 @@
'version' => '1.1',
'table' => 'site_templates',
'extends' => 'modElement',
- 'fields' =>
+ 'fields' =>
array (
'templatename' => '',
'description' => 'Template',
@@ -22,9 +22,9 @@
'static' => 0,
'static_file' => '',
),
- 'fieldMeta' =>
+ 'fieldMeta' =>
array (
- 'templatename' =>
+ 'templatename' =>
array (
'dbtype' => 'nvarchar',
'precision' => '50',
@@ -33,7 +33,7 @@
'default' => '',
'index' => 'unique',
),
- 'description' =>
+ 'description' =>
array (
'dbtype' => 'nvarchar',
'precision' => '255',
@@ -41,14 +41,14 @@
'null' => false,
'default' => 'Template',
),
- 'editor_type' =>
+ 'editor_type' =>
array (
'dbtype' => 'int',
'phptype' => 'integer',
'null' => false,
'default' => 0,
),
- 'category' =>
+ 'category' =>
array (
'dbtype' => 'int',
'phptype' => 'integer',
@@ -56,7 +56,7 @@
'default' => 0,
'index' => 'fk',
),
- 'icon' =>
+ 'icon' =>
array (
'dbtype' => 'nvarchar',
'precision' => '255',
@@ -64,14 +64,14 @@
'null' => false,
'default' => '',
),
- 'template_type' =>
+ 'template_type' =>
array (
'dbtype' => 'int',
'phptype' => 'integer',
'null' => false,
'default' => 0,
),
- 'content' =>
+ 'content' =>
array (
'dbtype' => 'nvarchar',
'precision' => 'max',
@@ -79,7 +79,7 @@
'null' => false,
'default' => '',
),
- 'locked' =>
+ 'locked' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -87,14 +87,14 @@
'default' => 0,
'index' => 'index',
),
- 'properties' =>
+ 'properties' =>
array (
'dbtype' => 'nvarchar',
'precision' => 'max',
'phptype' => 'array',
'null' => true,
),
- 'static' =>
+ 'static' =>
array (
'dbtype' => 'bit',
'phptype' => 'boolean',
@@ -102,7 +102,7 @@
'default' => 0,
'index' => 'index',
),
- 'static_file' =>
+ 'static_file' =>
array (
'dbtype' => 'nvarchar',
'precision' => '255',
@@ -111,17 +111,17 @@
'default' => '',
),
),
- 'indexes' =>
+ 'indexes' =>
array (
- 'templatename' =>
+ 'templatename' =>
array (
'alias' => 'templatename',
'primary' => false,
'unique' => true,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'templatename' =>
+ 'templatename' =>
array (
'length' => '',
'collation' => 'A',
@@ -129,15 +129,15 @@
),
),
),
- 'category' =>
+ 'category' =>
array (
'alias' => 'category',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'category' =>
+ 'category' =>
array (
'length' => '',
'collation' => 'A',
@@ -145,15 +145,15 @@
),
),
),
- 'locked' =>
+ 'locked' =>
array (
'alias' => 'locked',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'locked' =>
+ 'locked' =>
array (
'length' => '',
'collation' => 'A',
@@ -161,15 +161,15 @@
),
),
),
- 'static' =>
+ 'static' =>
array (
'alias' => 'static',
'primary' => false,
'unique' => false,
'type' => 'BTREE',
- 'columns' =>
+ 'columns' =>
array (
- 'static' =>
+ 'static' =>
array (
'length' => '',
'collation' => 'A',
@@ -178,24 +178,24 @@
),
),
),
- 'composites' =>
+ 'composites' =>
array (
- 'PropertySets' =>
+ 'PropertySets' =>
array (
'class' => 'modElementPropertySet',
'local' => 'id',
'foreign' => 'element',
'owner' => 'local',
'cardinality' => 'many',
- 'criteria' =>
+ 'criteria' =>
array (
- 'foreign' =>
+ 'foreign' =>
array (
'element_class' => 'modTemplate',
),
),
),
- 'TemplateVarTemplates' =>
+ 'TemplateVarTemplates' =>
array (
'class' => 'modTemplateVarTemplate',
'local' => 'id',
@@ -204,9 +204,9 @@
'owner' => 'local',
),
),
- 'aggregates' =>
+ 'aggregates' =>
array (
- 'Category' =>
+ 'Category' =>
array (
'class' => 'modCategory',
'local' => 'category',
@@ -214,7 +214,7 @@
'cardinality' => 'one',
'owner' => 'foreign',
),
- 'Resources' =>
+ 'Resources' =>
array (
'class' => 'modResource',
'local' => 'id',
@@ -223,4 +223,19 @@
'owner' => 'local',
),
),
+ 'validation' =>
+ array (
+ 'rules' =>
+ array (
+ 'name' =>
+ array (
+ 'invalid' =>
+ array (
+ 'type' => 'preg_match',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'snippet_err_invalid_name',
+ ),
+ ),
+ ),
+ ),
);
diff --git a/core/model/modx/sqlsrv/modtemplatevar.map.inc.php b/core/model/modx/sqlsrv/modtemplatevar.map.inc.php
index 79ebb22e5e4..00d1052d261 100644
--- a/core/model/modx/sqlsrv/modtemplatevar.map.inc.php
+++ b/core/model/modx/sqlsrv/modtemplatevar.map.inc.php
@@ -302,7 +302,7 @@
'invalid' =>
array (
'type' => 'preg_match',
- 'rule' => '/^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/',
+ 'rule' => '/^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(? 'tv_err_invalid_name',
),
'reserved' =>
diff --git a/core/model/modx/validation/modvalidator.class.php b/core/model/modx/validation/modvalidator.class.php
index e4847acaa24..2b8a7843c40 100644
--- a/core/model/modx/validation/modvalidator.class.php
+++ b/core/model/modx/validation/modvalidator.class.php
@@ -23,7 +23,7 @@ class modValidator extends xPDOValidator {
* @return boolean Either true or false indicating valid or invalid.
*/
public function validate(array $parameters= array()) {
- $result= parent :: validate($parameters);
+ $result = parent::validate($parameters);
if (!empty($this->messages)) {
foreach ($this->messages as $k => $v) {
if (array_key_exists('message',$this->messages[$k])) {
diff --git a/core/model/schema/modx.mysql.schema.xml b/core/model/schema/modx.mysql.schema.xml
index e9b3aab3d2c..38da477b212 100644
--- a/core/model/schema/modx.mysql.schema.xml
+++ b/core/model/schema/modx.mysql.schema.xml
@@ -393,7 +393,7 @@
-
+
@@ -812,7 +812,7 @@
-
+
@@ -1072,7 +1072,7 @@
-
+
@@ -1127,9 +1127,14 @@
{"element_class":"modTemplate"}
]]>
+
+
+
+
+
diff --git a/core/model/schema/modx.sqlsrv.schema.xml b/core/model/schema/modx.sqlsrv.schema.xml
index ff472b86f42..de3d3362bd7 100644
--- a/core/model/schema/modx.sqlsrv.schema.xml
+++ b/core/model/schema/modx.sqlsrv.schema.xml
@@ -313,7 +313,7 @@
-
+
@@ -765,7 +765,7 @@
-
+
@@ -1016,7 +1016,7 @@
]]>
-
+
@@ -1122,7 +1122,7 @@
-
+
diff --git a/manager/assets/modext/widgets/core/modx.panel.js b/manager/assets/modext/widgets/core/modx.panel.js
index 920ab9476d0..3e8f4b86f4f 100644
--- a/manager/assets/modext/widgets/core/modx.panel.js
+++ b/manager/assets/modext/widgets/core/modx.panel.js
@@ -69,6 +69,13 @@ Ext.extend(MODx.FormPanel,Ext.FormPanel,{
,defaultValues: []
,initialized: false
+ /*
+ Use these errorHandling properties to specify which tab components
+ should and should not be inspected for field errors
+ */
+ ,errorHandlingTabs: []
+ ,errorHandlingIgnoreTabs: []
+
,submit: function(o) {
var fm = this.getForm();
if (fm.isValid() || o.bypassValidCheck) {
@@ -102,14 +109,14 @@ Ext.extend(MODx.FormPanel,Ext.FormPanel,{
Ext.callback(this.config.success,this.config.scope || this,[f,a]);
}
this.fireEvent('success',{
- form:f
- ,result:a.result
- ,options:o
- ,config:this.config
+ form: f
+ ,result: a.result
+ ,options: o
+ ,config: this.config
});
this.clearDirty();
this.fireEvent('setup',this.config);
-
+
//get our Active input value and keep focus
var lastActiveEle = Ext.state.Manager.get('curFocus');
if (lastActiveEle && lastActiveEle != '') {
@@ -126,12 +133,22 @@ Ext.extend(MODx.FormPanel,Ext.FormPanel,{
return true;
}
+ ,failure: function(o) {
+ this.warnUnsavedChanges = true;
+ if(this.getForm().baseParams.action.indexOf('/create') !== -1) {
+ var btn = Ext.getCmp('modx-abtn-save');
+ if (btn) { btn.enable(); }
+ }
+ this.fireEvent('failureSubmit');
+ }
+
,focusFirstField: function() {
if (this.getForm().items.getCount() > 0) {
var fld = this.findFirstTextField();
if (fld) { fld.focus(false,200); }
}
}
+
,findFirstTextField: function(i) {
i = i || 0;
var fld = this.getForm().items.itemAt(i);
@@ -297,57 +314,112 @@ Ext.extend(MODx.FormPanel,Ext.FormPanel,{
MODx.FormPanel.superclass.destroy.call(this);
}
+ /**
+ * Get tab ids for use in further processing
+ *
+ * @param {Object} map - the items.map object of the primary tabs panel
+ * @param {Array} keys - an array of keys matching those in the tabsObj items.keys
+ */
+ ,getTabIdsFromKeys: function(map, keys) {
+
+ let tabIds = [];
+
+ if (typeof map == 'object') {
+ if (Array.isArray(keys) && keys.length > 0) {
+ keys.forEach(function(key) {
+ if(map.hasOwnProperty(key) && typeof map[key].id == 'string') {
+ tabIds.push(map[key].id);
+ } else if (key == 'modx-panel-resource-tv' && MODx.config.tvs_below_content == 1) {
+ /*
+ When evaluating a resource panel with TVs moved below content,
+ the panel id needs to be added explicitly as, in this case, the TV panel
+ is not part of the main tabs component
+ */
+ tabIds.push(key);
+ }
+ });
+ }
+ }
+ return tabIds;
+ }
+
/**
* Find errored field in the panel and activates the tab where the first error was found.
*
- * @param {Array} detectingForms - array of forms where we should find errors
- * @param {String} tabsId - id of tab component for a given panel
+ * @param {Array} targetForms - array of form tab itemIds to search for errors
+ * @param {String} tabsId - id of primary tab component for a given panel
*/
- ,showErroredTab: function(detectingForms, tabsId) {
- var tab = null, index = null;
- for (var i = 0; i < detectingForms.length; i++) {
- var component = Ext.getCmp(detectingForms[i]);
+ ,showErroredTab: function(targetForms, tabsId) {
+
+ const mainTabs = Ext.getCmp(tabsId);
+ let searchTabs = this.getTabIdsFromKeys(mainTabs.items.map, targetForms),
+ mainTabName = null,
+ mainTabIndex = null,
+ component,
+ erroredNode = null
+ ;
+ /*
+ Add any custom panels, created on the fly via manager customization or CMPs,
+ to the searchTabs
+ */
+ if (mainTabs.items.length > mainTabs.initialConfig.items.length) {
+ mainTabs.items.keys.forEach(function(key) {
+ if (mainTabs.items.map[key].hasOwnProperty('id')) {
+ if(this.errorHandlingIgnoreTabs.indexOf(mainTabs.items.map[key].id) === -1 && searchTabs.indexOf(mainTabs.items.map[key].id) === -1) {
+ searchTabs.push(mainTabs.items.map[key].id);
+ }
+ }
+ }, this);
+ }
+
+ for (let i = 0; i < searchTabs.length; i++) {
+ component = Ext.getCmp(searchTabs[i]);
if (component && component.el && component.el.dom) {
- if (this.detectErrors(component.el.dom)) {
- tab = component.itemId ? component.itemId : detectingForms[i];
+ erroredNode = this.detectErrors(component.el.dom);
+ if (erroredNode !== false) {
+ mainTabName = component.itemId ? component.itemId : searchTabs[i];
break;
}
}
}
- if (tab === null) {
- return;
- }
+ if (mainTabName !== null) {
- var tabs = Ext.getCmp(tabsId);
+ const errFld = document.getElementById(erroredNode);
- if (tabs && tabs.items && tabs.items.keys) {
- index = tabs.items.keys.indexOf(tab);
- }
+ if (mainTabs && mainTabs.items && mainTabs.items.keys) {
+ mainTabIndex = mainTabs.items.keys.indexOf(mainTabName);
+ if (component.id == 'modx-panel-resource-tv' && MODx.config.tvs_below_content == 0 || component.id != 'modx-panel-resource-tv') {
+ if (mainTabs.items.items[mainTabIndex].hidden) {
+ mainTabs.activate(mainTabName);
+ }
+ }
+ }
- if (!tabs.items.items[index].hidden) {
- return;
+ if (component.id == 'modx-panel-resource-tv') {
+ const errFldPanelId = errFld.closest('.x-panel').id,
+ tvTabs = Ext.getCmp('modx-resource-vtabs')
+ ;
+ if (tvTabs && tvTabs.items && tvTabs.items.keys) {
+ const tvTabIndex = tvTabs.items.keys.indexOf(errFldPanelId);
+ if (tvTabs.items.items[tvTabIndex].hidden) {
+ tvTabs.activate(errFldPanelId);
+ }
+ }
+ }
+ errFld.focus();
}
-
- tabs.activate(tab);
}
,detectErrors: function(node) {
- if (typeof node.classList !== 'undefined' && node.classList.contains('x-form-invalid')) {
- return true;
- }
-
- if (typeof node.children == 'undefined') {
+ let erroredFlds = document.getElementById(node.id).querySelectorAll('.x-form-invalid'),
+ numErrors = erroredFlds.length
+ ;
+ if (numErrors > 0) {
+ return erroredFlds[0].id;
+ } else {
return false;
}
-
- for (var i = 0; i < node.children.length; i++) {
- if (this.detectErrors(node.children[i])) {
- return true;
- }
- }
-
- return false;
}
});
Ext.reg('modx-formpanel',MODx.FormPanel);
@@ -578,15 +650,15 @@ Ext.extend(MODx.BreadcrumbsPanel,Ext.Panel,{
,getData: function() {
return this.data;
}
-
+
,reset: function(msg){
if(typeof(this.resetText) == "undefined"){
this.resetText = this.getResetText(this.root);
- }
+ }
this.data = { text : msg ,trail : [this.resetText] };
this._updatePanel(this.data);
- }
-
+ }
+
,onClick: function(e){
var target = e.getTarget();
diff --git a/manager/assets/modext/widgets/element/modx.panel.chunk.js b/manager/assets/modext/widgets/element/modx.panel.chunk.js
index dd2c2ed7955..40bfb052541 100644
--- a/manager/assets/modext/widgets/element/modx.panel.chunk.js
+++ b/manager/assets/modext/widgets/element/modx.panel.chunk.js
@@ -43,6 +43,11 @@ MODx.panel.Chunk = function(config) {
,border: false
,cls:'main-wrapper'
,labelSeparator: ''
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items: [{
columnWidth: .6
@@ -171,6 +176,11 @@ MODx.panel.Chunk = function(config) {
,id: 'modx-chunk-locked'
,inputValue: true
,checked: config.record.locked || 0
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-chunk-locked'
+ ,html: _('chunk_lock_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
,boxLabel: _('clear_cache_on_save')
@@ -181,6 +191,11 @@ MODx.panel.Chunk = function(config) {
,inputValue: 1
,checked: Ext.isDefined(config.record.clearCache) || true
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-chunk-clear-cache'
+ ,html: _('clear_cache_on_save_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
,hideLabel: true
@@ -257,6 +272,7 @@ MODx.panel.Chunk = function(config) {
,listeners: {
'setup': {fn:this.setup,scope:this}
,'success': {fn:this.success,scope:this}
+ ,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'failureSubmit': {
fn: function () {
@@ -274,8 +290,20 @@ MODx.panel.Chunk = function(config) {
Ext.extend(MODx.panel.Chunk,MODx.FormPanel,{
initialized: false
,setup: function() {
+
+ if (!this.initialized) {
+ /*
+ The itemId (not id) of each form tab to be included/excluded; these correspond to the
+ keys in each tab component's items property
+ */
+ this.errorHandlingTabs = ['modx-chunk-form'];
+ this.errorHandlingIgnoreTabs = ['modx-panel-element-properties'];
+
+ this.getForm().setValues(this.config.record);
+ }
+
if (this.initialized) { this.clearDirty(); return true; }
- this.getForm().setValues(this.config.record);
+
if (!Ext.isEmpty(this.config.record.name)) {
var title = _('chunk')+': '+this.config.record.name;
if (MODx.perm.tree_show_element_ids === 1) {
diff --git a/manager/assets/modext/widgets/element/modx.panel.plugin.js b/manager/assets/modext/widgets/element/modx.panel.plugin.js
index 5516a5d1c50..708803551a4 100644
--- a/manager/assets/modext/widgets/element/modx.panel.plugin.js
+++ b/manager/assets/modext/widgets/element/modx.panel.plugin.js
@@ -45,6 +45,11 @@ MODx.panel.Plugin = function(config) {
,border: false
,cls:'main-wrapper'
,labelSeparator: ''
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items: [{
columnWidth: .6
@@ -302,6 +307,7 @@ MODx.panel.Plugin = function(config) {
,listeners: {
'setup': {fn:this.setup,scope:this}
,'success': {fn:this.success,scope:this}
+ ,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'failureSubmit': {
fn: function () {
@@ -318,8 +324,20 @@ MODx.panel.Plugin = function(config) {
Ext.extend(MODx.panel.Plugin,MODx.FormPanel,{
initialized: false
,setup: function() {
+
+ if (!this.initialized) {
+ /*
+ The itemId (not id) of each form tab to be included/excluded; these correspond to the
+ keys in each tab component's items property
+ */
+ this.errorHandlingTabs = ['modx-plugin-form'];
+ this.errorHandlingIgnoreTabs = ['modx-plugin-sysevents','modx-panel-element-properties'];
+
+ this.getForm().setValues(this.config.record);
+ }
+
if (this.initialized) { this.clearDirty(); return true; }
- this.getForm().setValues(this.config.record);
+
if (!Ext.isEmpty(this.config.record.name)) {
var title = _('plugin')+': '+this.config.record.name;
if (MODx.perm.tree_show_element_ids === 1) {
diff --git a/manager/assets/modext/widgets/element/modx.panel.snippet.js b/manager/assets/modext/widgets/element/modx.panel.snippet.js
index f844aeab52c..6bdf671ce0d 100644
--- a/manager/assets/modext/widgets/element/modx.panel.snippet.js
+++ b/manager/assets/modext/widgets/element/modx.panel.snippet.js
@@ -44,6 +44,11 @@ MODx.panel.Snippet = function(config) {
,border: false
,cls:'main-wrapper'
,labelSeparator: ''
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items: [{
columnWidth: .6
@@ -168,20 +173,30 @@ MODx.panel.Snippet = function(config) {
},{
xtype: 'xcheckbox'
,boxLabel: _('snippet_lock')
- ,description: _('snippet_lock_msg')
+ ,description: MODx.expandHelp ? '' : _('snippet_lock_msg')
,name: 'locked'
,id: 'modx-snippet-locked'
,inputValue: 1
,checked: config.record.locked || 0
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-snippet-locked'
+ ,html: _('snippet_lock_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
,boxLabel: _('clear_cache_on_save')
- ,description: _('clear_cache_on_save_msg')
+ ,description: MODx.expandHelp ? '' : _('clear_cache_on_save_msg')
,hideLabel: true
,name: 'clearCache'
,id: 'modx-snippet-clear-cache'
,inputValue: 1
,checked: Ext.isDefined(config.record.clearCache) || true
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-snippet-clear-cache'
+ ,html: _('clear_cache_on_save_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
,hideLabel: true
@@ -258,6 +273,7 @@ MODx.panel.Snippet = function(config) {
,listeners: {
'setup': {fn:this.setup,scope:this}
,'success': {fn:this.success,scope:this}
+ ,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'failureSubmit': {
fn: function () {
@@ -274,8 +290,20 @@ MODx.panel.Snippet = function(config) {
Ext.extend(MODx.panel.Snippet,MODx.FormPanel,{
initialized: false
,setup: function() {
+
+ if (!this.initialized) {
+ /*
+ The itemId (not id) of each form tab to be included/excluded; these correspond to the
+ keys in each tab component's items property
+ */
+ this.errorHandlingTabs = ['modx-snippet-form'];
+ this.errorHandlingIgnoreTabs = ['modx-panel-element-properties'];
+
+ this.getForm().setValues(this.config.record);
+ }
+
if (this.initialized) { this.clearDirty(); return true; }
- this.getForm().setValues(this.config.record);
+
if (!Ext.isEmpty(this.config.record.name)) {
var title = _('snippet')+': '+this.config.record.name;
if (MODx.perm.tree_show_element_ids === 1) {
diff --git a/manager/assets/modext/widgets/element/modx.panel.template.js b/manager/assets/modext/widgets/element/modx.panel.template.js
index c59ae07062e..37d0d36c2bd 100644
--- a/manager/assets/modext/widgets/element/modx.panel.template.js
+++ b/manager/assets/modext/widgets/element/modx.panel.template.js
@@ -6,7 +6,6 @@
* @param {Object} config An object of configuration properties
* @xtype modx-panel-template
*/
-
MODx.panel.Template = function(config) {
config = config || {record:{}};
config.record = config.record || {};
@@ -46,6 +45,11 @@ MODx.panel.Template = function(config) {
,border: false
,cls:'main-wrapper'
,labelSeparator: ''
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items: [{
columnWidth: .6
@@ -125,7 +129,6 @@ MODx.panel.Template = function(config) {
return _('static_file_ns');
}
}
-
return true;
}
},{
@@ -184,20 +187,30 @@ MODx.panel.Template = function(config) {
},{
xtype: 'xcheckbox'
,boxLabel: _('template_lock')
- ,description: _('template_lock_msg')
+ ,description: MODx.expandHelp ? '' : _('template_lock_msg')
,name: 'locked'
,id: 'modx-template-locked'
,inputValue: 1
,checked: config.record.locked || false
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-template-locked'
+ ,html: _('template_lock_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
,boxLabel: _('clear_cache_on_save')
- ,description: _('clear_cache_on_save_msg')
+ ,description: MODx.expandHelp ? '' : _('clear_cache_on_save_msg')
,hideLabel: true
,name: 'clearCache'
,id: 'modx-template-clear-cache'
,inputValue: 1
,checked: Ext.isDefined(config.record.clearCache) || true
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-template-clear-cache'
+ ,html: _('clear_cache_on_save_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
,hideLabel: true
@@ -296,6 +309,7 @@ MODx.panel.Template = function(config) {
,listeners: {
'setup': {fn:this.setup,scope:this}
,'success': {fn:this.success,scope:this}
+ ,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'failureSubmit': {
fn: function () {
@@ -312,8 +326,20 @@ MODx.panel.Template = function(config) {
Ext.extend(MODx.panel.Template,MODx.FormPanel,{
initialized: false
,setup: function() {
+
+ if (!this.initialized) {
+ /*
+ The itemId (not id) of each form tab to be included/excluded; these correspond to the
+ keys in each tab component's items property
+ */
+ this.errorHandlingTabs = ['modx-template-form'];
+ this.errorHandlingIgnoreTabs = ['modx-panel-element-properties','form-template'];
+
+ this.getForm().setValues(this.config.record);
+ }
+
if (this.initialized) { this.clearDirty(); return true; }
- this.getForm().setValues(this.config.record);
+
if (!Ext.isEmpty(this.config.record.templatename)) {
var title = _('template') + ': ' + Ext.util.Format.htmlEncode(this.config.record.templatename);
if (MODx.perm.tree_show_element_ids === 1) {
diff --git a/manager/assets/modext/widgets/element/modx.panel.tv.js b/manager/assets/modext/widgets/element/modx.panel.tv.js
index c8b7793c07f..5359f2a240b 100644
--- a/manager/assets/modext/widgets/element/modx.panel.tv.js
+++ b/manager/assets/modext/widgets/element/modx.panel.tv.js
@@ -10,7 +10,6 @@ MODx.panel.TV = function(config) {
config = config || {};
config.record = config.record || {};
config = MODx.setStaticElementsConfig(config, 'tv');
-
Ext.applyIf(config,{
url: MODx.config.connector_url
,baseParams: {
@@ -27,7 +26,11 @@ MODx.panel.TV = function(config) {
,xtype: 'modx-header'
},MODx.getPageStructure([{
title: _('general_information')
- ,defaults: {border: false ,msgTarget: 'side', layout: 'form'}
+ ,defaults: {
+ border: false
+ ,msgTarget: 'side'
+ ,layout: 'form'
+ }
,layout: 'form'
,id: 'modx-tv-form'
,itemId: 'form-tv'
@@ -47,6 +50,11 @@ MODx.panel.TV = function(config) {
,border: false
,cls:'main-wrapper'
,labelSeparator: ''
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items: [{
columnWidth: .6
@@ -180,22 +188,33 @@ MODx.panel.TV = function(config) {
},{
xtype: 'xcheckbox'
,boxLabel: _('tv_lock')
- ,description: _('tv_lock_msg')
+ ,description: MODx.expandHelp ? '' : _('tv_lock_msg')
,name: 'locked'
,id: 'modx-tv-locked'
,inputValue: 1
,checked: config.record.locked || false
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-tv-locked'
+ ,id: 'modx-tv-locked-help'
+ ,html: _('tv_lock_msg')
+ ,cls: 'desc-under'
},{
xtype: 'xcheckbox'
- ,boxLabel: _('clear_cache_on_save')
- ,description: _('clear_cache_on_save_msg')
,hideLabel: true
+ ,boxLabel: _('clear_cache_on_save')
+ ,description: MODx.expandHelp ? '' : _('clear_cache_on_save_msg')
,name: 'clearCache'
,id: 'modx-tv-clear-cache'
,inputValue: 1
,checked: Ext.isDefined(config.record.clearCache) || true
-
- },{border: false, html: '
'},{
+ },{
+ xtype: MODx.expandHelp ? 'label' : 'hidden'
+ ,forId: 'modx-tv-clear-cache'
+ ,id: 'modx-tv-clear-cache-help'
+ ,html: _('clear_cache_on_save_msg')
+ ,cls: 'desc-under'
+ },{
xtype: 'xcheckbox'
,hideLabel: true
,boxLabel: _('is_static')
@@ -345,10 +364,11 @@ MODx.panel.TV = function(config) {
,listeners: {
'setup': {fn:this.setup,scope:this}
,'success': {fn:this.success,scope:this}
+ ,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'failureSubmit': {
fn: function () {
- this.showErroredTab(['modx-tv-form'], 'modx-tv-tabs')
+ this.showErroredTab(this.errorHandlingTabs, 'modx-tv-tabs')
},
scope: this
}
@@ -360,9 +380,22 @@ MODx.panel.TV = function(config) {
};
Ext.extend(MODx.panel.TV,MODx.FormPanel,{
initialized: false
+
,setup: function() {
+
+ if (!this.initialized) {
+ /*
+ The itemId (not id) of each form tab to be included/excluded; these correspond to the
+ keys in each tab component's items property
+ */
+ this.errorHandlingTabs = ['form-tv'];
+ this.errorHandlingIgnoreTabs = ['panel-properties','form-template','form-access','form-sources'];
+
+ this.getForm().setValues(this.config.record);
+ }
+
if (this.initialized) { this.clearDirty(); return true; }
- this.getForm().setValues(this.config.record);
+
if (!Ext.isEmpty(this.config.record.name)) {
var title = _('tv')+': '+this.config.record.name;
if (MODx.perm.tree_show_element_ids === 1) {
@@ -421,6 +454,7 @@ Ext.extend(MODx.panel.TV,MODx.FormPanel,{
,stay: MODx.config.stay
});
}
+
,success: function(r) {
Ext.getCmp('modx-grid-tv-template').getStore().commitChanges();
Ext.getCmp('modx-grid-tv-security').getStore().commitChanges();
@@ -437,16 +471,19 @@ Ext.extend(MODx.panel.TV,MODx.FormPanel,{
t.refreshNode(u,true);
}
}
+
,changeEditor: function() {
this.cleanupEditor();
this.submit();
}
+
,cleanupEditor: function() {
if (MODx.onSaveEditor) {
var fld = Ext.getCmp('modx-tv-default-text');
MODx.onSaveEditor(fld);
}
}
+
,toggleStaticFile: function(cb) {
var flds = ['modx-tv-static-file','modx-tv-static-file-help','modx-tv-static-source','modx-tv-static-source-help'];
var fld,i;
@@ -474,7 +511,15 @@ MODx.panel.TVInputProperties = function(config) {
,title: _('tv_input_options')
,header: false
,border: false
- ,defaults: { border: false }
+ ,defaults: {
+ border: false
+ ,defaults: {
+ labelSeparator: ''
+ ,msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
+ }
,cls: 'form-with-labels'
,items: [{
html: _('tv_input_options_msg')
@@ -581,7 +626,6 @@ Ext.extend(MODx.panel.TVInputProperties,MODx.Panel,{
Ext.reg('modx-panel-tv-input-properties',MODx.panel.TVInputProperties);
-
MODx.panel.TVOutputProperties = function(config) {
config = config || {};
Ext.applyIf(config,{
@@ -590,7 +634,15 @@ MODx.panel.TVOutputProperties = function(config) {
,header: false
,layout: 'form'
,cls: 'form-with-labels'
- ,defaults: {border: false}
+ ,defaults: {
+ border: false
+ ,defaults: {
+ labelSeparator: ''
+ ,msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
+ }
,items: [{
html: _('tv_output_options_msg')
,itemId: 'desc-tv-output-properties'
diff --git a/manager/assets/modext/widgets/resource/modx.panel.resource.js b/manager/assets/modext/widgets/resource/modx.panel.resource.js
index 24b26696f40..481e29057bb 100644
--- a/manager/assets/modext/widgets/resource/modx.panel.resource.js
+++ b/manager/assets/modext/widgets/resource/modx.panel.resource.js
@@ -20,7 +20,12 @@ MODx.panel.Resource = function(config) {
,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'fieldChange': {fn:this.onFieldChange,scope:this}
- ,'failureSubmit': {fn:this.failureSubmit,scope:this}
+ ,'failureSubmit': {
+ fn: function () {
+ this.showErroredTab(this.errorHandlingTabs, 'modx-resource-tabs')
+ },
+ scope: this
+ }
}
});
MODx.panel.Resource.superclass.constructor.call(this,config);
@@ -38,9 +43,19 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,rteElements: 'ta'
,rteLoaded: false
,warnUnsavedChanges: false
+
,setup: function() {
if (!this.initialized) {
+
+ /*
+ The itemId (not id) of each form tab to be included/excluded; these correspond to the
+ keys in each tab component's items property
+ */
+ this.errorHandlingTabs = ['modx-resource-settings','modx-page-settings','modx-panel-resource-tv'];
+ this.errorHandlingIgnoreTabs = ['modx-resource-access-permissions'];
+
this.getForm().setValues(this.config.record);
+
var tpl = this.getForm().findField('modx-resource-template');
if (tpl) {
tpl.originalValue = this.config.record.template;
@@ -77,6 +92,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
this.defaultClassKey = this.config.record.class_key || this.defaultClassKey;
this.defaultValues = this.config.record || {};
+
if ((this.config.record && this.config.record.richtext) || MODx.request.reload || MODx.request.activeSave == 1) {
this.markDirty();
}
@@ -105,7 +121,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
this.rteLoaded = false;
}
}
-
+
this.fireEvent('ready');
this.initialized = true;
@@ -170,6 +186,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,stay: Ext.state.Manager.get('modx.stay.'+MODx.request.a,'stay')
});
}
+
,success: function(o) {
this.warnUnsavedChanges = false;
var g = Ext.getCmp('modx-grid-resource-security');
@@ -210,79 +227,6 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
Ext.getCmp('modx-page-update-resource').config.preview_url = object.preview_url;
}
}
- ,failureSubmit: function() {
- // This array contains the components we want to traverse in the order we prioritize them
- var forms = [
- 'modx-resource-settings', // Document
- 'modx-page-settings', // Settings
- 'modx-panel-resource-tv' // Template Variables
- ];
-
- var tab_name = null;
-
- // Loop each component and traverse the children recursively
- for (var i = 0; i < forms.length; i++) {
- var component = Ext.getCmp(forms[i]);
- if (component && component.el && component.el.dom) {
- if (this.traverseNode(component.el.dom)) {
- tab_name = forms[i];
-
- // We want to switch to the first tab that has an invalid state, no matter if the current
- // or any later tabs also have such states. We can therefore quit early here.
- break;
- }
- }
- }
-
- // If no invalid states were found, this check makes sure we don't switch tabs for no reason
- if (tab_name === null) {
- return;
- }
-
- var tabs = Ext.getCmp('modx-resource-tabs');
- var tabs_index = null;
-
- // The next check needs the tabs index value to check if it is hidden or not
- if (tabs && tabs.items && tabs.items.keys) {
- tabs_index = tabs.items.keys.indexOf(tab_name);
- }
-
- // We are already on a tab that has an invalid state. No need to switch
- if (!tabs.items.items[tabs_index].hidden) {
- return;
- }
-
- // Activate the tab (this is done by passing the name of the tab)
- tabs.activate(tab_name);
- }
-
- ,traverseNode: function(node) {
- if (typeof node.classList !== 'undefined' && node.classList.contains('x-form-invalid')) {
- return true;
- }
-
- if (typeof node.children == 'undefined') {
- return false;
- }
-
- for (var i = 0; i < node.children.length; i++) {
- if (this.traverseNode(node.children[i])) {
- return true;
- }
- }
-
- return false;
- }
-
- ,failure: function(o) {
- this.warnUnsavedChanges = true;
- if(this.getForm().baseParams.action == 'resource/create') {
- var btn = Ext.getCmp('modx-abtn-save');
- if (btn) { btn.enable(); }
- }
-
- this.fireEvent('failureSubmit');
- }
,freezeUri: function(cb) {
var uri = Ext.getCmp('modx-resource-uri');
@@ -293,6 +237,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
uri.hide();
}
}
+
// used for realtime-alias transliteration
,translitAlias: function(string) {
if (!this.config.translitloading) {
@@ -315,6 +260,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
});
}
}
+
,generateAliasRealTime: function(title) {
// check some system settings before doing real time alias transliteration
if (parseInt(MODx.config.friendly_alias_realtime) && parseInt(MODx.config.automatic_alias)) {
@@ -324,6 +270,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
}
}
}
+
,templateWarning: function() {
var t = Ext.getCmp('modx-resource-template');
if (!t) { return false; }
@@ -349,6 +296,7 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
},this);
}
}
+
,onFieldChange: function(o) {
//a11y - Set Active Input
if (o && o.field) {
@@ -473,20 +421,23 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,anchor: '100%'
,id: 'modx-resource-main-columns'
,defaults: {
- labelSeparator: ''
+ layout: 'form'
,labelAlign: 'top'
+ ,labelSeparator: ''
,border: false
- ,msgTarget: 'under'
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items:[{
columnWidth: .67
- ,layout: 'form'
,id: 'modx-resource-main-left'
,defaults: { msgTarget: 'under' }
,items: this.getMainLeftFields(config)
},{
columnWidth: .33
- ,layout: 'form'
,labelWidth: 0
,border: false
,id: 'modx-resource-main-right'
@@ -693,21 +644,23 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,border: false
,anchor: '100%'
,defaults: {
- labelSeparator: ''
+ layout: 'form'
,labelAlign: 'top'
+ ,labelSeparator: ''
,border: false
- ,layout: 'form'
- ,msgTarget: 'under'
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items:[{
columnWidth: .5
,id: 'modx-page-settings-left'
- ,defaults: { msgTarget: 'under' }
,items: this.getSettingLeftFields(config)
},{
columnWidth: .5
,id: 'modx-page-settings-right'
- ,defaults: { msgTarget: 'under' }
,items: this.getSettingRightFields(config)
}]
}];
@@ -742,7 +695,6 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,id: 'modx-resource-content-type'
,anchor: '100%'
,value: config.record.content_type || (MODx.config.default_content_type || 1)
-
},{
xtype: 'modx-combo-content-disposition'
,fieldLabel: _('resource_contentdispo')
@@ -752,7 +704,6 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,id: 'modx-resource-content-dispo'
,anchor: '100%'
,value: config.record.content_dispo || 0
-
},{
xtype: 'numberfield'
,fieldLabel: _('resource_menuindex')
@@ -820,21 +771,23 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,border: false
,anchor: '100%'
,defaults: {
- labelSeparator: ''
+ layout: 'form'
,labelAlign: 'top'
+ ,labelSeparator: ''
,border: false
- ,layout: 'form'
- ,msgTarget: 'under'
+ ,defaults: {
+ msgTarget: 'under'
+ ,validationEvent: 'change'
+ ,validateOnBlur: false
+ }
}
,items: [{
columnWidth: .5
,id: 'modx-page-settings-right-box-left'
- ,defaults: { msgTarget: 'under' }
,items: this.getSettingRightFieldsetLeft(config)
},{
columnWidth: .5
,id: 'modx-page-settings-right-box-right'
- ,defaults: { msgTarget: 'under' }
,items: this.getSettingRightFieldsetRight(config)
}]
}];
@@ -850,7 +803,6 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{
,id: 'modx-resource-isfolder'
,inputValue: 1
,checked: parseInt(config.record.isfolder) || 0
-
},{
xtype: 'xcheckbox'
,boxLabel: _('resource_searchable')