Allows addition of outsite JS scripts.
[platal.git] / classes / csvimporter.php
index 70aa377..6acb2c7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -64,12 +64,12 @@ class CSVImporter
         return true;
     }
 
-    private function getValue($line, $key, $action)
+    static public function getValue($line, $key, $action, $relation = null)
     {
         if (@array_key_exists($action, $line)) {
             $value = $line[$action];
         } elseif (is_callable($action, false)) {
-            $value = call_user_func($action, $line, $key);
+            $value = call_user_func($action, $line, $key, $relation);
         } else {
             $value = $action;
         }
@@ -83,7 +83,7 @@ class CSVImporter
     {
         $ops = array();
         foreach ($relation as $key=>$ref) {
-            $ops[$key] = $this->getValue($line, $key, $ref);
+            $ops[$key] = $this->getValue($line, $key, $ref, $relation);
         }
         return $ops;
     }
@@ -92,7 +92,7 @@ class CSVImporter
     {
         $ops = array();
         foreach ($relation as $key=>$ref) {
-            $value = $this->getValue($line, $key, $ref);
+            $value = $this->getValue($line, $key, $ref, $relation);
             if (!is_null($value) && $value != 'NULL') {
                 $value = "'" . addslashes($value) . "'";
             }
@@ -243,7 +243,7 @@ class CSVImporter
      * @param $url   URI of the page
      * @param $field Editable fields
      */
-    public function apply(&$page, $url, $fields = null)
+    public function apply($page, $url, $fields = null)
     {
         $sesfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
                            'csv_update', 'csv_action', 'csv_cond_field',