CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

View file

@ -0,0 +1,464 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* ColumnMap is used to model a column of a table in a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @version $Revision: 1612 $
* @package propel.runtime.map
*/
class ColumnMap
{
// Propel type of the column
protected $type;
// Size of the column
protected $size = 0;
// Is it a primary key?
protected $pk = false;
// Is null value allowed?
protected $notNull = false;
// The default value for this column
protected $defaultValue;
// Name of the table that this column is related to
protected $relatedTableName = "";
// Name of the column that this column is related to
protected $relatedColumnName = "";
// The TableMap for this column
protected $table;
// The name of the column
protected $columnName;
// The php name of the column
protected $phpName;
// The validators for this column
protected $validators = array();
/**
* Constructor.
*
* @param string $name The name of the column.
* @param TableMap containingTable TableMap of the table this column is in.
*/
public function __construct($name, TableMap $containingTable)
{
$this->columnName = $name;
$this->table = $containingTable;
}
/**
* Get the name of a column.
*
* @return string A String with the column name.
*/
public function getName()
{
return $this->columnName;
}
/**
* Get the table map this column belongs to.
* @return TableMap
*/
public function getTable()
{
return $this->table;
}
/**
* Get the name of the table this column is in.
*
* @return string A String with the table name.
*/
public function getTableName()
{
return $this->table->getName();
}
/**
* Get the table name + column name.
*
* @return string A String with the full column name.
*/
public function getFullyQualifiedName()
{
return $this->getTableName() . "." . $this->columnName;
}
/**
* Set the php anme of this column.
*
* @param string $phpName A string representing the PHP name.
* @return void
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
/**
* Get the name of a column.
*
* @return string A String with the column name.
*/
public function getPhpName()
{
return $this->phpName;
}
/**
* Set the Propel type of this column.
*
* @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE).
* @return void
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Get the Propel type of this column.
*
* @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE).
*/
public function getType()
{
return $this->type;
}
/**
* Get the PDO type of this column.
*
* @return int The PDO::PARMA_* value
*/
public function getPdoType()
{
return PropelColumnTypes::getPdoType($this->type);
}
/**
* Whether this is a BLOB, LONGVARBINARY, or VARBINARY.
* @return boolean
*/
public function isLob()
{
return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY);
}
/**
* Whether this is a DATE/TIME/TIMESTAMP column.
*
* @return boolean
* @since 1.3
*/
public function isTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP);
}
/**
* Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970).
*
* PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate
* between epoch and pre-epoch timestamps.
*
* @return boolean
* @deprecated Propel supports non-epoch dates
*/
public function isEpochTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME);
}
/**
* Whether this column is numeric (int, decimal, bigint etc).
* @return boolean
*/
public function isNumeric()
{
return ($this->type == PropelColumnTypes::NUMERIC || $this->type == PropelColumnTypes::DECIMAL || $this->type == PropelColumnTypes::TINYINT || $this->type == PropelColumnTypes::SMALLINT || $this->type == PropelColumnTypes::INTEGER || $this->type == PropelColumnTypes::BIGINT || $this->type == PropelColumnTypes::REAL || $this->type == PropelColumnTypes::FLOAT || $this->type == PropelColumnTypes::DOUBLE);
}
/**
* Whether this column is a text column (varchar, char, longvarchar).
* @return boolean
*/
public function isText()
{
return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR);
}
/**
* Set the size of this column.
*
* @param int $size An int specifying the size.
* @return void
*/
public function setSize($size)
{
$this->size = $size;
}
/**
* Get the size of this column.
*
* @return int An int specifying the size.
*/
public function getSize()
{
return $this->size;
}
/**
* Set if this column is a primary key or not.
*
* @param boolean $pk True if column is a primary key.
* @return void
*/
public function setPrimaryKey($pk)
{
$this->pk = $pk;
}
/**
* Is this column a primary key?
*
* @return boolean True if column is a primary key.
*/
public function isPrimaryKey()
{
return $this->pk;
}
/**
* Set if this column may be null.
*
* @param boolean nn True if column may be null.
* @return void
*/
public function setNotNull($nn)
{
$this->notNull = $nn;
}
/**
* Is null value allowed ?
*
* @return boolean True if column may not be null.
*/
public function isNotNull()
{
return ($this->notNull || $this->isPrimaryKey());
}
/**
* Sets the default value for this column.
* @param mixed $defaultValue the default value for the column
* @return void
*/
public function setDefaultValue($defaultValue)
{
$this->defaultValue = $defaultValue;
}
/**
* Gets the default value for this column.
* @return mixed String or NULL
*/
public function getDefaultValue()
{
return $this->defaultValue;
}
/**
* Set the foreign key for this column.
*
* @param string tableName The name of the table that is foreign.
* @param string columnName The name of the column that is foreign.
* @return void
*/
public function setForeignKey($tableName, $columnName)
{
if ($tableName && $columnName) {
$this->relatedTableName = $tableName;
$this->relatedColumnName = $columnName;
} else {
$this->relatedTableName = "";
$this->relatedColumnName = "";
}
}
/**
* Is this column a foreign key?
*
* @return boolean True if column is a foreign key.
*/
public function isForeignKey()
{
if ($this->relatedTableName) {
return true;
} else {
return false;
}
}
/**
* Get the RelationMap object for this foreign key
*/
public function getRelation()
{
if(!$this->relatedTableName) return null;
foreach ($this->getTable()->getRelations() as $name => $relation)
{
if($relation->getType() == RelationMap::MANY_TO_ONE)
{
if ($relation->getForeignTable()->getName() == $this->getRelatedTableName()
&& array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings()))
{
return $relation;
}
}
}
}
/**
* Get the table.column that this column is related to.
*
* @return string A String with the full name for the related column.
*/
public function getRelatedName()
{
return $this->relatedTableName . "." . $this->relatedColumnName;
}
/**
* Get the table name that this column is related to.
*
* @return string A String with the name for the related table.
*/
public function getRelatedTableName()
{
return $this->relatedTableName;
}
/**
* Get the column name that this column is related to.
*
* @return string A String with the name for the related column.
*/
public function getRelatedColumnName()
{
return $this->relatedColumnName;
}
/**
* Get the TableMap object that this column is related to.
*
* @return TableMap The related TableMap object
* @throws PropelException when called on a column with no foreign key
*/
public function getRelatedTable()
{
if ($this->relatedTableName) {
return $this->table->getDatabaseMap()->getTable($this->relatedTableName);
} else {
throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName);
}
}
/**
* Get the TableMap object that this column is related to.
*
* @return ColumnMap The related ColumnMap object
* @throws PropelException when called on a column with no foreign key
*/
public function getRelatedColumn()
{
return $this->getRelatedTable()->getColumn($this->relatedColumnName);
}
public function addValidator($validator)
{
$this->validators[] = $validator;
}
public function hasValidators()
{
return count($this->validators) > 0;
}
public function getValidators()
{
return $this->validators;
}
/**
* Performs DB-specific ignore case, but only if the column type necessitates it.
* @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name).
* @param DBAdapter $db
*/
public function ignoreCase($str, DBAdapter $db)
{
if ($this->isText()) {
return $db->ignoreCase($str);
} else {
return $str;
}
}
/**
* Normalizes the column name, removing table prefix and uppercasing.
*
* article.first_name becomes FIRST_NAME
*
* @param string $name
* @return string Normalized column name.
*/
public static function normalizeName($name)
{
if (false !== ($pos = strpos($name, '.'))) {
$name = substr($name, $pos + 1);
}
$name = strtoupper($name);
return $name;
}
// deprecated methods
/**
* Gets column name
* @deprecated Use getName() instead
* @return string
* @deprecated Use getName() instead.
*/
public function getColumnName()
{
return $this->getName();
}
}

