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,35 @@
<?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
*/
/**
* Basic Validator interface.
*
* BasicValidator objects perform validation without any knowledge of column/table
* context. They are simply given an input and some value and asked whether the input
* is valid.
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
interface BasicValidator
{
/**
* Determine whether a value meets the criteria specified
*
* @param ValidatorMap $map A column map object for the column to be validated.
* @param string $str a <code>String</code> to be tested
*
* @return mixed TRUE if valid, error message otherwise
*/
public function isValid(ValidatorMap $map, $str);
}

View file

@ -0,0 +1,68 @@
<?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
*/
/**
* A validator for regular expressions.
*
* This validator will return true, when the passed value *matches* the
* regular expression.
*
* ## This class replaces the former class MaskValidator ##
*
* If you do want to test if the value does *not* match an expression,
* you can use the MatchValidator class instead.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="email" type="VARCHAR" size="128" required="true" />
* <validator column="username">
* <!-- allow strings that match the email adress pattern -->
* <rule
* name="match"
* value="/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/"
* message="Please enter a valid email address." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class MatchValidator implements BasicValidator
{
/**
* Prepares the regular expression entered in the XML
* for use with preg_match().
* @param string $exp
* @return string Prepared regular expession.
*/
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) {
$exp = '/' . $exp . '/';
}
// if they did not escape / chars; we do that for them
$exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp);
return $exp;
}
/**
* Whether the passed string matches regular expression.
*/
public function isValid (ValidatorMap $map, $str)
{
return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0);
}
}

View file

@ -0,0 +1,39 @@
<?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
*/
/**
* A validator for maximum string length.
*
* Below is an example usage for your Propel xml schema file.
*
* Note that if you have specified the size attribute in the column tag
* you do not have to specify it as value in the validator rule again as
* this is done automatically.
*
* <code>
* <column name="username" type="VARCHAR" size="25" required="true" />
*
* <validator column="username">
* <rule name="maxLength" message="Passwort must be at least ${value} characters !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class MaxLengthValidator implements BasicValidator
{
public function isValid (ValidatorMap $map, $str)
{
return strlen($str) <= intval($map->getValue());
}
}

View file

@ -0,0 +1,43 @@
<?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
*/
/**
* A validator for maximum values.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="articles" type="INTEGER" required="true" />
*
* <validator column="articles">
* <rule name="minValue" value="1" message="Minimum value for selected articles is ${value} !" />
* <rule name="maxValue" value="10" message="Maximum value for selected articles is ${value} !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class MaxValueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value) == true) {
return intval($value) <= intval($map->getValue());
}
return false;
}
}

View file

@ -0,0 +1,36 @@
<?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
*/
/**
* A validator for minimum string length.
*
* <code>
* <column name="password" type="VARCHAR" size="34" required="true" />
*
* <validator column="password">
* <rule name="minLength" value="5" message="Passwort must be at least ${value} characters !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class MinLengthValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
return strlen($str) >= intval($map->getValue());
}
}

View file

@ -0,0 +1,43 @@
<?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
*/
/**
* A validator for minimum values.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="articles" type="INTEGER" required="true" />
*
* <validator column="articles">
* <rule name="minValue" value="1" message="Minimum value for selected articles is ${value} !" />
* <rule name="maxValue" value="10" message="Maximum value for selected articles is ${value} !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class MinValueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value)) {
return intval($value) >= intval($map->getValue());
}
return false;
}
}

View file

@ -0,0 +1,66 @@
<?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
*/
/**
* A validator for regular expressions.
*
* This validator will return true, when the passed value does *not* match
* the regular expression.
*
* If you do want to test if the value *matches* an expression, you can use
* the MatchValidator class instead.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="ISBN" type="VARCHAR" size="20" required="true" />
* <validator column="username">
* <!-- disallow everything that's not a digit or minus -->
* <rule
* name="notMatch"
* value="/[^\d-]+/"
* message="Please enter a valid email adress." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class NotMatchValidator implements BasicValidator
{
/**
* Prepares the regular expression entered in the XML
* for use with preg_match().
* @param string $exp
* @return string Prepared regular expession.
*/
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) {
$exp = '/' . $exp . '/';
}
// if they did not escape / chars; we do that for them
$exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp);
return $exp;
}
/**
* Whether the passed string matches regular expression.
*/
public function isValid (ValidatorMap $map, $str)
{
return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0);
}
}

