Author: mcantelon
Date: Thu Dec 29 13:02:04 2011
New Revision: 10468

Log:
Changed import script's variable names as per coding standard.

Modified:
   trunk/lib/task/csvImportTask.class.php

Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php      Thu Dec 29 12:55:22 2011        
(r10467)
+++ trunk/lib/task/csvImportTask.class.php      Thu Dec 29 13:02:04 2011        
(r10468)
@@ -61,17 +61,17 @@
       throw new sfException('You must specify a valid filename');
     }
 
-    $default_status_id = sfConfig::get(
+    $defaultStatusId = sfConfig::get(
       'app_defaultPubStatus',
       QubitTerm::PUBLICATION_STATUS_DRAFT_ID
     );
-    $default_status_type_id = QubitTerm::STATUS_TYPE_PUBLICATION_ID;
+    $defaultStatusTypeId = QubitTerm::STATUS_TYPE_PUBLICATION_ID;
 
     // Define import
     $import = new csvImport(array(
       'columns' => fgetcsv($fh, 60000), // 1st row supplies column names/order
-      'default_status_id' => $default_status_id,
-      'default_status_type_id' => $default_status_type_id,
+      'defaultStatusId' => $defaultStatusId,
+      'defaultStatusTypeId' => $defaultStatusTypeId,
       'columnMap' => array(
         'TITLE' => 'title',
         'Accruals' => 'accruals',
@@ -97,50 +97,50 @@
         'Rad note – conservation' => 231
       ),
       'rowInit' => function(&$self) {
-        $self->information_object = new QubitInformationObject;
+        $self->informationObject = new QubitInformationObject;
       },
       'rowStatusVars' => array(
-        'start_year',
-        'end_year'
+        'startYear',
+        'endYear'
       ),
       'rowComplete' => function(&$self) {
         // set to default status
-        $self->information_object->setStatus(array(
-          'statusId' => $self->default_status_id,
-          'typeId'   => $self->default_status_type_id
+        $self->informationObject->setStatus(array(
+          'statusId' => $self->defaultStatusId,
+          'typeId'   => $self->defaultStatusTypeId
         ));
 
-        $self->information_object->parentId = QubitInformationObject::ROOT_ID;
+        $self->informationObject->parentId = QubitInformationObject::ROOT_ID;
 
         if (!isset($self->testing) || !$self->testing)
         {
-          $self->information_object->save();
+          $self->informationObject->save();
         }
 
         //  add alpha-numeric designation if specified
-        if (isset($self->rowStatusVars['alphanumeric_designation']))
+        if (isset($self->rowStatusVars['alphanumericDesignation']))
         {
           # NOTE: This creates the note in the DB, but it doesn't show up
           # on the user side yet
-          $self->createNote(247, 
$self->rowStatusVars['alphanumeric_designation']);
+          $self->createNote(247, 
$self->rowStatusVars['alphanumericDesignation']);
         }
 
         // add create event if specified
         if (
-          isset($self->rowStatusVars['start_year'])
+          isset($self->rowStatusVars['startYear'])
           || (
-            isset($self->rowStatusVars['start_year'])
-            && isset($self->rowStatusVars['end_year'])
+            isset($self->rowStatusVars['startYear'])
+            && isset($self->rowStatusVars['endYear'])
           )
         )
         {
-          $endDate = (isset($self->rowStatusVars['end_year']))
-             ? $self->rowStatusVars['end_year'] .'-00-00'
+          $endDate = (isset($self->rowStatusVars['endYear']))
+             ? $self->rowStatusVars['endYear'] .'-00-00'
              : false;
 
           $self->createEvent(
             QubitTerm::CREATION_ID,
-            $self->rowStatusVars['start_year'] .'-00-00',
+            $self->rowStatusVars['startYear'] .'-00-00',
             $endDate
           );
         }
@@ -149,17 +149,17 @@
 
     $import->addColumnHandler('Level of description', function(&$self, $data)
     {
-      $self->information_object->setLevelOfDescriptionByName($data);
+      $self->informationObject->setLevelOfDescriptionByName($data);
     });
 
     $import->addColumnHandler('START YEAR', function(&$self, $data)
     {
-      $self->rowStatusVars['start_year'] = $data;
+      $self->rowStatusVars['startYear'] = $data;
     });
 
     $import->addColumnHandler('START YEAR', function(&$self, $data)
     {
-      $self->rowStatusVars['start_year'] = $data;
+      $self->rowStatusVars['startYear'] = $data;
     });
 
     $import->csv($fh);
@@ -170,10 +170,10 @@
 {
   public function __construct($options)
   {
-    $allowed_options = array(
+    $allowedOptions = array(
       'columns',
-      'default_status_id',
-      'default_status_type_id',
+      'defaultStatusId',
+      'defaultStatusTypeId',
       'testing',
       'rowInit',
       'rowComplete',
@@ -185,7 +185,7 @@
     // set properties from options, halting upon invalid option
     foreach($options as $option => $value)
     {
-      if (in_array($option, $allowed_options))
+      if (in_array($option, $allowedOptions))
       {
         $this->$option = $value;
       }
@@ -279,14 +279,14 @@
       // if column maps to an attribute, set the attribute
       if (isset($this->columnMap) && isset($this->columnMap[$columnName]))
       {
-        $this->information_object->{$this->columnMap[$columnName]} = 
$row[$index];
+        $this->informationObject->{$this->columnMap[$columnName]} = 
$row[$index];
       }
       else {
 
         // if column maps to a property, set the property
         if (isset($this->propertyMap) && 
isset($this->propertyMap[$columnName]))
         {
-          $this->information_object->addProperty(
+          $this->informationObject->addProperty(
             $this->propertyMap[$columnName], 
             $row[$index]
           );
@@ -328,11 +328,11 @@
     }
   }
 
-  public function createNote($type_id, $text)
+  public function createNote($typeId, $text)
   {
     $note = new QubitNote;
-    $note->objectId = $this->information_object->id;
-    $note->typeId = $type_id;
+    $note->objectId = $this->informationObject->id;
+    $note->typeId = $typeId;
     $note->content = $text;
     $note->scope = 'QubitTerm'; # not sure if this is needed
     $note->save();
@@ -343,7 +343,7 @@
   public function createEvent($typeId, $startDate, $endDate = false)
   {
     $date = new QubitEvent;
-    $date->informationObjectId = $this->information_object->id;
+    $date->informationObjectId = $this->informationObject->id;
     $date->typeId = $typeId;
     $date->startDate = $startDate;
     if ($endDate)

-- 
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.

Reply via email to