Пример #1
0
 /**
  * Get columns to create fields from.
  *
  * @return array
  */
 public function getFieldColumns()
 {
     $columns = array();
     foreach ($this->modelMap->getColumns() as $column) {
         if ($column->isForeignKey() && $this->ignoreFks) {
             continue;
         }
         if ($column->isPrimaryKey() && $this->ignorePks) {
             continue;
         }
         $columns[strtolower($column->getName())] = $column;
     }
     if (array_key_exists('sortable', $tmp = $this->modelMap->getBehaviors())) {
         unset($columns[strtolower($tmp['sortable']['rank_column'])]);
     }
     return $columns;
 }
Пример #2
0
 /**
  * Get row properties.
  *
  * @param BaseObject $obj
  * @return array
  */
 protected function getRow($obj)
 {
     $columnToPhpName = array();
     foreach ($this->tableMap->getColumns() as $name => $column) {
         $columnToPhpName[strtolower($name)] = $column->getPhpName();
     }
     $celldata = array();
     foreach ($this->columns as $column => $opts) {
         if (isset($this->callbacks[$column])) {
             $value = call_user_func($this->callbacks[$column], $obj);
         } else {
             try {
                 if (isset($columnToPhpName[$column])) {
                     $phpName = $columnToPhpName[$column];
                 } else {
                     $tmp = $this->query->getAsColumns();
                     if (isset($tmp[$column])) {
                         $phpName = $column;
                     }
                 }
                 $value = $obj->{'get' . $phpName}();
             } catch (Exception $e) {
                 throw new Exception("Unable to fetch value from column '{$column}'.");
             }
         }
         if (is_null($value)) {
             $value = 'Ø';
         } else {
             if (is_bool($value)) {
                 $value = $value ? 'true' : 'false';
             } else {
                 if (is_array($value)) {
                     $value = join(', ', $value);
                 }
             }
         }
         $escape = !isset($opts['escape']) ? true : (bool) $opts['escape'];
         $value = str_replace(PHP_EOL, "", $value);
         $celldata[] = $escape ? htmlspecialchars($value) : $value;
     }
     return array("id" => "_" . $obj->getPrimaryKey(), "cell" => $celldata);
 }
Пример #3
0
 public static function findAutoLabel(TableMap $map)
 {
     if (count(self::$scores) == 0) {
         self::$scores = array('VARCHAR' => 6, 'LONGVARCHAR' => 5, 'ENUM' => 4, 'CHAR' => 4, 'DATE' => 3, 'DATETIME' => 3, 'TIMESTAMP' => 3, 'TIME' => 3, 'YEAR' => 3, 'TEXT' => 2, 'BLOB' => 2, 'CLOB' => 2, 'TINYBLOB' => 2, 'TINYTEXT' => 2, 'MEDIUMBLOB' => 2, 'MEDIUMTEXT' => 2, 'LONGTEXT' => 2, 'BOOLEAN' => 1, 'INT' => 1, 'INTEGER' => 1, 'TINYINT' => 1, 'SMALLINT' => 1, 'MEDIUMINT' => 1, 'BIGINT' => 1, 'FLOAT' => 1, 'DOUBLE' => 1, 'DECIMAL' => 1);
     }
     /** @var $column ColumnMap */
     $scoreTable = array();
     foreach ($map->getColumns() as $column) {
         if (isset(self::$scores[$column->getType()])) {
             $score = self::$scores[$column->getType()];
         } else {
             //todo $x = 'tablenotfound';
             $score = 0;
         }
         if (!isset($scoreTable[$score])) {
             $scoreTable[$score] = $column;
         }
     }
     $key = max(array_keys($scoreTable));
     $map->autoLabel = $scoreTable[$key];
 }
Пример #4
0
 protected function getHashableColumns(MeshingBaseObject $object, TableMap $tableMap)
 {
     return $tableMap->getColumns();
 }