Ejemplo n.º 1
0
 /**
  * Returns an array with all attribute names not used in template
  *
  * We accept Tx_Rnbase_Domain_Model_DataInterface, but the model must also
  * implement IteratorAggregate!
  *
  * @param Tx_Rnbase_Domain_Model_Data $item
  * @param string $template
  * @param string $marker
  * @return array
  */
 public static function findUnusedAttributes(Tx_Rnbase_Domain_Model_DataInterface $item, $template, $marker)
 {
     $ignore = array();
     $minfo = self::containsMarker($template, $marker . '___MINFO');
     $minfoArr = array();
     foreach ($item as $key => $value) {
         if ($minfo) {
             $minfoArr[$key] = $marker . '_' . strtoupper($key);
         }
         if (!self::containsMarker($template, $marker . '_' . strtoupper($key))) {
             $ignore[] = $key;
         }
     }
     if ($minfo) {
         tx_rnbase::load('tx_rnbase_util_Debug');
         $item->setProperty('__MINFO', tx_rnbase_util_Debug::viewArray($minfoArr));
     }
     return $ignore;
 }
 /**
  * Returns an array with all column names not used in template
  *
  * @param array $record
  * @param string $template
  * @param string $marker
  * @return array
  * @deprecated use Tx_Rnbase_Frontend_Marker_Utility::findUnusedAttributes
  */
 public static function findUnusedCols(&$record, $template, $marker)
 {
     $ignore = array();
     $minfo = self::containsMarker($template, $marker . '___MINFO');
     $minfoArr = array();
     foreach ($record as $key => $value) {
         if ($minfo) {
             $minfoArr[$key] = $marker . '_' . strtoupper($key);
         }
         if (!self::containsMarker($template, $marker . '_' . strtoupper($key))) {
             $ignore[] = $key;
         }
     }
     if ($minfo) {
         tx_rnbase::load('tx_rnbase_util_Debug');
         $record['__MINFO'] = tx_rnbase_util_Debug::viewArray($minfoArr);
     }
     return $ignore;
 }
 /**
  * Puts all columns in $record to a Marker-Array. Each column is wrapped according to it's name.
  * So if your confId is 'profile.' and your column is 'date' you can define a TS setup like
  * <pre>profile.date.strftime = %Y</pre>
  * @return Array
  */
 function getItemMarkerArrayWrapped($record, $confId, $noMap = 0, $markerPrefix = '', $initMarkers = 0)
 {
     if (!is_array($record)) {
         return array();
     }
     $start = microtime(TRUE);
     $mem = memory_get_usage();
     $tmpArr = $this->cObj->data;
     // Ensure the initMarkers are part of the record
     if (is_array($initMarkers)) {
         for ($i = 0, $cnt = count($initMarkers); $i < $cnt; $i++) {
             if (!array_key_exists($initMarkers[$i], $record)) {
                 $record[$initMarkers[$i]] = '';
             }
         }
     }
     // extend the record by dc columns
     $conf = $this->getConfigurations()->get($confId);
     if (is_array($conf)) {
         // Add dynamic columns
         $keys = $this->getConfigurations()->getUniqueKeysNames($conf);
         foreach ($keys as $key) {
             if ($key[0] === 'd' && $key[1] === 'c' && !isset($record[$key])) {
                 $record[$key] = $conf[$key];
             }
         }
     }
     if (array_key_exists('__MINFO', $record)) {
         // Die TS-Config in die Ausgabe integrieren
         $record['__MINFO'] .= tx_rnbase_util_Debug::viewArray(array('TS-Path' => $confId));
         $record['__MINFO'] .= tx_rnbase_util_Debug::viewArray(array($conf));
     }
     $this->cObj->data = $record;
     // Alle Metadaten auslesen und wrappen
     $data = array();
     foreach ($record as $colname => $value) {
         if (is_array($noMap) && in_array($colname, $noMap)) {
             continue;
         }
         // Für DATETIME gibt es eine Sonderbehandlung, um leere Werte zu behandeln
         if ($conf[$colname] == 'DATETIME' && $conf[$colname . '.']['ifEmpty'] && !$value) {
             $data[$colname] = $conf[$colname . '.']['ifEmpty'];
         } elseif ($conf[$colname]) {
             // Get value using cObjGetSingle
             $this->cObj->setCurrentVal($value);
             $data[$colname] = $this->cObj->cObjGetSingle($conf[$colname], $conf[$colname . '.']);
             $this->cObj->setCurrentVal(FALSE);
         } elseif ($conf[$colname] == 'CASE') {
             $data[$colname] = $this->cObj->CASEFUNC($conf[$colname . '.']);
         } else {
             // Es wird ein normaler Wrap gestartet
             // Zuerst Numberformat durchführen
             $value = $this->numberFormat($value, $conf[$colname . '.']);
             $data[$colname] = $this->stdWrap($value, $conf[$colname . '.']);
         }
     }
     reset($record);
     $markerArray = tx_rnbase_util_FormatUtil::getItemMarkerArray($data, $noMap, $markerPrefix, $initMarkers);
     unset($data);
     // 400 kB
     $this->cObj->data = $tmpArr;
     self::$time += microtime(TRUE) - $start;
     self::$mem += memory_get_usage() - $mem;
     return $markerArray;
 }