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/Exceptions/messages.txt | 4 +++- framework/I18N/TGlobalization.php | 27 ++++++++++++++++++++++++--- framework/I18N/core/MessageSource_XLIFF.php | 6 +++++- framework/I18N/core/MessageSource_gettext.php | 6 +++++- framework/IO/TTarFileExtractor.php | 2 ++ framework/TApplication.php | 3 +++ framework/Web/TAssetManager.php | 3 +++ framework/prado-cli.php | 4 ---- 8 files changed, 45 insertions(+), 10 deletions(-) (limited to 'framework') diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index 54d9d085..90872e2f 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -320,4 +320,6 @@ databoundcontrol_datamember_invalid = databoundcontrol_datamember_invalid clientscript_invalid_file_position = Invalid file position '{1}' for TClientScript control '{0}', must be 'Head', 'Here' or 'Begin'. -tdatepicker_autopostback_unsupported = '{0}' does not support AutoPostBack. \ No newline at end of file +tdatepicker_autopostback_unsupported = '{0}' does not support AutoPostBack. +globalization_cache_path_failed = Unable to create translation message cache path '{0}'. Make sure the parent directory exists and is writable by the Web process. +globalization_source_path_failed = Unable to create translation message path '{0}'. Make sure the parent directory exists and is writable by the Web process. \ No newline at end of file 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"); diff --git a/framework/IO/TTarFileExtractor.php b/framework/IO/TTarFileExtractor.php index 611662c5..4ff37b1f 100644 --- a/framework/IO/TTarFileExtractor.php +++ b/framework/IO/TTarFileExtractor.php @@ -460,6 +460,7 @@ class TTarFileExtractor .$v_header['filename'].'}'); return false; } + chmod($v_header['filename'], 0777); } } else { if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { @@ -549,6 +550,7 @@ class TTarFileExtractor $this->_error("Unable to create directory '$p_dir'"); return false; } + chmod($p_dir,0777); return true; } diff --git a/framework/TApplication.php b/framework/TApplication.php index aa46f39d..375df885 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -309,8 +309,11 @@ class TApplication extends TComponent $subdir=basename($this->_configFile); $this->_runtimePath.='/'.$subdir; if(!is_dir($this->_runtimePath)) + { if(@mkdir($this->_runtimePath)===false) throw new TConfigurationException('application_runtimepath_failed',$this->_runtimePath); + chmod($this->_runtimePath, 0777); //make it deletable + } } } else diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index 94c84ae7..5e861cc2 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -199,7 +199,10 @@ class TAssetManager extends TModule protected function copyFile($src,$dst) { if(!is_dir($dst)) + { @mkdir($dst); + @chmod($dst, 0777); + } $dstFile=$dst.'/'.basename($src); if(@filemtime($dstFile)<@filemtime($src)) { diff --git a/framework/prado-cli.php b/framework/prado-cli.php index 1a0e5498..36739ad2 100755 --- a/framework/prado-cli.php +++ b/framework/prado-cli.php @@ -65,10 +65,6 @@ function create_new_prado_project($dir) create_directory($runtimePath,0777); create_directory($pagesPath,0755); - create_directory($tests,0755); - create_directory($unit_tests,0755); - create_directory($functional_tests,0755); - create_file($indexFile, render_index_file()); create_file($htaccessFile, render_htaccess_file()); create_file($defaultPageFile, render_default_page()); -- cgit v1.2.3