Beispiel #1
0
 public function processRow(PHPExcel_Worksheet_Row $row)
 {
     $data = array();
     $rowData = new DataInput($data);
     $empty = TRUE;
     foreach ($this->columnMapping as $c) {
         list($char, $key) = $c;
         $cell = $this->getCell($char);
         $value = $cell->getValue();
         if ($value instanceof \PHPExcel_RichText) {
             $value = $value->getPlainText();
         }
         $style = $this->getStyle($char);
         $value = $this->filterValue($value, $style);
         if ($value != NULL) {
             $empty = FALSE;
         }
         $rowData->setDataWithKeys($key, $value);
         $this->processedColumn($c, $cell, $style, $value, $empty, $rowData, $row);
     }
     if (!$empty || $this->getOption('filterEmptyRow', FALSE) == FALSE) {
         $this->data->setDataWithKeys(array('rows', $row->getRowIndex()), $rowData->toArray());
     } else {
         $this->log .= 'Skipped.Empty: ' . $row->getRowIndex() . "\n";
     }
 }
Beispiel #2
0
 public function testSetDataWithKeys()
 {
     $data = array();
     $input = new DataInput($data);
     $input->setDataWithKeys(array(), array('key1' => 'key1value'));
     $this->assertEquals('key1value', $input->get('key1'));
     $this->assertEquals(array('key1' => 'key1value'), $input->get(array()));
 }
Beispiel #3
0
 public function testWeirdComparison()
 {
     $ar = array();
     $data = new \Psc\DataInput($ar);
     /* im code war hier Vergleich von $do (int(1)) == self::THROW_EXCEPTION (string('throw'))
          ergibt TRUE
          
          da schmeisst das hier eine Exception, obwohl es default zurückgeben müsste
        */
     $this->assertEquals(0, $data->get(array('noneexistant'), 0, 0));
 }
Beispiel #4
0
 protected function createPage(DataInput $data)
 {
     $this->createSheet('Tabelle1');
     $header = FALSE;
     foreach ($this->columnMapping as $c) {
         list($char, $key, $label) = $c;
         $name = implode('-', $key);
         if ($label != NULL) {
             $header = TRUE;
         }
         $this->addColumn($name, $char, $label);
         $this->sheet->getColumnDimension($char)->setAutoSize(TRUE);
     }
     if ($header) {
         $this->createStandardHeader();
     }
     $rows = $data->get(array('rows'), array(), array());
     foreach ($rows as $rowIndex => $row) {
         $this->processRow($row);
         $this->nextRow();
     }
 }
Beispiel #5
0
 /**
    * Gibt das Feld mit einem Defaultwert belegt zurück
    *
    * Im FormDataInput ist der dritte Parameter wirkungslos (er wird auf dasselbe wie $do gesetzt)
    * Deshalb ist hier der dritte Parameter unwirksam denn hier gilt $do = $default
    * zu beachten ist auch, dass der Defaultwert im FormDataInput auch genommen wird wenn der Wert trim() === '' ist
    *
    * also der $default -Wert wird genommen wenn:
    * - im Array die Schlüssel $keys nicht vorkommen
    * - der Wert der Schlüssel $keys im Array entweder === NULL oder trim() == '' ist
    * @see DataInput::get();
 */
 public function get($keys, $do = self::RETURN_NULL, $default = NULL)
 {
     // der default NULL für exception ist eigentlich uninteressant, da es zur Auswertung dieses Wertes vor der Exception nie kommt
     return parent::get($keys, $do, $do === self::RETURN_NULL || $do === self::THROW_EXCEPTION ? NULL : $do);
 }
Beispiel #6
0
 public function remove($key)
 {
     $this->cachedObjects->remove($key);
     return $this;
 }
Beispiel #7
0
 /**
  * 
  */
 public function merge(DataInput $dataInput, array $fromKeys = array(), $toKeys = array())
 {
     $ownData = $this->get($toKeys, array(), array());
     $foreignData = $dataInput->get($fromKeys, array(), array());
     $this->setDataWithKeys($toKeys, array_replace_recursive($ownData, $foreignData));
     return $this;
 }
Beispiel #8
0
 /**
  *
  * der gleiche Array wie bei getIterator() (somit bei foreach auch )
  * @return array
  */
 public function toArray()
 {
     return $this->fields->toArray();
 }