[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7390] property: more on for import
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7390] property: more on for import |
Date: |
Thu, 16 Jun 2011 13:17:27 +0000 |
Revision: 7390
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7390
Author: sigurdne
Date: 2011-06-16 13:17:27 +0000 (Thu, 16 Jun 2011)
Log Message:
-----------
property: more on for import
Modified Paths:
--------------
trunk/property/inc/class.soentity.inc.php
trunk/property/inc/class.uiimport.inc.php
Added Paths:
-----------
trunk/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2011-06-16 12:38:13 UTC (rev
7389)
+++ trunk/property/inc/class.soentity.inc.php 2011-06-16 13:17:27 UTC (rev
7390)
@@ -595,8 +595,8 @@
function read_single($data,$values = array())
{
- $entity_id = (int)$data['entity_id'];
- $cat_id = (int)$data['cat_id'];
+ $entity_id = isset($data['entity_id']) &&
$data['entity_id'] ? (int)$data['entity_id'] : $this->entity_id;
+ $cat_id = isset($data['cat_id']) &&
$data['cat_id'] ? (int)$data['cat_id'] : $this->cat_id;
$id = (int)$data['id'];
$num = isset($data['num']) && $data['num'] ?
$data['num'] : '';
$table = "fm_{$this->type}_{$entity_id}_{$cat_id}";
Modified: trunk/property/inc/class.uiimport.inc.php
===================================================================
--- trunk/property/inc/class.uiimport.inc.php 2011-06-16 12:38:13 UTC (rev
7389)
+++ trunk/property/inc/class.uiimport.inc.php 2011-06-16 13:17:27 UTC (rev
7390)
@@ -32,6 +32,7 @@
{
set_time_limit(10000); //Set the time limit for this
request oto 3000 seconds
$this->account =
(int)$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->db = & $GLOBALS['phpgw']->db;
}
@@ -225,8 +226,7 @@
$this->messages[] = "Read 'import_all.csv' file in " .
(time() - $start_time) . " seconds";
$this->messages[] = "'importfile.csv' contained " .
count($datalines) . " lines";
- $this->db = & $GLOBALS['phpgw']->db;
-
+
$ok = true;
$_ok = false;
$this->db->transaction_begin();
Added: trunk/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
===================================================================
--- trunk/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
(rev 0)
+++ trunk/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
2011-06-16 13:17:27 UTC (rev 7390)
@@ -0,0 +1,106 @@
+<?php
+ class import_conversion
+ {
+ protected $bofiles;
+ protected $db;
+ public $messages = array();
+ public $warnings = array();
+ public $errors = array();
+ protected $dir = '/opt/kunst/001';
+ protected $entity_id = 4;
+ protected $cat_id = 1;
+
+
+ public function __construct()
+ {
+ set_time_limit(10000); //Set the time limit for this
request
+ $this->account =
(int)$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->db = & $GLOBALS['phpgw']->db;
+ $this->bofiles =
CreateObject('property.bofiles');
+ $this->category_dir =
"entity_{$this->entity_id}_{$this->cat_id}";
+ $this->soentity =
CreateObject('property.soentity',$this->entity_id,$this->cat_id);
+ }
+
+ public function add($data)
+ {
+// $debug = true;
+ $error = false;
+//_debug_array($data);
+
+ $values = $this->soentity->read_single(array('id' =>
$data[0] ));
+
+ if(isset($values['location_code']))
+ {
+ $filename = sprintf('%05s',$data[1]);
+ $from_file =
"{$this->dir}/{$filename}.jpg";
+ if(!is_file($from_file))
+ {
+ $this->errors[] ="'Missing file:
{$from_file}";
+ }
+
+ $location = explode('-',
$values['location_code']);
+
+ $to_file =
"{$this->bofiles->fakebase}/{$this->category_dir}/{$location[0]}/{$data[0]}/{$filename}.jpg";
+
+ if ($this->bofiles->vfs->file_exists(array
+ (
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+ $this->errors[] ="This file already
exists: {$to_file}";
+ }
+ else if (!$debug)
+ {
+
$this->bofiles->create_document_dir("{$this->category_dir}/{$location[0]}/{$data[0]}");
+ $this->bofiles->vfs->override_acl = 1;
+
+ if(!$this->bofiles->vfs->cp (array (
+ 'from' => $from_file,
+ 'to' => $to_file,
+ 'relatives' => array
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+ $this->errors[] ="'Failed to
upload file: {$to_file}";
+ }
+ else
+ {
+ $this->messages[] =
"Successfully imported file: Title ({$filename}.jpg)";
+ }
+ $this->bofiles->vfs->override_acl = 0;
+ }
+
+// _debug_array($to_file);
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Convert from the locale encoding to UTF-8 encoding and
escape single quotes
+ *
+ * @param string $value The value to convert
+ * @return string
+ */
+ protected function decode($value)
+ {
+ $converted = mb_convert_encoding($value, 'UTF-8');
+ if ($this->is_null(trim($converted)))
+ {
+ return null;
+ }
+ return stripslashes($converted);
+ }
+
+ /**
+ * Test a value for null according to several formats that can
exist in the export.
+ * Returns true if the value is null according to these rules,
false otherwise.
+ *
+ * @param string $value The value to test
+ * @return bool
+ */
+ protected function is_null($value)
+ {
+ return ((trim($value) == "") || ($data == "<NULL>") ||
($data == "''"));
+ }
+ }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7390] property: more on for import,
Sigurd Nes <=