Index: branches/RC/core/install/install_schema.sql
===================================================================
diff -u -N -r10887 -r10906
--- branches/RC/core/install/install_schema.sql (.../install_schema.sql) (revision 10887)
+++ branches/RC/core/install/install_schema.sql (.../install_schema.sql) (revision 10906)
@@ -134,6 +134,7 @@
ThousandSep VARCHAR(10) NOT NULL DEFAULT '',
`Charset` varchar(20) NOT NULL default '',
UnitSystem tinyint(4) NOT NULL default '1',
+ FilenameReplacements TEXT NULL,
PRIMARY KEY (LanguageId),
KEY Enabled (Enabled),
KEY PrimaryLang (PrimaryLang),
Index: branches/RC/core/install/upgrades.sql
===================================================================
diff -u -N -r10887 -r10906
--- branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 10887)
+++ branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 10906)
@@ -343,3 +343,9 @@
INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:agents.edit', 11, 1, 1, 0);
INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:agents.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:agents.view', 11, 1, 1, 0);
+
+INSERT INTO ConfigurationAdmin VALUES ('FilenameSpecialCharReplacement', 'la_Text_General', 'la_config_FilenameSpecialCharReplacement', 'select', NULL, '_=+_,-=+-', 10.16, 0, 0);
+INSERT INTO ConfigurationValues VALUES (DEFAULT, 'FilenameSpecialCharReplacement', '_', 'In-Portal', 'in-portal:configure_categories');
+
+ALTER TABLE `Language` ADD `FilenameReplacements` TEXT NULL ;
+
Index: branches/RC/core/admin_templates/regional/languages_edit.tpl
===================================================================
diff -u -N -r9854 -r10906
--- branches/RC/core/admin_templates/regional/languages_edit.tpl (.../languages_edit.tpl) (revision 9854)
+++ branches/RC/core/admin_templates/regional/languages_edit.tpl (.../languages_edit.tpl) (revision 10906)
@@ -78,6 +78,7 @@
+
">
Index: branches/RC/core/units/general/helpers/filenames_helper.php
===================================================================
diff -u -N -r10098 -r10906
--- branches/RC/core/units/general/helpers/filenames_helper.php (.../filenames_helper.php) (revision 10098)
+++ branches/RC/core/units/general/helpers/filenames_helper.php (.../filenames_helper.php) (revision 10906)
@@ -1,23 +1,78 @@
_escapeChar = $this->Application->ConfigValue('FilenameSpecialCharReplacement');
+
+ $language =& $this->Application->recallObject('lang.current');
+ /* @var $language kDBItem */
+
+ $replacements = $language->GetDBField('FilenameReplacements');
+ if ($replacements) {
+ $replacements = explode("\r\n", $replacements);
+ foreach ($replacements as $replacement) {
+ list ($replace_from, $replace_to) = explode('=', $replacement);
+ $this->_filenameReplaceFrom[] = trim($replace_from);
+ $this->_filenameReplaceTo[] = trim($replace_to);
+ }
+ }
+ }
+
+ function replaceSequences($filename)
+ {
+ $not_allowed = Array (
+ ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`',
+ '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~',
+ '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',', "\r", "\n"
+ );
+
+ if ($this->_filenameReplaceFrom) {
+ // replace predefined sequences
+ $filename = str_replace($this->_filenameReplaceFrom, $this->_filenameReplaceTo, $filename);
+ }
+
+ $filename = str_replace($not_allowed, $this->_escapeChar, $filename);
+ $filename = preg_replace('/(' . $this->_escapeChar . '+)/', $this->_escapeChar, $filename);
+ return trim($filename, $this->_escapeChar); // remove trailing escape chars
+ }
+
+ /**
* replace not allowed symbols with "_" chars + remove duplicate "_" chars in result
*
* @param string $string
* @return string
*/
function stripDisallowed($table, $id_field, $item_id, $filename)
{
- $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`',
- '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~',
- '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',', "\r", "\n");
+ $filename = $this->replaceSequences($filename);
- $filename = str_replace($not_allowed, '_', $filename);
- $filename = preg_replace('/(_+)/', '_', $filename);
- $filename = $this->checkAutoFilename($table, $id_field, $item_id, $filename);
-
- return $filename;
+ return $this->checkAutoFilename($table, $id_field, $item_id, $filename);
}
function checkAutoFilename($table, $id_field, $item_id, $filename)
Index: branches/RC/core/units/categories/categories_item.php
===================================================================
diff -u -N -r10780 -r10906
--- branches/RC/core/units/categories/categories_item.php (.../categories_item.php) (revision 10780)
+++ branches/RC/core/units/categories/categories_item.php (.../categories_item.php) (revision 10906)
@@ -53,7 +53,8 @@
return $parent_path.$this->GetID().'|';
}
-
+
+
/**
* replace not allowed symbols with "_" chars + remove duplicate "_" chars in result
*
@@ -62,16 +63,14 @@
*/
function stripDisallowed($string)
{
- $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`',
- '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~',
- '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',');
+ $filenames_helper =& $this->Application->recallObject('FilenamesHelper');
+ /* @var $filenames_helper EFilenameHelper */
- $string = str_replace($not_allowed, '_', $string);
- $string = preg_replace('/(_+)/', '_', $string);
- $string = $this->checkAutoFilename($string);
+ $string = $filenames_helper->replaceSequences($string);
- return $string;
+ return $this->checkAutoFilename($string);
}
+
function checkFilename()
{
@@ -87,6 +86,8 @@
{
if(!$filename) return $filename;
+ $escape_char = $this->Application->ConfigValue('FilenameSpecialCharReplacement');
+
$item_id = !$this->GetID() ? 0 : $this->GetID();
$check_in_parent_cat_only = $item_id ? ' AND ParentId = '.$this->GetDBField("ParentId") : '';
@@ -105,11 +106,11 @@
$duplicates_found = (count($found_item_ids) > 1) || ($found_item_ids && $found_item_ids[0] != $item_id);
if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number
{
- $append = $duplicates_found ? '_a' : '';
+ $append = $duplicates_found ? $escape_char . 'a' : '';
if($has_page)
{
$filename = $rets[1].'_'.$rets[2];
- $append = $rets[3] ? $rets[3] : '_a';
+ $append = $rets[3] ? $rets[3] : $escape_char . 'a';
}
// check live & temp table
Index: branches/RC/core/install/english.lang
===================================================================
diff -u -N -r10898 -r10906
--- branches/RC/core/install/english.lang (.../english.lang) (revision 10898)
+++ branches/RC/core/install/english.lang (.../english.lang) (revision 10906)
@@ -6,7 +6,9 @@
TmV4dCBSdW4gT24=
UnVuIEludGVydmFs
UnVuIE1vZGU=
+ RmlsZW5hbWUgU3BlY2lhbCBDaGFyIFJlcGxhY2VtZW50
RXZlbnQ=
+ RmlsZW5hbWUgUmVwbGFjZW1lbnRz
TGFzdCBSdW4gT24=
TGFzdCBSdW4gU3RhdHVz
TmV4dCBSdW4gT24=
Index: branches/RC/core/install/install_data.sql
===================================================================
diff -u -N -r10887 -r10906
--- branches/RC/core/install/install_data.sql (.../install_data.sql) (revision 10887)
+++ branches/RC/core/install/install_data.sql (.../install_data.sql) (revision 10906)
@@ -62,6 +62,7 @@
INSERT INTO ConfigurationAdmin VALUES ('UseJSRedirect', 'la_Text_Website', 'la_config_use_js_redirect', 'checkbox', '', '', 10.14, 0, 0);
INSERT INTO ConfigurationAdmin VALUES ('MaxImportCategoryLevels', 'la_Text_General', 'la_prompt_max_import_category_levels', 'text', '', '', 10.08, 0, 1);
INSERT INTO ConfigurationAdmin VALUES ('UseCronForRegularEvent', 'la_Text_Website', 'la_UseCronForRegularEvent', 'checkbox', NULL, NULL, 10.15, 0, 0);
+INSERT INTO ConfigurationAdmin VALUES ('FilenameSpecialCharReplacement', 'la_Text_General', 'la_config_FilenameSpecialCharReplacement', 'select', NULL, '_=+_,-=+-', 10.16, 0, 0);
INSERT INTO ConfigurationAdmin VALUES ('NoPermissionTemplate', 'la_Text_Website', 'la_config_nopermission_template', 'text', '', '', 10.17, 0, 0);
INSERT INTO ConfigurationAdmin VALUES ('UseOutputCompression', 'la_Text_Website', 'la_config_UseOutputCompression', 'checkbox', '', '', 10.18, 0, 1);
INSERT INTO ConfigurationAdmin VALUES ('OutputCompressionLevel', 'la_Text_Website', 'la_config_OutputCompressionLevel', 'text', '', '', 10.19, 0, 1);
@@ -220,6 +221,7 @@
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'UseJSRedirect', '0', 'In-Portal', 'in-portal:configure_general');
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'MaxImportCategoryLevels', '10', 'In-Portal', 'in-portal:configure_categories');
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'UseCronForRegularEvent', '0', 'In-Portal', 'in-portal:configure_general');
+INSERT INTO ConfigurationValues VALUES (DEFAULT, 'FilenameSpecialCharReplacement', '_', 'In-Portal', 'in-portal:configure_categories');
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'NoPermissionTemplate', 'no_permission', 'In-Portal', 'in-portal:configure_general');
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'UseOutputCompression', '0', 'In-Portal', 'in-portal:configure_general');
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'OutputCompressionLevel', '7', 'In-Portal', 'in-portal:configure_general');
Index: branches/RC/core/units/languages/languages_config.php
===================================================================
diff -u -N -r9936 -r10906
--- branches/RC/core/units/languages/languages_config.php (.../languages_config.php) (revision 9936)
+++ branches/RC/core/units/languages/languages_config.php (.../languages_config.php) (revision 10906)
@@ -159,6 +159,7 @@
'ThousandSep' => Array('type' => 'string','not_null' => 1, 'default' => ''),
'Charset' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1),
'UnitSystem' => Array('type' => 'int','not_null' => 1, 'default' => 1, 'formatter' => 'kOptionsFormatter','options' => Array(1 => 'la_Metric', 2 => 'la_US_UK'),'use_phrases' => 1),
+ 'FilenameReplacements' => Array('type' => 'string'),
),
'VirtualFields' => Array(