Esempio n. 1
0
 public function testISO()
 {
     $time = 1405267200;
     $expected = '2014-07-13T16:00:00+00:00';
     $datetime = DateUtils::date($time);
     $isoDatetime = DateUtils::convertToISOFormat($datetime);
     $this->assertEquals($expected, $isoDatetime);
     $isoDatetime = DateUtils::convertToISOFormat($time);
     $this->assertEquals($expected, $isoDatetime);
     $expected = '2014-07-13T12:00:00-04:00';
     $isoDatetime = DateUtils::convertToISOFormat($time, 'UTC', 'America/Santo_Domingo');
     $this->assertEquals($expected, $isoDatetime);
 }
Esempio n. 2
0
 public static function getTable($tbl_name)
 {
     $acl = Bootstrap::get('acl');
     $zendDb = Bootstrap::get('ZendDb');
     // TODO: getTable should return an empty object
     // or and empty array instead of false
     // in any given situation that the table
     // can be find or used.
     if (!self::canGroupViewTable($tbl_name)) {
         return false;
     }
     $info = SchemaManager::getTable($tbl_name);
     if (!$info) {
         return false;
     }
     if ($info) {
         $info['count'] = (int) $info['count'];
         $info['date_created'] = DateUtils::convertToISOFormat($info['date_created'], 'UTC', get_user_timezone());
         $info['hidden'] = (bool) $info['hidden'];
         $info['single'] = (bool) $info['single'];
         $info['footer'] = (bool) $info['footer'];
     }
     $relationalTableGateway = new RelationalTableGateway($acl, $tbl_name, $zendDb);
     $info = array_merge($info, $relationalTableGateway->countActiveOld());
     $info['columns'] = self::getSchemaArray($tbl_name);
     $directusPreferencesTableGateway = new DirectusPreferencesTableGateway($acl, $zendDb);
     $currentUser = Auth::getUserInfo();
     $info['preferences'] = $directusPreferencesTableGateway->fetchByUserAndTable($currentUser['id'], $tbl_name);
     return $info;
 }
Esempio n. 3
0
 public function convertDates(array $records, array $schemaArray, $tableName = null)
 {
     $tableName = $tableName === null ? $this->table : $tableName;
     if (!SchemaManager::isDirectusTable($tableName)) {
         return $records;
     }
     // ==========================================================================
     // hotfix: records sometimes are no set as an array of rows.
     // NOTE: this code is duplicate @see: AbstractSchema::parseRecordValuesByType
     // ==========================================================================
     $singleRecord = false;
     if (!is_numeric_keys_array($records)) {
         $records = [$records];
         $singleRecord = true;
     }
     foreach ($records as $index => $row) {
         foreach ($schemaArray as $column) {
             if (in_array(strtolower($column['type']), ['timestamp', 'datetime'])) {
                 $columnName = $column['id'];
                 if (array_key_exists($columnName, $row)) {
                     $records[$index][$columnName] = DateUtils::convertToISOFormat($row[$columnName], 'UTC', get_user_timezone());
                 }
             }
         }
     }
     return $singleRecord ? reset($records) : $records;
 }