From 7d868c13a401d13f8777c0db5626832ac3f3a952 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 5 Aug 2006 01:05:07 +0000 Subject: Fixed #318 and add chmod for each mkdir --- framework/I18N/TGlobalization.php | 27 ++++++++++++++++++++++++--- framework/I18N/core/MessageSource_XLIFF.php | 6 +++++- framework/I18N/core/MessageSource_gettext.php | 6 +++++- 3 files changed, 34 insertions(+), 5 deletions(-) (limited to 'framework/I18N') diff --git a/framework/I18N/TGlobalization.php b/framework/I18N/TGlobalization.php index aa545d21..1ea7ce2b 100644 --- a/framework/I18N/TGlobalization.php +++ b/framework/I18N/TGlobalization.php @@ -168,12 +168,33 @@ class TGlobalization extends TModule { if($config['type'] == 'XLIFF' || $config['type'] == 'gettext') { - $config['source'] = Prado::getPathOfNamespace($config['source']); - if($config['source']===null || !is_dir($config['source'])) - throw new TException("invalid source dir '{$config['source']}'"); + if($config['source']) + { + $config['source'] = Prado::getPathOfNamespace($config['source']); + if(!is_dir($config['source'])) + { + if(@mkdir($config['source'])===false) + throw new TConfigurationException('globalization_source_path_failed', + $config['source']); + chmod($config['source'], 0777); //make it deletable + } + } + else + { + throw new TConfigurationException("invalid source dir '{$config['source']}'"); + } } if($config['cache']) + { $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; + if(!is_dir($config['cache'])) + { + if(@mkdir($config['cache'])===false) + throw new TConfigurationException('globalization_cache_path_failed', + $config['cache']); + chmod($config['cache'], 0777); //make it deletable + } + } $this->_translation = $config; } diff --git a/framework/I18N/core/MessageSource_XLIFF.php b/framework/I18N/core/MessageSource_XLIFF.php index 2194ca41..15af971a 100644 --- a/framework/I18N/core/MessageSource_XLIFF.php +++ b/framework/I18N/core/MessageSource_XLIFF.php @@ -473,7 +473,11 @@ class MessageSource_XLIFF extends MessageSource $variant = array_shift($variants); $file = $this->getSource($variant); $dir = dirname($file); - if(!is_dir($dir)) @mkdir($dir); + if(!is_dir($dir)) + { + @mkdir($dir); + @chmod($dir,0777); + } if(!is_dir($dir)) throw new TException("Unable to create directory $dir"); file_put_contents($file, $this->getTemplate($catalogue)); diff --git a/framework/I18N/core/MessageSource_gettext.php b/framework/I18N/core/MessageSource_gettext.php index 78fa5259..c92577d4 100644 --- a/framework/I18N/core/MessageSource_gettext.php +++ b/framework/I18N/core/MessageSource_gettext.php @@ -431,7 +431,11 @@ class MessageSource_gettext extends MessageSource $po_file = $this->getPOFile($mo_file); $dir = dirname($mo_file); - if(!is_dir($dir)) @mkdir($dir); + if(!is_dir($dir)) + { + @mkdir($dir); + @chmod($dir,0777); + } if(!is_dir($dir)) throw new TException("Unable to create directory $dir"); -- cgit v1.2.3