View file

@ -0,0 +1,191 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* DatabaseMap is used to model a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Daniel Rall <dlr@collab.net> (Torque)
* @version $Revision: 1802 $
* @package propel.runtime.map
*/
class DatabaseMap
{
/** @var string Name of the database. */
protected $name;
/** @var array TableMap[] Tables in the database, using table name as key */
protected $tables = array();
/** @var array TableMap[] Tables in the database, using table phpName as key */
protected $tablesByPhpName = array();
/**
* Constructor.
*
* @param string $name Name of the database.
*/
public function __construct($name)
{
$this->name = $name;
}
/**
* Get the name of this database.
*
* @return string The name of the database.
*/
public function getName()
{
return $this->name;
}
/**
* Add a new table to the database by name.
*
* @param string $tableName The name of the table.
* @return TableMap The newly created TableMap.
*/
public function addTable($tableName)
{
$this->tables[$tableName] = new TableMap($tableName, $this);
return $this->tables[$tableName];
}
/**
* Add a new table object to the database.
*
* @param TableMap $table The table to add
*/
public function addTableObject(TableMap $table)
{
$table->setDatabaseMap($this);
$this->tables[$table->getName()] = $table;
$this->tablesByPhpName[$table->getClassname()] = $table;
}
/**
* Add a new table to the database, using the tablemap class name.
*
* @param string $tableMapClass The name of the table map to add
* @return TableMap The TableMap object
*/
public function addTableFromMapClass($tableMapClass)
{
$table = new $tableMapClass();
if(!$this->hasTable($table->getName())) {
$this->addTableObject($table);
return $table;
} else {
return $this->getTable($table->getName());
}
}
/**
* Does this database contain this specific table?
*
* @param string $name The String representation of the table.
* @return boolean True if the database contains the table.
*/
public function hasTable($name)
{
if ( strpos($name, '.') > 0) {
$name = substr($name, 0, strpos($name, '.'));
}
return array_key_exists($name, $this->tables);
}
/**
* Get a TableMap for the table by name.
*
* @param string $name Name of the table.
* @return TableMap A TableMap
* @throws PropelException if the table is undefined
*/
public function getTable($name)
{
if (!isset($this->tables[$name])) {
throw new PropelException("Cannot fetch TableMap for undefined table: " . $name );
}
return $this->tables[$name];
}
/**
* Get a TableMap[] of all of the tables in the database.
*
* @return array A TableMap[].
*/
public function getTables()
{
return $this->tables;
}
/**
* Get a ColumnMap for the column by name.
* Name must be fully qualified, e.g. book.AUTHOR_ID
*
* @param $qualifiedColumnName Name of the column.
* @return ColumnMap A TableMap
* @throws PropelException if the table is undefined, or if the table is undefined
*/
public function getColumn($qualifiedColumnName)
{
list($tableName, $columnName) = explode('.', $qualifiedColumnName);
return $this->getTable($tableName)->getColumn($columnName, false);
}
// deprecated methods
/**
* Does this database contain this specific table?
*
* @deprecated Use hasTable() instead
* @param string $name The String representation of the table.
* @return boolean True if the database contains the table.
*/
public function containsTable($name)
{
return $this->hasTable($name);
}
public function getTableByPhpName($phpName)
{
if (array_key_exists($phpName, $this->tablesByPhpName)) {
return $this->tablesByPhpName[$phpName];
} else if (class_exists($tmClass = $phpName . 'TableMap')) {
$this->addTableFromMapClass($tmClass);
return $this->tablesByPhpName[$phpName];
} else if (class_exists($tmClass = substr_replace($phpName, '\\map\\', strrpos($phpName, '\\'), 1) . 'TableMap')) {
$this->addTableFromMapClass($tmClass);
return $this->tablesByPhpName[$phpName];
} else {
throw new PropelException("Cannot fetch TableMap for undefined table phpName: " . $phpName);
}
}
/**
* Convenience method to get the DBAdapter registered with Propel for this database.
* @return DBAdapter
* @see Propel::getDB(string)
*/
public function getDBAdapter()
{
return Propel::getDB($this->name);
}
}

