Author: david
Date: Tue Aug 23 11:35:59 2011
New Revision: 9571
Log:
Cosmetic change. Match coding convention for indent width and open/close
brackets
Modified:
trunk/apps/qubit/modules/object/actions/importAction.class.php
Modified: trunk/apps/qubit/modules/object/actions/importAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/object/actions/importAction.class.php Tue Aug
23 11:29:01 2011 (r9570)
+++ trunk/apps/qubit/modules/object/actions/importAction.class.php Tue Aug
23 11:35:59 2011 (r9571)
@@ -42,80 +42,83 @@
// set indexing preference
if ($request->getParameter('noindex'))
{
- QubitSearch::getInstance()->disabled = true;
+ QubitSearch::getInstance()->disabled = true;
}
else
{
- QubitSearch::getInstance()->getEngine()->enableBatchMode();
+ QubitSearch::getInstance()->getEngine()->enableBatchMode();
}
try
{
- // choose import type based on file extension, eg. csv, xml
- if ('csv' == pathinfo($file['name'], PATHINFO_EXTENSION)) {
- $importer = new QubitCsvImport;
- $importer->import($file['tmp_name'], array('schema' =>
$request->getParameter('schema')));
- }
- elseif ('xml' == pathinfo($file['name'], PATHINFO_EXTENSION))
+ // choose import type based on file extension, eg. csv, xml
+ if ('csv' == pathinfo($file['name'], PATHINFO_EXTENSION))
+ {
+ $importer = new QubitCsvImport;
+ $importer->import($file['tmp_name'], array('schema' =>
$request->getParameter('schema')));
+ }
+ elseif ('xml' == pathinfo($file['name'], PATHINFO_EXTENSION))
+ {
+ $importer = new QubitXmlImport;
+ $importer->import($file['tmp_name'], array('strictXmlParsing' =>
false));
+ }
+ elseif ('zip' == pathinfo($file['name'], PATHINFO_EXTENSION) &&
class_exists('ZipArchive'))
+ {
+ $zipFolder = $file['tmp_name'].'-zip';
+ if (!file_exists($zipFolder))
{
- $importer = new QubitXmlImport;
- $importer->import($file['tmp_name'], array('strictXmlParsing' =>
false));
+ mkdir($zipFolder, 0755);
}
- elseif ('zip' == pathinfo($file['name'], PATHINFO_EXTENSION) &&
class_exists('ZipArchive'))
- {
- $zipFolder = $file['tmp_name'].'-zip';
- if (!file_exists($zipFolder))
- {
- mkdir($zipFolder, 0755);
- }
- // extract the zip archive into the temporary folder
- // TODO: need some error handling here
- $zip = new ZipArchive();
- $zip->open($file['tmp_name']);
- $zip->extractTo($zipFolder);
- $zip->close();
-
- $files = $this->dir_tree($zipFolder);
-
- // this code is from lib/importBulkTask.class.php
- foreach ($files as $import_file) {
- // try to free up memory
- unset($importer);
-
- // choose import type based on file extension, eg. csv, xml
- if ('csv' == pathinfo($import_file, PATHINFO_EXTENSION)) {
- $importer = new QubitCsvImport;
- $importer->import($import_file, array('schema'));
-
- } elseif ('xml' == pathinfo($import_file, PATHINFO_EXTENSION))
{
- $importer = new QubitXmlImport;
- $importer->import($import_file, array('strictXmlParsing'
=> false));
-
- } else {
- // move on to the next file
- continue;
- }
- }
- }
- else
+ // extract the zip archive into the temporary folder
+ // TODO: need some error handling here
+ $zip = new ZipArchive();
+ $zip->open($file['tmp_name']);
+ $zip->extractTo($zipFolder);
+ $zip->close();
+
+ $files = $this->dir_tree($zipFolder);
+
+ // this code is from lib/importBulkTask.class.php
+ foreach ($files as $import_file)
{
- $this->context->user->setFlash('error',
$this->context->i18n->__('Unable to import selected file'));
+ // try to free up memory
+ unset($importer);
- $this->redirect(array('module' => 'object', 'action' =>
'importSelect'));
+ // choose import type based on file extension, eg. csv, xml
+ if ('csv' == pathinfo($import_file, PATHINFO_EXTENSION))
+ {
+ $importer = new QubitCsvImport;
+ $importer->import($import_file, array('schema'));
+ }
+ elseif ('xml' == pathinfo($import_file, PATHINFO_EXTENSION))
+ {
+ $importer = new QubitXmlImport;
+ $importer->import($import_file, array('strictXmlParsing' =>
false));
+ }
+ else
+ {
+ // move on to the next file
+ continue;
+ }
}
+ }
+ else
+ {
+ $this->context->user->setFlash('error',
$this->context->i18n->__('Unable to import selected file'));
+ $this->redirect(array('module' => 'object', 'action' =>
'importSelect'));
+ }
}
catch (sfException $e)
{
$this->context->user->setFlash('error', $e->getMessage());
-
$this->redirect(array('module' => 'object', 'action' => 'importSelect'));
}
// optimize index if enabled
if (!$request->getParameter('noindex'))
{
- QubitSearch::getInstance()->getEngine()->optimize();
+ QubitSearch::getInstance()->getEngine()->optimize();
}
$this->errors = $importer->getErrors();
@@ -125,35 +128,35 @@
protected function dir_tree($dir)
{
- $path = '';
- $stack[] = $dir;
- while ($stack)
- {
- $thisdir = array_pop($stack);
- if ($dircont = scandir($thisdir))
- {
- $i=0;
- while (isset($dircont[$i]))
- {
- if ($dircont[$i] !== '.' && $dircont[$i] !== '..'
- // ignore system/hidden files
- && !preg_match('/^\..*/', $dircont[$i]))
- {
- $current_file = "{$thisdir}/{$dircont[$i]}";
- if (is_file($current_file))
- {
- $path[] = "{$thisdir}/{$dircont[$i]}";
- }
- elseif (is_dir($current_file))
- {
- $stack[] = $current_file;
- }
- }
- $i++;
- }
- }
- }
- return $path;
- }
+ $path = '';
+ $stack[] = $dir;
+ while ($stack)
+ {
+ $thisdir = array_pop($stack);
+ if ($dircont = scandir($thisdir))
+ {
+ $i=0;
+ while (isset($dircont[$i]))
+ {
+ if ($dircont[$i] !== '.' && $dircont[$i] !== '..'
+ // ignore system/hidden files
+ && !preg_match('/^\..*/', $dircont[$i]))
+ {
+ $current_file = "{$thisdir}/{$dircont[$i]}";
+ if (is_file($current_file))
+ {
+ $path[] = "{$thisdir}/{$dircont[$i]}";
+ }
+ elseif (is_dir($current_file))
+ {
+ $stack[] = $current_file;
+ }
+ }
+ $i++;
+ }
+ }
+ }
+ return $path;
+ }
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.