View file

@ -0,0 +1,38 @@
<?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
*/
/**
* A validator for required fields.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="username" type="VARCHAR" size="25" required="true" />
*
* <validator column="username">
* <rule name="required" message="Username is required." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class RequiredValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
return ($str !== null && $str !== "");
}
}

View file

@ -0,0 +1,68 @@
<?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
*/
/**
* A validator for validating the (PHP) type of the value submitted.
*
* <code>
* <column name="some_int" type="INTEGER" required="true"/>
*
* <validator column="some_int">
* <rule name="type" value="integer" message="Please specify an integer value for some_int column." />
* </validator>
* </code>
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class TypeValidator implements BasicValidator
{
public function isValid(ValidatorMap $map, $value)
{
switch ($map->getValue()) {
case 'array':
return is_array($value);
break;
case 'bool':
case 'boolean':
return is_bool($value);
break;
case 'float':
return is_float($value);
break;
case 'int':
case 'integer':
return is_int($value);
break;
case 'numeric':
return is_numeric($value);
break;
case 'object':
return is_object($value);
break;
case 'resource':
return is_resource($value);
break;
case 'scalar':
return is_scalar($value);
break;
case 'string':
return is_string($value);
break;
case 'function':
return function_exists($value);
break;
default:
throw new PropelException('Unkonwn type ' . $map->getValue());
break;
}
}
}

View file

@ -0,0 +1,48 @@
<?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
*/
/**
* A validator for unique column names.
*
* <code>
* <column name="username" type="VARCHAR" size="25" required="true" />
*
* <validator column="username">
* <rule name="unique" message="Username already exists !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class UniqueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
$column = $map->getColumn();
$c = new Criteria();
$c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL);
$table = $column->getTable()->getClassName();
$clazz = $table . 'Peer';
$count = call_user_func(array($clazz, 'doCount'), $c);
$isValid = ($count === 0);
return $isValid;
}
}

View file

@ -0,0 +1,33 @@
<?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
*/
/**
* A validator for valid values (e.g. for enum fields)
*
* <code>
* <column name="address_type" type="VARCHAR" required="true" default="delivery" />
*
* <validator column="address_type">
* <rule name="validValues" value="account|delivery" message="Please select a valid address type." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 1612 $
* @package propel.runtime.validator
*/
class ValidValuesValidator implements BasicValidator
{
public function isValid (ValidatorMap $map, $str)
{
return in_array($str, preg_split("/[|,]/", $map->getValue()));
}
}

View file

@ -0,0 +1,115 @@
<?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
*/
/**
* Simple class that serves as a container for any information about a failed validation.
*
* Currently this class stores the qualified column name (e.g. tablename.COLUMN_NAME) and
* the message that should be displayed to the user.
*
* An array of these objects will be returned by BasePeer::doValidate() if validation
* failed.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1612 $
* @package propel.runtime.validator
* @see BasePeer::doValidate()
*/
class ValidationFailed {
/** Column name in tablename.COLUMN_NAME format */
private $colname;
/** Message to display to user. */
private $message;
/** Validator object that caused this to fail. */
private $validator;
/**
* Construct a new ValidationFailed object.
* @param string $colname Column name.
* @param string $message Message to display to user.
* @param object $validator The Validator that caused this column to fail.
*/
public function __construct($colname, $message, $validator = null)
{
$this->colname = $colname;
$this->message = $message;
$this->validator = $validator;
}
/**
* Set the column name.
* @param string $v
*/
public function setColumn($v)
{
$this->colname = $v;
}
/**
* Gets the column name.
* @return string Qualified column name (tablename.COLUMN_NAME)
*/
public function getColumn()
{
return $this->colname;
}
/**
* Set the message for the validation failure.
* @param string $v
*/
public function setMessage($v)
{
$this->message = $v;
}
/**
* Gets the message for the validation failure.
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* Set the validator object that caused this to fail.
* @param object $v
*/
public function setValidator($v)
{
$this->validator = $v;
}
/**
* Gets the validator object that caused this to fail.
* @return object
*/
public function getValidator()
{
return $this->validator;
}
/**
* "magic" method to get string represenation of object.
* Maybe someday PHP5 will support the invoking this method automatically
* on (string) cast. Until then it's pretty useless.
* @return string
*/
public function __toString()
{
return $this->getMessage();
}
}