View file

@ -0,0 +1,299 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* RelationMap is used to model a database relationship.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups.
*
* @author Francois Zaninotto
* @version $Revision: 1728 $
* @package propel.runtime.map
*/
class RelationMap
{
const
// types
MANY_TO_ONE = 1,
ONE_TO_MANY = 2,
ONE_TO_ONE = 3,
MANY_TO_MANY = 4,
// representations
LOCAL_TO_FOREIGN = 0,
LEFT_TO_RIGHT = 1;
protected
$name,
$type,
$localTable,
$foreignTable,
$localColumns = array(),
$foreignColumns = array(),
$onUpdate, $onDelete;
/**
* Constructor.
*
* @param string $name Name of the relation.
*/
public function __construct($name)
{
$this->name = $name;
}
/**
* Get the name of this relation.
*
* @return string The name of the relation.
*/
public function getName()
{
return $this->name;
}
/**
* Set the type
*
* @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE)
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Get the type
*
* @return integer the relation type
*/
public function getType()
{
return $this->type;
}
/**
* Set the local table
*
* @param TableMap $table The local table for this relationship
*/
public function setLocalTable($table)
{
$this->localTable = $table;
}
/**
* Get the local table
*
* @return TableMap The local table for this relationship
*/
public function getLocalTable()
{
return $this->localTable;
}
/**
* Set the foreign table
*
* @param TableMap $table The foreign table for this relationship
*/
public function setForeignTable($table)
{
$this->foreignTable = $table;
}
/**
* Get the foreign table
*
* @return TableMap The foreign table for this relationship
*/
public function getForeignTable()
{
return $this->foreignTable;
}
/**
* Get the left table of the relation
*
* @return TableMap The left table for this relationship
*/
public function getLeftTable()
{
return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalTable() : $this->getForeignTable();
}
/**
* Get the right table of the relation
*
* @return TableMap The right table for this relationship
*/
public function getRightTable()
{
return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignTable() : $this->getLocalTable();
}
/**
* Add a column mapping
*
* @param ColumnMap $local The local column
* @param ColumnMap $foreign The foreign column
*/
public function addColumnMapping(ColumnMap $local, ColumnMap $foreign)
{
$this->localColumns[] = $local;
$this->foreignColumns[] = $foreign;
}
/**
* Get an associative array mapping local column names to foreign column names
* The arrangement of the returned array depends on the $direction parameter:
* - If the value is RelationMap::LOCAL_TO_FOREIGN, then the returned array is local => foreign
* - If the value is RelationMap::LEFT_TO_RIGHT, then the returned array is left => right
*
* @param int $direction How the associative array must return columns
* @return Array Associative array (local => foreign) of fully qualified column names
*/
public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN)
{
$h = array();
if ($direction == RelationMap::LEFT_TO_RIGHT && $this->getType() == RelationMap::MANY_TO_ONE) {
$direction = RelationMap::LOCAL_TO_FOREIGN;
}
for ($i=0, $size=count($this->localColumns); $i < $size; $i++) {
if ($direction == RelationMap::LOCAL_TO_FOREIGN) {
$h[$this->localColumns[$i]->getFullyQualifiedName()] = $this->foreignColumns[$i]->getFullyQualifiedName();
} else {
$h[$this->foreignColumns[$i]->getFullyQualifiedName()] = $this->localColumns[$i]->getFullyQualifiedName();
}
}
return $h;
}
/**
* Returns true if the relation has more than one column mapping
*
* @return boolean
*/
public function isComposite()
{
return $this->countColumnMappings() > 1;
}
/**
* Return the number of column mappings
*
* @return int
*/
public function countColumnMappings()
{
return count($this->localColumns);
}
/**
* Get the local columns
*
* @return Array list of ColumnMap objects
*/
public function getLocalColumns()
{
return $this->localColumns;
}
/**
* Get the foreign columns
*
* @return Array list of ColumnMap objects
*/
public function getForeignColumns()
{
return $this->foreignColumns;
}
/**
* Get the left columns of the relation
*
* @return array of ColumnMap objects
*/
public function getLeftColumns()
{
return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalColumns() : $this->getForeignColumns();
}
/**
* Get the right columns of the relation
*
* @return array of ColumnMap objects
*/
public function getRightColumns()
{
return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignColumns() : $this->getLocalColumns();
}
/**
* Set the onUpdate behavior
*
* @param string $onUpdate
*/
public function setOnUpdate($onUpdate)
{
$this->onUpdate = $onUpdate;
}
/**
* Get the onUpdate behavior
*
* @return integer the relation type
*/
public function getOnUpdate()
{
return $this->onUpdate;
}
/**
* Set the onDelete behavior
*
* @param string $onDelete
*/
public function setOnDelete($onDelete)
{
$this->onDelete = $onDelete;
}
/**
* Get the onDelete behavior
*
* @return integer the relation type
*/
public function getOnDelete()
{
return $this->onDelete;
}
/**
* Gets the symmetrical relation
*
* @return RelationMap
*/
public function getSymmetricalRelation()
{
$localMapping = array($this->getLeftColumns(), $this->getRightColumns());
foreach ($this->getRightTable()->getRelations() as $relation) {
if ($localMapping == array($relation->getRightColumns(), $relation->getLeftColumns())) {
return $relation;
}
}
}
}

