handle the case that no columns are defined in export definition
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 15 Jul 2015 16:13:31 +0000 (18:13 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jul 2015 08:21:09 +0000 (10:21 +0200)
Change-Id: I9457a82456d65a436b1cb73175895c2b4be087d9
Reviewed-on: http://gerrit.tine20.com/customers/2043
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Export/Spreadsheet/Ods.php

index a77b89b..6a243d3 100644 (file)
@@ -200,33 +200,38 @@ class Tinebase_Export_Spreadsheet_Ods extends Tinebase_Export_Spreadsheet_Abstra
             }
             $this->_addColumnStyle('co0', $defaultStyles);
         }
-        
-        foreach($this->_config->columns->column as $column) {
 
-            if ($column->style) {
-                if (! $defaultStyles) {
-                    $msg = 'If a column contains style, the "defaultColumnStyle" has to be defined!';
-                    
-                    if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
-                        Tinebase_Core::getLogger()->log(__METHOD__ . '::' . __LINE__ . ' ' . $msg . ' Definition Name: ' . (string) $this->_config->name);
+        if (isset($this->_config->columns)) {
+            foreach ($this->_config->columns->column as $column) {
+
+                if ($column->style) {
+                    if (!$defaultStyles) {
+                        $msg = 'If a column contains style, the "defaultColumnStyle" has to be defined!';
+
+                        if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
+                            Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' ' . $msg . ' Definition Name: ' . (string)$this->_config->name);
+                        }
+
+                        throw new Tinebase_Exception_UnexpectedValue($msg);
                     }
-                    
-                    throw new Tinebase_Exception_UnexpectedValue($msg);
-                }
-                
-                $columnStyles = array();
-                foreach($column->style as $name => $style) {
-                    $columnStyles[$name] = (string) $style;
+
+                    $columnStyles = array();
+                    foreach ($column->style as $name => $style) {
+                        $columnStyles[$name] = (string)$style;
+                    }
+
+                    $this->_addColumnStyle($classPrefix . $index, $columnStyles);
+
+                    $this->_columnStyles[$index] = $classPrefix . $index;
+                } else {
+                    $this->_columnStyles[$index] = 'co0';
                 }
-                
-                $this->_addColumnStyle($classPrefix . $index, $columnStyles);
-                
-                $this->_columnStyles[$index] = $classPrefix . $index;
-            } else {
-                $this->_columnStyles[$index] = 'co0';
+
+                $index++;
             }
-            
-            $index++;
+        } else {
+            if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ .
+                ' No column config found');
         }
         
         foreach($this->_columnStyles as $key => $style) {