/**
  * Creates a proper result array from the database data
  *
  * @param array $DBdata the data as it is retrieved from the database, i.e. by SchemaData::getDataFromDB
  * @param bool $asarray return data as associative array (true) or as array of Values (false)
  * @return array|Value[]
  */
 protected function consolidateData($DBdata, $asarray = false)
 {
     $data = array();
     $sep = Search::CONCAT_SEPARATOR;
     foreach ($this->schema->getColumns(false) as $col) {
         // if no data saved yet, return empty strings
         if ($DBdata) {
             $val = $DBdata[0]['out' . $col->getColref()];
         } else {
             $val = '';
         }
         // multi val data is concatenated
         if ($col->isMulti()) {
             $val = explode($sep, $val);
             $val = array_filter($val);
         }
         $value = new Value($col, $val);
         if ($this->opt_skipempty && $value->isEmpty()) {
             continue;
         }
         if ($this->opt_skipempty && !$col->isVisibleInPage()) {
             continue;
         }
         //FIXME is this a correct assumption?
         // for arrays, we return the raw value only
         if ($asarray) {
             $data[$col->getLabel()] = $value->getRawValue();
         } else {
             $data[] = $value;
         }
     }
     return $data;
 }
Beispiel #2
0
 /**
  * Containment checker
  *
  * @param mixed $value Value
  * @param mixed $set   Set
  *
  * @return boolean
  */
 public static function contains($value, $set)
 {
     if (Value::isEmpty($value) || !Value::isArray($set)) {
         return false;
     }
     if (is_array($set)) {
         return in_array($value, $set);
     } else {
         foreach ($set as $val) {
             if ($value == $val) {
                 return true;
             }
         }
     }
     return false;
 }