mirror of
https://github.com/atlanticbiomedical/portal-legacy.git
synced 2025-07-02 01:47:28 -04:00
initial commit
This commit is contained in:
9
lib/symfony/vendor/phing/system/util/Message.php
vendored
Executable file
9
lib/symfony/vendor/phing/system/util/Message.php
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
//
|
||||
// FIXME. Logger will be renamed to Message, new level is introduces MSG_NOTICE
|
||||
// Message can handle some more later on
|
||||
// - formatted output
|
||||
// - sending to dialog or phpgtk whatever
|
||||
// - etc
|
||||
//
|
||||
?>
|
270
lib/symfony/vendor/phing/system/util/Properties.php
vendored
Executable file
270
lib/symfony/vendor/phing/system/util/Properties.php
vendored
Executable file
@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* $Id: Properties.php 3076 2006-12-18 08:52:12Z fabien $
|
||||
*
|
||||
* 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>.
|
||||
*/
|
||||
|
||||
include_once 'phing/system/io/PhingFile.php';
|
||||
include_once 'phing/system/io/FileWriter.php';
|
||||
|
||||
/**
|
||||
* Convenience class for reading and writing property files.
|
||||
*
|
||||
* FIXME
|
||||
* - Add support for arrays (separated by ',')
|
||||
*
|
||||
* @package phing.system.util
|
||||
* @version $Revision: 1.13 $
|
||||
*/
|
||||
class Properties {
|
||||
|
||||
private $properties = array();
|
||||
|
||||
/**
|
||||
* Load properties from a file.
|
||||
*
|
||||
* @param PhingFile $file
|
||||
* @return void
|
||||
* @throws IOException - if unable to read file.
|
||||
*/
|
||||
function load(PhingFile $file) {
|
||||
if ($file->canRead()) {
|
||||
$this->parse($file->getPath(), false);
|
||||
} else {
|
||||
throw new IOException("Can not read file ".$file->getPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces parse_ini_file() or better_parse_ini_file().
|
||||
* Saves a step since we don't have to parse and then check return value
|
||||
* before throwing an error or setting class properties.
|
||||
*
|
||||
* @param string $filePath
|
||||
* @param boolean $processSections Whether to honor [SectionName] sections in INI file.
|
||||
* @return array Properties loaded from file (no prop replacements done yet).
|
||||
*/
|
||||
protected function parse($filePath) {
|
||||
|
||||
// load() already made sure that file is readable
|
||||
// but we'll double check that when reading the file into
|
||||
// an array
|
||||
|
||||
if (($lines = @file($filePath)) === false) {
|
||||
throw new IOException("Unable to parse contents of $filePath");
|
||||
}
|
||||
|
||||
$this->properties = array();
|
||||
$sec_name = "";
|
||||
|
||||
foreach($lines as $line) {
|
||||
|
||||
$line = trim($line);
|
||||
|
||||
if($line == "")
|
||||
continue;
|
||||
|
||||
if ($line{0} == '#' or $line{0} == ';') {
|
||||
// it's a comment, so continue to next line
|
||||
continue;
|
||||
} else {
|
||||
$pos = strpos($line, '=');
|
||||
$property = trim(substr($line, 0, $pos));
|
||||
$value = trim(substr($line, $pos + 1));
|
||||
$this->properties[$property] = $this->inVal($value);
|
||||
}
|
||||
|
||||
} // for each line
|
||||
}
|
||||
|
||||
/**
|
||||
* Process values when being read in from properties file.
|
||||
* does things like convert "true" => true
|
||||
* @param string $val Trimmed value.
|
||||
* @return mixed The new property value (may be boolean, etc.)
|
||||
*/
|
||||
protected function inVal($val) {
|
||||
if ($val === "true") {
|
||||
$val = true;
|
||||
} elseif ($val === "false") {
|
||||
$val = false;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process values when being written out to properties file.
|
||||
* does things like convert true => "true"
|
||||
* @param mixed $val The property value (may be boolean, etc.)
|
||||
* @return string
|
||||
*/
|
||||
protected function outVal($val) {
|
||||
if ($val === true) {
|
||||
$val = "true";
|
||||
} elseif ($val === false) {
|
||||
$val = "false";
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create string representation that can be written to file and would be loadable using load() method.
|
||||
*
|
||||
* Essentially this function creates a string representation of properties that is ready to
|
||||
* write back out to a properties file. This is used by store() method.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString() {
|
||||
$buf = "";
|
||||
foreach($this->properties as $key => $item) {
|
||||
$buf .= $key . "=" . $this->outVal($item) . Phing::getProperty('line.separator');
|
||||
}
|
||||
return $buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores current properties to specified file.
|
||||
*
|
||||
* @param PhingFile $file File to create/overwrite with properties.
|
||||
* @param string $header Header text that will be placed (within comments) at the top of properties file.
|
||||
* @return void
|
||||
* @throws IOException - on error writing properties file.
|
||||
*/
|
||||
function store(PhingFile $file, $header = null) {
|
||||
// stores the properties in this object in the file denoted
|
||||
// if file is not given and the properties were loaded from a
|
||||
// file prior, this method stores them in the file used by load()
|
||||
try {
|
||||
$fw = new FileWriter($file);
|
||||
$fw->open();
|
||||
if ($header !== null) {
|
||||
$fw->write( "# " . $header . Phing::getProperty("line.separator") );
|
||||
}
|
||||
$fw->write($this->toString());
|
||||
$fw->close();
|
||||
} catch (IOException $e) {
|
||||
throw new IOException("Error writing property file: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns copy of internal properties hash.
|
||||
* Mostly for performance reasons, property hashes are often
|
||||
* preferable to passing around objects.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getProperties() {
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value for specified property.
|
||||
* This is the same as get() method.
|
||||
*
|
||||
* @param string $prop The property name (key).
|
||||
* @return mixed
|
||||
* @see get()
|
||||
*/
|
||||
function getProperty($prop) {
|
||||
if (!isset($this->properties[$prop])) {
|
||||
return null;
|
||||
}
|
||||
return $this->properties[$prop];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value for specified property.
|
||||
* This function exists to provide a hashtable-like interface for
|
||||
* properties.
|
||||
*
|
||||
* @param string $prop The property name (key).
|
||||
* @return mixed
|
||||
* @see getProperty()
|
||||
*/
|
||||
function get($prop) {
|
||||
if (!isset($this->properties[$prop])) {
|
||||
return null;
|
||||
}
|
||||
return $this->properties[$prop];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for a property.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return mixed Old property value or NULL if none was set.
|
||||
*/
|
||||
function setProperty($key, $value) {
|
||||
$oldValue = @$this->properties[$key];
|
||||
$this->properties[$key] = $value;
|
||||
return $oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for a property.
|
||||
* This function exists to provide hashtable-lie
|
||||
* interface for properties.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
function put($key, $value) {
|
||||
return $this->setProperty($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as keys() function, returns an array of property names.
|
||||
* @return array
|
||||
*/
|
||||
function propertyNames() {
|
||||
return $this->keys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether loaded properties array contains specified property name.
|
||||
* @return boolean
|
||||
*/
|
||||
function containsKey($key) {
|
||||
return isset($this->properties[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns properties keys.
|
||||
* Use this for foreach() {} iterations, as this is
|
||||
* faster than looping through property values.
|
||||
* @return array
|
||||
*/
|
||||
function keys() {
|
||||
return array_keys($this->properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether properties list is empty.
|
||||
* @return boolean
|
||||
*/
|
||||
function isEmpty() {
|
||||
return empty($this->properties);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
115
lib/symfony/vendor/phing/system/util/Register.php
vendored
Executable file
115
lib/symfony/vendor/phing/system/util/Register.php
vendored
Executable file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Static class to handle a slot-listening system.
|
||||
*
|
||||
* Unlike the slots/signals Qt model, this class manages something that is
|
||||
* more like a simple hashtable, where each slot has only one value. For that
|
||||
* reason "Registers" makes more sense, the reference being to CPU registers.
|
||||
*
|
||||
* This could be used for anything, but it's been built for a pretty specific phing
|
||||
* need, and that is to allow access to dynamic values that are set by logic
|
||||
* that is not represented in a build file. For exampe, we need a system for getting
|
||||
* the current resource (file) that is being processed by a filterchain in a fileset.
|
||||
*
|
||||
* Each slot corresponds to only one read-only, dynamic-value RegisterSlot object. In
|
||||
* a build.xml register slots are expressed using a syntax similar to variables:
|
||||
*
|
||||
* <replaceregexp>
|
||||
* <regexp pattern="\n" replace="%{task.current_file}"/>
|
||||
* </replaceregexp>
|
||||
*
|
||||
* The task/type must provide a supporting setter for the attribute:
|
||||
*
|
||||
* <code>
|
||||
* function setListeningReplace(RegisterSlot $slot) {
|
||||
* $this->replace = $slot;
|
||||
* }
|
||||
*
|
||||
* // in main()
|
||||
* if ($this->replace instanceof RegisterSlot) {
|
||||
* $this->regexp->setReplace($this->replace->getValue());
|
||||
* } else {
|
||||
* $this->regexp->setReplace($this->replace);
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.3 $
|
||||
* @package phing.system.util
|
||||
*/
|
||||
class Register {
|
||||
|
||||
/** Slots that have been registered */
|
||||
private static $slots = array();
|
||||
|
||||
/**
|
||||
* Returns RegisterSlot for specified key.
|
||||
*
|
||||
* If not slot exists a new one is created for key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return RegisterSlot
|
||||
*/
|
||||
public static function getSlot($key) {
|
||||
if (!isset(self::$slots[$key])) {
|
||||
self::$slots[$key] = new RegisterSlot($key);
|
||||
}
|
||||
return self::$slots[$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a slot in the register.
|
||||
*/
|
||||
class RegisterSlot {
|
||||
|
||||
/** The name of this slot. */
|
||||
private $key;
|
||||
|
||||
/** The value for this slot. */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Constructs a new RegisterSlot, setting the key to passed param.
|
||||
* @param string $key
|
||||
*/
|
||||
public function __construct($key) {
|
||||
$this->key = (string) $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key / name for this slot.
|
||||
* @param string $k
|
||||
*/
|
||||
public function setKey($k) {
|
||||
$this->key = (string) $k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key / name for this slot.
|
||||
* @return string
|
||||
*/
|
||||
public function getKey() {
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value for this slot.
|
||||
* @param mixed
|
||||
*/
|
||||
public function setValue($v) {
|
||||
$this->value = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at this slot.
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
96
lib/symfony/vendor/phing/system/util/Timer.php
vendored
Executable file
96
lib/symfony/vendor/phing/system/util/Timer.php
vendored
Executable file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: Timer.php 3076 2006-12-18 08:52:12Z fabien $
|
||||
*
|
||||
* 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>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This class can be used to obtain the execution time of all of the scripts
|
||||
* that are executed in the process of building a page.
|
||||
*
|
||||
* Example:
|
||||
* To be done before any scripts execute:
|
||||
*
|
||||
* $Timer = new Timer;
|
||||
* $Timer->Start_Timer();
|
||||
*
|
||||
* To be done after all scripts have executed:
|
||||
*
|
||||
* $timer->Stop_Timer();
|
||||
* $timer->Get_Elapsed_Time(int number_of_places);
|
||||
*
|
||||
* @author Charles Killian
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @package phing.system.util
|
||||
* @version $Revision: 1.5 $ $Date: 2003/12/24 13:02:09 $
|
||||
*/
|
||||
class Timer {
|
||||
|
||||
/** start time */
|
||||
protected $stime;
|
||||
|
||||
/** end time */
|
||||
protected $etime;
|
||||
|
||||
/**
|
||||
* This function sets the class variable $stime to the current time in
|
||||
* microseconds.
|
||||
* @return void
|
||||
*/
|
||||
public function start() {
|
||||
$this->stime = $this->getMicrotime();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function sets the class variable $etime to the current time in
|
||||
* microseconds.
|
||||
* @return void
|
||||
*/
|
||||
function stop() {
|
||||
$this->etime = $this->getMicrotime();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the elapsed time in seconds.
|
||||
*
|
||||
* Call start_time() at the beginning of script execution and end_time() at
|
||||
* the end of script execution. Then, call elapsed_time() to obtain the
|
||||
* difference between start_time() and end_time().
|
||||
*
|
||||
* @param $places decimal place precision of elapsed time (default is 5)
|
||||
* @return string Properly formatted time.
|
||||
*/
|
||||
function getElapsedTime($places=5) {
|
||||
$etime = $this->etime - $this->stime;
|
||||
$format = "%0.".$places."f";
|
||||
return (sprintf ($format, $etime));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the current time in microseconds.
|
||||
*
|
||||
* @author Everett Michaud, Zend.com
|
||||
* @return current time in microseconds
|
||||
* @access private
|
||||
*/
|
||||
function getMicrotime() {
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user