Commit 779bce9f authored by Prosper De Laure's avatar Prosper De Laure
Browse files

First commit

parent f5b0cdb5
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="Laabs Framework [trunk]" default="build">
<property name="workspace" value="${basedir}" />
<property name="sourcedir" value="${basedir}/core" />
<property name="builddir" value="${workspace}/build" />
<!-- CLEAN -->
<target name="clean" description="Cleanup build artifacts">
<delete dir="${builddir}/logs"/>
<delete dir="${builddir}/pdepend"/>
<delete dir="${builddir}/docs/*"/>
<delete dir="${builddir}/code-browser"/>
<delete dir="${builddir}/coverage"/>
</target>
<!-- BUILD -->
<target name="build" depends="prepare,lint,phploc,pdepend,phpcpd,phpmd,phpcs,phpdoc,phpunit,phpcb"/>
<!-- BUILD-PARALLEL -->
<!-- target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,phpcb"/ -->
<!-- TOOLS-PARALLEL -->
<!-- target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd"/>
</sequential>
<antcall target="phploc"/>
<antcall target="phpcpd"/>
<antcall target="phpcs"/>
<antcall target="phpdoc"/>
</parallel>
</target -->
<!-- PREPARE -->
<target name="prepare" depends="clean" description="Prepare for build">
<exec executable="svn">
<arg value="up" />
<arg path="${workspace}" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_authentication/trunk" />
<arg path="${workspace}/dependency/authentication" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_authorization/trunk" />
<arg path="${workspace}/dependency/authorization" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_datasource/trunk" />
<arg path="${workspace}/dependency/datasource" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_fileSystem/trunk" />
<arg path="${workspace}/dependency/fileSystem" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_html/trunk" />
<arg path="${workspace}/dependency/html" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_json/trunk" />
<arg path="${workspace}/dependency/json" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_localisation/trunk" />
<arg path="${workspace}/dependency/localisation" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_logger/trunk" />
<arg path="${workspace}/dependency/logger" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_repository/trunk" />
<arg path="${workspace}/dependency/repository" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_sdo/trunk" />
<arg path="${workspace}/dependency/sdo" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_xml/trunk" />
<arg path="${workspace}/dependency/xml" />
</exec>
<mkdir dir="${builddir}/logs"/>
<mkdir dir="${builddir}/pdepend"/>
<mkdir dir="${builddir}/code-browser"/>
<mkdir dir="${builddir}/coverage"/>
</target>
<!-- LINT -->
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="false">
<arg value="-l" />
<fileset dir="${sourcedir}">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<!-- PHPLOC -->
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${builddir}/logs/phploc.csv" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PDEPEND -->
<target name="pdepend" description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${builddir}/logs/jdepend.xml" />
<arg value="--jdepend-chart=${builddir}/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${builddir}/pdepend/overview-pyramid.svg" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PHPCPD -->
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${builddir}/logs/pmd-cpd.xml" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PHPMD -->
<target name="phpmd" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${sourcedir}" />
<arg value="xml" />
<arg value="${workspace}/phpmd.xml" />
<arg value="--reportfile" />
<arg value="${builddir}/logs/pmd.xml" />
<arg value="--minimumpriority" />
<arg value="3" />
</exec>
</target>
<!-- PHPCS -->
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${builddir}/logs/checkstyle.xml" />
<arg value="--standard=Symfony2" />
<arg value="--extensions=php" />
<arg value="--error-severity=5" />
<arg value="--warning-severity=8" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PHPDOC -->
<target name="phpdoc" description="Generate API documentation using phpDocumentor">
<exec executable="phpdoc">
<arg line="-d '${sourcedir}' -t '${builddir}/docs' --title='Laabs Framework [trunk]' " />
</exec>
</target>
<!-- PHPDOX -->
<!-- target name="phpdox" description="Generate API documentation using phpDox">
<exec executable="phpdox"/>
</target -->
<!-- PHPUNIT -->
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="false">
<arg value="-c" />
<arg path="${basedir}/phpunit.xml" />
</exec>
</target>
<!-- PHPCB -->
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${builddir}/logs" />
<arg value="--source" />
<arg path="${sourcedir}" />
<arg value="--output" />
<arg path="${builddir}/code-browser" />
</exec>
</target>
</project>
<?php
/**
* Class file for App Configuration
* @package core\Configuration
*/
namespace core\Configuration;
/**
* Class that defines the configuration singleton object
*/
class Configuration
extends Section
{
/* Constants */
/* Properties */
/**
* The object storage for the singleton instance
* @var array
* @static
* @access protected
*/
protected static $instance;
/**
* The set of variables defined on configurations
* @var array
*/
public $variables;
/* Methods */
/**
* Get the configuration instance. It can be
* * from configuration files
* * from Instance of application if loaded
* * from the already instantiated instance during the same call to app
* @return \core\Configuration\Configuration object
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
if ($configuration = \laabs::getCache('configuration')) {
self::$instance = $configuration;
} else {
self::$instance = new Configuration();
self::$instance->registerVariable('laabsDirectory', dirname(getcwd()));
$confFile = \laabs::getConfiguration();
self::$instance->loadFile($confFile);
\laabs::setCache('configuration', self::$instance);
}
}
return self::$instance;
}
/**
* Registers a variable on the global scope
* @param string $name The name of the variable
* @param mixed $value The value of the variable
*
* @return void
*/
public function registerVariable($name, $value)
{
$this->variables[$name] = $value;
}
/**
* Retrieves a variable on the global scope
* @param string $name the name of the variable
*
* @return mixed $value The value of the variable
*/
public function getVariable($name)
{
if (isset($this->variables[$name])) {
return $this->variables[$name];
}
}
/**
* Parse and loads a configuration file into current section
* @param string $conffile The path of a configuration file from conf root
*
* @return void
*
* @access protected
*/
protected function loadFile($conffile)
{
$parsedContent = $this->parseFile($conffile);
if ($this->name) {
$section = false;
} else {
$section = true;
}
$contents = parse_ini_string($parsedContent, $section);
$this->load($contents);
}
protected function parseFile($conffile)
{
if (!is_file($conffile)) {
throw new \Exception("Unable to load configuration file '".$conffile."'");
}
$confdir = \laabs\dirname($conffile);
// Load file or directory and process includes
$confstring = "";
$confhdl = fopen($conffile, 'r');
while ($line = fgets($confhdl)) {
if (strpos($line, "@include") === 0) {
$includedFile = trim(str_replace("@include", "", $line));
$includeDir = null;
if (is_dir($includedFile)) {
$includeDir = $includedFile;
} else if (is_dir($confdir . DIRECTORY_SEPARATOR . $includedFile)) {
$includeDir = $confdir . DIRECTORY_SEPARATOR . $includedFile;
}
else if (is_file($confdir . DIRECTORY_SEPARATOR . $includedFile)) {
$includedFile = $confdir . DIRECTORY_SEPARATOR . $includedFile;
}
if ($includeDir) {
foreach (glob($includeDir . DIRECTORY_SEPARATOR . "*.ini") as $filename) {
$includedFile = $filename;
$includedString = $this->parseFile($includedFile);
$confstring .= $includedString . PHP_EOL;
}
} else {
$includedString = $this->parseFile($includedFile);
$confstring .= $includedString . PHP_EOL;
}
} else {
$confstring .= str_replace('\"', '&quot;', $line);
}
}
return $confstring;
}
}
\ No newline at end of file
<?php
/**
* Class file for App Configuration Section
* @package core\Configuration
*/
namespace core\Configuration;
/**
* Class file for App Configuration Section
*
* @package Core
*/
class Section
extends \ArrayObject
{
/* Constants */
/* Properties */
/**
* The name of the section or null if config root
* @var string
*/
protected $name;
/* Methods */
/**
* Constructor for a configuration section
* @param string $name The name of the configuration section
* @param array $contents The associative array of configuration sections or directives to load on construction or null
*
* @return void
*/
public function __construct($name = null, $contents = null)
{
$this->name = $name;
if ($contents) {
$this->load($contents);
}
}
/**
* Load an array of configuration sections or directives
* @param array $contents The associative array of configuration sections or directives
*/
public function load($contents)
{
foreach ($contents as $name => $content) {
if (is_array($content)) {
if (!isset($this[$name])) {
$this[$name] = new Section($name);
}
$this[$name]->load($content);
} else {
if (isset($this[$name])) {
continue;
}
// Try to find and replace constants
if (defined($content)) {
$content = constant($content);
}
$content = trim(str_replace('&quot;', '\"', $content));
$content = str_replace('\"', '"', $content);
// Check name, if variable, content will be stored for later use
if (preg_match("/^%[A-Za-z_]%$/", $name)) {
$varname = substr($name, 1, -1);
Configuration::getInstance()->registerVariable($varname, $content);
continue;
}
if (preg_match("/^\@var\.(\w+)$/", $name, $match)) {
$varname = $match[1];
Configuration::getInstance()->registerVariable($varname, $content);
continue;
}
// Find and replace variables
if (preg_match_all("#%[A-Za-z_]+%#", $content, $variables)) {
foreach ($variables[0] as $variable) {
//$value = $this->getVariable($variable);
$varname = substr($variable, 1, -1);
$value = Configuration::getInstance()->getVariable($varname);
if (is_null($value)) {
throw new \Exception("Error retrieving variable '$varname' for configuration directive '$name'");
}
$content = str_replace($variable, $value, $content);
}
}
// Parse array
if (preg_match("/^\[.+\]$/s", $content) || preg_match("/^\{.+\}$/s", $content)) {
$content = \laabs::decodeIni($content);
}
//preg_replace('#\\\\"#', '"', $value);
// Finally set directive value
$this->offsetSet($name, $content);
}
}
}
/**
* Imports a configuration section