Remove system file class

This commit is contained in:
Romain Neutron
2012-05-21 16:49:58 +02:00
parent 0c4850213d
commit 05073d7703
3 changed files with 22 additions and 21 deletions

View File

@@ -75,6 +75,8 @@ class module_console_systemExport extends Command
public function execute(InputInterface $input, OutputInterface $output) public function execute(InputInterface $input, OutputInterface $output)
{ {
$core = \bootstrap::getCore();
$docPerDir = max(1, (int) $input->getOption('docperdir')); $docPerDir = max(1, (int) $input->getOption('docperdir'));
/** /**
@@ -167,7 +169,7 @@ class module_console_systemExport extends Command
. '/' . $unicode->remove_nonazAZ09($databox->get_viewname(), true, true) . '/' . $unicode->remove_nonazAZ09($databox->get_viewname(), true, true)
. '/'; . '/';
system_file::mkdir($local_export); $core['file-system']->mkdir($local_export);
$sql = 'SELECT record_id FROM record WHERE parent_record_id = 0 '; $sql = 'SELECT record_id FROM record WHERE parent_record_id = 0 ';
@@ -201,7 +203,7 @@ class module_console_systemExport extends Command
$dir_increment ++; $dir_increment ++;
$in_dir_files = array(); $in_dir_files = array();
$current_dir = $local_export . sprintf($dir_format, $dir_increment) . '/'; $current_dir = $local_export . sprintf($dir_format, $dir_increment) . '/';
system_file::mkdir($current_dir); $core['file-system']->mkdir($current_dir);
} }
if ($sanitize) { if ($sanitize) {
@@ -250,16 +252,14 @@ class module_console_systemExport extends Command
protected function processRecords(\record_adapter $record, $outfile, $caption) protected function processRecords(\record_adapter $record, $outfile, $caption)
{ {
if ( ! file_exists($record->get_subdef('document')->get_pathfile())) {
try {
$file = new system_file($record->get_subdef('document')->get_pathfile());
} catch (\Exception_Media_SubdefNotFound $e) {
return false; return false;
} }
$core = \bootstrap::getCore();
copy($file->getPathname(), $outfile); $core['file-system']->copy($record->get_subdef('document')->get_pathfile(), $outfile);
$dest_file = new system_file($outfile); $dest_file = new \SplFileInfo($outfile);
touch( touch(
$dest_file->getPathname() $dest_file->getPathname()

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use MediaVorus\Media\Media;
/** /**
* *
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -81,7 +83,7 @@ interface record_Interface
public function get_sbas_id(); public function get_sbas_id();
public function substitute_subdef($name, system_file $pathfile); public function substitute_subdef($name, Media $media);
public function set_metadatas(Array $metadatas, $force_readonly = false); public function set_metadatas(Array $metadatas, $force_readonly = false);

View File

@@ -393,6 +393,7 @@ class set_export extends set_abstract
$includeBusinessFields = ! ! $includeBusinessFields; $includeBusinessFields = ! ! $includeBusinessFields;
$core = \bootstrap::getCore();
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
@@ -406,7 +407,7 @@ class set_export extends set_abstract
$file_names = array(); $file_names = array();
$size = 0; $size = 0;
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = $core->getAuthenticatedUser();
foreach ($this->elements as $download_element) { foreach ($this->elements as $download_element) {
$id = count($files); $id = count($files);
@@ -639,7 +640,7 @@ class set_export extends set_abstract
. time() . $session->get_usr_id() . time() . $session->get_usr_id()
. $session->get_ses_id() . '/'; . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir); $core['file-system']->mkdir($caption_dir, 0750);
$desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_XML, $BF); $desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_XML, $BF);
@@ -660,7 +661,8 @@ class set_export extends set_abstract
$caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/' $caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/'
. time() . $session->get_usr_id() . time() . $session->get_usr_id()
. $session->get_ses_id() . '/'; . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir);
$core['file-system']->mkdir($caption_dir, 0750);
$desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $BF); $desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $BF);
@@ -699,6 +701,8 @@ class set_export extends set_abstract
*/ */
public static function build_zip($token, Array $list, $zipFile) public static function build_zip($token, Array $list, $zipFile)
{ {
$core = bootstrap::getCore();
$zip = new ZipArchiveImproved(); $zip = new ZipArchiveImproved();
if ($zip->open($zipFile, ZIPARCHIVE::CREATE) !== true) { if ($zip->open($zipFile, ZIPARCHIVE::CREATE) !== true) {
@@ -715,12 +719,7 @@ class set_export extends set_abstract
random::updateToken($token, serialize($list)); random::updateToken($token, serialize($list));
$str_in = array("à", "á", "â", "ã", "ä", "å", "ç", "è", "é", "ê", $unicode = new \unicode();
"ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô",
"õ", "ö", "ù", "ú", "û", "ü", "ý", "ÿ");
$str_out = array("a", "a", "a", "a", "a", "a", "c", "e", "e", "e",
"e", "i", "i", "i", "i", "o", "n", "o", "o", "o",
"o", "o", "u", "u", "u", "u", "y", "y");
$caption_dirs = $unlinks = array(); $caption_dirs = $unlinks = array();
@@ -734,7 +733,7 @@ class set_export extends set_abstract
. $obj["ajout"] . $obj["ajout"]
. '.' . $obj["exportExt"]; . '.' . $obj["exportExt"];
$name = str_replace($str_in, $str_out, $name); $name = $unicode->remove_diacritics($name);
$zip->addFile($path, $name); $zip->addFile($path, $name);
@@ -751,6 +750,7 @@ class set_export extends set_abstract
$zip->close(); $zip->close();
$list['complete'] = true; $list['complete'] = true;
$unicode = null;
random::updateToken($token, serialize($list)); random::updateToken($token, serialize($list));
@@ -761,8 +761,7 @@ class set_export extends set_abstract
@rmdir($c); @rmdir($c);
} }
$system_file = new system_file($zipFile); $core['file-system']->chmod($zipFile, 0760);
$system_file->chmod();
return $zipFile; return $zipFile;
} }