libraries for propel

This commit is contained in:
naomiaro 2010-11-08 23:16:28 -05:00
parent 1e0cba6a63
commit 06cb25a68b
317 changed files with 58926 additions and 0 deletions

View file

@ -0,0 +1,81 @@
<?php
/*
* $Id: DefaultInputHandler.php 905 2010-10-05 16:28:03Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://phing.info>.
*/
require_once 'phing/input/InputHandler.php';
include_once 'phing/system/io/ConsoleReader.php';
/**
* Prompts using print(); reads input from Console.
*
* @author Hans Lellelid <hans@xmpl.org> (Phing)
* @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
* @version $Revision: 905 $
* @package phing.input
*/
class DefaultInputHandler implements InputHandler {
/**
* Prompts and requests input. May loop until a valid input has
* been entered.
* @throws BuildException
*/
public function handleInput(InputRequest $request) {
$prompt = $this->getPrompt($request);
$in = new ConsoleReader();
do {
print $prompt;
try {
$input = $in->readLine();
if ($input === "" && ($request->getDefaultValue() !== null) ) {
$input = $request->getDefaultValue();
}
$request->setInput($input);
} catch (Exception $e) {
throw new BuildException("Failed to read input from Console.", $e);
}
} while (!$request->isInputValid());
}
/**
* Constructs user prompt from a request.
*
* <p>This implementation adds (choice1,choice2,choice3,...) to the
* prompt for <code>MultipleChoiceInputRequest</code>s.</p>
*
* @param $request the request to construct the prompt for.
* Must not be <code>null</code>.
*/
protected function getPrompt(InputRequest $request) {
$prompt = $request->getPrompt();
if ($request instanceof YesNoInputRequest) {
$prompt .= '(' . implode('/', $request->getChoices()) .')';
} elseif ($request instanceof MultipleChoiceInputRequest) { // (a,b,c,d)
$prompt .= '(' . implode(',', $request->getChoices()) . ')';
}
if ($request->getDefaultValue() !== null) {
$prompt .= ' ['.$request->getDefaultValue().']';
}
$pchar = $request->getPromptChar();
return $prompt . ($pchar ? $pchar . ' ' : ' ');
}
}

View file

@ -0,0 +1,45 @@
<?php
/*
* $Id: InputHandler.php 905 2010-10-05 16:28:03Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://phing.info>.
*/
/**
* Plugin to Phing to handle requests for user input.
*
* @author Stefan Bodewig <stefan.bodewig@epost.de>
* @version $Revision: 905 $
* @package phing.input
*/
interface InputHandler {
/**
* Handle the request encapsulated in the argument.
*
* <p>Precondition: the request.getPrompt will return a non-null
* value.</p>
*
* <p>Postcondition: request.getInput will return a non-null
* value, request.isInputValid will return true.</p>
* @return void
* @throws BuildException
*/
public function handleInput(InputRequest $request);
}

View file

@ -0,0 +1,107 @@
<?php
/*
* $Id: InputRequest.php 905 2010-10-05 16:28:03Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://phing.info>.
*/
/**
* Encapsulates an input request.
*
* @author Hans Lellelid <hans@xmpl.org> (Phing)
* @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
* @version $Revision: 905 $
* @package phing.input
*/
class InputRequest {
protected $prompt;
protected $input;
protected $defaultValue;
protected $promptChar;
/**
* @param string $prompt The prompt to show to the user. Must not be null.
*/
public function __construct($prompt) {
if ($prompt === null) {
throw new BuildException("prompt must not be null");
}
$this->prompt = $prompt;
}
/**
* Retrieves the prompt text.
*/
public function getPrompt() {
return $this->prompt;
}
/**
* Sets the user provided input.
*/
public function setInput($input) {
$this->input = $input;
}
/**
* Is the user input valid?
*/
public function isInputValid() {
return true;
}
/**
* Retrieves the user input.
*/
public function getInput() {
return $this->input;
}
/**
* Set the default value to use.
* @param mixed $v
*/
public function setDefaultValue($v) {
$this->defaultValue = $v;
}
/**
* Return the default value to use.
* @return mixed
*/
public function getDefaultValue() {
return $this->defaultValue;
}
/**
* Set the default value to use.
* @param string $c
*/
public function setPromptChar($c) {
$this->promptChar = $c;
}
/**
* Return the default value to use.
* @return string
*/
public function getPromptChar() {
return $this->promptChar;
}
}

View file

@ -0,0 +1,58 @@
<?php
/*
* $Id: MultipleChoiceInputRequest.php 905 2010-10-05 16:28:03Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://phing.info>.
*/
require_once 'phing/input/InputRequest.php';
/**
* Encapsulates an input request.
*
* @author Stefan Bodewig <stefan.bodewig@epost.de>
* @version $Revision: 905 $
* @package phing.input
*/
class MultipleChoiceInputRequest extends InputRequest {
protected $choices = array();
/**
* @param string $prompt The prompt to show to the user. Must not be null.
* @param array $choices holds all input values that are allowed.
* Must not be null.
*/
public function __construct($prompt, $choices) {
parent::__construct($prompt);
$this->choices = $choices;
}
/**
* @return The possible values.
*/
public function getChoices() {
return $this->choices;
}
/**
* @return true if the input is one of the allowed values.
*/
public function isInputValid() {
return in_array($this->getInput(), $this->choices); // not strict (?)
}
}

View file

@ -0,0 +1,47 @@
<?php
/*
* $Id: YesNoInputRequest.php 905 2010-10-05 16:28:03Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://phing.info>.
*/
require_once 'phing/input/MultipleChoiceInputRequest.php';
/**
* Encapsulates an input request that returns a boolean (yes/no).
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 905 $
* @package phing.input
*/
class YesNoInputRequest extends MultipleChoiceInputRequest {
/**
* @return true if the input is one of the allowed values.
*/
public function isInputValid() {
return StringHelper::isBoolean($this->input);
}
/**
* Converts input to boolean.
* @return boolean
*/
public function getInput() {
return StringHelper::booleanValue($this->input);
}
}