View file

@ -0,0 +1,712 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* TableMap is used to model a table in a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @version $Revision: 1612 $
* @package propel.runtime.map
*/
class TableMap
{
/**
* Columns in the table
* @var array TableMap[]
*/
protected $columns = array();
/**
* Columns in the table, using table phpName as key
* @var array TableMap[]
*/
protected $columnsByPhpName = array();
// The database this table belongs to
protected $dbMap;
// The name of the table
protected $tableName;
// The PHP name of the table
protected $phpName;
// The Classname for this table
protected $classname;
// The Package for this table
protected $package;
// Whether to use an id generator for pkey
protected $useIdGenerator;
// Whether the table uses single table inheritance
protected $isSingleTableInheritance = false;
// The primary key columns in the table
protected $primaryKeys = array();
// The foreign key columns in the table
protected $foreignKeys = array();
// The relationships in the table
protected $relations = array();
// Relations are lazy loaded. This property tells if the relations are loaded or not
protected $relationsBuilt = false;
// Object to store information that is needed if the for generating primary keys
protected $pkInfo;
/**
* Construct a new TableMap.
*
*/
public function __construct($name = null, $dbMap = null)
{
if (null !== $name) {
$this->setName($name);
}
if (null !== $dbMap) {
$this->setDatabaseMap($dbMap);
}
$this->initialize();
}
/**
* Initialize the TableMap to build columns, relations, etc
* This method should be overridden by descendents
*/
public function initialize()
{
}
/**
* Set the DatabaseMap containing this TableMap.
*
* @param DatabaseMap $dbMap A DatabaseMap.
*/
public function setDatabaseMap(DatabaseMap $dbMap)
{
$this->dbMap = $dbMap;
}
/**
* Get the DatabaseMap containing this TableMap.
*
* @return DatabaseMap A DatabaseMap.
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* Set the name of the Table.
*
* @param string $name The name of the table.
*/
public function setName($name)
{
$this->tableName = $name;
}
/**
* Get the name of the Table.
*
* @return string A String with the name of the table.
*/
public function getName()
{
return $this->tableName;
}
/**
* Set the PHP name of the Table.
*
* @param string $phpName The PHP Name for this table
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
/**
* Get the PHP name of the Table.
*
* @return string A String with the name of the table.
*/
public function getPhpName()
{
return $this->phpName;
}
/**
* Set the Classname of the Table. Could be useful for calling
* Peer and Object methods dynamically.
* @param string $classname The Classname
*/
public function setClassname($classname)
{
$this->classname = $classname;
}
/**
* Get the Classname of the Propel Class belonging to this table.
* @return string
*/
public function getClassname()
{
return $this->classname;
}
/**
* Get the Peer Classname of the Propel Class belonging to this table.
* @return string
*/
public function getPeerClassname()
{
return constant($this->classname . '::PEER');
}
/**
* Set the Package of the Table
*
* @param string $package The Package
*/
public function setPackage($package)
{
$this->package = $package;
}
/**
* Get the Package of the table.
* @return string
*/
public function getPackage()
{
return $this->package;
}
/**
* Set whether or not to use Id generator for primary key.
* @param boolean $bit
*/
public function setUseIdGenerator($bit)
{
$this->useIdGenerator = $bit;
}
/**
* Whether to use Id generator for primary key.
* @return boolean
*/
public function isUseIdGenerator()
{
return $this->useIdGenerator;
}
/**
* Set whether or not to this table uses single table inheritance
* @param boolean $bit
*/
public function setSingleTableInheritance($bit)
{
$this->isSingleTableInheritance = $bit;
}
/**
* Whether this table uses single table inheritance
* @return boolean
*/
public function isSingleTableInheritance()
{
return $this->isSingleTableInheritance;
}
/**
* Sets the pk information needed to generate a key
*
* @param $pkInfo information needed to generate a key
*/
public function setPrimaryKeyMethodInfo($pkInfo)
{
$this->pkInfo = $pkInfo;
}
/**
* Get the information used to generate a primary key
*
* @return An Object.
*/
public function getPrimaryKeyMethodInfo()
{
return $this->pkInfo;
}
/**
* Add a column to the table.
*
* @param string name A String with the column name.
* @param string $type A string specifying the Propel type.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param boolean $pk True if column is a primary key.
* @param string $fkTable A String with the foreign key table name.
* @param $fkColumn A String with the foreign key column name.
* @param string $defaultValue The default value for this column.
* @return ColumnMap The newly created column.
*/
public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null)
{
$col = new ColumnMap($name, $this);
$col->setType($type);
$col->setSize($size);
$col->setPhpName($phpName);
$col->setNotNull($isNotNull);
$col->setDefaultValue($defaultValue);
if ($pk) {
$col->setPrimaryKey(true);
$this->primaryKeys[$name] = $col;
}
if ($fkTable && $fkColumn) {
$col->setForeignKey($fkTable, $fkColumn);
$this->foreignKeys[$name] = $col;
}
$this->columns[$name] = $col;
$this->columnsByPhpName[$phpName] = $col;
return $col;
}
/**
* Add a pre-created column to this table. It will replace any
* existing column.
*
* @param ColumnMap $cmap A ColumnMap.
* @return ColumnMap The added column map.
*/
public function addConfiguredColumn($cmap)
{
$this->columns[ $cmap->getColumnName() ] = $cmap;
return $cmap;
}
/**
* Does this table contain the specified column?
*
* @param mixed $name name of the column or ColumnMap instance
* @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
* @return boolean True if the table contains the column.
*/
public function hasColumn($name, $normalize = true)
{
if ($name instanceof ColumnMap) {
$name = $name->getColumnName();
} else if($normalize) {
$name = ColumnMap::normalizeName($name);
}
return isset($this->columns[$name]);
}
/**
* Get a ColumnMap for the table.
*
* @param string $name A String with the name of the table.
* @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
* @return ColumnMap A ColumnMap.
* @throws PropelException if the column is undefined
*/
public function getColumn($name, $normalize = true)
{
if ($normalize) {
$name = ColumnMap::normalizeName($name);
}
if (!$this->hasColumn($name, false)) {
throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name);
}
return $this->columns[$name];
}
/**
* Does this table contain the specified column?
*
* @param mixed $phpName name of the column
* @return boolean True if the table contains the column.
*/
public function hasColumnByPhpName($phpName)
{
return isset($this->columnsByPhpName[$phpName]);
}
/**
* Get a ColumnMap for the table.
*
* @param string $phpName A String with the name of the table.
* @return ColumnMap A ColumnMap.
* @throws PropelException if the column is undefined
*/
public function getColumnByPhpName($phpName)
{
if (!isset($this->columnsByPhpName[$phpName])) {
throw new PropelException("Cannot fetch ColumnMap for undefined column phpName: " . $phpName);
}
return $this->columnsByPhpName[$phpName];
}
/**
* Get a ColumnMap[] of the columns in this table.
*
* @return array A ColumnMap[].
*/
public function getColumns()
{
return $this->columns;
}
/**
* Add a primary key column to this Table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the Propel type.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param $size An int specifying the size.
* @return ColumnMap Newly added PrimaryKey column.
*/
public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null)
{
return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, null, null);
}
/**
* Add a foreign key column to the table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the Propel type.
* @param string $fkTable A String with the foreign key table name.
* @param string $fkColumn A String with the foreign key column name.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param string $defaultValue The default value for this column.
* @return ColumnMap Newly added ForeignKey column.
*/
public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null)
{
return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, false, $fkTable, $fkColumn);
}
/**
* Add a foreign primary key column to the table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the Propel type.
* @param string $fkTable A String with the foreign key table name.
* @param string $fkColumn A String with the foreign key column name.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param string $defaultValue The default value for this column.
* @return ColumnMap Newly created foreign pkey column.
*/
public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null)
{
return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, $fkTable, $fkColumn);
}
/**
* Returns array of ColumnMap objects that make up the primary key for this table
*
* @return array ColumnMap[]
*/
public function getPrimaryKeys()
{
return $this->primaryKeys;
}
/**
* Returns array of ColumnMap objects that are foreign keys for this table
*
* @return array ColumnMap[]
*/
public function getForeignKeys()
{
return $this->foreignKeys;
}
/**
* Add a validator to a table's column
*
* @param string $columnName The name of the validator's column
* @param string $name The rule name of this validator
* @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
* @param string $value
* @param string $message The error message which is returned on invalid values
* @return void
*/
public function addValidator($columnName, $name, $classname, $value, $message)
{
if (false !== ($pos = strpos($columnName, '.'))) {
$columnName = substr($columnName, $pos + 1);
}
$col = $this->getColumn($columnName);
if ($col !== null) {
$validator = new ValidatorMap($col);
$validator->setName($name);
$validator->setClass($classname);
$validator->setValue($value);
$validator->setMessage($message);
$col->addValidator($validator);
}
}
/**
* Build relations
* Relations are lazy loaded for performance reasons
* This method should be overridden by descendents
*/
public function buildRelations()
{
}
/**
* Adds a RelationMap to the table
*
* @param string $name The relation name
* @param string $tablePhpName The related table name
* @param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE)
* @param array $columnMapping An associative array mapping column names (local => foreign)
* @return RelationMap the built RelationMap object
*/
public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null)
{
// note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName()
// and this method autoloads the TableMap if the table isn't loaded yet
$relation = new RelationMap($name);
$relation->setType($type);
$relation->setOnUpdate($onUpdate);
$relation->setOnDelete($onDelete);
// set tables
if ($type == RelationMap::MANY_TO_ONE) {
$relation->setLocalTable($this);
$relation->setForeignTable($this->dbMap->getTableByPhpName($tablePhpName));
} else {
$relation->setLocalTable($this->dbMap->getTableByPhpName($tablePhpName));
$relation->setForeignTable($this);
$columnMapping = array_flip($columnMapping);
}
// set columns
foreach ($columnMapping as $local => $foreign) {
$relation->addColumnMapping(
$relation->getLocalTable()->getColumn($local),
$relation->getForeignTable()->getColumn($foreign)
);
}
$this->relations[$name] = $relation;
return $relation;
}
/**
* Gets a RelationMap of the table by relation name
* This method will build the relations if they are not built yet
*
* @param String $name The relation name
* @return boolean true if the relation exists
*/
public function hasRelation($name)
{
return array_key_exists($name, $this->getRelations());
}
/**
* Gets a RelationMap of the table by relation name
* This method will build the relations if they are not built yet
*
* @param String $name The relation name
* @return RelationMap The relation object
* @throws PropelException When called on an inexistent relation
*/
public function getRelation($name)
{
if (!array_key_exists($name, $this->getRelations()))
{
throw new PropelException('Calling getRelation() on an unknown relation, ' . $name);
}
return $this->relations[$name];
}
/**
* Gets the RelationMap objects of the table
* This method will build the relations if they are not built yet
*
* @return Array list of RelationMap objects
*/
public function getRelations()
{
if(!$this->relationsBuilt)
{
$this->buildRelations();
$this->relationsBuilt = true;
}
return $this->relations;
}
/**
*
* Gets the list of behaviors registered for this table
*
* @return array
*/
public function getBehaviors()
{
return array();
}
// Deprecated methods and attributres, to be removed
/**
* Does this table contain the specified column?
*
* @deprecated Use hasColumn instead
* @param mixed $name name of the column or ColumnMap instance
* @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
* @return boolean True if the table contains the column.
*/
public function containsColumn($name, $normalize = true)
{
return $this->hasColumn($name, $normalize);
}
/**
* Normalizes the column name, removing table prefix and uppercasing.
* article.first_name becomes FIRST_NAME
*
* @deprecated Use ColumnMap::normalizeColumName() instead
* @param string $name
* @return string Normalized column name.
*/
protected function normalizeColName($name)
{
return ColumnMap::normalizeName($name);
}
/**
* Returns array of ColumnMap objects that make up the primary key for this table.
*
* @deprecated Use getPrimaryKeys instead
* @return array ColumnMap[]
*/
public function getPrimaryKeyColumns()
{
return array_values($this->primaryKeys);
}
//---Utility methods for doing intelligent lookup of table names
/**
* The prefix on the table name.
* @deprecated Not used anywhere in Propel
*/
private $prefix;
/**
* Get table prefix name.
*
* @deprecated Not used anywhere in Propel
* @return string A String with the prefix.
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* Set table prefix name.
*
* @deprecated Not used anywhere in Propel
* @param string $prefix The prefix for the table name (ie: SCARAB for
* SCARAB_PROJECT).
* @return void
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
/**
* Tell me if i have PREFIX in my string.
*
* @deprecated Not used anywhere in Propel
* @param data A String.
* @return boolean True if prefix is contained in data.
*/
protected function hasPrefix($data)
{
return (strpos($data, $this->prefix) === 0);
}
/**
* Removes the PREFIX if found
*
* @deprecated Not used anywhere in Propel
* @param string $data A String.
* @return string A String with data, but with prefix removed.
*/
protected function removePrefix($data)
{
return $this->hasPrefix($data) ? substr($data, strlen($this->prefix)) : $data;
}
/**
* Removes the PREFIX, removes the underscores and makes
* first letter caps.
*
* SCARAB_FOO_BAR becomes FooBar.
*
* @deprecated Not used anywhere in Propel. At buildtime, use Column::generatePhpName() for that purpose
* @param data A String.
* @return string A String with data processed.
*/
public final function removeUnderScores($data)
{
$out = '';
$tmp = $this->removePrefix($data);
$tok = strtok($tmp, '_');
while ($tok) {
$out .= ucfirst($tok);
$tok = strtok('_');
}
return $out;
}
/**
* Makes the first letter caps and the rest lowercase.
*
* @deprecated Not used anywhere in Propel.
* @param string $data A String.
* @return string A String with data processed.
*/
private function firstLetterCaps($data)
{
return(ucfirst(strtolower($data)));
}
}

View file

@ -0,0 +1,92 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* ValidatorMap is used to model a column validator.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups.
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.map
*/
class ValidatorMap
{
/** rule name of this validator */
private $name;
/** the dot-path to class to use for validator */
private $classname;
/** value to check against */
private $value;
/** execption message thrown on invalid input */
private $message;
/** related column */
private $column;
public function __construct($containingColumn)
{
$this->column = $containingColumn;
}
public function getColumn()
{
return $this->column;
}
public function getColumnName()
{
return $this->column->getColumnName();
}
public function setName($name)
{
$this->name = $name;
}
public function setClass($classname)
{
$this->classname = $classname;
}
public function setValue($value)
{
$this->value = $value;
}
public function setMessage($message)
{
$this->message = $message;
}
public function getName()
{
return $this->name;
}
public function getClass()
{
return $this->classname;
}
public function getValue()
{
return $this->value;
}
public function getMessage()
{
return $this->message;
}
}