FEATURE, PM Rest Api: Adding rest api crud generator
This commit is contained in:
140
gulliver/core/Autoloader.php
Normal file
140
gulliver/core/Autoloader.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Autoloader
|
||||
*
|
||||
* Adaptation of Alchemy/Component/ClassLoader on https://github.com/eriknyk/ClassLoader for php 5.2.x
|
||||
*
|
||||
* ""SplClassLoader implementation that implements the technical interoperability
|
||||
* standards for PHP 5.3 namespaces and class names. ""
|
||||
*
|
||||
* Singleton Class
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com>
|
||||
* @link https://github.com/eriknyk/phpalchemy
|
||||
* @copyright Copyright 2012 Erik Amaru Ortiz
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/**
|
||||
* Holds singleton object
|
||||
*
|
||||
* @var ClassLoader
|
||||
*/
|
||||
protected static $instance = null;
|
||||
protected $includePaths = array();
|
||||
protected $includeClassPaths = array();
|
||||
|
||||
protected $relativeIncludePaths = array();
|
||||
|
||||
/**
|
||||
* Creates a new SplClassLoader and installs the class on the SPL autoload stack
|
||||
*
|
||||
* @param string $ns The namespace to use.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
|
||||
|
||||
spl_autoload_register(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base include path for all class files in the namespace of this class loader.
|
||||
*
|
||||
* @return string $includePath
|
||||
*/
|
||||
public function getIncludePaths()
|
||||
{
|
||||
return $this->includePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* register a determinated namespace and its include path to find it.
|
||||
*
|
||||
* @param string $namespace namespace of a class given
|
||||
* @param string $includePath path where the class exists
|
||||
* @param string $excludeNsPart contais a part of class to exclude from classname passed by SPL hanlder
|
||||
*/
|
||||
public function register($namespace, $includePath)
|
||||
{
|
||||
$this->includePaths[$namespace] = rtrim($includePath, DS) . DS;
|
||||
}
|
||||
|
||||
public function registerClass($classname, $includeFile)
|
||||
{
|
||||
$includeFile = strpos($includeFile, '.php') !== false ? $includeFile : $includeFile . '.php';
|
||||
$classname = strtolower($classname);
|
||||
|
||||
if (! file_exists($includeFile)) {
|
||||
throw new Exception("Error, Autoloader can't register a inexisten file: " . $includeFile);
|
||||
}
|
||||
|
||||
if (strpos($classname, '*') !== false) {
|
||||
$tmp = str_replace('*', '(.+)', $classname);
|
||||
$this->relativeIncludePaths[$tmp] = $includeFile;
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_key_exists($classname, $this->includeClassPaths)) {
|
||||
throw new Exception("Error, class '%s' is already registered in Autoloader.");
|
||||
}
|
||||
|
||||
$this->includeClassPaths[$classname] = strpos($includeFile, '.php') !== false ? $includeFile : $includeFile . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls this class loader from the SPL autoloader stack.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $className The name of the class to load.
|
||||
* @return void
|
||||
*/
|
||||
protected function loadClass($class)
|
||||
{
|
||||
$className = strtolower($class);
|
||||
|
||||
if (array_key_exists($className, $this->includeClassPaths)) {
|
||||
require_once $this->includeClassPaths[$className];
|
||||
return true;
|
||||
} else {
|
||||
foreach ($this->relativeIncludePaths as $relClassname => $includeFile) {
|
||||
if ($r = preg_match('/'.$relClassname.'/', $className, $match)) {
|
||||
require_once $includeFile;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filename = str_replace('_', DS, $class) . '.php';
|
||||
|
||||
foreach ($this->includePaths as $namespace => $includePath) {
|
||||
//var_dump($includePath . $filename);
|
||||
if (file_exists($includePath . $filename)) {
|
||||
require_once $includePath . $filename;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
88
gulliver/core/Bootstrap.php
Normal file
88
gulliver/core/Bootstrap.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
public $startingTime;
|
||||
public $autoloader;
|
||||
public $routes = array();
|
||||
|
||||
protected $matchRoute = array();
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->startingTime = microtime(true);
|
||||
|
||||
// Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/'
|
||||
define('PATH_SEP', DIRECTORY_SEPARATOR);
|
||||
|
||||
$config['path_trunk'] = rtrim($config['path_trunk'], PATH_SEP) . PATH_SEP;
|
||||
|
||||
if (! array_key_exists('path_trunk', $config)) {
|
||||
throw new Exception("path_trunk config not defined!");
|
||||
}
|
||||
|
||||
if (! is_dir($config['path_trunk'] . 'gulliver')) {
|
||||
throw new Exception(sprintf(
|
||||
"Gulliver Framework not found in path trunk: '%s'", $config['path_trunk']
|
||||
));
|
||||
}
|
||||
|
||||
define('PATH_TRUNK', $config['path_trunk']);
|
||||
|
||||
// Including these files we get the PM paths and definitions (that should be just one file.
|
||||
require_once PATH_TRUNK . 'gulliver/core/Autoloader.php';
|
||||
|
||||
$this->autoloader = Autoloader::getInstance();
|
||||
}
|
||||
|
||||
public function addRoute($name, $pattern, $basePath, $type = '', $skip = false)
|
||||
{
|
||||
$this->routes[$name] = array(
|
||||
'pattern' => $pattern,
|
||||
'basePath' => $basePath,
|
||||
'type' => $type,
|
||||
'skip' => $skip
|
||||
);
|
||||
}
|
||||
|
||||
public function route($uri)
|
||||
{
|
||||
foreach ($this->routes as $name => $route) {
|
||||
//$urlPattern = addcslashes( $urlPattern , '/'); ???
|
||||
$route['pattern'] = addcslashes( $route['pattern'] , './');
|
||||
$route['pattern'] = '/^' . str_replace(array('*','?'), array('.*','.?'), $route['pattern']) . '$/';
|
||||
|
||||
// remove url GET params '..?var=val&....'
|
||||
list($uri, ) = explode('?', $uri);
|
||||
|
||||
if (preg_match($route['pattern'], $uri, $match)) {
|
||||
$this->matchRoute = $route;
|
||||
$this->matchRoute['name'] = $name;
|
||||
$this->matchRoute['match'] = $match[1];
|
||||
$this->matchRoute['path'] = $this->matchRoute['basePath'] . $match[1];
|
||||
|
||||
return $route['skip'] ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getMatchRoute()
|
||||
{
|
||||
return $this->matchRoute;
|
||||
}
|
||||
|
||||
public function dispatchResource()
|
||||
{
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
}
|
||||
|
||||
protected function registerClasses()
|
||||
{
|
||||
$this->autoloader->registerClass('G', PATH_TRUNK . 'gulliver/system/class.g');
|
||||
}
|
||||
}
|
||||
@@ -2814,7 +2814,7 @@ $output = $outputHeader.$output;
|
||||
/**
|
||||
* Generate a numeric or alphanumeric code
|
||||
*
|
||||
* @author Julio Cesar Laura Avenda𭞼juliocesar@colosa.com>
|
||||
* @author Julio Cesar Laura Avendaힼjuliocesar@colosa.com>
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
@@ -5182,7 +5182,10 @@ function getDirectorySize($path,$maxmtime=0)
|
||||
|
||||
// getting all services class
|
||||
$srvClasses = glob(PATH_SERVICES_REST . '*.php');
|
||||
$crudClasses = glob(PATH_SERVICES_REST . 'crud/*.php');
|
||||
|
||||
$srvClasses = array_merge($srvClasses, $crudClasses);
|
||||
|
||||
foreach ($srvClasses as $classFile) {
|
||||
require_once $classFile;
|
||||
|
||||
|
||||
11
gulliver/thirdparty/Haanga/.travis.yml
vendored
Normal file
11
gulliver/thirdparty/Haanga/.travis.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
language: php
|
||||
script: cd tests/; phpunit TestSuite.php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
before_script:
|
||||
- curl -s http://getcomposer.org/installer | php
|
||||
- php composer.phar install
|
||||
|
||||
30
gulliver/thirdparty/Haanga/LICENSE
vendored
Normal file
30
gulliver/thirdparty/Haanga/LICENSE
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
Copyright (c) 2011, César D. Rodas <crodas@php.net> and Menéame Comunicacions S.L.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
This product includes software developed by César D. Rodas.
|
||||
|
||||
4. Neither the name of the Menéame Comunicacions S.L. nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY MENÉAME COMUNICACIONS S.L. ''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 CÉSAR D. RODAS 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
|
||||
17
gulliver/thirdparty/Haanga/Makefile
vendored
Normal file
17
gulliver/thirdparty/Haanga/Makefile
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
all: build test
|
||||
|
||||
build:
|
||||
#plex lib/Haanga/Compiler/Lexer.lex
|
||||
phplemon lib/Haanga/Compiler/Parser.y
|
||||
|
||||
|
||||
test:
|
||||
cd tests; ~/bin/php-5.2/bin/php /usr/bin/phpunit --colors --verbose TestSuite.php
|
||||
cd tests; php /usr/bin/phpunit --coverage-html coverage/ --colors --verbose TestSuite.php
|
||||
|
||||
test-fast:
|
||||
cd tests; php /usr/bin/phpunit --stop-on-failure --colors --verbose TestSuite.php
|
||||
|
||||
|
||||
edit:
|
||||
vim lib/Haanga/Compiler/Parser.y lib/Haanga/Compiler/Tokenizer.php -O
|
||||
3
gulliver/thirdparty/Haanga/README
vendored
Normal file
3
gulliver/thirdparty/Haanga/README
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
This project was created* and sponsored by Menéame (http://meneame.net/)
|
||||
|
||||
[*] http://twitter.com/gallir/status/16256084676
|
||||
11
gulliver/thirdparty/Haanga/contrib/dummy.php
vendored
Normal file
11
gulliver/thirdparty/Haanga/contrib/dummy.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
Class Haanga_Extension_Tag_Dummy
|
||||
{
|
||||
public $is_block = TRUE;
|
||||
|
||||
static function main($html)
|
||||
{
|
||||
return strtolower($html);
|
||||
}
|
||||
}
|
||||
45
gulliver/thirdparty/Haanga/contrib/meneame_pagination.php
vendored
Normal file
45
gulliver/thirdparty/Haanga/contrib/meneame_pagination.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_MeneamePagination
|
||||
{
|
||||
public $is_block = FALSE;
|
||||
|
||||
static function generator($cmp, $args, $redirected)
|
||||
{
|
||||
if (count($args) != 3 && count($args) != 4) {
|
||||
throw new Haanga_CompilerException("Memeame_Pagination requires 3 or 4 parameters");
|
||||
}
|
||||
|
||||
if (count($args) == 3) {
|
||||
$args[3] = 5;
|
||||
}
|
||||
|
||||
$current = hvar('mnm_current');
|
||||
$total = hvar('mnm_total');
|
||||
$start = hvar('mnm_start');
|
||||
$end = hvar('mnm_end');
|
||||
$prev = hvar('mnm_prev');
|
||||
$next = hvar('mnm_next');
|
||||
$pages = 'mnm_pages';
|
||||
|
||||
$code = hcode();
|
||||
|
||||
$code->decl($current, $args[0]);
|
||||
$code->decl($total, hexec('ceil', hexpr($args[2], '/', $args[1])) );
|
||||
$code->decl($start, hexec('max', hexpr($current, '-', hexec('intval', hexpr($args[3],'/', 2))), 1));
|
||||
$code->decl($end, hexpr($start, '+', $args[3], '-', 1));
|
||||
$code->decl($prev, hexpr_cond( hexpr(1, '==', $current), FALSE, hexpr($current, '-', 1)) );
|
||||
$code->decl($next, hexpr_cond( hexpr($args[2], '<', 0, '||', $current, '<', $total), hexpr($current, '+', 1), FALSE));
|
||||
$code->decl('mnm_pages', hexec('range', $start, hexpr_cond(hexpr($end,'<', $total), $end, $total)));
|
||||
|
||||
$cmp->set_safe($current);
|
||||
$cmp->set_safe($total);
|
||||
$cmp->set_safe($prev);
|
||||
$cmp->set_safe($next);
|
||||
$cmp->set_safe($pages);
|
||||
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
8
gulliver/thirdparty/Haanga/haanga-cli.php
vendored
Normal file
8
gulliver/thirdparty/Haanga/haanga-cli.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__)."/lib/Haanga.php";
|
||||
|
||||
Haanga::registerAutoload();
|
||||
|
||||
Haanga_Compiler::main_cli();
|
||||
427
gulliver/thirdparty/Haanga/lib/Haanga.php
vendored
Normal file
427
gulliver/thirdparty/Haanga/lib/Haanga.php
vendored
Normal file
@@ -0,0 +1,427 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
if (!defined('HAANGA_VERSION')) {
|
||||
/* anyone can override this value to force recompilation */
|
||||
define('HAANGA_VERSION', '1.0.4');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Haanga Runtime class
|
||||
*
|
||||
* Simple class to call templates efficiently. This class aims
|
||||
* to reduce the compilation of a template as less a possible. Also
|
||||
* it will not load in memory the compiler, except when there is not
|
||||
* cache (compiled template) or it is out-dated.
|
||||
*
|
||||
*/
|
||||
class Haanga
|
||||
{
|
||||
protected static $cache_dir;
|
||||
protected static $templates_dir='.';
|
||||
protected static $debug;
|
||||
protected static $bootstrap = NULL;
|
||||
protected static $check_ttl;
|
||||
protected static $check_get;
|
||||
protected static $check_set;
|
||||
protected static $use_autoload = TRUE;
|
||||
protected static $hash_filename = TRUE;
|
||||
protected static $compiler = array();
|
||||
|
||||
public static $has_compiled;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
/* The class can't be instanced */
|
||||
}
|
||||
|
||||
public static function getTemplateDir()
|
||||
{
|
||||
return self::$templates_dir;
|
||||
}
|
||||
|
||||
// configure(Array $opts) {{{
|
||||
/**
|
||||
* Configuration to load Haanga
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - (string) cache_dir
|
||||
* - (string) tempalte_dir
|
||||
* - (callback) on_compile
|
||||
* - (boolean) debug
|
||||
* - (int) check_ttl
|
||||
* - (callback) check_get
|
||||
* - (callback) check_set
|
||||
* - (boolean) autoload
|
||||
* - (boolean) use_hash_filename
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
final public static function configure(Array $opts)
|
||||
{
|
||||
foreach ($opts as $option => $value) {
|
||||
switch (strtolower($option)) {
|
||||
case 'cache_dir':
|
||||
self::$cache_dir = $value;
|
||||
break;
|
||||
case 'template_dir':
|
||||
self::$templates_dir = $value;
|
||||
break;
|
||||
case 'bootstrap':
|
||||
if (is_callable($value)) {
|
||||
self::$bootstrap = $value;
|
||||
}
|
||||
break;
|
||||
case 'debug':
|
||||
self::enableDebug((bool)$value);
|
||||
break;
|
||||
case 'check_ttl':
|
||||
self::$check_ttl = (int)$value;
|
||||
break;
|
||||
case 'check_get':
|
||||
if (is_callable($value)) {
|
||||
self::$check_get = $value;
|
||||
}
|
||||
break;
|
||||
case 'check_set':
|
||||
if (is_callable($value)) {
|
||||
self::$check_set = $value;
|
||||
}
|
||||
break;
|
||||
case 'autoload':
|
||||
self::$use_autoload = (bool)$value;
|
||||
break;
|
||||
case 'use_hash_filename':
|
||||
self::$hash_filename = (bool)$value;
|
||||
break;
|
||||
case 'compiler':
|
||||
if (is_array($value)) {
|
||||
self::$compiler = $value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// checkCacheDir(string $dir) {{{
|
||||
/**
|
||||
* Check the directory where the compiled templates
|
||||
* are stored.
|
||||
*
|
||||
* @param string $dir
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function checkCacheDir()
|
||||
{
|
||||
$dir = self::$cache_dir;
|
||||
if (!is_dir($dir)) {
|
||||
$old = umask(0);
|
||||
if (!mkdir($dir, 0777, TRUE)) {
|
||||
throw new Haanga_Exception("{$dir} is not a valid directory");
|
||||
}
|
||||
umask($old);
|
||||
}
|
||||
if (!is_writable($dir)) {
|
||||
throw new Haanga_Exception("{$dir} can't be written");
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// enableDebug($bool) {{{
|
||||
public static function enableDebug($bool)
|
||||
{
|
||||
self::$debug = $bool;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// getCompiler($checkdir=TRUE) {{{
|
||||
/**
|
||||
* This function is a singleton for the Haanga_Compiler_Runtime class.
|
||||
* The instance is already set up properly and resetted.
|
||||
*
|
||||
*
|
||||
* @param bool $checkdir TRUE
|
||||
*
|
||||
* @return Haanga_Compiler_Runtime
|
||||
*/
|
||||
protected static function getCompiler($checkdir=TRUE)
|
||||
{
|
||||
static $compiler;
|
||||
static $has_checkdir = FALSE;
|
||||
|
||||
if (!$compiler) {
|
||||
|
||||
/* Load needed files (to avoid autoload as much as possible) */
|
||||
$dir = dirname(__FILE__);
|
||||
require_once "{$dir}/Haanga/AST.php";
|
||||
require_once "{$dir}/Haanga/Compiler.php";
|
||||
require_once "{$dir}/Haanga/Compiler/Runtime.php";
|
||||
require_once "{$dir}/Haanga/Compiler/Parser.php";
|
||||
require_once "{$dir}/Haanga/Compiler/Tokenizer.php";
|
||||
require_once "{$dir}/Haanga/Generator/PHP.php";
|
||||
require_once "{$dir}/Haanga/Extension.php";
|
||||
require_once "{$dir}/Haanga/Extension/Filter.php";
|
||||
require_once "{$dir}/Haanga/Extension/Tag.php";
|
||||
|
||||
/* load compiler (done just once) */
|
||||
if (self::$use_autoload) {
|
||||
require_once "{$dir}/Haanga/Loader.php";
|
||||
}
|
||||
|
||||
$compiler = new Haanga_Compiler_Runtime;
|
||||
|
||||
if (self::$bootstrap) {
|
||||
/* call bootstrap hook, just the first time */
|
||||
call_user_func(self::$bootstrap);
|
||||
}
|
||||
|
||||
if (count(self::$compiler) != 0) {
|
||||
foreach (self::$compiler as $opt => $value) {
|
||||
Haanga_Compiler::setOption($opt, $value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($checkdir && !$has_checkdir) {
|
||||
self::checkCacheDir();
|
||||
$has_checkdir = TRUE;
|
||||
}
|
||||
|
||||
$compiler->reset();
|
||||
return $compiler;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// callback compile(string $tpl, $context=array()) {{{
|
||||
/**
|
||||
* Compile one template and return a PHP function
|
||||
*
|
||||
* @param string $tpl Template body
|
||||
* @param array $context Context variables useful to generate efficient code (for array, objects and array)
|
||||
*
|
||||
* @return callback($vars=array(), $return=TRUE, $block=array())
|
||||
*/
|
||||
public static function compile($tpl, $context=array())
|
||||
{
|
||||
$compiler = self::getCompiler(FALSE);
|
||||
|
||||
foreach ($context as $var => $value) {
|
||||
$compiler->set_context($var, $value);
|
||||
}
|
||||
|
||||
$code = $compiler->compile($tpl);
|
||||
|
||||
return create_function('$' . $compiler->getScopeVariable(NULL, TRUE) . '=array(), $return=TRUE, $blocks=array()', $code);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// safe_load(string $file, array $vars, bool $return, array $blocks) {{{
|
||||
public static function Safe_Load($file, $vars = array(), $return=FALSE, $blocks=array())
|
||||
{
|
||||
try {
|
||||
|
||||
$tpl = self::$templates_dir.'/'.$file;
|
||||
if (file_exists($tpl)) {
|
||||
/* call load if the tpl file exists */
|
||||
return self::Load($file, $vars, $return, $blocks);
|
||||
}
|
||||
} Catch (Exception $e) {
|
||||
}
|
||||
/* some error but we don't care at all */
|
||||
return "";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// load(string $file, array $vars, bool $return, array $blocks) {{{
|
||||
/**
|
||||
* Load
|
||||
*
|
||||
* Load template. If the template is already compiled, just the compiled
|
||||
* PHP file will be included an used. If the template is new, or it
|
||||
* had changed, the Haanga compiler is loaded in memory, and the template
|
||||
* is compiled.
|
||||
*
|
||||
*
|
||||
* @param string $file
|
||||
* @param array $vars
|
||||
* @param bool $return
|
||||
* @param array $blocks
|
||||
*
|
||||
* @return string|NULL
|
||||
*/
|
||||
public static function Load($file, $vars = array(), $return=FALSE, $blocks=array())
|
||||
{
|
||||
if (empty(self::$cache_dir)) {
|
||||
throw new Haanga_Exception("Cache dir or template dir is missing");
|
||||
}
|
||||
|
||||
self::$has_compiled = FALSE;
|
||||
|
||||
$tpl = self::$templates_dir.'/'.$file;
|
||||
$fnc = sha1($tpl);
|
||||
$callback = "haanga_".$fnc;
|
||||
|
||||
if (is_callable($callback)) {
|
||||
return $callback($vars, $return, $blocks);
|
||||
}
|
||||
|
||||
$php = self::$hash_filename ? $fnc : $file;
|
||||
$php = self::$cache_dir.'/'.$php.'.php';
|
||||
|
||||
$check = TRUE;
|
||||
|
||||
if (self::$check_ttl && self::$check_get && self::$check_set) {
|
||||
/* */
|
||||
if (call_user_func(self::$check_get, $callback)) {
|
||||
/* disable checking for the next $check_ttl seconds */
|
||||
$check = FALSE;
|
||||
} else {
|
||||
$result = call_user_func(self::$check_set, $callback, TRUE, self::$check_ttl);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_file($php) || ($check && filemtime($tpl) > filemtime($php))) {
|
||||
|
||||
if (!is_file($tpl)) {
|
||||
/* There is no template nor compiled file */
|
||||
throw new Exception("View {$file} doesn't exists");
|
||||
}
|
||||
|
||||
if (!is_dir(dirname($php))) {
|
||||
$old = umask(0);
|
||||
mkdir(dirname($php), 0777, TRUE);
|
||||
umask($old);
|
||||
}
|
||||
|
||||
$fp = fopen($php, "a+");
|
||||
/* try to block PHP file */
|
||||
if (!flock($fp, LOCK_EX | LOCK_NB)) {
|
||||
/* couldn't block, another process is already compiling */
|
||||
fclose($fp);
|
||||
if (is_file($php)) {
|
||||
/*
|
||||
** if there is an old version of the cache
|
||||
** load it
|
||||
*/
|
||||
require $php;
|
||||
if (is_callable($callback)) {
|
||||
return $callback($vars, $return, $blocks);
|
||||
}
|
||||
}
|
||||
/*
|
||||
** no luck, probably the template is new
|
||||
** the compilation will be done, but we won't
|
||||
** save it (we'll use eval instead)
|
||||
*/
|
||||
unset($fp);
|
||||
}
|
||||
|
||||
/* recompile */
|
||||
$compiler = self::getCompiler();
|
||||
|
||||
if (self::$debug) {
|
||||
$compiler->setDebug($php.".dump");
|
||||
}
|
||||
|
||||
try {
|
||||
$code = $compiler->compile_file($tpl, FALSE, $vars);
|
||||
} catch (Exception $e) {
|
||||
if (isset($fp)) {
|
||||
/*
|
||||
** set the $php file as old (to force future
|
||||
** recompilation)
|
||||
*/
|
||||
touch($php, 300, 300);
|
||||
chmod($php, 0777);
|
||||
}
|
||||
/* re-throw exception */
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (isset($fp)) {
|
||||
ftruncate($fp, 0); // truncate file
|
||||
fwrite($fp, "<?php".$code);
|
||||
flock($fp, LOCK_UN); // release the lock
|
||||
fclose($fp);
|
||||
} else {
|
||||
/* local eval */
|
||||
eval($code);
|
||||
}
|
||||
|
||||
self::$has_compiled = TRUE;
|
||||
}
|
||||
|
||||
if (!is_callable($callback)) {
|
||||
/* Load the cached PHP file */
|
||||
require $php;
|
||||
if (!is_callable($callback)) {
|
||||
/*
|
||||
really weird case ($php is empty, another process is compiling
|
||||
the $tpl for the first time), so create a lambda function
|
||||
for the template
|
||||
*/
|
||||
$lambda= self::compile(file_get_contents($tpl), $vars);
|
||||
return $lambda($vars, $return, $blocks);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($HAANGA_VERSION) || $HAANGA_VERSION != HAANGA_VERSION) {
|
||||
touch($php, 300, 300);
|
||||
chmod($php, 0777);
|
||||
}
|
||||
|
||||
return $callback($vars, $return, $blocks);
|
||||
}
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
545
gulliver/thirdparty/Haanga/lib/Haanga/AST.php
vendored
Normal file
545
gulliver/thirdparty/Haanga/lib/Haanga/AST.php
vendored
Normal file
@@ -0,0 +1,545 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple AST (abstract syntax tree) helper class. This
|
||||
* helps to generate array structure that is then translated by
|
||||
* the Haanga_Generator class.
|
||||
*
|
||||
*/
|
||||
class Haanga_AST
|
||||
{
|
||||
public $stack = array();
|
||||
public $current = array();
|
||||
public $doesPrint = FALSE;
|
||||
|
||||
|
||||
// getLast() {{{
|
||||
/**
|
||||
* Return a refernce to the last element
|
||||
* of the AST stack.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function & getLast()
|
||||
{
|
||||
$f = array();
|
||||
if (count($this->stack) == 0) {
|
||||
return $f;
|
||||
}
|
||||
return $this->stack[count($this->stack)-1];
|
||||
}
|
||||
// }}}
|
||||
|
||||
|
||||
static protected function check_type($obj, $type)
|
||||
{
|
||||
if (is_string($obj)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (is_object($obj)) {
|
||||
$obj = $obj->getArray();
|
||||
}
|
||||
return isset($obj[$type]);
|
||||
}
|
||||
|
||||
public static function is_str($arr)
|
||||
{
|
||||
return self::check_type($arr, 'string');
|
||||
}
|
||||
|
||||
public static function is_var($arr)
|
||||
{
|
||||
return self::check_type($arr, 'var');
|
||||
}
|
||||
|
||||
public static function is_exec($arr)
|
||||
{
|
||||
return self::check_type($arr, 'exec');
|
||||
}
|
||||
|
||||
public static function is_expr($arr)
|
||||
{
|
||||
return self::check_type($arr, 'op_expr');
|
||||
}
|
||||
|
||||
|
||||
public static function str($string)
|
||||
{
|
||||
return array("string" => $string);
|
||||
}
|
||||
|
||||
public static function num($number)
|
||||
{
|
||||
return array("number" => $number);
|
||||
}
|
||||
|
||||
function stack_size()
|
||||
{
|
||||
return count($this->stack);
|
||||
}
|
||||
|
||||
function append_ast(Haanga_AST $obj)
|
||||
{
|
||||
$this->end();
|
||||
$obj->end();
|
||||
$this->stack = array_merge($this->stack, $obj->stack);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
static function constant($str)
|
||||
{
|
||||
return array('constant' => $str);
|
||||
}
|
||||
|
||||
function comment($str)
|
||||
{
|
||||
$this->stack[] = array("op" => "comment", 'comment' => $str);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function declare_function($name)
|
||||
{
|
||||
$this->stack[] = array('op' => 'function', 'name' => $name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_return($name)
|
||||
{
|
||||
$this->getValue($name, $expr);
|
||||
$this->stack[] = array('op' => 'return', $expr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_if($expr)
|
||||
{
|
||||
$this->getValue($expr, $vexpr);
|
||||
$this->stack[] = array('op' => 'if', 'expr' => $vexpr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_else()
|
||||
{
|
||||
$this->stack[] = array('op' => 'else');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_endif()
|
||||
{
|
||||
$this->stack[] = array('op' => 'end_if');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_endfunction()
|
||||
{
|
||||
$this->stack[] = array('op' => 'end_function');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function v()
|
||||
{
|
||||
$var = array();
|
||||
foreach (func_get_args() as $id => $def) {
|
||||
if ($id == 0) {
|
||||
$var[$id] = $def;
|
||||
} else {
|
||||
$this->getValue($def, $value);
|
||||
$var[$id] = $value;
|
||||
}
|
||||
}
|
||||
if (count($var) == 1) {
|
||||
$var = $var[0];
|
||||
}
|
||||
$this->current = array('var' => $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
final function __get($property)
|
||||
{
|
||||
$property = strtolower($property);
|
||||
if (isset($this->current[$property])) {
|
||||
return $this->current[$property];
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static function fromArrayGetAST($obj)
|
||||
{
|
||||
$class = __CLASS__;
|
||||
if ($obj InstanceOf $class) {
|
||||
return $obj;
|
||||
}
|
||||
foreach (array('op_expr', 'expr_cond', 'exec', 'var', 'string', 'number', 'constant') as $type) {
|
||||
if (isset($obj[$type])) {
|
||||
$nobj = new $class;
|
||||
$nobj->stack[] = $obj;
|
||||
return $nobj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function getValue($obj, &$value, $get_all=FALSE)
|
||||
{
|
||||
$class = __CLASS__;
|
||||
|
||||
if ($obj InstanceOf $class) {
|
||||
$value = $obj->getArray($get_all);
|
||||
} else if (is_string($obj)) {
|
||||
$value = self::str($obj);
|
||||
} else if (is_numeric($obj) or $obj === 0) {
|
||||
$value = self::num($obj);
|
||||
} else if ($obj === FALSE) {
|
||||
$value = array('expr' => FALSE);
|
||||
} else if ($obj === TRUE) {
|
||||
$value = array('expr' => TRUE);
|
||||
} else if (is_array($obj)) {
|
||||
foreach (array('op_expr', 'exec', 'var', 'string', 'number', 'constant') as $type) {
|
||||
if (isset($obj[$type])) {
|
||||
$value = $obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
$h = hcode()->arr();
|
||||
$first = 0;
|
||||
foreach($obj as $key => $value) {
|
||||
if ($key === $first) {
|
||||
$key = NULL;
|
||||
$first++;
|
||||
}
|
||||
$h->element($key, $value);
|
||||
}
|
||||
$value = $h->getArray();
|
||||
} else if ($obj === NULL) {
|
||||
$value = array();
|
||||
} else {
|
||||
var_Dump($obj);
|
||||
throw new Exception("Imposible to get the value of the object");
|
||||
}
|
||||
}
|
||||
|
||||
function getArray($get_all=FALSE)
|
||||
{
|
||||
$this->end();
|
||||
if ($get_all) {
|
||||
return $this->stack;
|
||||
}
|
||||
return isset($this->stack[0]) ? $this->stack[0] : NULL;
|
||||
}
|
||||
|
||||
function do_for($index, $min, $max, $step, Haanga_AST $body)
|
||||
{
|
||||
$def = array(
|
||||
'op' => 'for',
|
||||
'index' => $index,
|
||||
'min' => $min,
|
||||
'max' => $max,
|
||||
'step' => $step,
|
||||
);
|
||||
|
||||
$this->stack[] = $def;
|
||||
$this->stack = array_merge($this->stack, $body->getArray(TRUE));
|
||||
$this->stack[] = array('op' => 'end_for');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_foreach($array, $value, $key, Haanga_AST $body)
|
||||
{
|
||||
foreach (array('array', 'value', 'key') as $var) {
|
||||
if ($$var === NULL) {
|
||||
continue;
|
||||
}
|
||||
$var1 = & $$var;
|
||||
if (is_string($var1)) {
|
||||
$var1 = hvar($var1);
|
||||
}
|
||||
if (is_object($var1)) {
|
||||
$var1 = $var1->getArray();
|
||||
}
|
||||
if (empty($var1['var'])) {
|
||||
throw new Exception("Can't iterate, apparently $var isn't a variable");
|
||||
}
|
||||
$var1 = $var1['var'];
|
||||
}
|
||||
$def = array('op' => 'foreach', 'array' => $array, 'value' => $value);
|
||||
if ($key) {
|
||||
$def['key'] = $key;
|
||||
}
|
||||
$this->stack[] = $def;
|
||||
$this->stack = array_merge($this->stack, $body->getArray(TRUE));
|
||||
$this->stack[] = array('op' => 'end_foreach');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_echo($stmt)
|
||||
{
|
||||
$this->getValue($stmt, $value);
|
||||
$this->stack[] = array('op' => 'print', $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_global($array)
|
||||
{
|
||||
$this->stack[] = array('op' => 'global', 'vars' => $array);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function do_exec()
|
||||
{
|
||||
$params = func_get_args();
|
||||
$exec = call_user_func_array('hexec', $params);
|
||||
$this->stack[] = array('op' => 'expr', $exec->getArray());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function exec($function)
|
||||
{
|
||||
$this->current = array('exec' => $function, 'args' => array());
|
||||
foreach (func_get_args() as $id => $param) {
|
||||
if ($id > 0) {
|
||||
$this->param($param);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
function expr($operation, $term1, $term2=NULL)
|
||||
{
|
||||
$this->getValue($term1, $value1);
|
||||
if ($term2 !== NULL) {
|
||||
$this->getValue($term2, $value2);
|
||||
} else {
|
||||
$value2 = NULL;
|
||||
}
|
||||
$this->current = array('op_expr' => $operation, $value1, $value2);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function expr_cond($expr, $if_true, $if_false)
|
||||
{
|
||||
$this->getValue($expr, $vExpr);
|
||||
$this->getValue($if_true, $vIfTrue);
|
||||
$this->getValue($if_false, $vIfFalse);
|
||||
|
||||
$this->current = array('expr_cond' => $vExpr, 'true' => $vIfTrue, 'false' => $vIfFalse);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
function arr()
|
||||
{
|
||||
$this->current = array('array' => array());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function element($key=NULL, $value)
|
||||
{
|
||||
$last = & $this->current;
|
||||
|
||||
if (!isset($last['array'])) {
|
||||
throw new Exception("Invalid call to element()");
|
||||
}
|
||||
|
||||
$this->getValue($value, $val);
|
||||
if ($key !== NULL) {
|
||||
$this->getValue($key, $kval);
|
||||
$val = array('key' => array($kval, $val));
|
||||
}
|
||||
$last['array'][] = $val;
|
||||
}
|
||||
|
||||
function decl_raw($name, $value)
|
||||
{
|
||||
if (is_string($name)) {
|
||||
$name = hvar($name);
|
||||
}
|
||||
$this->getValue($name, $name);
|
||||
$array = array('op' => 'declare', 'name' => $name['var']);
|
||||
foreach (func_get_args() as $id => $value) {
|
||||
if ($id != 0) {
|
||||
$array[] = $value;
|
||||
}
|
||||
}
|
||||
$this->stack[] = $array;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function decl($name, $value)
|
||||
{
|
||||
if (is_string($name)) {
|
||||
$name = hvar($name);
|
||||
}
|
||||
$this->getValue($name, $name);
|
||||
$array = array('op' => 'declare', 'name' => $name['var']);
|
||||
foreach (func_get_args() as $id => $value) {
|
||||
if ($id != 0) {
|
||||
$this->getValue($value, $stmt);
|
||||
$array[] = $stmt;
|
||||
}
|
||||
}
|
||||
$this->stack[] = $array;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function append($name, $value)
|
||||
{
|
||||
if (is_string($name)) {
|
||||
$name = hvar($name);
|
||||
}
|
||||
$this->getValue($value, $stmt);
|
||||
$this->getValue($name, $name);
|
||||
$this->stack[] = array('op' => 'append_var', 'name' => $name['var'], $stmt);
|
||||
return $this;
|
||||
}
|
||||
|
||||
function param($param)
|
||||
{
|
||||
$last = & $this->current;
|
||||
|
||||
if (!isset($last['exec'])) {
|
||||
throw new Exception("Invalid call to param()");
|
||||
}
|
||||
|
||||
$this->getValue($param, $value);
|
||||
$last['args'][] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function end()
|
||||
{
|
||||
if (count($this->current) > 0) {
|
||||
$this->stack[] = $this->current;
|
||||
$this->current = array();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
function hcode()
|
||||
{
|
||||
return new Haanga_AST;
|
||||
}
|
||||
|
||||
function hexpr($term1, $op='expr', $term2=NULL, $op2=NULL)
|
||||
{
|
||||
$code = hcode();
|
||||
switch ($op2) {
|
||||
case '+':
|
||||
case '-':
|
||||
case '/':
|
||||
case '*':
|
||||
case '%':
|
||||
case '||':
|
||||
case '&&':
|
||||
case '<':
|
||||
case '>':
|
||||
case '<=':
|
||||
case '>=':
|
||||
case '==':
|
||||
case '!=':
|
||||
/* call recursive to resolve term2 */
|
||||
$args = func_get_args();
|
||||
$term2 = call_user_func_array('hexpr', array_slice($args, 2));
|
||||
break;
|
||||
}
|
||||
return $code->expr($op, $term1, $term2);
|
||||
}
|
||||
|
||||
function hexpr_cond($expr, $if_true, $if_false)
|
||||
{
|
||||
$code = hcode();
|
||||
$code->expr_cond($expr, $if_true, $if_false);
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
function hexec()
|
||||
{
|
||||
$code = hcode();
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($code, 'exec'), $args);
|
||||
}
|
||||
|
||||
function hconst($str)
|
||||
{
|
||||
return Haanga_AST::Constant($str);
|
||||
}
|
||||
|
||||
// hvar() {{{
|
||||
/**
|
||||
* Create the representation of a variable
|
||||
*
|
||||
* @return Haanga_AST
|
||||
*/
|
||||
function hvar()
|
||||
{
|
||||
$args = func_get_args();
|
||||
return hvar_ex($args);
|
||||
}
|
||||
|
||||
function hvar_ex($args)
|
||||
{
|
||||
$code = hcode();
|
||||
return call_user_func_array(array($code, 'v'), $args);
|
||||
}
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
1529
gulliver/thirdparty/Haanga/lib/Haanga/Compiler.php
vendored
Normal file
1529
gulliver/thirdparty/Haanga/lib/Haanga/Compiler.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
55
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Exception.php
vendored
Normal file
55
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Exception.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// Exception Class {{{
|
||||
/**
|
||||
* Exception class
|
||||
*
|
||||
*/
|
||||
class Haanga_Compiler_Exception extends Exception
|
||||
{
|
||||
}
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
2319
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Parser.php
vendored
Normal file
2319
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Parser.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
408
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Parser.y
vendored
Normal file
408
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Parser.y
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
%name Haanga_
|
||||
%include {
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
}
|
||||
|
||||
%declare_class { class Haanga_Compiler_Parser }
|
||||
%include_class {
|
||||
protected $lex;
|
||||
protected $file;
|
||||
|
||||
function __construct($lex, $file='')
|
||||
{
|
||||
$this->lex = $lex;
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
function Error($text)
|
||||
{
|
||||
throw new Haanga_Compiler_Exception($text.' in '.$this->file.':'.$this->lex->getLine());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%parse_accept {
|
||||
}
|
||||
|
||||
%right T_TAG_OPEN.
|
||||
%right T_NOT.
|
||||
%left T_AND.
|
||||
%left T_OR.
|
||||
%nonassoc T_EQ T_NE.
|
||||
%nonassoc T_GT T_GE T_LT T_LE.
|
||||
%nonassoc T_IN.
|
||||
%left T_PLUS T_MINUS T_CONCAT.
|
||||
%left T_TIMES T_DIV T_MOD.
|
||||
%left T_PIPE T_BITWISE.
|
||||
|
||||
%syntax_error {
|
||||
$expect = array();
|
||||
foreach ($this->yy_get_expected_tokens($yymajor) as $token) {
|
||||
$expect[] = self::$yyTokenName[$token];
|
||||
}
|
||||
$this->Error('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN. ')');
|
||||
}
|
||||
|
||||
|
||||
start ::= body(B). { $this->body = B; }
|
||||
|
||||
body(A) ::= body(B) code(C). { A=B; A[] = C; }
|
||||
body(A) ::= . { A = array(); }
|
||||
|
||||
/* List of statements */
|
||||
code(A) ::= T_TAG_OPEN stmts(B). { if (count(B)) B['line'] = $this->lex->getLine(); A = B; }
|
||||
|
||||
code(A) ::= T_HTML(B). {
|
||||
A = array('operation' => 'html', 'html' => B, 'line' => $this->lex->getLine() );
|
||||
}
|
||||
|
||||
code(A) ::= T_COMMENT(B). {
|
||||
B=rtrim(B); A = array('operation' => 'comment', 'comment' => B);
|
||||
}
|
||||
|
||||
code(A) ::= T_PRINT_OPEN expr(B) T_PRINT_CLOSE. {
|
||||
A = array('operation' => 'print_var', 'expr' => B, 'line' => $this->lex->getLine() );
|
||||
}
|
||||
|
||||
stmts(A) ::= T_EXTENDS var_or_string(B) T_TAG_CLOSE. { A = array('operation' => 'base', B); }
|
||||
stmts(A) ::= stmt(B) T_TAG_CLOSE. { A = B; }
|
||||
stmts(A) ::= for_stmt(B). { A = B; }
|
||||
stmts(A) ::= ifchanged_stmt(B). { A = B; }
|
||||
stmts(A) ::= block_stmt(B). { A = B; }
|
||||
stmts(A) ::= filter_stmt(B). { A = B; }
|
||||
stmts(A) ::= if_stmt(B). { A = B; }
|
||||
stmts(A) ::= T_INCLUDE var_or_string(B) T_TAG_CLOSE. { A = array('operation' => 'include', B); }
|
||||
stmts(A) ::= custom_tag(B). { A = B; }
|
||||
stmts(A) ::= alias(B). { A = B; }
|
||||
stmts(A) ::= ifequal(B). { A = B; }
|
||||
stmts(A) ::= T_AUTOESCAPE varname(B) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(E) T_TAG_CLOSE. {
|
||||
B = strtolower(B);
|
||||
if (B != 'on' && B != 'off') {
|
||||
$this->Error("Invalid autoescape param (".B."), it must be on or off");
|
||||
}
|
||||
if (E != "endautoescape") {
|
||||
$this->Error("Invalid close tag ".E.", it must be endautoescape");
|
||||
}
|
||||
A = array('operation' => 'autoescape', 'value' => B, 'body' => X);
|
||||
}
|
||||
|
||||
/* Statement */
|
||||
|
||||
/* CUSTOM TAGS */
|
||||
custom_tag(A) ::= T_CUSTOM_TAG(B) T_TAG_CLOSE. {
|
||||
A = array('operation' => 'custom_tag', 'name' => B, 'list'=>array());
|
||||
}
|
||||
custom_tag(A) ::= T_CUSTOM_TAG(B) T_AS varname(C) T_TAG_CLOSE. {
|
||||
A = array('operation' => 'custom_tag', 'name' => B, 'as' => C, 'list'=>array());
|
||||
}
|
||||
custom_tag(A) ::= T_CUSTOM_TAG(B) params(X) T_TAG_CLOSE. {
|
||||
A = array('operation' => 'custom_tag', 'name' => B, 'list' => X);
|
||||
}
|
||||
custom_tag(A) ::= T_CUSTOM_TAG(B) params(X) T_AS varname(C) T_TAG_CLOSE. {
|
||||
A = array('operation' => 'custom_tag', 'name' => B, 'as' => C, 'list' => X);
|
||||
}
|
||||
|
||||
/* tags as blocks */
|
||||
custom_tag(A) ::= T_CUSTOM_BLOCK(B) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(C) T_TAG_CLOSE. {
|
||||
if ('end'.B != C) {
|
||||
$this->error("Unexpected ".C);
|
||||
}
|
||||
A = array('operation' => 'custom_tag', 'name' => B, 'body' => X, 'list' => array());
|
||||
}
|
||||
custom_tag(A) ::= T_CUSTOM_BLOCK(B) params(L) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(C) T_TAG_CLOSE. {
|
||||
if ('end'.B != C) {
|
||||
$this->error("Unexpected ".C);
|
||||
}
|
||||
A = array('operation' => 'custom_tag', 'name' => B, 'body' => X, 'list' => L);
|
||||
}
|
||||
|
||||
/* Spacefull is very special, and it is handled in the compiler class */
|
||||
custom_tag(A) ::= T_SPACEFULL T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(C) T_TAG_CLOSE. {
|
||||
if ('endspacefull' != C) {
|
||||
$this->error("Unexpected ".C);
|
||||
}
|
||||
A = array('operation' => 'spacefull', 'body' => X);
|
||||
}
|
||||
|
||||
/* variable alias (easier to handle in the compiler class) */
|
||||
alias(A) ::= T_WITH varname(B) T_AS varname(C) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endwith") {
|
||||
$this->Error("Unexpected ".Z.", expecting endwith");
|
||||
}
|
||||
A = array('operation' => 'alias', 'var' => B, 'as' => C, 'body' => X);
|
||||
}
|
||||
|
||||
/* Simple statements (don't require a end_tag or a body ) */
|
||||
stmt(A) ::= T_SET varname(C) T_ASSIGN expr(X). { A = array('operation' => 'set', 'var' => C,'expr' => X); }
|
||||
stmt(A) ::= regroup(B). { A = B; }
|
||||
stmt ::= T_LOAD string(B). {
|
||||
if (!is_file(B) || !Haanga_Compiler::getOption('enable_load')) {
|
||||
$this->error(B." is not a valid file");
|
||||
}
|
||||
require_once B;
|
||||
}
|
||||
|
||||
/* FOR loop */
|
||||
|
||||
for_def(A) ::= T_FOR varname(B) T_IN filtered_var(C) T_TAG_CLOSE . {
|
||||
$var = $this->compiler->get_context(C[0]);
|
||||
if (is_array($var) || $var instanceof Iterator) {
|
||||
/* let's check if it is an object or array */
|
||||
$this->compiler->set_context(B, current($var));
|
||||
}
|
||||
A = array('operation' => 'loop', 'variable' => B, 'index' => NULL, 'array' => C);
|
||||
}
|
||||
|
||||
for_def(A) ::= T_FOR varname(I) T_COMMA varname(B) T_IN filtered_var(C) T_TAG_CLOSE . {
|
||||
$var = $this->compiler->get_context(C[0]);
|
||||
if (is_array($var) || $var instanceof Iterator) {
|
||||
/* let's check if it is an object or array */
|
||||
$this->compiler->set_context(B, current($var));
|
||||
}
|
||||
A = array('operation' => 'loop', 'variable' => B, 'index' => I, 'array' => C);
|
||||
|
||||
}
|
||||
|
||||
|
||||
for_stmt(A) ::= for_def(B) body(D) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endfor") {
|
||||
$this->Error("Unexpected ".Z.", expecting endfor");
|
||||
}
|
||||
A = B;
|
||||
A['body'] = D;
|
||||
}
|
||||
|
||||
for_stmt(A) ::= T_FOR varname(B) T_IN range(X) T_TAG_CLOSE body(E) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endfor") {
|
||||
$this->Error("Unexpected ".Z.", expecting endfor");
|
||||
}
|
||||
A = array('operation' => 'loop', 'variable' => B, 'range' => X, 'body' => E, 'variable' => B, 'step' => 1);
|
||||
}
|
||||
|
||||
for_stmt(A) ::= T_FOR varname(B) T_IN range(X) T_STEP numvar(S) T_TAG_CLOSE body(E) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endfor") {
|
||||
$this->Error("Unexpected ".Z.", expecting endfor");
|
||||
}
|
||||
A = array('operation' => 'loop', 'variable' => B, 'range' => X, 'body' => E, 'variable' => B, 'step' => S);
|
||||
}
|
||||
|
||||
for_stmt(A) ::= for_def(B) body(D) T_TAG_OPEN T_EMPTY T_TAG_CLOSE body(E) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endfor") {
|
||||
$this->Error("Unexpected ".Z.", expecting endfor");
|
||||
}
|
||||
A = B;
|
||||
A['body'] = D;
|
||||
A['empty'] = E;
|
||||
}
|
||||
/* IF */
|
||||
if_stmt(A) ::= T_IF expr(B) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endif") {
|
||||
$this->Error("Unexpected ".Z.", expecting endif");
|
||||
}
|
||||
A = array('operation' => 'if', 'expr' => B, 'body' => X);
|
||||
}
|
||||
if_stmt(A) ::= T_IF expr(B) T_TAG_CLOSE body(X) T_TAG_OPEN T_ELSE T_TAG_CLOSE body(Y) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endif") {
|
||||
$this->Error("Unexpected ".Z.", expecting endif");
|
||||
}
|
||||
A = array('operation' => 'if', 'expr' => B, 'body' => X, 'else' => Y);
|
||||
}
|
||||
|
||||
/* ifchanged */
|
||||
ifchanged_stmt(A) ::= T_IFCHANGED T_TAG_CLOSE body(B) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifchanged") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifchanged");
|
||||
}
|
||||
A = array('operation' => 'ifchanged', 'body' => B);
|
||||
}
|
||||
|
||||
ifchanged_stmt(A) ::= T_IFCHANGED params(X) T_TAG_CLOSE body(B) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifchanged") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifchanged");
|
||||
}
|
||||
A = array('operation' => 'ifchanged', 'body' => B, 'check' => X);
|
||||
}
|
||||
ifchanged_stmt(A) ::= T_IFCHANGED T_TAG_CLOSE body(B) T_TAG_OPEN T_ELSE T_TAG_CLOSE body(C) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifchanged") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifchanged");
|
||||
}
|
||||
A = array('operation' => 'ifchanged', 'body' => B, 'else' => C);
|
||||
}
|
||||
|
||||
ifchanged_stmt(A) ::= T_IFCHANGED params(X) T_TAG_CLOSE body(B) T_TAG_OPEN T_ELSE T_TAG_CLOSE body(C) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifchanged") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifchanged");
|
||||
}
|
||||
A = array('operation' => 'ifchanged', 'body' => B, 'check' => X, 'else' => C);
|
||||
}
|
||||
|
||||
/* ifequal */
|
||||
ifequal(A) ::= T_IFEQUAL fvar_or_string(B) fvar_or_string(C) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifequal") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifequal");
|
||||
}
|
||||
A = array('operation' => 'ifequal', 'cmp' => '==', 1 => B, 2 => C, 'body' => X);
|
||||
}
|
||||
ifequal(A) ::= T_IFEQUAL fvar_or_string(B) fvar_or_string(C) T_TAG_CLOSE body(X) T_TAG_OPEN T_ELSE T_TAG_CLOSE body(Y) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifequal") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifequal");
|
||||
}
|
||||
A = array('operation' => 'ifequal', 'cmp' => '==', 1 => B, 2 => C, 'body' => X, 'else' => Y);
|
||||
}
|
||||
ifequal(A) ::= T_IFNOTEQUAL fvar_or_string(B) fvar_or_string(C) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifnotequal") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifnotequal");
|
||||
}
|
||||
A = array('operation' => 'ifequal', 'cmp' => '!=', 1 => B, 2 => C, 'body' => X);
|
||||
}
|
||||
ifequal(A) ::= T_IFNOTEQUAL fvar_or_string(B) fvar_or_string(C) T_TAG_CLOSE body(X) T_TAG_OPEN T_ELSE T_TAG_CLOSE body(Y) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endifnotequal") {
|
||||
$this->Error("Unexpected ".Z.", expecting endifnotequal");
|
||||
}
|
||||
A = array('operation' => 'ifequal', 'cmp' => '!=', 1 => B, 2 => C, 'body' => X, 'else' => Y);
|
||||
}
|
||||
|
||||
/* block stmt */
|
||||
block_stmt(A) ::= T_BLOCK varname(B) T_TAG_CLOSE body(C) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endblock") {
|
||||
$this->Error("Unexpected ".Z.", expecting endblock");
|
||||
}
|
||||
A = array('operation' => 'block', 'name' => B, 'body' => C);
|
||||
}
|
||||
|
||||
block_stmt(A) ::= T_BLOCK varname(B) T_TAG_CLOSE body(C) T_TAG_OPEN T_CUSTOM_END(Z) varname T_TAG_CLOSE. {
|
||||
if (Z != "endblock") {
|
||||
$this->Error("Unexpected ".Z.", expecting endblock");
|
||||
}
|
||||
A = array('operation' => 'block', 'name' => B, 'body' => C);
|
||||
}
|
||||
|
||||
block_stmt(A) ::= T_BLOCK number(B) T_TAG_CLOSE body(C) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endblock") {
|
||||
$this->Error("Unexpected ".Z.", expecting endblock");
|
||||
}
|
||||
A = array('operation' => 'block', 'name' => B, 'body' => C);
|
||||
}
|
||||
|
||||
block_stmt(A) ::= T_BLOCK number(B) T_TAG_CLOSE body(C) T_TAG_OPEN T_CUSTOM_END(Z) number T_TAG_CLOSE. {
|
||||
if (Z != "endblock") {
|
||||
$this->Error("Unexpected ".Z.", expecting endblock");
|
||||
}
|
||||
A = array('operation' => 'block', 'name' => B, 'body' => C);
|
||||
}
|
||||
|
||||
/* filter stmt */
|
||||
filter_stmt(A) ::= T_FILTER filtered_var(B) T_TAG_CLOSE body(X) T_TAG_OPEN T_CUSTOM_END(Z) T_TAG_CLOSE. {
|
||||
if (Z != "endfilter") {
|
||||
$this->Error("Unexpected ".Z.", expecting endfilter");
|
||||
}
|
||||
A = array('operation' => 'filter', 'functions' => B, 'body' => X);
|
||||
}
|
||||
|
||||
/* regroup stmt */
|
||||
regroup(A) ::= T_REGROUP filtered_var(B) T_BY varname(C) T_AS varname(X). { A=array('operation' => 'regroup', 'array' => B, 'row' => C, 'as' => X); }
|
||||
|
||||
/* variables with filters */
|
||||
filtered_var(A) ::= filtered_var(B) T_PIPE varname_args(C). { A = B; A[] = C; }
|
||||
filtered_var(A) ::= varname_args(B). { A = array(B); }
|
||||
|
||||
varname_args(A) ::= varname(B) T_COLON var_or_string(X) . { A = array(B, 'args'=>array(X)); }
|
||||
varname_args(A) ::= varname(B). { A = B; }
|
||||
|
||||
/* List of variables */
|
||||
params(A) ::= params(B) var_or_string(C). { A = B; A[] = C; }
|
||||
params(A) ::= params(B) T_COMMA var_or_string(C). { A = B; A[] = C; }
|
||||
params(A) ::= var_or_string(B). { A = array(B); }
|
||||
|
||||
|
||||
/* variable or string (used on params) */
|
||||
var_or_string(A) ::= varname(B). { A = array('var' => B); }
|
||||
var_or_string(A) ::= number(B). { A = array('number' => B); }
|
||||
var_or_string(A) ::= T_TRUE|T_FALSE(B). { A = trim(@B); }
|
||||
var_or_string(A) ::= string(B). { A = array('string' => B); }
|
||||
|
||||
/* filtered variables */
|
||||
fvar_or_string(A) ::= filtered_var(B). { A = array('var_filter' => B); }
|
||||
fvar_or_string(A) ::= number(B). { A = array('number' => B); }
|
||||
fvar_or_string(A) ::= T_TRUE|T_FALSE(B). { A = trim(@B); }
|
||||
fvar_or_string(A) ::= string(B). { A = array('string' => B); }
|
||||
|
||||
/* */
|
||||
string(A) ::= T_STRING(B). { A = B; }
|
||||
string(A) ::= T_INTL T_STRING(B) T_RPARENT. { A = B; }
|
||||
|
||||
/* expr */
|
||||
expr(A) ::= T_NOT expr(B). { A = array('op_expr' => 'not', B); }
|
||||
expr(A) ::= expr(B) T_AND(X) expr(C). { A = array('op_expr' => @X, B, C); }
|
||||
expr(A) ::= expr(B) T_OR(X) expr(C). { A = array('op_expr' => @X, B, C); }
|
||||
expr(A) ::= expr(B) T_PLUS|T_MINUS|T_CONCAT(X) expr(C). { A = array('op_expr' => @X, B, C); }
|
||||
expr(A) ::= expr(B) T_EQ|T_NE|T_GT|T_GE|T_LT|T_LE|T_IN(X) expr(C). { A = array('op_expr' => trim(@X), B, C); }
|
||||
expr(A) ::= expr(B) T_TIMES|T_DIV|T_MOD(X) expr(C). { A = array('op_expr' => @X, B, C); }
|
||||
expr(A) ::= expr(B) T_BITWISE|T_PIPE(X) expr(C). { A = array('op_expr' => 'expr', array('op_expr' => @X, B, C)); }
|
||||
expr(A) ::= T_LPARENT expr(B) T_RPARENT. { A = array('op_expr' => 'expr', B); }
|
||||
expr(A) ::= fvar_or_string(B). { A = B; }
|
||||
|
||||
/* Variable name */
|
||||
|
||||
varname(A) ::= varpart(B). { A = current($this->compiler->generate_variable_name(B, false)); }
|
||||
|
||||
varpart(A) ::= varpart(B) T_OBJ|T_DOT varpart_single(C). {
|
||||
if (!is_array(B)) { A = array(B); }
|
||||
else { A = B; } A[]=array('object' => C);
|
||||
}
|
||||
|
||||
varpart(A) ::= varpart(B) T_CLASS varpart_single(C). {
|
||||
if (!is_array(B)) { A = array(B); }
|
||||
else { A = B; } A[]=array('class' => '$'.C);
|
||||
}
|
||||
|
||||
varpart(A) ::= varpart(B) T_BRACKETS_OPEN var_or_string(C) T_BRACKETS_CLOSE. {
|
||||
if (!is_array(B)) { A = array(B); }
|
||||
else { A = B; } A[]=C;
|
||||
}
|
||||
varpart(A) ::= varpart_single(B). { A = B; }
|
||||
|
||||
/* T_BLOCK|T_CUSTOM|T_CUSTOM_BLOCK are also T_ALPHA */
|
||||
varpart_single(A) ::= T_ALPHA|T_BLOCK|T_CUSTOM_TAG|T_CUSTOM_END|T_CUSTOM_BLOCK(B). { A = B; }
|
||||
|
||||
range(A) ::= numvar(B) T_DOTDOT numvar(C). { A = array(B, C); }
|
||||
|
||||
numvar(A) ::= number(B). { A = B; }
|
||||
numvar(A) ::= varname(B). { A = array('var' => B); }
|
||||
|
||||
number(A) ::= T_NUMERIC(B). { A = B; }
|
||||
number(A) ::= T_MINUS T_NUMERIC(B). { A = -1 * (B); }
|
||||
136
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Runtime.php
vendored
Normal file
136
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Runtime.php
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Runtime compiler
|
||||
*
|
||||
*/
|
||||
final class Haanga_Compiler_Runtime extends Haanga_Compiler
|
||||
{
|
||||
|
||||
// get_function_name($name=NULL) {{{
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_function_name($name)
|
||||
{
|
||||
return "haanga_".sha1($name);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// set_template_name($path) {{{
|
||||
function set_template_name($path)
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Override {% include %} {{{
|
||||
protected function generate_op_include($details, &$body)
|
||||
{
|
||||
$this->do_print($body,
|
||||
hexec('Haanga::Load', $details[0], $this->getScopeVariable(),
|
||||
TRUE,
|
||||
hvar('blocks'))
|
||||
);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {% base "" %} {{{
|
||||
function expr_call_base_template()
|
||||
{
|
||||
return hexec('Haanga::Load', $this->subtemplate,
|
||||
$this->getScopeVariable(), TRUE, hvar('blocks'));
|
||||
}
|
||||
// }}}
|
||||
|
||||
// get_base_template($base) {{{
|
||||
function get_base_template($base)
|
||||
{
|
||||
$this->subtemplate = $base;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Override get_Custom_tag {{{
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_custom_tag($name)
|
||||
{
|
||||
static $tag = NULL;
|
||||
if (!$tag) $tag = Haanga_Extension::getInstance('Tag');
|
||||
$loaded = &$this->tags;
|
||||
|
||||
if (!isset($loaded[$name])) {
|
||||
$this->prepend_op->comment("Load tag {$name} definition");
|
||||
$this->prepend_op->do_exec('require_once', $tag->getFilePath($name, FALSE));
|
||||
$loaded[$name] = TRUE;
|
||||
}
|
||||
|
||||
return $tag->getClassName($name)."::main";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Override get_custom_filter {{{
|
||||
function get_custom_filter($name)
|
||||
{
|
||||
static $filter = NULL;
|
||||
if (!$filter) $filter=Haanga_Extension::getInstance('Filter');
|
||||
$loaded = &$this->filters;
|
||||
|
||||
if (!isset($loaded[$name])) {
|
||||
$this->prepend_op->comment("Load filter {$name} definition");
|
||||
$this->prepend_op->do_exec('require_once', $filter->getFilePath($name, FALSE));
|
||||
$loaded[$name] = TRUE;
|
||||
}
|
||||
|
||||
return $filter->getClassName($name)."::main";
|
||||
}
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
572
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Tokenizer.php
vendored
Normal file
572
gulliver/thirdparty/Haanga/lib/Haanga/Compiler/Tokenizer.php
vendored
Normal file
@@ -0,0 +1,572 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
class HG_Parser Extends Haanga_Compiler_Parser
|
||||
{
|
||||
/* subclass to made easier references to constants */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hand-written Tokenizer class inspired by SQLite's tokenize.c
|
||||
*
|
||||
*/
|
||||
class Haanga_Compiler_Tokenizer
|
||||
{
|
||||
/* they are case sensitive and sorted! */
|
||||
static $keywords = array(
|
||||
'AND' => HG_Parser::T_AND,
|
||||
'FALSE' => HG_Parser::T_FALSE,
|
||||
'NOT' => HG_Parser::T_NOT,
|
||||
'OR' => HG_Parser::T_OR,
|
||||
'TRUE' => HG_Parser::T_TRUE,
|
||||
'_(' => HG_Parser::T_INTL,
|
||||
'as' => HG_Parser::T_AS,
|
||||
'autoescape' => HG_Parser::T_AUTOESCAPE,
|
||||
'block' => HG_Parser::T_BLOCK,
|
||||
'by' => HG_Parser::T_BY,
|
||||
'else' => HG_Parser::T_ELSE,
|
||||
'empty' => HG_Parser::T_EMPTY,
|
||||
'extends' => HG_Parser::T_EXTENDS,
|
||||
'filter' => HG_Parser::T_FILTER,
|
||||
'for' => HG_Parser::T_FOR,
|
||||
'if' => HG_Parser::T_IF,
|
||||
'ifchanged' => HG_Parser::T_IFCHANGED,
|
||||
'ifequal' => HG_Parser::T_IFEQUAL,
|
||||
'ifnotequal' => HG_Parser::T_IFNOTEQUAL,
|
||||
'in' => HG_Parser::T_IN,
|
||||
'include' => HG_Parser::T_INCLUDE,
|
||||
'load' => HG_Parser::T_LOAD,
|
||||
'not' => HG_Parser::T_NOT,
|
||||
'regroup' => HG_Parser::T_REGROUP,
|
||||
'set' => HG_Parser::T_SET,
|
||||
'spacefull' => HG_Parser::T_SPACEFULL,
|
||||
'step' => HG_Parser::T_STEP,
|
||||
'with' => HG_Parser::T_WITH,
|
||||
);
|
||||
|
||||
/* common operations */
|
||||
static $operators_single = array(
|
||||
'!' => HG_Parser::T_NOT,
|
||||
'%' => HG_Parser::T_MOD,
|
||||
'&' => HG_Parser::T_BITWISE,
|
||||
'(' => HG_Parser::T_LPARENT,
|
||||
')' => HG_Parser::T_RPARENT,
|
||||
'*' => HG_Parser::T_TIMES,
|
||||
'+' => HG_Parser::T_PLUS,
|
||||
',' => HG_Parser::T_COMMA,
|
||||
'-' => HG_Parser::T_MINUS,
|
||||
'.' => HG_Parser::T_DOT,
|
||||
'/' => HG_Parser::T_DIV,
|
||||
':' => HG_Parser::T_COLON,
|
||||
'<' => HG_Parser::T_LT,
|
||||
'=' => HG_Parser::T_ASSIGN,
|
||||
'>' => HG_Parser::T_GT,
|
||||
'[' => HG_Parser::T_BRACKETS_OPEN,
|
||||
']' => HG_Parser::T_BRACKETS_CLOSE,
|
||||
'|' => HG_Parser::T_PIPE,
|
||||
);
|
||||
static $operators = array(
|
||||
'!==' => HG_Parser::T_NE,
|
||||
'!=' => HG_Parser::T_NE,
|
||||
'&&' => HG_Parser::T_AND,
|
||||
'->' => HG_Parser::T_OBJ,
|
||||
'..' => HG_Parser::T_DOTDOT,
|
||||
'::' => HG_Parser::T_CLASS,
|
||||
'<<' => HG_Parser::T_BITWISE,
|
||||
'<=' => HG_Parser::T_LE,
|
||||
'===' => HG_Parser::T_EQ,
|
||||
'==' => HG_Parser::T_EQ,
|
||||
'>=' => HG_Parser::T_GE,
|
||||
'>>' => HG_Parser::T_BITWISE,
|
||||
'||' => HG_Parser::T_OR,
|
||||
);
|
||||
|
||||
static $close_tags = array();
|
||||
|
||||
static $open_tag = "{%";
|
||||
static $end_tag = "%}";
|
||||
static $open_comment = "{#";
|
||||
static $end_comment = "#}";
|
||||
static $open_print = "{{";
|
||||
static $end_print = "}}";
|
||||
|
||||
public $open_tags;
|
||||
public $value;
|
||||
public $token;
|
||||
public $status = self::IN_NONE;
|
||||
|
||||
const IN_NONE = 0;
|
||||
const IN_HTML = 1;
|
||||
const IN_TAG = 2;
|
||||
const IN_ECHO = 3;
|
||||
|
||||
function __construct($data, $compiler, $file)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->compiler = $compiler;
|
||||
$this->line = 1;
|
||||
$this->N = 0;
|
||||
$this->file = $file;
|
||||
$this->length = strlen($data);
|
||||
|
||||
|
||||
/*$tmp1 = self::$operators;
|
||||
$tmp2 = $tmp1;
|
||||
ksort($tmp2);
|
||||
var_dump($tmp2, $tmp1 === $tmp2);die();/**/
|
||||
|
||||
self::$close_tags =array(
|
||||
self::$end_tag => HG_Parser::T_TAG_CLOSE,
|
||||
self::$end_print => HG_Parser::T_PRINT_CLOSE,
|
||||
);
|
||||
|
||||
|
||||
$this->open_tags = array(
|
||||
self::$open_tag => HG_Parser::T_TAG_OPEN,
|
||||
self::$open_print => HG_Parser::T_PRINT_OPEN,
|
||||
self::$open_comment => HG_Parser::T_COMMENT,
|
||||
);
|
||||
}
|
||||
|
||||
function yylex()
|
||||
{
|
||||
$this->token = NULL;
|
||||
|
||||
if ($this->length == $this->N) {
|
||||
if ($this->status != self::IN_NONE && $this->status != self::IN_HTML) {
|
||||
$this->Error("Unexpected end");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($this->status == self::IN_NONE) {
|
||||
$i = &$this->N;
|
||||
$data = substr($this->data, $i, 12);
|
||||
|
||||
static $lencache = array();
|
||||
foreach ($this->open_tags as $value => $token) {
|
||||
if (!isset($lencache[$value])) {
|
||||
$lencache[$value] = strlen($value);
|
||||
}
|
||||
$len = $lencache[$value];
|
||||
if (strncmp($data, $value, $len) == 0) {
|
||||
$this->value = $value;
|
||||
$this->token = $token;
|
||||
$i += $len;
|
||||
switch ($this->token) {
|
||||
case HG_Parser::T_TAG_OPEN:
|
||||
$this->status = self::IN_TAG;
|
||||
break;
|
||||
case HG_Parser::T_COMMENT:
|
||||
$zdata = & $this->data;
|
||||
|
||||
if (($pos=strpos($zdata, self::$end_comment, $i)) === FALSE) {
|
||||
$this->error("unexpected end");
|
||||
}
|
||||
|
||||
$this->value = substr($zdata, $i, $pos-2);
|
||||
$this->status = self::IN_NONE;
|
||||
$i = $pos + 2;
|
||||
break;
|
||||
case HG_Parser::T_PRINT_OPEN:
|
||||
$this->status = self::IN_ECHO;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
$this->status = self::IN_HTML;
|
||||
}
|
||||
|
||||
switch ($this->status)
|
||||
{
|
||||
case self::IN_TAG:
|
||||
case self::IN_ECHO:
|
||||
$this->yylex_main();
|
||||
break;
|
||||
default:
|
||||
$this->yylex_html();
|
||||
}
|
||||
|
||||
|
||||
if (empty($this->token)) {
|
||||
if ($this->status != self::IN_NONE && $this->status != self::IN_HTML) {
|
||||
$this->Error("Unexpected end");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
function yylex_html()
|
||||
{
|
||||
$data = &$this->data;
|
||||
$i = &$this->N;
|
||||
|
||||
foreach ($this->open_tags as $value => $status) {
|
||||
$pos = strpos($data, $value, $i);
|
||||
if ($pos === FALSE) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($lowest_pos) || $lowest_pos > $pos) {
|
||||
$lowest_pos = $pos;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($lowest_pos)) {
|
||||
$this->value = substr($data, $i, $lowest_pos-$i);
|
||||
$this->token = HG_Parser::T_HTML;
|
||||
$this->status = self::IN_NONE;
|
||||
$i += $lowest_pos - $i;
|
||||
} else {
|
||||
$this->value = substr($data, $i);
|
||||
$this->token = HG_Parser::T_HTML;
|
||||
$i = $this->length;
|
||||
}
|
||||
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function yylex_main()
|
||||
{
|
||||
$data = &$this->data;
|
||||
|
||||
for ($i=&$this->N; is_null($this->token) && $i < $this->length; ++$i) {
|
||||
switch ($data[$i]) {
|
||||
|
||||
/* strings {{{ */
|
||||
case '"':
|
||||
case "'":
|
||||
$end = $data[$i];
|
||||
$value = "";
|
||||
while ($data[++$i] != $end) {
|
||||
switch ($data[$i]) {
|
||||
case "\\":
|
||||
switch ($data[++$i]) {
|
||||
case "n":
|
||||
$value .= "\n";
|
||||
break;
|
||||
case "t":
|
||||
$value .= "\t";
|
||||
break;
|
||||
default:
|
||||
$value .= $data[$i];
|
||||
}
|
||||
break;
|
||||
case $end:
|
||||
--$i;
|
||||
break 2;
|
||||
default:
|
||||
if ($data[$i] == "\n") {
|
||||
$this->line++;
|
||||
}
|
||||
$value .= $data[$i];
|
||||
}
|
||||
if (!isset($data[$i+1])) {
|
||||
$this->Error("unclosed string");
|
||||
}
|
||||
}
|
||||
$this->value = $value;
|
||||
$this->token = HG_Parser::T_STRING;
|
||||
break;
|
||||
/* }}} */
|
||||
|
||||
/* number {{{ */
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
$value = "";
|
||||
$dot = FALSE;
|
||||
for ($e=0; $i < $this->length; ++$e, ++$i) {
|
||||
switch ($data[$i]) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
$value .= $data[$i];
|
||||
break;
|
||||
case '.':
|
||||
if (!$dot) {
|
||||
$value .= ".";
|
||||
$dot = TRUE;
|
||||
} else {
|
||||
$this->error("Invalid number");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break 2; /* break the main loop */
|
||||
}
|
||||
}
|
||||
if (!$this->is_token_end($data[$i]) &&
|
||||
!isset(self::$operators_single[$data[$i]]) || $value[$e-1] == '.') {
|
||||
$this->error("Unexpected '{$data[$i]}'");
|
||||
}
|
||||
$this->value = $value;
|
||||
$this->token = HG_Parser::T_NUMERIC;
|
||||
break 2;
|
||||
/* }}} */
|
||||
|
||||
case "\n": case " ": case "\t": case "\r": case "\f":
|
||||
for (; is_null($this->token) && $i < $this->length; ++$i) {
|
||||
switch ($data[$i]) {
|
||||
case "\n":
|
||||
$this->line++;
|
||||
case " ": case "\t": case "\r": case "\f":
|
||||
break;
|
||||
case '.':
|
||||
if ($data[$i+1] != '.') {
|
||||
$this->token = HG_Parser::T_CONCAT;
|
||||
$this->value = '.';
|
||||
$i++;
|
||||
return;
|
||||
}
|
||||
default:
|
||||
/* break main loop */
|
||||
/* and decrease because last processed byte */
|
||||
/* wasn't a dot (T_CONCAT) */
|
||||
--$i;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
break; /* whitespaces are ignored */
|
||||
default:
|
||||
if (!$this->getTag() && !$this->getOperator()) {
|
||||
$alpha = $this->getAlpha();
|
||||
if ($alpha === FALSE) {
|
||||
$this->error("error: unexpected ".substr($data, $i));
|
||||
}
|
||||
static $tag=NULL;
|
||||
if (!$tag) {
|
||||
$tag = Haanga_Extension::getInstance('Tag');
|
||||
}
|
||||
$value = $tag->isValid($alpha);
|
||||
$this->token = $value ? $value : HG_Parser::T_ALPHA;
|
||||
$this->value = $alpha;
|
||||
|
||||
}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->token == HG_Parser::T_TAG_CLOSE ||
|
||||
$this->token == HG_Parser::T_PRINT_CLOSE) {
|
||||
$this->status = self::IN_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getTag()
|
||||
{
|
||||
static $lencache = array();
|
||||
|
||||
$i = &$this->N;
|
||||
$data = substr($this->data, $i, 12);
|
||||
foreach (self::$close_tags as $value => $token) {
|
||||
if (!isset($lencache[$value])) {
|
||||
$lencache[$value] = strlen($value);
|
||||
}
|
||||
$len = $lencache[$value];
|
||||
if (strncmp($data, $value, $len) == 0) {
|
||||
$this->token = $token;
|
||||
$this->value = $value;
|
||||
$i += $len;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::$keywords as $value => $token) {
|
||||
if (!isset($lencache[$value])) {
|
||||
$lencache[$value] = strlen($value);
|
||||
}
|
||||
$len = $lencache[$value];
|
||||
switch (strncmp($data, $value, $len)) {
|
||||
case -1:
|
||||
break 2;
|
||||
case 0: // match
|
||||
if (isset($data[$len]) && !$this->is_token_end($data[$len])) {
|
||||
/* probably a variable name TRUEfoo (and not TRUE) */
|
||||
continue;
|
||||
}
|
||||
$this->token = $token;
|
||||
$this->value = $value;
|
||||
$i += $len;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* /end([a-zA-Z][a-zA-Z0-9]*)/ */
|
||||
if (strncmp($data, "end", 3) == 0) {
|
||||
$this->value = $this->getAlpha();
|
||||
$this->token = HG_Parser::T_CUSTOM_END;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function Error($text)
|
||||
{
|
||||
throw new Haanga_Compiler_Exception($text." in ".$this->file.":".$this->line);
|
||||
}
|
||||
|
||||
function getOperator()
|
||||
{
|
||||
static $lencache = array();
|
||||
|
||||
$i = &$this->N;
|
||||
$data = substr($this->data, $i, 12);
|
||||
|
||||
foreach (self::$operators as $value => $token) {
|
||||
if (!isset($lencache[$value])) {
|
||||
$lencache[$value] = strlen($value);
|
||||
}
|
||||
$len = $lencache[$value];
|
||||
switch (strncmp($data, $value, $len)) {
|
||||
case -1:
|
||||
if (strlen($data) == $len) {
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
$this->token = $token;
|
||||
$this->value = $value;
|
||||
$i += $len;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->data[$i];
|
||||
foreach (self::$operators_single as $value => $token) {
|
||||
if ($value == $data) {
|
||||
$this->token = $token;
|
||||
$this->value = $value;
|
||||
$i += 1;
|
||||
return TRUE;
|
||||
} else if ($value > $data) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return TRUE if $letter is a valid "token_end". We use token_end
|
||||
* to avoid confuse T_ALPHA TRUEfoo with TRUE and foo (T_ALPHA)
|
||||
*
|
||||
* @param string $letter
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_token_end($letter)
|
||||
{
|
||||
/* [^a-zA-Z0-9_] */
|
||||
return !(
|
||||
('a' <= $letter && 'z' >= $letter) ||
|
||||
('A' <= $letter && 'Z' >= $letter) ||
|
||||
('0' <= $letter && '9' >= $letter) ||
|
||||
$letter == "_"
|
||||
);
|
||||
}
|
||||
|
||||
function getAlpha()
|
||||
{
|
||||
/* [a-zA-Z_][a-zA-Z0-9_]* */
|
||||
$i = &$this->N;
|
||||
$data = &$this->data;
|
||||
|
||||
if ( !('a' <= $data[$i] && 'z' >= $data[$i]) &&
|
||||
!('A' <= $data[$i] && 'Z' >= $data[$i]) && $data[$i] != '_') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$value = "";
|
||||
for (; $i < $this->length; ++$i) {
|
||||
if (
|
||||
('a' <= $data[$i] && 'z' >= $data[$i]) ||
|
||||
('A' <= $data[$i] && 'Z' >= $data[$i]) ||
|
||||
('0' <= $data[$i] && '9' >= $data[$i]) ||
|
||||
$data[$i] == "_"
|
||||
) {
|
||||
$value .= $data[$i];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function getLine()
|
||||
{
|
||||
return $this->line;
|
||||
}
|
||||
|
||||
|
||||
static function init($template, $compiler, $file='')
|
||||
{
|
||||
$lexer = new Haanga_Compiler_Tokenizer($template, $compiler, $file);
|
||||
$parser = new Haanga_Compiler_Parser($lexer, $file);
|
||||
|
||||
$parser->compiler = $compiler;
|
||||
|
||||
try {
|
||||
for($i=0; ; $i++) {
|
||||
if (!$lexer->yylex()) {
|
||||
break;
|
||||
}
|
||||
$parser->doParse($lexer->token, $lexer->value);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* destroy the parser */
|
||||
try {
|
||||
$parser->doParse(0,0);
|
||||
} catch (Exception $y) {}
|
||||
throw $e; /* re-throw exception */
|
||||
}
|
||||
|
||||
$parser->doParse(0, 0);
|
||||
|
||||
return (array)$parser->body;
|
||||
|
||||
}
|
||||
}
|
||||
57
gulliver/thirdparty/Haanga/lib/Haanga/Exception.php
vendored
Normal file
57
gulliver/thirdparty/Haanga/lib/Haanga/Exception.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// Haanga_Exception {{{
|
||||
/**
|
||||
* General exception class. It is thrown
|
||||
* when something is not configured properly
|
||||
*
|
||||
*/
|
||||
class Haanga_Exception extends Exception
|
||||
{
|
||||
}
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
|
||||
183
gulliver/thirdparty/Haanga/lib/Haanga/Extension.php
vendored
Normal file
183
gulliver/thirdparty/Haanga/lib/Haanga/Extension.php
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
Abstract Class Haanga_Extension
|
||||
{
|
||||
private static $_instances;
|
||||
|
||||
final private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
final static function getInstance($name)
|
||||
{
|
||||
$name = 'Haanga_Extension_'.$name;
|
||||
if (!class_exists($name)) {
|
||||
throw new Haanga_Compiler_Exception("{$name} is not a class");
|
||||
}
|
||||
if (!is_subclass_of($name, __CLASS__)) {
|
||||
throw new Haanga_Compiler_Exception("{$name} is not a sub-class of ".__CLASS__);
|
||||
}
|
||||
|
||||
if (!isset(self::$_instances[$name])) {
|
||||
self::$_instances[$name] = new $name;
|
||||
}
|
||||
return self::$_instances[$name];
|
||||
}
|
||||
|
||||
abstract function isValid($name);
|
||||
abstract function getClassName($name);
|
||||
|
||||
final function getFilePath($name, $rel=TRUE, $pref=NULL)
|
||||
{
|
||||
try {
|
||||
$reflection = new ReflectionClass($this->getClassName($name));
|
||||
$file = $reflection->getFileName();
|
||||
} catch (Exception $e) {
|
||||
$file = "";
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
final public function getFunctionAlias($name)
|
||||
{
|
||||
if (!$this->isValid($name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
$properties = get_class_vars($zclass);
|
||||
if (isset($properties['php_alias'])) {
|
||||
return $properties['php_alias'];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
final public function isSafe($name)
|
||||
{
|
||||
if (!$this->isValid($name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
$properties = get_class_vars($zclass);
|
||||
return isset($properties['is_safe']) ? $properties['is_safe'] : FALSE;
|
||||
}
|
||||
|
||||
// generator(string $name, Haanga_Compiler $compiler, Array $args) {{{
|
||||
/**
|
||||
* Executer the generator method of the extension. If
|
||||
* the extension doesn't has any generator method, an empty
|
||||
* will be returned.
|
||||
*
|
||||
* @param string $name extension name
|
||||
* @param Haanga_Compiler Compiler object
|
||||
* @param array Arrays
|
||||
* @param mixed Extra param
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generator($name, Haanga_Compiler $compiler, $args, $extra=NULL)
|
||||
{
|
||||
if (!$this->hasGenerator($name)) {
|
||||
return array();
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
return call_user_func(array($zclass, 'generator'), $compiler, $args, $extra);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// hasGenerator(string $name) {{{
|
||||
/**
|
||||
* Return TRUE if the extension has a
|
||||
* generator method
|
||||
*
|
||||
* @param string $name Extension name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function hasGenerator($name)
|
||||
{
|
||||
if (!$this->isValid($name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
return is_callable(array($zclass, 'generator'));
|
||||
}
|
||||
// }}}
|
||||
|
||||
// getFunctionBody(string $name, string $name) {{{
|
||||
/**
|
||||
* Return the body function of the custom extension main method.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFunctionBody($tag_name, $name)
|
||||
{
|
||||
if (!$this->isValid($tag_name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($tag_name);
|
||||
if (!is_callable(array($zclass, 'main'))) {
|
||||
throw new Haanga_Compiler_Exception("{$name}: missing main method in {$zclass} class");
|
||||
}
|
||||
|
||||
$reflection = new ReflectionMethod($zclass, 'main');
|
||||
$content = file($this->getFilePath($tag_name));
|
||||
|
||||
$start = $reflection->getStartLine()-1;
|
||||
$end = $reflection->getEndLine();
|
||||
$content = array_slice($content, $start, $end-$start);
|
||||
|
||||
$content[0] = str_replace("main", $name, $content[0]);
|
||||
|
||||
|
||||
return "if (!function_exists('{$name}')) {\n".implode("", $content)."}";
|
||||
}
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
79
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter.php
vendored
Normal file
79
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
class Haanga_Extension_Filter extends Haanga_Extension
|
||||
{
|
||||
/**
|
||||
* isValid
|
||||
*
|
||||
*
|
||||
*/
|
||||
final function isValid($filter)
|
||||
{
|
||||
static $cache = array();
|
||||
$filter = strtolower($filter);
|
||||
|
||||
if (!isset($cache[$filter])) {
|
||||
$class_name = $this->getClassName($filter);
|
||||
if (class_exists($class_name)) {
|
||||
$cache[$filter] = TRUE;
|
||||
} else {
|
||||
$cache[$filter] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return $cache[$filter];
|
||||
}
|
||||
|
||||
final function getClassName($filter)
|
||||
{
|
||||
$filter = str_replace("_", "", ucfirst($filter));
|
||||
return "Haanga_Extension_Filter_{$filter}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Capfirst.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Capfirst.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Capfirst
|
||||
{
|
||||
public $php_alias = "ucfirst";
|
||||
}
|
||||
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Count.php
vendored
Normal file
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Count.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Count
|
||||
{
|
||||
public $php_alias = "count";
|
||||
public $is_safe = TRUE; /* a number if safe */
|
||||
}
|
||||
23
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Cut.php
vendored
Normal file
23
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Cut.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
Class Haanga_Extension_Filter_Cut
|
||||
{
|
||||
|
||||
/**
|
||||
* We implement "cut" filter at compilation time, to
|
||||
* avoid senseless includes for simple things.
|
||||
*
|
||||
* We can also define an "php_alias" that will simple
|
||||
* call this function (therefore it must exists at
|
||||
* rendering time).
|
||||
*
|
||||
* Also a Main() static method could be declared, this will
|
||||
* included at runtime or copied as a function if the CLI is used (more
|
||||
* or less django style).
|
||||
*
|
||||
*/
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexec('str_replace', $args[1], "", $args[0]);
|
||||
}
|
||||
}
|
||||
11
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Date.php
vendored
Normal file
11
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Date.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Date
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexec('date', $args[1], $args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Default.php
vendored
Normal file
9
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Default.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Default
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexpr_cond(hexpr(hexec('empty', $args[0]), '==', TRUE), $args[1], $args[0]);
|
||||
}
|
||||
}
|
||||
21
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Dictsort.php
vendored
Normal file
21
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Dictsort.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Dictsort
|
||||
{
|
||||
/**
|
||||
* Sorted a nested array by '$sort_by'
|
||||
* property on each sub-array. This
|
||||
* filter is included at rendering time, if you want
|
||||
* to see the generated version see tags/dictsort.php
|
||||
*/
|
||||
static function main($array, $sort_by)
|
||||
{
|
||||
$field = array();
|
||||
foreach ($array as $key => $item) {
|
||||
$field[$key] = $item[$sort_by];
|
||||
}
|
||||
array_multisort($field, SORT_REGULAR, $array);
|
||||
return $array;
|
||||
|
||||
}
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Empty.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Empty.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Empty
|
||||
{
|
||||
public $php_alias = 'empty';
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Escape.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Escape.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Escape
|
||||
{
|
||||
public $php_alias = "htmlspecialchars";
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Exists.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Exists.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Exists
|
||||
{
|
||||
public $php_alias = 'isset';
|
||||
}
|
||||
9
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Hostname.php
vendored
Normal file
9
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Hostname.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Hostname
|
||||
{
|
||||
static function generator($cmp, $args)
|
||||
{
|
||||
return hexec('parse_url', $args[0], hconst('PHP_URL_HOST'));
|
||||
}
|
||||
}
|
||||
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Intval.php
vendored
Normal file
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Intval.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_intval
|
||||
{
|
||||
public $php_alias = 'intval';
|
||||
}
|
||||
|
||||
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Isarray.php
vendored
Normal file
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Isarray.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_IsArray
|
||||
{
|
||||
public $php_alias = "is_array";
|
||||
public $is_safe = TRUE; /* boolean if safe */
|
||||
}
|
||||
12
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Join.php
vendored
Normal file
12
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Join.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Join
|
||||
{
|
||||
public static function generator($compiler, $args)
|
||||
{
|
||||
if (count($args) == 1) {
|
||||
$args[1] = "";
|
||||
}
|
||||
return hexec("implode", $args[1], $args[0]);
|
||||
}
|
||||
}
|
||||
32
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Length.php
vendored
Normal file
32
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Length.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Length
|
||||
{
|
||||
public $is_safe = TRUE; /* a number if safe */
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
$count = hexec('count', $args[0]);
|
||||
$strlen = hexec('strlen', $args[0]);
|
||||
$guess = hexpr_cond(hexec('is_array', $args[0]), hexec('count', $args[0]),
|
||||
hexec('strlen', $args[0]));
|
||||
|
||||
if (Haanga_AST::is_var($args[0])) {
|
||||
/* if it is a variable, best effort to detect
|
||||
its type at compile time */
|
||||
$value = $compiler->get_context($args[0]['var']);
|
||||
if (is_array($value)) {
|
||||
return $count;
|
||||
} else if (is_string($value)) {
|
||||
return $strlen;
|
||||
} else {
|
||||
return $guess;
|
||||
}
|
||||
}
|
||||
|
||||
if (Haanga_AST::is_str($args[0])) {
|
||||
return $strlen;
|
||||
}
|
||||
|
||||
return $guess;
|
||||
}
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Lower.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Lower.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Lower
|
||||
{
|
||||
public $php_alias = "strtolower";
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Null.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Null.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Null
|
||||
{
|
||||
public $php_alias = 'is_null';
|
||||
}
|
||||
26
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Pluralize.php
vendored
Normal file
26
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Pluralize.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Pluralize
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
if (count($args) > 1) {
|
||||
if (!Haanga_AST::is_str($args[1])) {
|
||||
$compiler->Error("pluralize: First parameter must be an string");
|
||||
}
|
||||
$parts = explode(",", $args[1]['string']);
|
||||
$singular = "";
|
||||
if (count($parts) == 1) {
|
||||
$plural = $parts[0];
|
||||
} else {
|
||||
$singular = $parts[0];
|
||||
$plural = $parts[1];
|
||||
}
|
||||
} else {
|
||||
$singular = "";
|
||||
$plural = "s";
|
||||
}
|
||||
|
||||
return hexpr_cond(hexpr($args[0], '<=', 1), $singular, $plural);
|
||||
}
|
||||
}
|
||||
13
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Reverse.php
vendored
Normal file
13
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Reverse.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Reverse
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
if (count($args) != 1) {
|
||||
$compiler->Error("Reverse only needs one parameter");
|
||||
}
|
||||
|
||||
return hexec('array_reverse', $args[0], TRUE);
|
||||
}
|
||||
}
|
||||
10
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Safe.php
vendored
Normal file
10
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Safe.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Safe
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
$compiler->var_is_safe = TRUE;
|
||||
return current($args);
|
||||
}
|
||||
}
|
||||
16
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Slugify.php
vendored
Normal file
16
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Slugify.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Slugify
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
if (count($args) != 1) {
|
||||
$compiler->Error("slugify filter only needs one parameter");
|
||||
}
|
||||
|
||||
$arg = hexec('strtolower', $args[0]);
|
||||
$arg = hexec('str_replace'," ","-",$arg);
|
||||
$arg = hexec('preg_replace',"/[^\d\w-_]/",'',$arg);
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
9
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Stringformat.php
vendored
Normal file
9
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Stringformat.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_StringFormat
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexec('sprintf', $args[1], $args[0]);
|
||||
}
|
||||
}
|
||||
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Strlen.php
vendored
Normal file
7
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Strlen.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Length
|
||||
{
|
||||
public $php_alias = "strlen";
|
||||
public $is_safe = TRUE; /* a number if safe */
|
||||
}
|
||||
16
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Substr.php
vendored
Normal file
16
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Substr.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Substr
|
||||
{
|
||||
public static function generator($cmp, $args)
|
||||
{
|
||||
if (count($args) != 2) {
|
||||
$cmp->Error("substr parameter must have one param");
|
||||
}
|
||||
if (!isset($args[1]['string'])) {
|
||||
$cmp->Error("substr parameter must be a string");
|
||||
}
|
||||
list($start, $end) = explode(",", $args[1]['string']);
|
||||
return hexec('substr', $args[0], (int)$start, (int)$end);
|
||||
}
|
||||
}
|
||||
13
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Title.php
vendored
Normal file
13
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Title.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Title
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
if (count($args) != 1) {
|
||||
$compiler->Error("title filter only needs one parameter");
|
||||
}
|
||||
|
||||
return hexec('ucwords', hexec('strtolower', $args[0]));
|
||||
}
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Trans.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Trans.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Trans
|
||||
{
|
||||
public $php_alias = '_';
|
||||
}
|
||||
5
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Translation.php
vendored
Normal file
5
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Translation.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Translation extends Haanga_Extension_Filter_Trans
|
||||
{
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Trim.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Trim.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Trim
|
||||
{
|
||||
public $php_alias = "trim";
|
||||
}
|
||||
16
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Truncatechars.php
vendored
Normal file
16
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Truncatechars.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Truncatechars
|
||||
{
|
||||
static function main($text, $limit)
|
||||
{
|
||||
if(strlen($text) <= $limit)
|
||||
return $text;
|
||||
$trunctext = substr($text, 0, $limit);
|
||||
$trunctext[$limit-3] = '.';
|
||||
$trunctext[$limit-2] = '.';
|
||||
$trunctext[$limit-1] = '.';
|
||||
return $trunctext;
|
||||
}
|
||||
}
|
||||
|
||||
13
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Truncatewords.php
vendored
Normal file
13
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Truncatewords.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Truncatewords
|
||||
{
|
||||
static function main($text, $limit)
|
||||
{
|
||||
$words = explode(" ", $text, $limit+1);
|
||||
if (count($words) == $limit+1) {
|
||||
$words[$limit] = '...';
|
||||
}
|
||||
return implode(" ", $words);
|
||||
}
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Upper.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Upper.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Upper
|
||||
{
|
||||
public $php_alias = "strtoupper";
|
||||
}
|
||||
11
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Urlencode.php
vendored
Normal file
11
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Filter/Urlencode.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_UrlEncode
|
||||
{
|
||||
|
||||
public static function generator($cmp, $args)
|
||||
{
|
||||
$cmp->var_is_safe = TRUE;
|
||||
return hexec('urlencode', $args[0]);
|
||||
}
|
||||
}
|
||||
93
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag.php
vendored
Normal file
93
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
class Haanga_Extension_Tag extends Haanga_Extension
|
||||
{
|
||||
/**
|
||||
* isValid
|
||||
*
|
||||
* Check if the current $tag (string) is registered as a custom
|
||||
* tag, if so, it check wether it is just a custom tag or a custom block.
|
||||
*
|
||||
* This method is called from the lexer for each alpha (within {% %}),
|
||||
* to avoid parsing conflicts.
|
||||
*
|
||||
* @param string $tag Tag to check
|
||||
*
|
||||
* @return int|bool HG_Parser::T_CUSTOM_TAG, HG_Parser::T_CUSTOM_TAG or FALSE
|
||||
*/
|
||||
final function isValid($tag)
|
||||
{
|
||||
static $cache = array();
|
||||
$tag = strtolower($tag);
|
||||
|
||||
if (!isset($cache[$tag])) {
|
||||
$class_name = $this->getClassName($tag);
|
||||
if (class_exists($class_name)) {
|
||||
$properties = get_class_vars($class_name);
|
||||
$is_block = FALSE;
|
||||
if (isset($properties['is_block'])) {
|
||||
$is_block = (bool)$properties['is_block'];
|
||||
}
|
||||
$cache[$tag] = $is_block ? HG_Parser::T_CUSTOM_BLOCK : HG_Parser::T_CUSTOM_TAG;
|
||||
}
|
||||
if (!isset($cache[$tag])) {
|
||||
$cache[$tag] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return $cache[$tag];
|
||||
}
|
||||
|
||||
final function getClassName($tag)
|
||||
{
|
||||
$tag = str_replace("_", "", ucfirst($tag));
|
||||
return "Haanga_Extension_Tag_{$tag}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
25
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Buffer.php
vendored
Normal file
25
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Buffer.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Buffer
|
||||
{
|
||||
public $is_block = TRUE;
|
||||
|
||||
static function generator($cmp, $args, $redirected)
|
||||
{
|
||||
if (count($args) != 2) {
|
||||
$cmp->Error("buffer filter must have one parameter");
|
||||
}
|
||||
|
||||
/* get new code object */
|
||||
$code = hcode();
|
||||
/* redirect buffer to $args[1] */
|
||||
$code->decl($args[1], $args[0]);
|
||||
/* telling to Haanga that we're handling the output */
|
||||
$code->doesPrint = TRUE;
|
||||
|
||||
/* $args[1] is already safe (it might have HTML) */
|
||||
$cmp->set_safe($args[1]['var']);
|
||||
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
8
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Currenttime.php
vendored
Normal file
8
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Currenttime.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_CurrentTime
|
||||
{
|
||||
public static $is_block = FALSE;
|
||||
/* This tag calls to a PHP native function */
|
||||
public static $php_alias = "date";
|
||||
}
|
||||
57
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Cycle.php
vendored
Normal file
57
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Cycle.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Cycle
|
||||
{
|
||||
public $is_block = FALSE;
|
||||
|
||||
static function generator($cmp, $args, $declared)
|
||||
{
|
||||
static $cycle = 0;
|
||||
if (!isset($cmp->cycle)) {
|
||||
$cmp->cycle = array();
|
||||
}
|
||||
|
||||
$code = hcode();
|
||||
|
||||
$index = 'index_'.$cycle;
|
||||
$def = 'def_cycle_'.$cycle;
|
||||
|
||||
if (count($args) == 1 && Haanga_AST::is_var($args[0]) && isset($cmp->cycle[$args[0]['var']])) {
|
||||
$id = $cmp->cycle[$args[0]['var']];
|
||||
$index = 'index_'.$id;
|
||||
$def = 'def_cycle_'.$id;
|
||||
} else {
|
||||
if (!$declared) {
|
||||
$code->do_if(hexpr(hexec('isset', hvar($def)), '==', FALSE));
|
||||
}
|
||||
$code->decl($def, $args);
|
||||
if (!$declared) {
|
||||
$code->do_endif();
|
||||
}
|
||||
}
|
||||
|
||||
/* isset($var) == FALSE */
|
||||
$expr = hexpr(hexec('isset', hvar($index)), '==', FALSE);
|
||||
$inc = hexpr(hexpr(hexpr(hvar($index), '+', 1)), '%', hexec('count', hvar($def)));
|
||||
|
||||
|
||||
if (!$declared) {
|
||||
if (isset($id)) {
|
||||
$code->decl($index, $inc);
|
||||
} else {
|
||||
$code->decl($index, hexpr_cond($expr, 0, $inc));
|
||||
}
|
||||
$code->end();
|
||||
$var = hvar($def, hvar($index));
|
||||
$cmp->do_print($code, $var);
|
||||
} else {
|
||||
$code->decl($index, -1);
|
||||
$cmp->cycle[$declared] = $cycle;
|
||||
}
|
||||
|
||||
$cycle++;
|
||||
|
||||
return $code;
|
||||
|
||||
}
|
||||
}
|
||||
43
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Dictsort.php
vendored
Normal file
43
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Dictsort.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Dictsort
|
||||
{
|
||||
|
||||
/**
|
||||
* Sorted a nested array by '$sort_by'
|
||||
* property on each sub-array. , if you want
|
||||
* to see the original php file look filters/dictsort.php
|
||||
*/
|
||||
static function generator($cmp, $args, $redirected)
|
||||
{
|
||||
if (!$redirected) {
|
||||
$cmp->Error("dictsort must be redirected to a variable using AS <varname>");
|
||||
}
|
||||
if (count($args) != 2) {
|
||||
$cmp->Error("Dictsort must have two params");
|
||||
}
|
||||
|
||||
if (!Haanga_AST::is_var($args[0])) {
|
||||
$cmp->Error("Dictsort: First parameter must be an array");
|
||||
}
|
||||
|
||||
$var = $cmp->get_context($args[0]['var']);
|
||||
$cmp->set_context($redirected, $var);
|
||||
|
||||
$redirected = hvar($redirected);
|
||||
$field = hvar('field');
|
||||
$key = hvar('key');
|
||||
|
||||
$code = hcode();
|
||||
$body = hcode();
|
||||
|
||||
$body->decl(hvar('field', $key), hvar('item', $args[1]));
|
||||
|
||||
$code->decl($redirected, $args[0]);
|
||||
$code->decl($field, array());
|
||||
$code->do_foreach($redirected, 'item', $key, $body);
|
||||
$code->do_exec('array_multisort', $field, hconst('SORT_REGULAR'), $redirected);
|
||||
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
49
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Exec.php
vendored
Normal file
49
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Exec.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Haanga_Extension_Tag_Exec
|
||||
{
|
||||
public $is_block = FALSE;
|
||||
|
||||
static function generator($cmp, $args, $assign=NULL)
|
||||
{
|
||||
if (!$cmp->getOption('allow_exec')) {
|
||||
$cmp->Error("Tag exec is disabled for security reasons");
|
||||
}
|
||||
|
||||
|
||||
$code = hcode();
|
||||
if (Haanga_AST::is_var($args[0])) {
|
||||
$args[0] = $args[0]['var'];
|
||||
} else if (Haanga_AST::is_str($args[0])) {
|
||||
$args[0] = $args[0]['string'];
|
||||
} else {
|
||||
$cmp->Error("invalid param");
|
||||
}
|
||||
|
||||
// fix for static calls {{{
|
||||
if (is_array($args[0])) {
|
||||
$end = end($args[0]);
|
||||
if (isset($end['class'])) {
|
||||
$args[0][ key($args[0]) ]['class'] = substr($end['class'], 1);
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
$exec = hexec($args[0]);
|
||||
for ($i=1; $i < count($args); $i++) {
|
||||
$exec->param($args[$i]);
|
||||
}
|
||||
$exec->end();
|
||||
if ($assign) {
|
||||
$code->decl($assign, $exec);
|
||||
|
||||
// make it global
|
||||
$code->decl($cmp->getScopeVariable($assign), hvar($assign));
|
||||
} else {
|
||||
$cmp->do_print($code, $exec);
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
22
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Firstof.php
vendored
Normal file
22
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Firstof.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_FirstOf
|
||||
{
|
||||
/**
|
||||
* firstof tag
|
||||
*
|
||||
*/
|
||||
static function generator($cmp, $args)
|
||||
{
|
||||
$count = count($args);
|
||||
$args = array_reverse($args);
|
||||
for ($i=0; $i < $count; $i++) {
|
||||
if (isset($expr) && Haanga_AST::is_var($args[$i])) {
|
||||
$expr = hexpr_cond(hexpr(hexec('empty', $args[$i]),'==', FALSE), $args[$i], $expr);
|
||||
} else {
|
||||
$expr = $args[$i];
|
||||
}
|
||||
}
|
||||
return $expr;
|
||||
}
|
||||
}
|
||||
30
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Inline.php
vendored
Normal file
30
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Inline.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Inline
|
||||
{
|
||||
public static function generator($cmp, $args, $redirected)
|
||||
{
|
||||
if (count($args) != 1) {
|
||||
$cmp->Error("inline needs one argument");
|
||||
}
|
||||
|
||||
if ($redirected) {
|
||||
$cmp->Error("inline can't be redirected to one variable");
|
||||
}
|
||||
|
||||
if (!Haanga_AST::is_str($args[0])) {
|
||||
$cmp->Error("The argument to inline must be an string");
|
||||
}
|
||||
$file = $args[0]['string'];
|
||||
|
||||
if (class_exists('Haanga')) {
|
||||
$file = Haanga::GetTemplateDir().'/'.$file;
|
||||
}
|
||||
|
||||
if (!is_file($file)) {
|
||||
$cmp->Error("{$file} is not a template");
|
||||
}
|
||||
|
||||
return $cmp->getOpCodes(file_get_contents($file), $file);
|
||||
}
|
||||
}
|
||||
8
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Lower.php
vendored
Normal file
8
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Lower.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Lower
|
||||
{
|
||||
public static $is_block = TRUE;
|
||||
/* This tag calls to a PHP native function */
|
||||
public static $php_alias = "strtolower";
|
||||
}
|
||||
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Min.php
vendored
Normal file
6
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Min.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Min
|
||||
{
|
||||
public $php_alias = "min";
|
||||
}
|
||||
17
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Setsafe.php
vendored
Normal file
17
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Setsafe.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_SetSafe
|
||||
{
|
||||
public $is_block = FALSE;
|
||||
|
||||
static function generator($cmp, $args)
|
||||
{
|
||||
foreach ($args as $arg) {
|
||||
if (Haanga_AST::is_var($arg)) {
|
||||
$cmp->set_safe($arg['var']);
|
||||
}
|
||||
}
|
||||
|
||||
return hcode();
|
||||
}
|
||||
}
|
||||
51
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Spaceless.php
vendored
Normal file
51
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Spaceless.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Spaceless custom tag
|
||||
*
|
||||
* @author crodas
|
||||
*/
|
||||
class Haanga_Extension_Tag_Spaceless
|
||||
{
|
||||
/* This tag is a block */
|
||||
public $is_block = TRUE;
|
||||
|
||||
/**
|
||||
* main() {{{
|
||||
*
|
||||
* This static function contains the definition of spaceless
|
||||
* tag, it is important not to refence to $compiler since it
|
||||
* will copied and paste in the generated PHP code from the
|
||||
* template as a static function.
|
||||
*
|
||||
* It is also important to put the start and the end of the
|
||||
* static function in new lines.
|
||||
*
|
||||
*
|
||||
static static function main($html)
|
||||
{
|
||||
$regex = array(
|
||||
'/>[ \t\r\n]+</sU',
|
||||
'/^[ \t\r\n]+</sU',
|
||||
'/>[ \t\r\n]+$/sU',
|
||||
);
|
||||
$replaces = array('><', '<', '>');
|
||||
$html = preg_replace($regex, $replaces, $html);
|
||||
return $html;
|
||||
} }}} */
|
||||
|
||||
/**
|
||||
* spaceless now uses generated code instead of
|
||||
* calling Spaceless_Tag::main() at everytime.
|
||||
*
|
||||
*/
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
$regex = array('/>[ \t\r\n]+</sU','/^[ \t\r\n]+</sU','/>[ \t\r\n]+$/sU');
|
||||
$repl = array('><', '<', '>');
|
||||
|
||||
return hexec('preg_replace', $regex, $repl, $args[0]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
56
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Templatetag.php
vendored
Normal file
56
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Templatetag.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Templatetag
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
if (count($args) != 1) {
|
||||
$compiler->Error("templatetag only needs one parameter");
|
||||
}
|
||||
|
||||
if (Haanga_AST::is_var($args[0])) {
|
||||
$type = $args[0]['var'];
|
||||
if (!is_string($type)) {
|
||||
$compiler->Error("Invalid parameter");
|
||||
}
|
||||
} else if (Haanga_AST::is_str($args[0])) {
|
||||
$type = $args[0]['string'];
|
||||
}
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'openblock':
|
||||
$str = '{%';
|
||||
break;
|
||||
case 'closeblock':
|
||||
$str = '%}';
|
||||
break;
|
||||
case 'openbrace':
|
||||
$str = '{';
|
||||
break;
|
||||
case 'closebrace':
|
||||
$str = '}';
|
||||
break;
|
||||
case 'openvariable':
|
||||
$str = '{{';
|
||||
break;
|
||||
case 'closevariable':
|
||||
$str = '}}';
|
||||
break;
|
||||
case 'opencomment':
|
||||
$str = '{#';
|
||||
break;
|
||||
case 'closecomment':
|
||||
$str = '#}';
|
||||
break;
|
||||
default:
|
||||
$compiler->Error("Invalid parameter");
|
||||
break;
|
||||
}
|
||||
|
||||
$code = hcode();
|
||||
$compiler->do_print($code, Haanga_AST::str($str));
|
||||
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
32
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Trans.php
vendored
Normal file
32
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Trans.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Trans
|
||||
{
|
||||
public $is_block = FALSE;
|
||||
|
||||
static function generator($cmp, $args, $redirect)
|
||||
{
|
||||
$code = hcode();
|
||||
|
||||
$exec = hexec('_', $args[0]);
|
||||
|
||||
if (count($args) > 1) {
|
||||
$exec = hexec('sprintf', $exec);
|
||||
foreach ($args as $id => $arg) {
|
||||
if ($id !== 0) {
|
||||
$exec->param($arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($redirect) {
|
||||
$code->decl($redirect, $exec);
|
||||
} else {
|
||||
$cmp->do_print($code, $exec);
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
19
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Tryinclude.php
vendored
Normal file
19
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Tryinclude.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Tryinclude
|
||||
{
|
||||
static function generator($cmp, $args, $declared)
|
||||
{
|
||||
if ($declared) {
|
||||
$cmp->Error("try_include can't be redirected to a variable");
|
||||
}
|
||||
|
||||
$code = hcode();
|
||||
$exec = hexec('Haanga::Safe_Load', $args[0], $cmp->getScopeVariable(), TRUE, array());
|
||||
|
||||
$cmp->do_print($code, $exec);
|
||||
|
||||
return $code;
|
||||
|
||||
}
|
||||
}
|
||||
8
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Upper.php
vendored
Normal file
8
gulliver/thirdparty/Haanga/lib/Haanga/Extension/Tag/Upper.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_Upper
|
||||
{
|
||||
public static $is_block = TRUE;
|
||||
/* This tag calls to a PHP native function */
|
||||
public static $php_alias = "strtoupper";
|
||||
}
|
||||
681
gulliver/thirdparty/Haanga/lib/Haanga/Generator/PHP.php
vendored
Normal file
681
gulliver/thirdparty/Haanga/lib/Haanga/Generator/PHP.php
vendored
Normal file
@@ -0,0 +1,681 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. Redistributions in binary form must reproduce the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer in the |
|
||||
| documentation and/or other materials provided with the distribution. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// addslashes_ex($string) {{{
|
||||
/**
|
||||
* addslashes like function for single quote string ('foo')
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function addslashes_ex($string)
|
||||
{
|
||||
return str_replace(array("\\", "'"), array("\\\\", "\\'"), $string);
|
||||
}
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* Haanga_Generator_PHP class
|
||||
*
|
||||
* This class takes the generated AST structure (arrays),
|
||||
* and generated the PHP represantion.
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Haanga_Generator_PHP
|
||||
{
|
||||
protected $ident;
|
||||
protected $tab = " ";
|
||||
protected $scopeVariableName;
|
||||
|
||||
// getCode (AST $op_code) {{{
|
||||
/**
|
||||
* Transform the AST generated by the Haanga_Compiler class
|
||||
* and return the equivalent PHP code.
|
||||
*
|
||||
* @param array $op_code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
final function getCode($op_code, $scope)
|
||||
{
|
||||
$this->scopeVariableName = $scope;
|
||||
$this->ident = 0;
|
||||
$code = "";
|
||||
$size = count($op_code);
|
||||
for ($i=0; $i < $size; $i++) {
|
||||
$op = $op_code[$i];
|
||||
if (!isset($op['op'])) {
|
||||
throw new Haanga_Compiler_Exception("Invalid \$op_code ".print_r($op, TRUE));
|
||||
}
|
||||
|
||||
/* echo optimization {{{ */
|
||||
if ($op['op'] == 'print') {
|
||||
do {
|
||||
$next_op = $op_code[$i+1];
|
||||
if (!isset($next_op) || $next_op['op'] != 'print') {
|
||||
break;
|
||||
}
|
||||
for ($e=0; $e < count($next_op); $e++) {
|
||||
if (!isset($next_op[$e])) {
|
||||
break;
|
||||
}
|
||||
$op[] = $next_op[$e];
|
||||
}
|
||||
$i++;
|
||||
} while(TRUE);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* declare optimization {{{ */
|
||||
if ($op['op'] == 'declare' || $op['op'] == 'append_var') {
|
||||
/* Code optimization
|
||||
**
|
||||
** If a variable declaration, or append variable is followed
|
||||
** by several append_var, then merge everything into a
|
||||
** single STMT.
|
||||
**
|
||||
*/
|
||||
do {
|
||||
$next_op = $op_code[$i+1];
|
||||
if (!isset($next_op) || $next_op['op'] != 'append_var' || $next_op['name'] != $op['name']) {
|
||||
break;
|
||||
}
|
||||
for ($e=0; $e < count($next_op); $e++) {
|
||||
if (!isset($next_op[$e])) {
|
||||
break;
|
||||
}
|
||||
$op[] = $next_op[$e];
|
||||
}
|
||||
$i++;
|
||||
} while(TRUE);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
$method = "php_{$op['op']}";
|
||||
if (!is_callable(array($this, $method))) {
|
||||
throw new Exception("CodeGenerator: Missing method $method");
|
||||
}
|
||||
switch ($op['op']) {
|
||||
case 'end_for':
|
||||
case 'end_foreach':
|
||||
case 'end_if':
|
||||
case 'end_function':
|
||||
case 'else':
|
||||
break;
|
||||
default:
|
||||
$code .= $this->ident();
|
||||
}
|
||||
$code .= $this->$method($op);
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// ident() {{{
|
||||
/**
|
||||
* Get the string for the current tabulation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function ident()
|
||||
{
|
||||
$code = PHP_EOL;
|
||||
$code .= str_repeat($this->tab, $this->ident);
|
||||
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_else() {{{
|
||||
/**
|
||||
* Return code for "else"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_else()
|
||||
{
|
||||
$this->ident--;
|
||||
$code = $this->ident()."} else {";
|
||||
$this->ident++;
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_comment() {{{
|
||||
/**
|
||||
* Return code for "comments"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function php_comment($op)
|
||||
{
|
||||
return "/* {$op['comment']} */";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_function(array $op) {{{
|
||||
/**
|
||||
* Return the function declaration of the class, for now
|
||||
* it has fixed params, this should change soon to generate
|
||||
* any sort of functions
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function php_function($op)
|
||||
{
|
||||
$code = "function {$op['name']}(\${$this->scopeVariableName}, \$return=FALSE, \$blocks=array())".$this->ident()."{";
|
||||
$this->ident++;
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_if(array $op) {{{
|
||||
/**
|
||||
* Return the "if" declaration and increase $this->ident
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_if($op)
|
||||
{
|
||||
$code = "if (".$this->php_generate_expr($op['expr']).") {";
|
||||
$this->ident++;
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_expr($op) {{{
|
||||
/**
|
||||
* Return a stand-alone statement
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_expr($op)
|
||||
{
|
||||
return $this->php_generate_expr($op[0]).";";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_end_block() {{{
|
||||
/**
|
||||
* Finish the current block (if, for, function, etc),
|
||||
* return the final "}", and decrease $this->ident
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_end_block()
|
||||
{
|
||||
$this->ident--;
|
||||
return $this->ident()."}";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_end_function() {{{
|
||||
/**
|
||||
* Return code to end a function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_end_function()
|
||||
{
|
||||
return $this->php_end_block();
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_end_if() {{{
|
||||
/**
|
||||
* Return code to end a if
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_end_if()
|
||||
{
|
||||
return $this->php_end_block();
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_end_for() {{{
|
||||
/**
|
||||
* Return code to end a for
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_end_for()
|
||||
{
|
||||
return $this->php_end_block();
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_end_foreach() {{{
|
||||
/**
|
||||
* Return code to end a foreach
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_end_foreach()
|
||||
{
|
||||
return $this->php_end_block();
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_for() {{{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function php_for($op)
|
||||
{
|
||||
$index = $this->php_get_varname($op['index']);
|
||||
foreach (array('min', 'max', 'step') as $type) {
|
||||
if (is_array($op[$type])) {
|
||||
$$type = $this->php_get_varname($op[$type]['var']);
|
||||
} else {
|
||||
$$type = $op[$type];
|
||||
}
|
||||
}
|
||||
$cmp = "<=";
|
||||
if (is_numeric($step) && $step < 0) {
|
||||
$cmp = ">=";
|
||||
}
|
||||
if (is_numeric($min) && is_numeric($max) && $max < $min) {
|
||||
if (is_numeric($step) && $step > 0) {
|
||||
$step *= -1;
|
||||
}
|
||||
$cmp = ">=";
|
||||
}
|
||||
|
||||
$code = "for ({$index} = {$min}; {$index} {$cmp} {$max}; {$index} += {$step}) {";
|
||||
$this->ident++;
|
||||
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_foreach(array $op) {{{
|
||||
/**
|
||||
* Return the declaration of a "foreach" statement.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_foreach($op)
|
||||
{
|
||||
$op['array'] = $this->php_get_varname($op['array']);
|
||||
$op['value'] = $this->php_get_varname($op['value']);
|
||||
$code = "foreach ((array) {$op['array']} as ";
|
||||
if (!isset($op['key'])) {
|
||||
$code .= " {$op['value']}";
|
||||
} else {
|
||||
$op['key'] = $this->php_get_varname($op['key']);
|
||||
$code .= " {$op['key']} => {$op['value']}";
|
||||
}
|
||||
|
||||
$code .= ") {";
|
||||
$this->ident++;
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_append_var(array $op) {{{
|
||||
/**
|
||||
* Return code to append something to a variable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_append_var($op)
|
||||
{
|
||||
return $this->php_declare($op, '.=');
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_exec($op) {{{
|
||||
/**
|
||||
* Return code for a function calling.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_exec($op)
|
||||
{
|
||||
$code = "";
|
||||
if (is_string($op['name'])) {
|
||||
$code .= $op['name'];
|
||||
} else {
|
||||
$function = $this->php_get_varname($op['name']);
|
||||
$code .= $function;
|
||||
}
|
||||
$code .= '(';
|
||||
if (isset($op['args'])) {
|
||||
$code .= $this->php_generate_list($op['args']);
|
||||
}
|
||||
$code .= ')';
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_global($op) {{{
|
||||
function php_global($op)
|
||||
{
|
||||
return "global \$".implode(", \$", $op['vars']).";";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_generate_expr($op) {{{
|
||||
/**
|
||||
* Return an expression
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_generate_expr($expr)
|
||||
{
|
||||
$code = '';
|
||||
if (is_object($expr)) {
|
||||
$expr = $expr->getArray();
|
||||
}
|
||||
if (is_array($expr) && isset($expr['op_expr'])) {
|
||||
if ($expr['op_expr'] == 'expr') {
|
||||
$code .= "(";
|
||||
$code .= $this->php_generate_expr($expr[0]);
|
||||
$code .= ")";
|
||||
} else if ($expr['op_expr'] == 'not') {
|
||||
$code .= "!".$this->php_generate_expr($expr[0]);
|
||||
} else {
|
||||
$code .= $this->php_generate_expr($expr[0]);
|
||||
if (is_object($expr['op_expr'])) {
|
||||
var_dump($expr);die('unexpected error');
|
||||
}
|
||||
$code .= " {$expr['op_expr']} ";
|
||||
$code .= $this->php_generate_expr($expr[1]);
|
||||
}
|
||||
} else {
|
||||
if (is_array($expr)) {
|
||||
$code .= $this->php_generate_stmt(array($expr));
|
||||
} else {
|
||||
if ($expr === FALSE) {
|
||||
$expr = 'FALSE';
|
||||
} else if ($expr === TRUE) {
|
||||
$expr = 'TRUE';
|
||||
}
|
||||
$code .= $expr;
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_generate_list(array ($array) {{{
|
||||
/**
|
||||
* Return a list of expressions for parameters
|
||||
* of a function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_generate_list($array)
|
||||
{
|
||||
$code = "";
|
||||
foreach ($array as $value) {
|
||||
$code .= $this->php_generate_stmt(array($value));
|
||||
$code .= ", ";
|
||||
}
|
||||
return substr($code, 0, -2);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_generate_stmt(Array $op) {{{
|
||||
/**
|
||||
* Return the representation of a statement
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_generate_stmt($op, $concat='.')
|
||||
{
|
||||
$code = "";
|
||||
|
||||
for ($i=0; $i < count($op); $i++) {
|
||||
if (!isset($op[$i])) {
|
||||
continue;
|
||||
}
|
||||
if (!is_Array($op[$i])) {
|
||||
throw new Haanga_Compiler_Exception("Malformed declaration ".print_r($op, TRUE));
|
||||
}
|
||||
$key = key($op[$i]);
|
||||
$value = current($op[$i]);
|
||||
switch ($key) {
|
||||
case 'array':
|
||||
$code .= "Array(";
|
||||
$code .= $this->php_generate_list($value);
|
||||
$code .= ")";
|
||||
break;
|
||||
case 'function':
|
||||
case 'exec':
|
||||
if (strlen($code) != 0 && $code[strlen($code) -1] != $concat) {
|
||||
$code .= $concat;
|
||||
}
|
||||
|
||||
$value = array('name' => $value, 'args' => $op[$i]['args']);
|
||||
$code .= $this->php_exec($value, FALSE);
|
||||
$code .= $concat;
|
||||
break;
|
||||
case 'key':
|
||||
$code .= $this->php_generate_stmt(array($value[0]))." => ".$this->php_generate_stmt(array($value[1]));
|
||||
break;
|
||||
case 'string':
|
||||
if ($code != "" && $code[strlen($code)-1] == "'") {
|
||||
$code = substr($code, 0, -1);
|
||||
} else {
|
||||
$code .= "'";
|
||||
}
|
||||
$html = addslashes_ex($value);
|
||||
$code .= $html."'";
|
||||
break;
|
||||
case 'var':
|
||||
if (strlen($code) != 0 && $code[strlen($code) -1] != $concat) {
|
||||
$code .= $concat;
|
||||
}
|
||||
$code .= $this->php_get_varname($value). $concat;
|
||||
break;
|
||||
case 'number':
|
||||
if (!is_numeric($value)) {
|
||||
throw new Exception("$value is not a valid number");
|
||||
}
|
||||
$code .= $value;
|
||||
break;
|
||||
case 'op_expr':
|
||||
if (strlen($code) != 0 && $code[strlen($code) -1] != $concat) {
|
||||
$code .= $concat;
|
||||
}
|
||||
$code .= '(' . $this->php_generate_expr($op[$i]) . ')';
|
||||
$code .= $concat;
|
||||
break;
|
||||
case 'expr':
|
||||
if (strlen($code) != 0 && $code[strlen($code) -1] != $concat) {
|
||||
$code .= $concat;
|
||||
}
|
||||
$code .= $this->php_generate_expr($value);
|
||||
$code .= $concat;
|
||||
break;
|
||||
case 'expr_cond':
|
||||
if (strlen($code) != 0 && $code[strlen($code) -1] != $concat) {
|
||||
$code .= $concat;
|
||||
}
|
||||
$code .= "(";
|
||||
$code .= $this->php_generate_expr($value);
|
||||
$code .= " ? ";
|
||||
$code .= $this->php_generate_stmt(array($op[$i]['true']));
|
||||
$code .= " : ";
|
||||
$code .= $this->php_generate_stmt(array($op[$i]['false']));
|
||||
$code .= "){$concat}";
|
||||
break;
|
||||
case 'constant':
|
||||
$code = $value;
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Don't know how to declare {$key} = {$value} (".print_r($op, TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
if ($code != "" && $code[strlen($code)-1] == $concat) {
|
||||
$code = substr($code, 0, -1);
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_print(array $op) {{{
|
||||
/**
|
||||
* Return an echo of an stmt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_print($op)
|
||||
{
|
||||
$output = $this->php_generate_stmt($op, Haanga_Compiler::getOption('echo_concat'));
|
||||
if ($output == "' '" && Haanga_Compiler::getOption('strip_whitespace')) {
|
||||
return; /* ignore this */
|
||||
}
|
||||
return 'echo '.$output.';';
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_inc(array $op) {{{
|
||||
/**
|
||||
* Return increment a variable ($var++)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_inc($op)
|
||||
{
|
||||
return "++".$this->php_get_varname($op['name']);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_declare(array $op, $assign='=') {{{
|
||||
/**
|
||||
* Return a variable declaration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_declare($op, $assign=' =')
|
||||
{
|
||||
$op['name'] = $this->php_get_varname($op['name']);
|
||||
$code = "{$op['name']} {$assign} ".$this->php_generate_stmt($op).";";
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_get_varname(mixed $var) {{{
|
||||
/**
|
||||
* Return a variable
|
||||
*
|
||||
* @param mixed $var
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_get_varname($var)
|
||||
{
|
||||
if (is_array($var)) {
|
||||
if (!is_string($var[0])) {
|
||||
if (count($var) == 1) {
|
||||
return $this->php_get_varname($var[0]);
|
||||
} else {
|
||||
throw new Exception("Invalid variable definition ".print_r($var, TRUE));
|
||||
}
|
||||
}
|
||||
$var_str = $this->php_get_varname($var[0]);
|
||||
for ($i=1; $i < count($var); $i++) {
|
||||
if (is_string($var[$i])) {
|
||||
$var_str .= "['".addslashes_ex($var[$i])."']";
|
||||
} else if (is_array($var[$i])) {
|
||||
if (isset($var[$i]['var'])) {
|
||||
/* index is a variable */
|
||||
$var_str .= '['.$this->php_get_varname($var[$i]['var']).']';
|
||||
} else if (isset($var[$i]['string'])) {
|
||||
/* index is a string */
|
||||
$var_str .= "['".addslashes_ex($var[$i]['string'])."']";
|
||||
} else if (isset($var[$i]['number'])) {
|
||||
/* index is a number */
|
||||
$var_str .= '['.$var[$i]['number'].']';
|
||||
} else if (isset($var[$i]['object'])) {
|
||||
/* Accessing a object's property */
|
||||
if (is_array($var[$i]['object'])) {
|
||||
$var_str .= '->{'.$this->php_get_varname($var[$i]['object']['var']).'}';
|
||||
} else {
|
||||
$var_str .= '->'.$var[$i]['object'];
|
||||
}
|
||||
} else if (isset($var[$i]['class'])) {
|
||||
/* Accessing a class' property */
|
||||
$var_str = substr($var_str, 1);
|
||||
if (is_array($var[$i]['class'])) {
|
||||
$var_str .= '::{'.$this->php_get_varname($var[$i]['class']['var']).'}';
|
||||
} else {
|
||||
$var_str .= '::'.$var[$i]['class'];
|
||||
}
|
||||
} else if ($var[$i] === array()) {
|
||||
/* index is a NULL (do append) */
|
||||
$var_str .= '[]';
|
||||
} else {
|
||||
throw new Haanga_Compiler_Exception('Unknown variable definition '.print_r($var, TRUE));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $var_str;
|
||||
} else {
|
||||
return "\$".$var;
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// php_return($op) {{{
|
||||
/**
|
||||
* Return "return"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function php_return($op)
|
||||
{
|
||||
$code = "return ".$this->php_generate_stmt($op).";";
|
||||
return $code;
|
||||
}
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
117
gulliver/thirdparty/Haanga/lib/Haanga/Loader.php
vendored
Normal file
117
gulliver/thirdparty/Haanga/lib/Haanga/Loader.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
/*
|
||||
This array has a map of (class => file)
|
||||
*/
|
||||
|
||||
// classes {{{
|
||||
static $classes = array (
|
||||
'haanga' => '/../Haanga.php',
|
||||
'haanga_ast' => '/AST.php',
|
||||
'haanga_extension_filter' => '/Extension/Filter.php',
|
||||
'haanga_extension' => '/Extension.php',
|
||||
'haanga_extension_tag_spaceless' => '/Extension/Tag/Spaceless.php',
|
||||
'haanga_extension_tag_exec' => '/Extension/Tag/Exec.php',
|
||||
'haanga_extension_tag_inline' => '/Extension/Tag/Inline.php',
|
||||
'haanga_extension_tag_upper' => '/Extension/Tag/Upper.php',
|
||||
'haanga_extension_tag_trans' => '/Extension/Tag/Trans.php',
|
||||
'haanga_extension_tag_templatetag' => '/Extension/Tag/Templatetag.php',
|
||||
'haanga_extension_tag_tryinclude' => '/Extension/Tag/Tryinclude.php',
|
||||
'haanga_extension_tag_setsafe' => '/Extension/Tag/Setsafe.php',
|
||||
'haanga_extension_tag_dictsort' => '/Extension/Tag/Dictsort.php',
|
||||
'haanga_extension_tag_min' => '/Extension/Tag/Min.php',
|
||||
'haanga_extension_tag_lower' => '/Extension/Tag/Lower.php',
|
||||
'haanga_extension_tag_currenttime' => '/Extension/Tag/Currenttime.php',
|
||||
'haanga_extension_tag_firstof' => '/Extension/Tag/Firstof.php',
|
||||
'haanga_extension_tag_buffer' => '/Extension/Tag/Buffer.php',
|
||||
'haanga_extension_tag_cycle' => '/Extension/Tag/Cycle.php',
|
||||
'haanga_extension_filter_urlencode' => '/Extension/Filter/Urlencode.php',
|
||||
'haanga_extension_filter_default' => '/Extension/Filter/Default.php',
|
||||
'haanga_extension_filter_length' => '/Extension/Filter/Length.php',
|
||||
'haanga_extension_filter_truncatechars' => '/Extension/Filter/Truncatechars.php',
|
||||
'haanga_extension_filter_intval' => '/Extension/Filter/Intval.php',
|
||||
'haanga_extension_filter_translation' => '/Extension/Filter/Translation.php',
|
||||
'haanga_extension_filter_trans' => '/Extension/Filter/Trans.php',
|
||||
'haanga_extension_filter_stringformat' => '/Extension/Filter/Stringformat.php',
|
||||
'haanga_extension_filter_capfirst' => '/Extension/Filter/Capfirst.php',
|
||||
'haanga_extension_filter_reverse' => '/Extension/Filter/Reverse.php',
|
||||
'haanga_extension_filter_substr' => '/Extension/Filter/Substr.php',
|
||||
'haanga_extension_filter_upper' => '/Extension/Filter/Upper.php',
|
||||
'haanga_extension_filter_isarray' => '/Extension/Filter/Isarray.php',
|
||||
'haanga_extension_filter_empty' => '/Extension/Filter/Empty.php',
|
||||
'haanga_extension_filter_trim' => '/Extension/Filter/Trim.php',
|
||||
'haanga_extension_filter_hostname' => '/Extension/Filter/Hostname.php',
|
||||
'haanga_extension_filter_count' => '/Extension/Filter/Count.php',
|
||||
'haanga_extension_filter_truncatewords' => '/Extension/Filter/Truncatewords.php',
|
||||
'haanga_extension_filter_dictsort' => '/Extension/Filter/Dictsort.php',
|
||||
'haanga_extension_filter_exists' => '/Extension/Filter/Exists.php',
|
||||
'haanga_extension_filter_title' => '/Extension/Filter/Title.php',
|
||||
'haanga_extension_filter_cut' => '/Extension/Filter/Cut.php',
|
||||
'haanga_extension_filter_date' => '/Extension/Filter/Date.php',
|
||||
'haanga_extension_filter_lower' => '/Extension/Filter/Lower.php',
|
||||
'haanga_extension_filter_slugify' => '/Extension/Filter/Slugify.php',
|
||||
'haanga_extension_filter_join' => '/Extension/Filter/Join.php',
|
||||
'haanga_extension_filter_escape' => '/Extension/Filter/Escape.php',
|
||||
'haanga_extension_filter_pluralize' => '/Extension/Filter/Pluralize.php',
|
||||
'haanga_extension_filter_safe' => '/Extension/Filter/Safe.php',
|
||||
'haanga_extension_filter_null' => '/Extension/Filter/Null.php',
|
||||
'haanga_extension_tag' => '/Extension/Tag.php',
|
||||
'hg_parser' => '/Compiler/Tokenizer.php',
|
||||
'haanga_compiler_parser' => '/Compiler/Parser.php',
|
||||
'haanga_compiler_tokenizer' => '/Compiler/Tokenizer.php',
|
||||
'haanga_yytoken' => '/Compiler/Parser.php',
|
||||
'haanga_yystackentry' => '/Compiler/Parser.php',
|
||||
'haanga_compiler_exception' => '/Compiler/Exception.php',
|
||||
'haanga_compiler_runtime' => '/Compiler/Runtime.php',
|
||||
'haanga_compiler' => '/Compiler.php',
|
||||
'haanga_exception' => '/Exception.php',
|
||||
'haanga_generator_php' => '/Generator/PHP.php',
|
||||
);
|
||||
// }}}
|
||||
|
||||
// deps {{{
|
||||
static $deps = array (
|
||||
'haanga_extension_filter' =>
|
||||
array (
|
||||
0 => 'haanga_extension',
|
||||
),
|
||||
'haanga_extension_filter_translation' =>
|
||||
array (
|
||||
0 => 'haanga_extension_filter_trans',
|
||||
),
|
||||
'haanga_extension_tag' =>
|
||||
array (
|
||||
0 => 'haanga_extension',
|
||||
),
|
||||
'hg_parser' =>
|
||||
array (
|
||||
0 => 'haanga_compiler_parser',
|
||||
),
|
||||
'haanga_compiler_runtime' =>
|
||||
array (
|
||||
0 => 'haanga_compiler',
|
||||
),
|
||||
);
|
||||
// }}}
|
||||
|
||||
$class = strtolower($class);
|
||||
if (isset($classes[$class])) {
|
||||
if (!empty($deps[$class])) {
|
||||
foreach ($deps[$class] as $zclass) {
|
||||
if (!class_exists($zclass, false) && !interface_exists($zclass, false)) {
|
||||
require __DIR__ . $classes[$zclass];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($class, false) && !interface_exists($class, false)) {
|
||||
require __DIR__ . $classes[$class];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
396
workflow/engine/PmBootstrap.php
Normal file
396
workflow/engine/PmBootstrap.php
Normal file
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
class PmBootstrap extends Bootstrap
|
||||
{
|
||||
public $pmConfig = array();
|
||||
public $isRestRequest = false;
|
||||
|
||||
//wrapped
|
||||
public function __construct($config)
|
||||
{
|
||||
parent::__construct($config);
|
||||
|
||||
define('PATH_HOME', PATH_TRUNK . 'workflow' . PATH_SEP);
|
||||
define('PATH_OUTTRUNK', realpath(PATH_TRUNK . '../') . PATH_SEP);
|
||||
|
||||
require_once PATH_HOME . 'engine/config/paths.php';
|
||||
|
||||
//if (php_sapi_name() !== 'cli') {
|
||||
session_start(); // starting session
|
||||
//}
|
||||
}
|
||||
|
||||
//wrapped
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this->pmConfig = System::getSystemConfiguration();
|
||||
|
||||
$e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
|
||||
$e_all = defined('E_STRICT') ? $e_all & ~E_STRICT : $e_all;
|
||||
$e_all = $this->pmConfig['debug'] ? $e_all : $e_all & ~E_NOTICE;
|
||||
|
||||
// Do not change any of these settings directly, use env.ini instead
|
||||
ini_set('display_errors', $this->pmConfig['debug']);
|
||||
ini_set('error_reporting', $e_all);
|
||||
ini_set('short_open_tag', 'On');
|
||||
ini_set('default_charset', "UTF-8");
|
||||
ini_set('memory_limit', $this->pmConfig['memory_limit']);
|
||||
ini_set('soap.wsdl_cache_enabled', $this->pmConfig['wsdl_cache']);
|
||||
ini_set('date.timezone', $this->pmConfig['time_zone']);
|
||||
|
||||
define ('DEBUG_SQL_LOG', $this->pmConfig['debug_sql']);
|
||||
define ('DEBUG_TIME_LOG', $this->pmConfig['debug_time']);
|
||||
define ('DEBUG_CALENDAR_LOG', $this->pmConfig['debug_calendar']);
|
||||
define ('MEMCACHED_ENABLED', $this->pmConfig['memcached']);
|
||||
define ('MEMCACHED_SERVER', $this->pmConfig['memcached_server']);
|
||||
define ('TIME_ZONE', $this->pmConfig['time_zone']);
|
||||
|
||||
// enable ERROR_SHOW_SOURCE_CODE to display the source code for any WARNING OR NOTICE
|
||||
define ('ERROR_SHOW_SOURCE_CODE', true);
|
||||
}
|
||||
|
||||
//wrapped
|
||||
public function registerClasses()
|
||||
{
|
||||
parent::registerClasses();
|
||||
|
||||
// (dynamic load)
|
||||
$basePath = PATH_CORE . 'lib/';
|
||||
|
||||
$this->autoloader->register('ProcessMaker', PATH_CORE . 'lib/');
|
||||
|
||||
$this->autoloader->register('Haanga', PATH_THIRDPARTY . 'Haanga/lib/');
|
||||
|
||||
// pm workflow classes (static load)
|
||||
$this->autoloader->registerClass('System', PATH_CORE . 'classes/class.system');
|
||||
|
||||
$this->autoloader->registerClass('Services_JSON', PATH_THIRDPARTY .'pear/json/class.json');
|
||||
$this->autoloader->registerClass('Smarty', PATH_THIRDPARTY . 'smarty/libs/Smarty.class');
|
||||
|
||||
$this->autoloader->registerClass('Propel', PATH_THIRDPARTY . 'propel/Propel');
|
||||
$this->autoloader->registerClass('Creole', PATH_THIRDPARTY . 'creole/Creole');
|
||||
$this->autoloader->registerClass('Log', PATH_THIRDPARTY . 'pear/Log');
|
||||
|
||||
|
||||
$this->autoloader->registerClass('error', PATH_GULLIVER . 'class.error');
|
||||
$this->autoloader->registerClass('dbconnection', PATH_GULLIVER . 'class.dbconnection');
|
||||
$this->autoloader->registerClass('dbsession', PATH_GULLIVER . 'class.dbsession');
|
||||
$this->autoloader->registerClass('dbrecordset', PATH_GULLIVER . 'class.dbrecordset');
|
||||
$this->autoloader->registerClass('dbtable', PATH_GULLIVER . 'class.dbtable');
|
||||
$this->autoloader->registerClass('rbac', PATH_GULLIVER . 'class.rbac' );
|
||||
$this->autoloader->registerClass('publisher', PATH_GULLIVER . 'class.publisher');
|
||||
$this->autoloader->registerClass('templatePower', PATH_GULLIVER . 'class.templatePower');
|
||||
$this->autoloader->registerClass('xmlDocument', PATH_GULLIVER . 'class.xmlDocument');
|
||||
$this->autoloader->registerClass('XmlForm_Field_XmlMenu', PATH_GULLIVER . 'class.xmlMenu');
|
||||
$this->autoloader->registerClass('xmlform', PATH_GULLIVER . 'class.xmlform');
|
||||
|
||||
$this->autoloader->registerClass('xmlformExtension', PATH_GULLIVER . 'class.xmlformExtension');
|
||||
$this->autoloader->registerClass('form', PATH_GULLIVER . 'class.form');
|
||||
$this->autoloader->registerClass('menu', PATH_GULLIVER . 'class.menu');
|
||||
$this->autoloader->registerClass('xmlMenu', PATH_GULLIVER . 'class.xmlMenu');
|
||||
$this->autoloader->registerClass('dvEditor', PATH_GULLIVER . 'class.dvEditor');
|
||||
$this->autoloader->registerClass('Controller', PATH_GULLIVER . 'class.controller');
|
||||
$this->autoloader->registerClass('HttpProxyController', PATH_GULLIVER . 'class.httpProxyController');
|
||||
$this->autoloader->registerClass('PmException', PATH_GULLIVER . 'class.pmException');
|
||||
$this->autoloader->registerClass('headPublisher', PATH_GULLIVER . 'class.headPublisher');
|
||||
$this->autoloader->registerClass('Xml_Node', PATH_GULLIVER . 'class.xmlDocument');
|
||||
$this->autoloader->registerClass('Xml_document', PATH_GULLIVER . 'class.xmlDocument');
|
||||
$this->autoloader->registerClass('XmlForm_Field_*', PATH_GULLIVER . 'class.xmlform');
|
||||
$this->autoloader->registerClass('serverConf', PATH_CORE . 'classes/class.serverConfiguration');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify write permissions for folders that processmaker needs write
|
||||
*/
|
||||
public function verifyWritableFolders()
|
||||
{
|
||||
// Verifiying permissions processmaker writable directories
|
||||
$writableDirs = array(PATH_CONFIG, PATH_XMLFORM, PATH_HTML, PATH_PLUGINS);
|
||||
|
||||
if (defined('PATH_DATA')) {
|
||||
$writableDirs[] = PATH_DATA;
|
||||
}
|
||||
|
||||
try {
|
||||
G::verifyWriteAccess($writableDirs);
|
||||
} catch (Exception $e) {
|
||||
G::renderTemplate('write_access_denied.exception', array('files' => $e->files));
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On this method have some sys env, configuration, and other fixes
|
||||
*/
|
||||
public function fixEnvironment()
|
||||
{
|
||||
// IIS Compatibility, SERVER_ADDR doesn't exist on that env, so we need to define it.
|
||||
$_SERVER['SERVER_ADDR'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['SERVER_NAME'];
|
||||
|
||||
//check if it is a installation instance
|
||||
if(!defined('PATH_C')) {
|
||||
// is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily
|
||||
define('PATH_C', (rtrim(G::sys_get_temp_dir(), PATH_SEP) . PATH_SEP));
|
||||
define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' );
|
||||
}
|
||||
}
|
||||
|
||||
public function loadLeimud()
|
||||
{
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
|
||||
// Defining the maborak js file, this file is the concat of many js files and here we are including all of them.
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/maborak.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/common.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/effects.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/webResource.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'dveditor/core/dveditor.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/tree/tree.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'json/core/json.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/form.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/pagedTable.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'grid/core/grid.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.panel.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.validator.js', true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.app.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.rpc.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.fx.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drag.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drop.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dom.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.abbr.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dashboard.js', true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/js-calendar/js-calendar.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/suggest/bsn.AutoSuggest_2.1.3.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/tooltip/pmtooltip.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'thirdparty/krumo/krumo.js' );
|
||||
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/calendar/pmcalendar.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases.js' , true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases_Step.js', true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'processmap/core/processmap.js', true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'appFolder/core/appFolderList.js', true );
|
||||
$oHeadPublisher->addMaborakFile(PATH_THIRDPARTY . 'htmlarea/editor.js', true );
|
||||
|
||||
//$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . "widgets/jscalendar/lang/calendar-" . SYS_LANG . ".js");
|
||||
}
|
||||
|
||||
public function dispatchResource()
|
||||
{
|
||||
$realPath = $this->matchRoute['path'];
|
||||
|
||||
switch ($this->matchRoute['type']) {
|
||||
case 'sysUnnamed' :
|
||||
require_once('sysUnnamed.php');
|
||||
die;
|
||||
break;
|
||||
|
||||
case 'sysNamed' :
|
||||
header('location : ' . $_SERVER['REQUEST_URI'] . '/' .SYS_LANG. '/classic/login/login' );
|
||||
die;
|
||||
break;
|
||||
|
||||
case 'jsMethod' :
|
||||
G::parseURI(getenv("REQUEST_URI"));
|
||||
$filename = PATH_METHODS . SYS_COLLECTION . '/' . SYS_TARGET . '.js';
|
||||
G::streamFile($filename);
|
||||
die;
|
||||
break;
|
||||
|
||||
case 'errorFile':
|
||||
header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
|
||||
if ( DEBUG_TIME_LOG )
|
||||
G::logTimeByPage(); //log this page
|
||||
die;
|
||||
break;
|
||||
|
||||
case 'plugin':
|
||||
//Get the Plugin Folder, always the first element
|
||||
$pluginFolder = array_shift($realPath);
|
||||
//The other parts are the realpath into public_html (no matter how many elements)
|
||||
$filePath = implode(PATH_SEP, $realPath);
|
||||
$pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html'. PATH_SEP . $filePath;
|
||||
|
||||
if (file_exists($pluginFilename)) {
|
||||
G::streamFile ($pluginFilename);
|
||||
}
|
||||
die;
|
||||
break;
|
||||
|
||||
case 'skin':
|
||||
$fileToBeStreamed = str_replace("/skin/", PATH_CUSTOM_SKINS, $_SERVER['REQUEST_URI']);
|
||||
|
||||
if (file_exists($fileToBeStreamed)) {
|
||||
G::streamFile($fileToBeStreamed);
|
||||
}
|
||||
die;
|
||||
break;
|
||||
|
||||
default :
|
||||
$realPath .= strpos(basename($realPath), '.') === false ? '.php' : '';
|
||||
G::streamFile($realPath);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
public function fixPmFiles()
|
||||
{
|
||||
// verify if index.html exists
|
||||
if (!file_exists(PATH_HTML . 'index.html')) { // if not, create it from template
|
||||
file_put_contents(
|
||||
PATH_HTML . 'index.html',
|
||||
G::parseTemplate(PATH_TPL . 'index.html', array('lang' => SYS_LANG, 'skin' => SYS_SKIN))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function dispatchInstaller()
|
||||
{
|
||||
// new installer, extjs based
|
||||
define('PATH_DATA', PATH_C);
|
||||
require_once ( PATH_CONTROLLERS . 'installer.php' );
|
||||
$controller = 'Installer';
|
||||
|
||||
// if the method name is empty set default to index method
|
||||
if (strpos(SYS_TARGET, '/') !== false) {
|
||||
list($controller, $controllerAction) = explode('/', SYS_TARGET);
|
||||
}
|
||||
else {
|
||||
$controllerAction = SYS_TARGET;
|
||||
}
|
||||
|
||||
$controllerAction = ($controllerAction != '' && $controllerAction != 'login')? $controllerAction: 'index';
|
||||
|
||||
// create the installer controller and call its method
|
||||
if( is_callable(Array('Installer', $controllerAction)) ) {
|
||||
$installer = new $controller();
|
||||
$installer->setHttpRequestData($_REQUEST);
|
||||
$installer->call($controllerAction);
|
||||
}
|
||||
else {
|
||||
$_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI'];
|
||||
header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
|
||||
}
|
||||
}
|
||||
|
||||
public function initPropel($sys = '')
|
||||
{
|
||||
if (empty($sys)) {
|
||||
if (! defined(SYS_SYS)) {
|
||||
throw new Exception("Error: Undefined syemtem env. constant 'SYS_SYS'");
|
||||
}
|
||||
|
||||
$sys = SYS_SYS;
|
||||
}
|
||||
|
||||
// setup propel definitions and logging
|
||||
if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) {
|
||||
define('PM_PID', mt_rand(1,999999));
|
||||
|
||||
// register debug connection decorator driver
|
||||
Creole::registerDriver('*', 'creole.contrib.DebugConnection');
|
||||
|
||||
// initialize Propel with converted config file
|
||||
Propel::init( PATH_CORE . "config/databases.php" );
|
||||
|
||||
// unified log file for all databases
|
||||
$logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log';
|
||||
$logger = Log::singleton('file', $logFile, 'wf ' . $sys, null, PEAR_LOG_INFO);
|
||||
Propel::setLogger($logger);
|
||||
|
||||
// log file for workflow database
|
||||
$con = Propel::getConnection('workflow');
|
||||
if ($con instanceof DebugConnection) {
|
||||
$con->setLogger($logger);
|
||||
}
|
||||
// log file for rbac database
|
||||
$con = Propel::getConnection('rbac');
|
||||
|
||||
if ($con instanceof DebugConnection) {
|
||||
$con->setLogger($logger);
|
||||
}
|
||||
|
||||
// log file for report database
|
||||
$con = Propel::getConnection('rp');
|
||||
if ($con instanceof DebugConnection) {
|
||||
$con->setLogger($logger);
|
||||
}
|
||||
} else {
|
||||
Propel::init( PATH_CORE . "config/databases.php" );
|
||||
}
|
||||
|
||||
Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
|
||||
}
|
||||
|
||||
public function verifyUserSession($target, $collection)
|
||||
{
|
||||
// this is the blank list to allow execute scripts with no login (without session started)
|
||||
$noLoginFiles = $noLoginFolders = array();
|
||||
$noLoginFiles[] = 'login';
|
||||
$noLoginFiles[] = 'authentication';
|
||||
$noLoginFiles[] = 'login_Ajax';
|
||||
$noLoginFiles[] = 'dbInfo';
|
||||
$noLoginFiles[] = 'sysLoginVerify';
|
||||
$noLoginFiles[] = 'processes_Ajax';
|
||||
$noLoginFiles[] = 'updateTranslation';
|
||||
$noLoginFiles[] = 'autoinstallProcesses';
|
||||
$noLoginFiles[] = 'autoinstallPlugins';
|
||||
$noLoginFiles[] = 'heartbeatStatus';
|
||||
$noLoginFiles[] = 'showLogoFile';
|
||||
$noLoginFiles[] = 'forgotPassword';
|
||||
$noLoginFiles[] = 'retrivePassword';
|
||||
$noLoginFiles[] = 'defaultAjaxDynaform';
|
||||
$noLoginFiles[] = 'dynaforms_checkDependentFields';
|
||||
|
||||
$noLoginFolders[] = 'services';
|
||||
$noLoginFolders[] = 'tracker';
|
||||
$noLoginFolders[] = 'installer';
|
||||
|
||||
// This sentence is used when you lost the Session
|
||||
if (! in_array(SYS_TARGET, $noLoginFiles)
|
||||
&& ! in_array(SYS_COLLECTION, $noLoginFolders)
|
||||
&& $bWE != true && $collectionPlugin != 'services'
|
||||
&& ! $isRestRequest
|
||||
) {
|
||||
$bRedirect = true;
|
||||
|
||||
if (isset($_GET['sid'])) {
|
||||
G::LoadClass('sessions');
|
||||
$oSessions = new Sessions();
|
||||
if ($aSession = $oSessions->verifySession($_GET['sid'])) {
|
||||
require_once 'classes/model/Users.php';
|
||||
$oUser = new Users();
|
||||
$aUser = $oUser->load($aSession['USR_UID']);
|
||||
$_SESSION['USER_LOGGED'] = $aUser['USR_UID'];
|
||||
$_SESSION['USR_USERNAME'] = $aUser['USR_USERNAME'];
|
||||
$bRedirect = false;
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] );
|
||||
$memKey = 'rbacSession' . session_id();
|
||||
$memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS );
|
||||
}
|
||||
}
|
||||
|
||||
if ($bRedirect) {
|
||||
if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') { // verify if the current skin is a 'ux' variant
|
||||
$loginUrl = 'main/login';
|
||||
} else if (strpos($_SERVER['REQUEST_URI'], '/home') !== false){ //verify is it is using the uxs skin for simplified interface
|
||||
$loginUrl = 'home/login';
|
||||
} else {
|
||||
$loginUrl = 'login/login'; // just set up the classic login
|
||||
}
|
||||
|
||||
if (empty($_POST)) {
|
||||
header('location: ' . SYS_URI . $loginUrl . '?u=' . urlencode($_SERVER['REQUEST_URI']));
|
||||
} else {
|
||||
if ($isControllerCall) {
|
||||
header("HTTP/1.0 302 session lost in controller");
|
||||
} else {
|
||||
header('location: ' . SYS_URI . $loginUrl);
|
||||
}
|
||||
}
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
workflow/engine/bin/rest-gen.php
Normal file
57
workflow/engine/bin/rest-gen.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
include '../../../gulliver/Core/Bootstrap.php';
|
||||
include '../../../workflow/engine/PmBootstrap.php';
|
||||
|
||||
$config = array(
|
||||
'path_trunk' => realpath('../../../')
|
||||
);
|
||||
|
||||
$bootstrap = new PmBootstrap($config);
|
||||
$bootstrap->registerClasses();
|
||||
$bootstrap->configure();
|
||||
|
||||
if (! isset($argv[1])) {
|
||||
$help = '$>' . $argv[0] . " [option]\n";
|
||||
$help .= "Avalaibles options:\n";
|
||||
$help .= " build-api : Build the PM Rest API.\n";
|
||||
$help .= " gen-ini : Generates the rest config ini file.\n\n";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$restTool = new Service_Rest_RestTool();
|
||||
|
||||
try {
|
||||
switch ($argv[1]) {
|
||||
case 'build-api':
|
||||
$restTool->buildApi();
|
||||
break;
|
||||
|
||||
case 'gen-ini':
|
||||
if (file_exists(PATH_CONFIG . '/rest-config.ini')) {
|
||||
echo "The file 'rest-config.ini' already exits, overwrite (Y/n)? ";
|
||||
$resp = trim(fgets(STDIN));
|
||||
|
||||
if (strtolower($resp) != 'y') {
|
||||
echo "Skipped\n";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Generating config ini file ... ";
|
||||
|
||||
$genFile = $restTool->buildConfigIni();
|
||||
|
||||
echo "DONE!\n";
|
||||
echo "File generated: $genFile\n\n";
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "Invalid option!\n";
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
233
workflow/engine/lib/Service/Rest/RestTool.php
Normal file
233
workflow/engine/lib/Service/Rest/RestTool.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
class Service_Rest_RestTool
|
||||
{
|
||||
protected $configFile = 'rest-config.ini';
|
||||
protected $config = array();
|
||||
protected $dbXmlSchemaFile = '';
|
||||
protected $dbInfo = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dbXmlSchemaFile = PATH_CONFIG . 'schema.xml';
|
||||
}
|
||||
|
||||
protected function loadConfig()
|
||||
{
|
||||
if (file_exists(PATH_CONFIG . $this->configFile)) {
|
||||
$this->config = @parse_ini_file(PATH_CONFIG . $this->configFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadDbXmlSchema($dbXmlSchemaFile = '')
|
||||
{
|
||||
if (! empty($dbXmlSchemaFile)) {
|
||||
$this->dbXmlSchemaFile = $dbXmlSchemaFile;
|
||||
}
|
||||
|
||||
if (! file_exists($this->dbXmlSchemaFile)) {
|
||||
throw new Exception("Xml Schema file: '{$this->dbXmlSchemaFile}' does not exist!");
|
||||
}
|
||||
|
||||
$doc = new Xml_DOMDocumentExtended();
|
||||
$doc->load($this->dbXmlSchemaFile);
|
||||
$data = $doc->toArray();
|
||||
$tables = $data['database']['table'];
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$this->dbInfo[$table['@name']]['pKeys'] = array();
|
||||
$this->dbInfo[$table['@name']]['columns'] = array();
|
||||
$this->dbInfo[$table['@name']]['required_columns'] = array();
|
||||
|
||||
foreach ($table['column'] as $column) {
|
||||
$this->dbInfo[$table['@name']]['columns'][] = $column['@name'];
|
||||
|
||||
if (array_key_exists('@primaryKey', $column) && self::cast($column['@primaryKey'])) {
|
||||
$this->dbInfo[$table['@name']]['pKeys'][] = $column['@name'];
|
||||
}
|
||||
|
||||
if (array_key_exists('@required', $column) && self::cast($column['@required'])) {
|
||||
$this->dbInfo[$table['@name']]['required_columns'][] = $column['@name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function buildConfigIni($filename = '')
|
||||
{
|
||||
$this->loadDbXmlSchema();
|
||||
|
||||
$this->configFile = empty($filename) ? PATH_CONFIG . $this->configFile : $filename;
|
||||
$configIniStr = '';
|
||||
|
||||
foreach ($this->dbInfo as $table => $columns) {
|
||||
$configIniStr .= "[$table]\n";
|
||||
$configIniStr .= " ALLOW_METHODS = GET POST PUT DELETE\n";
|
||||
$configIniStr .= " EXPOSE_COLUMNS_GET = *\n";
|
||||
$configIniStr .= " EXPOSE_COLUMNS_POST = ".implode(' ', $columns) . "\n";
|
||||
$configIniStr .= " EXPOSE_COLUMNS_PUT = ".implode(' ', $columns) . "\n";
|
||||
$configIniStr .= "\n";
|
||||
}
|
||||
|
||||
file_put_contents($this->configFile, $configIniStr);
|
||||
|
||||
return $this->configFile;
|
||||
}
|
||||
|
||||
public function buildApi()
|
||||
{
|
||||
/**
|
||||
* load configuration from /engine/config/rest-config.ini and
|
||||
* load database schemda from /engine/config/schema.xml
|
||||
*/
|
||||
$this->loadConfig();
|
||||
$this->loadDbXmlSchema();
|
||||
|
||||
Haanga::configure(array(
|
||||
'template_dir' => dirname(__FILE__) . '/templates/',
|
||||
'cache_dir' => sys_get_temp_dir() . '/haanga_cache/',
|
||||
'compiler' => array(
|
||||
'compiler' => array( /* opts for the tpl compiler */
|
||||
'if_empty' => FALSE,
|
||||
'autoescape' => FALSE,
|
||||
'strip_whitespace' => TRUE,
|
||||
'allow_exec' => TRUE,
|
||||
'global' => array('globals', 'current_user'),
|
||||
),
|
||||
|
||||
)
|
||||
));
|
||||
|
||||
foreach ($this->config as $table => $conf) {
|
||||
$classname = self::camelize($table, 'class');
|
||||
$allowedMethods = explode(' ', $conf['ALLOW_METHODS']);
|
||||
$methods = '';
|
||||
//$allowedMethods = array('DELETE');
|
||||
|
||||
foreach ($allowedMethods as $method) {
|
||||
$method = strtoupper($method);
|
||||
$exposedColumns = array();
|
||||
$params = array();
|
||||
$paramsStr = array();
|
||||
$primaryKeys = array();
|
||||
|
||||
// get columns to expose
|
||||
if (array_key_exists('EXPOSE_COLUMNS_'.$method, $conf)) {
|
||||
if ($conf['EXPOSE_COLUMNS_'.$method] == '*') {
|
||||
$exposedColumns = $this->dbInfo[$table]['columns'];
|
||||
} else {
|
||||
$exposedColumns = explode(' ', $conf['EXPOSE_COLUMNS_'.$method]);
|
||||
|
||||
// validate that all required columns are in exposed columns array
|
||||
if ($method == 'POST') {
|
||||
// intersect required columns with exposed columns
|
||||
// to verify is all required columns are exposed
|
||||
$intersect = array_intersect($this->dbInfo[$table]['required_columns'], $exposedColumns);
|
||||
|
||||
// the diff should be empty
|
||||
$diff = array_diff($this->dbInfo[$table]['required_columns'], $intersect);
|
||||
|
||||
if (! empty($diff)) {
|
||||
throw new Exception(sprintf(
|
||||
"Error: All required columns for table '%s' must be exposed for POST method.\n" .
|
||||
"PLease add all required columns on rule 'EXPOSE_COLUMNS_POST' or select all " .
|
||||
"with '*' selector.\n\n" .
|
||||
"Missing (%s) required fields for [%s] table:\n" .
|
||||
implode("\n", $diff),
|
||||
$table, count($diff), $table
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
foreach ($this->dbInfo[$table]['pKeys'] as $i => $pk) {
|
||||
$paramsStr[$i] = "\$".self::camelize($pk).'=null';
|
||||
$params[$i] = self::camelize($pk);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
foreach ($exposedColumns as $i => $column) {
|
||||
$paramsStr[$i] = "\$".self::camelize($column);
|
||||
|
||||
if (! in_array($column, $this->dbInfo[$table]['pKeys'])) {
|
||||
$params[$i] = self::camelize($column);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
foreach ($exposedColumns as $i => $column) {
|
||||
$paramsStr[$i] = "\$".self::camelize($column);
|
||||
$params[$i] = self::camelize($column);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$paramsStr = implode(', ', $paramsStr);
|
||||
|
||||
// formatting primary keys for template
|
||||
foreach ($this->dbInfo[$table]['pKeys'] as $i => $pk) {
|
||||
$primaryKeys[$i] = "\$".self::camelize($pk);
|
||||
}
|
||||
$primaryKeys = implode(', ', $primaryKeys);
|
||||
|
||||
$methods .= Haanga::Load(
|
||||
'method'.self::camelize($method, 'class').'.tpl',
|
||||
array(
|
||||
'params' => $params,
|
||||
'paramsStr' => $paramsStr,
|
||||
'primaryKeys' => $primaryKeys,
|
||||
'columns' => $exposedColumns,
|
||||
'classname' => $classname,
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$methods .= "\n";
|
||||
}
|
||||
|
||||
$classContent = Haanga::Load('class.tpl', array(
|
||||
'classname' => $classname,
|
||||
'methods' => $methods
|
||||
), true);
|
||||
|
||||
echo "saving $classname.php\n";
|
||||
file_put_contents(PATH_CORE."services/rest/crud/$classname.php", $classContent);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function camelize($str, $type = 'var')
|
||||
{
|
||||
if (is_array($str)) {
|
||||
foreach ($str as $i => $value) {
|
||||
$str[$i] = self::camelize($value);
|
||||
}
|
||||
} elseif (is_string($str)) {
|
||||
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($str))));
|
||||
}
|
||||
|
||||
if ($type == 'var') {
|
||||
$str = substr(strtolower($str), 0, 1) . substr($str, 1);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
protected static function cast($value)
|
||||
{
|
||||
if ($value === 'true') {
|
||||
return true;
|
||||
} elseif ($value === 'false') {
|
||||
return false;
|
||||
} elseif (is_numeric($value)) {
|
||||
return $value * 1;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
workflow/engine/lib/Service/Rest/templates/class.tpl
Normal file
6
workflow/engine/lib/Service/Rest/templates/class.tpl
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_{{ classname }}
|
||||
{
|
||||
{{ methods | safe }}
|
||||
}
|
||||
27
workflow/engine/lib/Service/Rest/templates/methodDelete.tpl
Normal file
27
workflow/engine/lib/Service/Rest/templates/methodDelete.tpl
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
{% for pk in primaryKeys %}* @param mixed {{ pk }} Primary key
|
||||
{% endfor %}*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete({{ primaryKeys }})
|
||||
{
|
||||
$conn = Propel::getConnection({{ classname }}Peer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = {{ classname }}Peer::retrieveByPK({{ primaryKeys }});
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
33
workflow/engine/lib/Service/Rest/templates/methodGet.tpl
Normal file
33
workflow/engine/lib/Service/Rest/templates/methodGet.tpl
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
{% for pk in primaryKeys %}* @param mixed {{ pk }} Primary key
|
||||
{% endfor %}*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get({{ paramsStr }})
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
{% for column in columns %}$criteria->addSelectColumn({{ classname }}Peer::{{column}});
|
||||
{% endfor %}
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = {{ classname }}Peer::retrieveByPK({{ primaryKeys }});
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
21
workflow/engine/lib/Service/Rest/templates/methodPost.tpl
Normal file
21
workflow/engine/lib/Service/Rest/templates/methodPost.tpl
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
{% for pk in primaryKeys %}* @param mixed {{ pk }} Primary key
|
||||
{% endfor %}*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post({{ paramsStr }})
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new {{ classname }}();
|
||||
|
||||
{% for param in params %}$obj->set{{ param | Capfirst }}(${{ param }});
|
||||
{% endfor %}
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
20
workflow/engine/lib/Service/Rest/templates/methodPut.tpl
Normal file
20
workflow/engine/lib/Service/Rest/templates/methodPut.tpl
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
{% for pk in primaryKeys %}* @param mixed {{ pk }} Primary key
|
||||
{% endfor %}*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put({{ paramsStr }})
|
||||
{
|
||||
try {
|
||||
$obj = {{ classname }}Peer::retrieveByPK({{ primaryKeys }});
|
||||
|
||||
{% for param in params %}$obj->set{{ param | Capfirst }}(${{ param }});
|
||||
{% endfor %}
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
66
workflow/engine/lib/Xml/DOMDocumentExtended.php
Normal file
66
workflow/engine/lib/Xml/DOMDocumentExtended.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
class Xml_DOMDocumentExtended extends DOMDocument
|
||||
{
|
||||
public function toArray(DOMNode $oDomNode = null)
|
||||
{
|
||||
// return empty array if dom is blank
|
||||
if (is_null($oDomNode) && !$this->hasChildNodes()) {
|
||||
return array();
|
||||
}
|
||||
$oDomNode = (is_null($oDomNode)) ? $this->documentElement : $oDomNode;
|
||||
if (!$oDomNode->hasChildNodes()) {
|
||||
$mResult = $oDomNode->nodeValue;
|
||||
} else {
|
||||
$mResult = array();
|
||||
foreach ($oDomNode->childNodes as $oChildNode) {
|
||||
// how many of these child nodes do we have?
|
||||
// this will give us a clue as to what the result structure should be
|
||||
$oChildNodeList = $oDomNode->getElementsByTagName($oChildNode->nodeName);
|
||||
$iChildCount = 0;
|
||||
// there are x number of childs in this node that have the same tag name
|
||||
// however, we are only interested in the # of siblings with the same tag name
|
||||
foreach ($oChildNodeList as $oNode) {
|
||||
if ($oNode->parentNode->isSameNode($oChildNode->parentNode)) {
|
||||
$iChildCount++;
|
||||
}
|
||||
}
|
||||
$mValue = $this->toArray($oChildNode);
|
||||
$sKey = ($oChildNode->nodeName{0} == '#') ? 0 : $oChildNode->nodeName;
|
||||
$mValue = is_array($mValue) ? $mValue[$oChildNode->nodeName] : $mValue;
|
||||
// how many of thse child nodes do we have?
|
||||
if ($iChildCount > 1) { // more than 1 child - make numeric array
|
||||
$mResult[$sKey][] = $mValue;
|
||||
} else {
|
||||
$mResult[$sKey] = $mValue;
|
||||
}
|
||||
}
|
||||
// if the child is <foo>bar</foo>, the result will be array(bar)
|
||||
// make the result just 'bar'
|
||||
if (count($mResult) == 1 && isset($mResult[0]) && !is_array($mResult[0])) {
|
||||
$mResult = $mResult[0];
|
||||
}
|
||||
}
|
||||
// get our attributes if we have any
|
||||
$arAttributes = array();
|
||||
if ($oDomNode->hasAttributes()) {
|
||||
foreach ($oDomNode->attributes as $sAttrName=>$oAttrNode) {
|
||||
// retain namespace prefixes
|
||||
$arAttributes["@{$oAttrNode->nodeName}"] = $oAttrNode->nodeValue;
|
||||
}
|
||||
}
|
||||
// check for namespace attribute - Namespaces will not show up in the attributes list
|
||||
if ($oDomNode instanceof DOMElement && $oDomNode->getAttribute('xmlns')) {
|
||||
$arAttributes["@xmlns"] = $oDomNode->getAttribute('xmlns');
|
||||
}
|
||||
if (count($arAttributes)) {
|
||||
if (!is_array($mResult)) {
|
||||
$mResult = (trim($mResult)) ? array($mResult) : array();
|
||||
}
|
||||
$mResult = array_merge($mResult, $arAttributes);
|
||||
}
|
||||
$arResult = array($oDomNode->nodeName=>$mResult);
|
||||
|
||||
return $arResult;
|
||||
}
|
||||
}
|
||||
155
workflow/engine/services/rest/crud/AdditionalTables.php
Normal file
155
workflow/engine/services/rest/crud/AdditionalTables.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AdditionalTables
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $addTabUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($addTabUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_CLASS_NAME);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_INSERT);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_UPDATE);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_DELETE);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_SELECT);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_MAX_LENGTH);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_AUTO_DELETE);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_PLG_UID);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::DBS_UID);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TYPE);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_GRID);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TAG);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AdditionalTablesPeer::retrieveByPK($addTabUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $addTabUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($addTabUid, $addTabName, $addTabClassName, $addTabDescription, $addTabSdwLogInsert, $addTabSdwLogUpdate, $addTabSdwLogDelete, $addTabSdwLogSelect, $addTabSdwMaxLength, $addTabSdwAutoDelete, $addTabPlgUid, $dbsUid, $proUid, $addTabType, $addTabGrid, $addTabTag)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AdditionalTables();
|
||||
|
||||
$obj->setAddTabUid($addTabUid);
|
||||
$obj->setAddTabName($addTabName);
|
||||
$obj->setAddTabClassName($addTabClassName);
|
||||
$obj->setAddTabDescription($addTabDescription);
|
||||
$obj->setAddTabSdwLogInsert($addTabSdwLogInsert);
|
||||
$obj->setAddTabSdwLogUpdate($addTabSdwLogUpdate);
|
||||
$obj->setAddTabSdwLogDelete($addTabSdwLogDelete);
|
||||
$obj->setAddTabSdwLogSelect($addTabSdwLogSelect);
|
||||
$obj->setAddTabSdwMaxLength($addTabSdwMaxLength);
|
||||
$obj->setAddTabSdwAutoDelete($addTabSdwAutoDelete);
|
||||
$obj->setAddTabPlgUid($addTabPlgUid);
|
||||
$obj->setDbsUid($dbsUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAddTabType($addTabType);
|
||||
$obj->setAddTabGrid($addTabGrid);
|
||||
$obj->setAddTabTag($addTabTag);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $addTabUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($addTabUid, $addTabName, $addTabClassName, $addTabDescription, $addTabSdwLogInsert, $addTabSdwLogUpdate, $addTabSdwLogDelete, $addTabSdwLogSelect, $addTabSdwMaxLength, $addTabSdwAutoDelete, $addTabPlgUid, $dbsUid, $proUid, $addTabType, $addTabGrid, $addTabTag)
|
||||
{
|
||||
try {
|
||||
$obj = AdditionalTablesPeer::retrieveByPK($addTabUid);
|
||||
|
||||
$obj->setAddTabName($addTabName);
|
||||
$obj->setAddTabClassName($addTabClassName);
|
||||
$obj->setAddTabDescription($addTabDescription);
|
||||
$obj->setAddTabSdwLogInsert($addTabSdwLogInsert);
|
||||
$obj->setAddTabSdwLogUpdate($addTabSdwLogUpdate);
|
||||
$obj->setAddTabSdwLogDelete($addTabSdwLogDelete);
|
||||
$obj->setAddTabSdwLogSelect($addTabSdwLogSelect);
|
||||
$obj->setAddTabSdwMaxLength($addTabSdwMaxLength);
|
||||
$obj->setAddTabSdwAutoDelete($addTabSdwAutoDelete);
|
||||
$obj->setAddTabPlgUid($addTabPlgUid);
|
||||
$obj->setDbsUid($dbsUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAddTabType($addTabType);
|
||||
$obj->setAddTabGrid($addTabGrid);
|
||||
$obj->setAddTabTag($addTabTag);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $addTabUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($addTabUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AdditionalTablesPeer::retrieveByPK($addTabUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
196
workflow/engine/services/rest/crud/AppCacheView.php
Normal file
196
workflow/engine/services/rest/crud/AppCacheView.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppCacheView
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null, $delIndex=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::USR_UID);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::PREVIOUS_USR_UID);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_DELEGATE_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_INIT_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_TASK_DUE_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_FINISH_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_THREAD_STATUS);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_THREAD_STATUS);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_TITLE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_TAS_TITLE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_CURRENT_USER);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_DEL_PREVIOUS_USER);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_PRIORITY);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_DURATION);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_QUEUE_DURATION);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_DELAY_DURATION);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_STARTED);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_FINISHED);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_DELAYED);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_CREATE_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_FINISH_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_UPDATE_DATE);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::APP_OVERDUE_PERCENTAGE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppCacheViewPeer::retrieveByPK($appUid, $delIndex);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $delIndex, $appNumber, $appStatus, $usrUid, $previousUsrUid, $tasUid, $proUid, $delDelegateDate, $delInitDate, $delTaskDueDate, $delFinishDate, $delThreadStatus, $appThreadStatus, $appTitle, $appProTitle, $appTasTitle, $appCurrentUser, $appDelPreviousUser, $delPriority, $delDuration, $delQueueDuration, $delDelayDuration, $delStarted, $delFinished, $delDelayed, $appCreateDate, $appFinishDate, $appUpdateDate, $appOverduePercentage)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppCacheView();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setAppNumber($appNumber);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setPreviousUsrUid($previousUsrUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setDelDelegateDate($delDelegateDate);
|
||||
$obj->setDelInitDate($delInitDate);
|
||||
$obj->setDelTaskDueDate($delTaskDueDate);
|
||||
$obj->setDelFinishDate($delFinishDate);
|
||||
$obj->setDelThreadStatus($delThreadStatus);
|
||||
$obj->setAppThreadStatus($appThreadStatus);
|
||||
$obj->setAppTitle($appTitle);
|
||||
$obj->setAppProTitle($appProTitle);
|
||||
$obj->setAppTasTitle($appTasTitle);
|
||||
$obj->setAppCurrentUser($appCurrentUser);
|
||||
$obj->setAppDelPreviousUser($appDelPreviousUser);
|
||||
$obj->setDelPriority($delPriority);
|
||||
$obj->setDelDuration($delDuration);
|
||||
$obj->setDelQueueDuration($delQueueDuration);
|
||||
$obj->setDelDelayDuration($delDelayDuration);
|
||||
$obj->setDelStarted($delStarted);
|
||||
$obj->setDelFinished($delFinished);
|
||||
$obj->setDelDelayed($delDelayed);
|
||||
$obj->setAppCreateDate($appCreateDate);
|
||||
$obj->setAppFinishDate($appFinishDate);
|
||||
$obj->setAppUpdateDate($appUpdateDate);
|
||||
$obj->setAppOverduePercentage($appOverduePercentage);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $delIndex, $appNumber, $appStatus, $usrUid, $previousUsrUid, $tasUid, $proUid, $delDelegateDate, $delInitDate, $delTaskDueDate, $delFinishDate, $delThreadStatus, $appThreadStatus, $appTitle, $appProTitle, $appTasTitle, $appCurrentUser, $appDelPreviousUser, $delPriority, $delDuration, $delQueueDuration, $delDelayDuration, $delStarted, $delFinished, $delDelayed, $appCreateDate, $appFinishDate, $appUpdateDate, $appOverduePercentage)
|
||||
{
|
||||
try {
|
||||
$obj = AppCacheViewPeer::retrieveByPK($appUid, $delIndex);
|
||||
|
||||
$obj->setAppNumber($appNumber);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setPreviousUsrUid($previousUsrUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setDelDelegateDate($delDelegateDate);
|
||||
$obj->setDelInitDate($delInitDate);
|
||||
$obj->setDelTaskDueDate($delTaskDueDate);
|
||||
$obj->setDelFinishDate($delFinishDate);
|
||||
$obj->setDelThreadStatus($delThreadStatus);
|
||||
$obj->setAppThreadStatus($appThreadStatus);
|
||||
$obj->setAppTitle($appTitle);
|
||||
$obj->setAppProTitle($appProTitle);
|
||||
$obj->setAppTasTitle($appTasTitle);
|
||||
$obj->setAppCurrentUser($appCurrentUser);
|
||||
$obj->setAppDelPreviousUser($appDelPreviousUser);
|
||||
$obj->setDelPriority($delPriority);
|
||||
$obj->setDelDuration($delDuration);
|
||||
$obj->setDelQueueDuration($delQueueDuration);
|
||||
$obj->setDelDelayDuration($delDelayDuration);
|
||||
$obj->setDelStarted($delStarted);
|
||||
$obj->setDelFinished($delFinished);
|
||||
$obj->setDelDelayed($delDelayed);
|
||||
$obj->setAppCreateDate($appCreateDate);
|
||||
$obj->setAppFinishDate($appFinishDate);
|
||||
$obj->setAppUpdateDate($appUpdateDate);
|
||||
$obj->setAppOverduePercentage($appOverduePercentage);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $delIndex)
|
||||
{
|
||||
$conn = Propel::getConnection(AppCacheViewPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppCacheViewPeer::retrieveByPK($appUid, $delIndex);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
149
workflow/engine/services/rest/crud/AppDelay.php
Normal file
149
workflow/engine/services/rest/crud/AppDelay.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppDelay
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appDelayUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appDelayUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID);
|
||||
$criteria->addSelectColumn(AppDelayPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_TYPE);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_NEXT_TASK);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_DELEGATION_USER);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_USER);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_USER);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE);
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_AUTOMATIC_DISABLED_DATE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppDelayPeer::retrieveByPK($appDelayUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appDelayUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appDelayUid, $proUid, $appUid, $appThreadIndex, $appDelIndex, $appType, $appStatus, $appNextTask, $appDelegationUser, $appEnableActionUser, $appEnableActionDate, $appDisableActionUser, $appDisableActionDate, $appAutomaticDisabledDate)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppDelay();
|
||||
|
||||
$obj->setAppDelayUid($appDelayUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppThreadIndex($appThreadIndex);
|
||||
$obj->setAppDelIndex($appDelIndex);
|
||||
$obj->setAppType($appType);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setAppNextTask($appNextTask);
|
||||
$obj->setAppDelegationUser($appDelegationUser);
|
||||
$obj->setAppEnableActionUser($appEnableActionUser);
|
||||
$obj->setAppEnableActionDate($appEnableActionDate);
|
||||
$obj->setAppDisableActionUser($appDisableActionUser);
|
||||
$obj->setAppDisableActionDate($appDisableActionDate);
|
||||
$obj->setAppAutomaticDisabledDate($appAutomaticDisabledDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appDelayUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appDelayUid, $proUid, $appUid, $appThreadIndex, $appDelIndex, $appType, $appStatus, $appNextTask, $appDelegationUser, $appEnableActionUser, $appEnableActionDate, $appDisableActionUser, $appDisableActionDate, $appAutomaticDisabledDate)
|
||||
{
|
||||
try {
|
||||
$obj = AppDelayPeer::retrieveByPK($appDelayUid);
|
||||
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppThreadIndex($appThreadIndex);
|
||||
$obj->setAppDelIndex($appDelIndex);
|
||||
$obj->setAppType($appType);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setAppNextTask($appNextTask);
|
||||
$obj->setAppDelegationUser($appDelegationUser);
|
||||
$obj->setAppEnableActionUser($appEnableActionUser);
|
||||
$obj->setAppEnableActionDate($appEnableActionDate);
|
||||
$obj->setAppDisableActionUser($appDisableActionUser);
|
||||
$obj->setAppDisableActionDate($appDisableActionDate);
|
||||
$obj->setAppAutomaticDisabledDate($appAutomaticDisabledDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appDelayUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appDelayUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppDelayPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppDelayPeer::retrieveByPK($appDelayUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
172
workflow/engine/services/rest/crud/AppDelegation.php
Normal file
172
workflow/engine/services/rest/crud/AppDelegation.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppDelegation
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null, $delIndex=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::USR_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_TYPE);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_THREAD);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_THREAD_STATUS);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_PRIORITY);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_DURATION);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_STARTED);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_DATA);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::APP_OVERDUE_PERCENTAGE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppDelegationPeer::retrieveByPK($appUid, $delIndex);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $delIndex, $delPrevious, $proUid, $tasUid, $usrUid, $delType, $delThread, $delThreadStatus, $delPriority, $delDelegateDate, $delInitDate, $delTaskDueDate, $delFinishDate, $delDuration, $delQueueDuration, $delDelayDuration, $delStarted, $delFinished, $delDelayed, $delData, $appOverduePercentage)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppDelegation();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setDelPrevious($delPrevious);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setDelType($delType);
|
||||
$obj->setDelThread($delThread);
|
||||
$obj->setDelThreadStatus($delThreadStatus);
|
||||
$obj->setDelPriority($delPriority);
|
||||
$obj->setDelDelegateDate($delDelegateDate);
|
||||
$obj->setDelInitDate($delInitDate);
|
||||
$obj->setDelTaskDueDate($delTaskDueDate);
|
||||
$obj->setDelFinishDate($delFinishDate);
|
||||
$obj->setDelDuration($delDuration);
|
||||
$obj->setDelQueueDuration($delQueueDuration);
|
||||
$obj->setDelDelayDuration($delDelayDuration);
|
||||
$obj->setDelStarted($delStarted);
|
||||
$obj->setDelFinished($delFinished);
|
||||
$obj->setDelDelayed($delDelayed);
|
||||
$obj->setDelData($delData);
|
||||
$obj->setAppOverduePercentage($appOverduePercentage);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $delIndex, $delPrevious, $proUid, $tasUid, $usrUid, $delType, $delThread, $delThreadStatus, $delPriority, $delDelegateDate, $delInitDate, $delTaskDueDate, $delFinishDate, $delDuration, $delQueueDuration, $delDelayDuration, $delStarted, $delFinished, $delDelayed, $delData, $appOverduePercentage)
|
||||
{
|
||||
try {
|
||||
$obj = AppDelegationPeer::retrieveByPK($appUid, $delIndex);
|
||||
|
||||
$obj->setDelPrevious($delPrevious);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setDelType($delType);
|
||||
$obj->setDelThread($delThread);
|
||||
$obj->setDelThreadStatus($delThreadStatus);
|
||||
$obj->setDelPriority($delPriority);
|
||||
$obj->setDelDelegateDate($delDelegateDate);
|
||||
$obj->setDelInitDate($delInitDate);
|
||||
$obj->setDelTaskDueDate($delTaskDueDate);
|
||||
$obj->setDelFinishDate($delFinishDate);
|
||||
$obj->setDelDuration($delDuration);
|
||||
$obj->setDelQueueDuration($delQueueDuration);
|
||||
$obj->setDelDelayDuration($delDelayDuration);
|
||||
$obj->setDelStarted($delStarted);
|
||||
$obj->setDelFinished($delFinished);
|
||||
$obj->setDelDelayed($delDelayed);
|
||||
$obj->setDelData($delData);
|
||||
$obj->setAppOverduePercentage($appOverduePercentage);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $delIndex)
|
||||
{
|
||||
$conn = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppDelegationPeer::retrieveByPK($appUid, $delIndex);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
148
workflow/engine/services/rest/crud/AppDocument.php
Normal file
148
workflow/engine/services/rest/crud/AppDocument.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppDocument
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appDocUid, $docVersion Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appDocUid=null, $docVersion=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::DOC_UID);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::USR_UID);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_TYPE);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_CREATE_DATE);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_INDEX);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::FOLDER_UID);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_PLUGIN);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_TAGS);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_STATUS);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_STATUS_DATE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppDocumentPeer::retrieveByPK($appDocUid, $docVersion);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appDocUid, $docVersion Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appDocUid, $docVersion, $appUid, $delIndex, $docUid, $usrUid, $appDocType, $appDocCreateDate, $appDocIndex, $folderUid, $appDocPlugin, $appDocTags, $appDocStatus, $appDocStatusDate)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppDocument();
|
||||
|
||||
$obj->setAppDocUid($appDocUid);
|
||||
$obj->setDocVersion($docVersion);
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setDocUid($docUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setAppDocType($appDocType);
|
||||
$obj->setAppDocCreateDate($appDocCreateDate);
|
||||
$obj->setAppDocIndex($appDocIndex);
|
||||
$obj->setFolderUid($folderUid);
|
||||
$obj->setAppDocPlugin($appDocPlugin);
|
||||
$obj->setAppDocTags($appDocTags);
|
||||
$obj->setAppDocStatus($appDocStatus);
|
||||
$obj->setAppDocStatusDate($appDocStatusDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appDocUid, $docVersion Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appDocUid, $docVersion, $appUid, $delIndex, $docUid, $usrUid, $appDocType, $appDocCreateDate, $appDocIndex, $folderUid, $appDocPlugin, $appDocTags, $appDocStatus, $appDocStatusDate)
|
||||
{
|
||||
try {
|
||||
$obj = AppDocumentPeer::retrieveByPK($appDocUid, $docVersion);
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setDocUid($docUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setAppDocType($appDocType);
|
||||
$obj->setAppDocCreateDate($appDocCreateDate);
|
||||
$obj->setAppDocIndex($appDocIndex);
|
||||
$obj->setFolderUid($folderUid);
|
||||
$obj->setAppDocPlugin($appDocPlugin);
|
||||
$obj->setAppDocTags($appDocTags);
|
||||
$obj->setAppDocStatus($appDocStatus);
|
||||
$obj->setAppDocStatusDate($appDocStatusDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appDocUid, $docVersion Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appDocUid, $docVersion)
|
||||
{
|
||||
$conn = Propel::getConnection(AppDocumentPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppDocumentPeer::retrieveByPK($appDocUid, $docVersion);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
126
workflow/engine/services/rest/crud/AppEvent.php
Normal file
126
workflow/engine/services/rest/crud/AppEvent.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppEvent
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex, $evnUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null, $delIndex=null, $evnUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppEventPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppEventPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppEventPeer::EVN_UID);
|
||||
$criteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
||||
$criteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
|
||||
$criteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
|
||||
$criteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppEventPeer::retrieveByPK($appUid, $delIndex, $evnUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex, $evnUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $delIndex, $evnUid, $appEvnActionDate, $appEvnAttempts, $appEvnLastExecutionDate, $appEvnStatus)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppEvent();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setEvnUid($evnUid);
|
||||
$obj->setAppEvnActionDate($appEvnActionDate);
|
||||
$obj->setAppEvnAttempts($appEvnAttempts);
|
||||
$obj->setAppEvnLastExecutionDate($appEvnLastExecutionDate);
|
||||
$obj->setAppEvnStatus($appEvnStatus);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex, $evnUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $delIndex, $evnUid, $appEvnActionDate, $appEvnAttempts, $appEvnLastExecutionDate, $appEvnStatus)
|
||||
{
|
||||
try {
|
||||
$obj = AppEventPeer::retrieveByPK($appUid, $delIndex, $evnUid);
|
||||
|
||||
$obj->setAppEvnActionDate($appEvnActionDate);
|
||||
$obj->setAppEvnAttempts($appEvnAttempts);
|
||||
$obj->setAppEvnLastExecutionDate($appEvnLastExecutionDate);
|
||||
$obj->setAppEvnStatus($appEvnStatus);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $delIndex, $evnUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $delIndex, $evnUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppEventPeer::retrieveByPK($appUid, $delIndex, $evnUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
122
workflow/engine/services/rest/crud/AppFolder.php
Normal file
122
workflow/engine/services/rest/crud/AppFolder.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppFolder
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $folderUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($folderUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppFolderPeer::FOLDER_UID);
|
||||
$criteria->addSelectColumn(AppFolderPeer::FOLDER_PARENT_UID);
|
||||
$criteria->addSelectColumn(AppFolderPeer::FOLDER_NAME);
|
||||
$criteria->addSelectColumn(AppFolderPeer::FOLDER_CREATE_DATE);
|
||||
$criteria->addSelectColumn(AppFolderPeer::FOLDER_UPDATE_DATE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppFolderPeer::retrieveByPK($folderUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $folderUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($folderUid, $folderParentUid, $folderName, $folderCreateDate, $folderUpdateDate)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppFolder();
|
||||
|
||||
$obj->setFolderUid($folderUid);
|
||||
$obj->setFolderParentUid($folderParentUid);
|
||||
$obj->setFolderName($folderName);
|
||||
$obj->setFolderCreateDate($folderCreateDate);
|
||||
$obj->setFolderUpdateDate($folderUpdateDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $folderUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($folderUid, $folderParentUid, $folderName, $folderCreateDate, $folderUpdateDate)
|
||||
{
|
||||
try {
|
||||
$obj = AppFolderPeer::retrieveByPK($folderUid);
|
||||
|
||||
$obj->setFolderParentUid($folderParentUid);
|
||||
$obj->setFolderName($folderName);
|
||||
$obj->setFolderCreateDate($folderCreateDate);
|
||||
$obj->setFolderUpdateDate($folderUpdateDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $folderUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($folderUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppFolderPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppFolderPeer::retrieveByPK($folderUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
135
workflow/engine/services/rest/crud/AppHistory.php
Normal file
135
workflow/engine/services/rest/crud/AppHistory.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppHistory
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get()
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppHistoryPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::DYN_UID);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::USR_UID);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::HISTORY_DATE);
|
||||
$criteria->addSelectColumn(AppHistoryPeer::HISTORY_DATA);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppHistoryPeer::retrieveByPK();
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $delIndex, $proUid, $tasUid, $dynUid, $usrUid, $appStatus, $historyDate, $historyData)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppHistory();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setDynUid($dynUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setHistoryDate($historyDate);
|
||||
$obj->setHistoryData($historyData);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $delIndex, $proUid, $tasUid, $dynUid, $usrUid, $appStatus, $historyDate, $historyData)
|
||||
{
|
||||
try {
|
||||
$obj = AppHistoryPeer::retrieveByPK();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setDynUid($dynUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setHistoryDate($historyDate);
|
||||
$obj->setHistoryData($historyData);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
$conn = Propel::getConnection(AppHistoryPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppHistoryPeer::retrieveByPK();
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
155
workflow/engine/services/rest/crud/AppMessage.php
Normal file
155
workflow/engine/services/rest/crud/AppMessage.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppMessage
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appMsgUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appMsgUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_UID);
|
||||
$criteria->addSelectColumn(AppMessagePeer::MSG_UID);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppMessagePeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_TYPE);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_SUBJECT);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_FROM);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_TO);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_BODY);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_DATE);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_CC);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_BCC);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_TEMPLATE);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_STATUS);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_ATTACH);
|
||||
$criteria->addSelectColumn(AppMessagePeer::APP_MSG_SEND_DATE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppMessagePeer::retrieveByPK($appMsgUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appMsgUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appMsgUid, $msgUid, $appUid, $delIndex, $appMsgType, $appMsgSubject, $appMsgFrom, $appMsgTo, $appMsgBody, $appMsgDate, $appMsgCc, $appMsgBcc, $appMsgTemplate, $appMsgStatus, $appMsgAttach, $appMsgSendDate)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppMessage();
|
||||
|
||||
$obj->setAppMsgUid($appMsgUid);
|
||||
$obj->setMsgUid($msgUid);
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setAppMsgType($appMsgType);
|
||||
$obj->setAppMsgSubject($appMsgSubject);
|
||||
$obj->setAppMsgFrom($appMsgFrom);
|
||||
$obj->setAppMsgTo($appMsgTo);
|
||||
$obj->setAppMsgBody($appMsgBody);
|
||||
$obj->setAppMsgDate($appMsgDate);
|
||||
$obj->setAppMsgCc($appMsgCc);
|
||||
$obj->setAppMsgBcc($appMsgBcc);
|
||||
$obj->setAppMsgTemplate($appMsgTemplate);
|
||||
$obj->setAppMsgStatus($appMsgStatus);
|
||||
$obj->setAppMsgAttach($appMsgAttach);
|
||||
$obj->setAppMsgSendDate($appMsgSendDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appMsgUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appMsgUid, $msgUid, $appUid, $delIndex, $appMsgType, $appMsgSubject, $appMsgFrom, $appMsgTo, $appMsgBody, $appMsgDate, $appMsgCc, $appMsgBcc, $appMsgTemplate, $appMsgStatus, $appMsgAttach, $appMsgSendDate)
|
||||
{
|
||||
try {
|
||||
$obj = AppMessagePeer::retrieveByPK($appMsgUid);
|
||||
|
||||
$obj->setMsgUid($msgUid);
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setDelIndex($delIndex);
|
||||
$obj->setAppMsgType($appMsgType);
|
||||
$obj->setAppMsgSubject($appMsgSubject);
|
||||
$obj->setAppMsgFrom($appMsgFrom);
|
||||
$obj->setAppMsgTo($appMsgTo);
|
||||
$obj->setAppMsgBody($appMsgBody);
|
||||
$obj->setAppMsgDate($appMsgDate);
|
||||
$obj->setAppMsgCc($appMsgCc);
|
||||
$obj->setAppMsgBcc($appMsgBcc);
|
||||
$obj->setAppMsgTemplate($appMsgTemplate);
|
||||
$obj->setAppMsgStatus($appMsgStatus);
|
||||
$obj->setAppMsgAttach($appMsgAttach);
|
||||
$obj->setAppMsgSendDate($appMsgSendDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appMsgUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appMsgUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppMessagePeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppMessagePeer::retrieveByPK($appMsgUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
138
workflow/engine/services/rest/crud/AppNotes.php
Normal file
138
workflow/engine/services/rest/crud/AppNotes.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppNotes
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get()
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppNotesPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppNotesPeer::USR_UID);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_DATE);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2);
|
||||
$criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppNotesPeer::retrieveByPK();
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $usrUid, $noteDate, $noteContent, $noteType, $noteAvailability, $noteOriginObj, $noteAffectedObj1, $noteAffectedObj2, $noteRecipients)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppNotes();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setNoteDate($noteDate);
|
||||
$obj->setNoteContent($noteContent);
|
||||
$obj->setNoteType($noteType);
|
||||
$obj->setNoteAvailability($noteAvailability);
|
||||
$obj->setNoteOriginObj($noteOriginObj);
|
||||
$obj->setNoteAffectedObj1($noteAffectedObj1);
|
||||
$obj->setNoteAffectedObj2($noteAffectedObj2);
|
||||
$obj->setNoteRecipients($noteRecipients);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $usrUid, $noteDate, $noteContent, $noteType, $noteAvailability, $noteOriginObj, $noteAffectedObj1, $noteAffectedObj2, $noteRecipients)
|
||||
{
|
||||
try {
|
||||
$obj = AppNotesPeer::retrieveByPK();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setNoteDate($noteDate);
|
||||
$obj->setNoteContent($noteContent);
|
||||
$obj->setNoteType($noteType);
|
||||
$obj->setNoteAvailability($noteAvailability);
|
||||
$obj->setNoteOriginObj($noteOriginObj);
|
||||
$obj->setNoteAffectedObj1($noteAffectedObj1);
|
||||
$obj->setNoteAffectedObj2($noteAffectedObj2);
|
||||
$obj->setNoteRecipients($noteRecipients);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
$conn = Propel::getConnection(AppNotesPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppNotesPeer::retrieveByPK();
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
114
workflow/engine/services/rest/crud/AppOwner.php
Normal file
114
workflow/engine/services/rest/crud/AppOwner.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppOwner
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null, $ownUid=null, $usrUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppOwnerPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppOwnerPeer::OWN_UID);
|
||||
$criteria->addSelectColumn(AppOwnerPeer::USR_UID);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $ownUid, $usrUid)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppOwner();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setOwnUid($ownUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $ownUid, $usrUid)
|
||||
{
|
||||
try {
|
||||
$obj = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
|
||||
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $ownUid, $usrUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppOwnerPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
113
workflow/engine/services/rest/crud/AppSolrQueue.php
Normal file
113
workflow/engine/services/rest/crud/AppSolrQueue.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppSolrQueue
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppSolrQueuePeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppSolrQueuePeer::retrieveByPK($appUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $appUpdated)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppSolrQueue();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppUpdated($appUpdated);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $appUpdated)
|
||||
{
|
||||
try {
|
||||
$obj = AppSolrQueuePeer::retrieveByPK($appUid);
|
||||
|
||||
$obj->setAppUpdated($appUpdated);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppSolrQueuePeer::retrieveByPK($appUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
121
workflow/engine/services/rest/crud/AppThread.php
Normal file
121
workflow/engine/services/rest/crud/AppThread.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_AppThread
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null, $appThreadIndex=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppThreadPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppThreadPeer::APP_THREAD_INDEX);
|
||||
$criteria->addSelectColumn(AppThreadPeer::APP_THREAD_PARENT);
|
||||
$criteria->addSelectColumn(AppThreadPeer::APP_THREAD_STATUS);
|
||||
$criteria->addSelectColumn(AppThreadPeer::DEL_INDEX);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = AppThreadPeer::retrieveByPK($appUid, $appThreadIndex);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $appThreadIndex, $appThreadParent, $appThreadStatus, $delIndex)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppThread();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppThreadIndex($appThreadIndex);
|
||||
$obj->setAppThreadParent($appThreadParent);
|
||||
$obj->setAppThreadStatus($appThreadStatus);
|
||||
$obj->setDelIndex($delIndex);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $appThreadIndex, $appThreadParent, $appThreadStatus, $delIndex)
|
||||
{
|
||||
try {
|
||||
$obj = AppThreadPeer::retrieveByPK($appUid, $appThreadIndex);
|
||||
|
||||
$obj->setAppThreadParent($appThreadParent);
|
||||
$obj->setAppThreadStatus($appThreadStatus);
|
||||
$obj->setDelIndex($delIndex);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $appThreadIndex)
|
||||
{
|
||||
$conn = Propel::getConnection(AppThreadPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppThreadPeer::retrieveByPK($appUid, $appThreadIndex);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
144
workflow/engine/services/rest/crud/Application.php
Normal file
144
workflow/engine/services/rest/crud/Application.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_Application
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($appUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_UID);
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_NUMBER);
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_PARENT);
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = ApplicationPeer::retrieveByPK($appUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Application();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppNumber($appNumber);
|
||||
$obj->setAppParent($appParent);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAppProcStatus($appProcStatus);
|
||||
$obj->setAppProcCode($appProcCode);
|
||||
$obj->setAppParallel($appParallel);
|
||||
$obj->setAppInitUser($appInitUser);
|
||||
$obj->setAppCurUser($appCurUser);
|
||||
$obj->setAppCreateDate($appCreateDate);
|
||||
$obj->setAppInitDate($appInitDate);
|
||||
$obj->setAppFinishDate($appFinishDate);
|
||||
$obj->setAppUpdateDate($appUpdateDate);
|
||||
$obj->setAppData($appData);
|
||||
$obj->setAppPin($appPin);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
|
||||
{
|
||||
try {
|
||||
$obj = ApplicationPeer::retrieveByPK($appUid);
|
||||
|
||||
$obj->setAppNumber($appNumber);
|
||||
$obj->setAppParent($appParent);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAppProcStatus($appProcStatus);
|
||||
$obj->setAppProcCode($appProcCode);
|
||||
$obj->setAppParallel($appParallel);
|
||||
$obj->setAppInitUser($appInitUser);
|
||||
$obj->setAppCurUser($appCurUser);
|
||||
$obj->setAppCreateDate($appCreateDate);
|
||||
$obj->setAppInitDate($appInitDate);
|
||||
$obj->setAppFinishDate($appFinishDate);
|
||||
$obj->setAppUpdateDate($appUpdateDate);
|
||||
$obj->setAppData($appData);
|
||||
$obj->setAppPin($appPin);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid)
|
||||
{
|
||||
$conn = Propel::getConnection(ApplicationPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = ApplicationPeer::retrieveByPK($appUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
116
workflow/engine/services/rest/crud/CalendarAssignments.php
Normal file
116
workflow/engine/services/rest/crud/CalendarAssignments.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CalendarAssignments
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $objectUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($objectUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CalendarAssignmentsPeer::OBJECT_UID);
|
||||
$criteria->addSelectColumn(CalendarAssignmentsPeer::CALENDAR_UID);
|
||||
$criteria->addSelectColumn(CalendarAssignmentsPeer::OBJECT_TYPE);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CalendarAssignmentsPeer::retrieveByPK($objectUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $objectUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($objectUid, $calendarUid, $objectType)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CalendarAssignments();
|
||||
|
||||
$obj->setObjectUid($objectUid);
|
||||
$obj->setCalendarUid($calendarUid);
|
||||
$obj->setObjectType($objectType);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $objectUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($objectUid, $calendarUid, $objectType)
|
||||
{
|
||||
try {
|
||||
$obj = CalendarAssignmentsPeer::retrieveByPK($objectUid);
|
||||
|
||||
$obj->setCalendarUid($calendarUid);
|
||||
$obj->setObjectType($objectType);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $objectUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($objectUid)
|
||||
{
|
||||
$conn = Propel::getConnection(CalendarAssignmentsPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CalendarAssignmentsPeer::retrieveByPK($objectUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
116
workflow/engine/services/rest/crud/CalendarBusinessHours.php
Normal file
116
workflow/engine/services/rest/crud/CalendarBusinessHours.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CalendarBusinessHours
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($calendarUid=null, $calendarBusinessDay=null, $calendarBusinessStart=null, $calendarBusinessEnd=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CalendarBusinessHoursPeer::CALENDAR_UID);
|
||||
$criteria->addSelectColumn(CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY);
|
||||
$criteria->addSelectColumn(CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START);
|
||||
$criteria->addSelectColumn(CalendarBusinessHoursPeer::CALENDAR_BUSINESS_END);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CalendarBusinessHoursPeer::retrieveByPK($calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CalendarBusinessHours();
|
||||
|
||||
$obj->setCalendarUid($calendarUid);
|
||||
$obj->setCalendarBusinessDay($calendarBusinessDay);
|
||||
$obj->setCalendarBusinessStart($calendarBusinessStart);
|
||||
$obj->setCalendarBusinessEnd($calendarBusinessEnd);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd)
|
||||
{
|
||||
try {
|
||||
$obj = CalendarBusinessHoursPeer::retrieveByPK($calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd);
|
||||
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd)
|
||||
{
|
||||
$conn = Propel::getConnection(CalendarBusinessHoursPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CalendarBusinessHoursPeer::retrieveByPK($calendarUid, $calendarBusinessDay, $calendarBusinessStart, $calendarBusinessEnd);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
128
workflow/engine/services/rest/crud/CalendarDefinition.php
Normal file
128
workflow/engine/services/rest/crud/CalendarDefinition.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CalendarDefinition
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($calendarUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID);
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_NAME);
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_CREATE_DATE);
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UPDATE_DATE);
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_WORK_DAYS);
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_DESCRIPTION);
|
||||
$criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_STATUS);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CalendarDefinitionPeer::retrieveByPK($calendarUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($calendarUid, $calendarName, $calendarCreateDate, $calendarUpdateDate, $calendarWorkDays, $calendarDescription, $calendarStatus)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CalendarDefinition();
|
||||
|
||||
$obj->setCalendarUid($calendarUid);
|
||||
$obj->setCalendarName($calendarName);
|
||||
$obj->setCalendarCreateDate($calendarCreateDate);
|
||||
$obj->setCalendarUpdateDate($calendarUpdateDate);
|
||||
$obj->setCalendarWorkDays($calendarWorkDays);
|
||||
$obj->setCalendarDescription($calendarDescription);
|
||||
$obj->setCalendarStatus($calendarStatus);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($calendarUid, $calendarName, $calendarCreateDate, $calendarUpdateDate, $calendarWorkDays, $calendarDescription, $calendarStatus)
|
||||
{
|
||||
try {
|
||||
$obj = CalendarDefinitionPeer::retrieveByPK($calendarUid);
|
||||
|
||||
$obj->setCalendarName($calendarName);
|
||||
$obj->setCalendarCreateDate($calendarCreateDate);
|
||||
$obj->setCalendarUpdateDate($calendarUpdateDate);
|
||||
$obj->setCalendarWorkDays($calendarWorkDays);
|
||||
$obj->setCalendarDescription($calendarDescription);
|
||||
$obj->setCalendarStatus($calendarStatus);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($calendarUid)
|
||||
{
|
||||
$conn = Propel::getConnection(CalendarDefinitionPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CalendarDefinitionPeer::retrieveByPK($calendarUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
118
workflow/engine/services/rest/crud/CalendarHolidays.php
Normal file
118
workflow/engine/services/rest/crud/CalendarHolidays.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CalendarHolidays
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarHolidayName Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($calendarUid=null, $calendarHolidayName=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CalendarHolidaysPeer::CALENDAR_UID);
|
||||
$criteria->addSelectColumn(CalendarHolidaysPeer::CALENDAR_HOLIDAY_NAME);
|
||||
$criteria->addSelectColumn(CalendarHolidaysPeer::CALENDAR_HOLIDAY_START);
|
||||
$criteria->addSelectColumn(CalendarHolidaysPeer::CALENDAR_HOLIDAY_END);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CalendarHolidaysPeer::retrieveByPK($calendarUid, $calendarHolidayName);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarHolidayName Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($calendarUid, $calendarHolidayName, $calendarHolidayStart, $calendarHolidayEnd)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CalendarHolidays();
|
||||
|
||||
$obj->setCalendarUid($calendarUid);
|
||||
$obj->setCalendarHolidayName($calendarHolidayName);
|
||||
$obj->setCalendarHolidayStart($calendarHolidayStart);
|
||||
$obj->setCalendarHolidayEnd($calendarHolidayEnd);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarHolidayName Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($calendarUid, $calendarHolidayName, $calendarHolidayStart, $calendarHolidayEnd)
|
||||
{
|
||||
try {
|
||||
$obj = CalendarHolidaysPeer::retrieveByPK($calendarUid, $calendarHolidayName);
|
||||
|
||||
$obj->setCalendarHolidayStart($calendarHolidayStart);
|
||||
$obj->setCalendarHolidayEnd($calendarHolidayEnd);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid, $calendarHolidayName Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($calendarUid, $calendarHolidayName)
|
||||
{
|
||||
$conn = Propel::getConnection(CalendarHolidaysPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CalendarHolidaysPeer::retrieveByPK($calendarUid, $calendarHolidayName);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
182
workflow/engine/services/rest/crud/CaseScheduler.php
Normal file
182
workflow/engine/services/rest/crud/CaseScheduler.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CaseScheduler
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $schUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($schUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_UID);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_DEL_USER_NAME);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_DEL_USER_PASS);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_DEL_USER_UID);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_NAME);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_TIME_NEXT_RUN);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_LAST_RUN_TIME);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_STATE);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_LAST_STATE);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::USR_UID);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_OPTION);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_START_TIME);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_START_DATE);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_DAYS_PERFORM_TASK);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_EVERY_DAYS);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_WEEK_DAYS);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_START_DAY);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_MONTHS);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_END_DATE);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_REPEAT_EVERY);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_REPEAT_UNTIL);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::SCH_REPEAT_STOP_IF_RUNNING);
|
||||
$criteria->addSelectColumn(CaseSchedulerPeer::CASE_SH_PLUGIN_UID);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CaseSchedulerPeer::retrieveByPK($schUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $schUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($schUid, $schDelUserName, $schDelUserPass, $schDelUserUid, $schName, $proUid, $tasUid, $schTimeNextRun, $schLastRunTime, $schState, $schLastState, $usrUid, $schOption, $schStartTime, $schStartDate, $schDaysPerformTask, $schEveryDays, $schWeekDays, $schStartDay, $schMonths, $schEndDate, $schRepeatEvery, $schRepeatUntil, $schRepeatStopIfRunning, $caseShPluginUid)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CaseScheduler();
|
||||
|
||||
$obj->setSchUid($schUid);
|
||||
$obj->setSchDelUserName($schDelUserName);
|
||||
$obj->setSchDelUserPass($schDelUserPass);
|
||||
$obj->setSchDelUserUid($schDelUserUid);
|
||||
$obj->setSchName($schName);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setSchTimeNextRun($schTimeNextRun);
|
||||
$obj->setSchLastRunTime($schLastRunTime);
|
||||
$obj->setSchState($schState);
|
||||
$obj->setSchLastState($schLastState);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setSchOption($schOption);
|
||||
$obj->setSchStartTime($schStartTime);
|
||||
$obj->setSchStartDate($schStartDate);
|
||||
$obj->setSchDaysPerformTask($schDaysPerformTask);
|
||||
$obj->setSchEveryDays($schEveryDays);
|
||||
$obj->setSchWeekDays($schWeekDays);
|
||||
$obj->setSchStartDay($schStartDay);
|
||||
$obj->setSchMonths($schMonths);
|
||||
$obj->setSchEndDate($schEndDate);
|
||||
$obj->setSchRepeatEvery($schRepeatEvery);
|
||||
$obj->setSchRepeatUntil($schRepeatUntil);
|
||||
$obj->setSchRepeatStopIfRunning($schRepeatStopIfRunning);
|
||||
$obj->setCaseShPluginUid($caseShPluginUid);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $schUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($schUid, $schDelUserName, $schDelUserPass, $schDelUserUid, $schName, $proUid, $tasUid, $schTimeNextRun, $schLastRunTime, $schState, $schLastState, $usrUid, $schOption, $schStartTime, $schStartDate, $schDaysPerformTask, $schEveryDays, $schWeekDays, $schStartDay, $schMonths, $schEndDate, $schRepeatEvery, $schRepeatUntil, $schRepeatStopIfRunning, $caseShPluginUid)
|
||||
{
|
||||
try {
|
||||
$obj = CaseSchedulerPeer::retrieveByPK($schUid);
|
||||
|
||||
$obj->setSchDelUserName($schDelUserName);
|
||||
$obj->setSchDelUserPass($schDelUserPass);
|
||||
$obj->setSchDelUserUid($schDelUserUid);
|
||||
$obj->setSchName($schName);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setSchTimeNextRun($schTimeNextRun);
|
||||
$obj->setSchLastRunTime($schLastRunTime);
|
||||
$obj->setSchState($schState);
|
||||
$obj->setSchLastState($schLastState);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setSchOption($schOption);
|
||||
$obj->setSchStartTime($schStartTime);
|
||||
$obj->setSchStartDate($schStartDate);
|
||||
$obj->setSchDaysPerformTask($schDaysPerformTask);
|
||||
$obj->setSchEveryDays($schEveryDays);
|
||||
$obj->setSchWeekDays($schWeekDays);
|
||||
$obj->setSchStartDay($schStartDay);
|
||||
$obj->setSchMonths($schMonths);
|
||||
$obj->setSchEndDate($schEndDate);
|
||||
$obj->setSchRepeatEvery($schRepeatEvery);
|
||||
$obj->setSchRepeatUntil($schRepeatUntil);
|
||||
$obj->setSchRepeatStopIfRunning($schRepeatStopIfRunning);
|
||||
$obj->setCaseShPluginUid($caseShPluginUid);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $schUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($schUid)
|
||||
{
|
||||
$conn = Propel::getConnection(CaseSchedulerPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CaseSchedulerPeer::retrieveByPK($schUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
119
workflow/engine/services/rest/crud/CaseTracker.php
Normal file
119
workflow/engine/services/rest/crud/CaseTracker.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CaseTracker
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($proUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CaseTrackerPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(CaseTrackerPeer::CT_MAP_TYPE);
|
||||
$criteria->addSelectColumn(CaseTrackerPeer::CT_DERIVATION_HISTORY);
|
||||
$criteria->addSelectColumn(CaseTrackerPeer::CT_MESSAGE_HISTORY);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CaseTrackerPeer::retrieveByPK($proUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($proUid, $ctMapType, $ctDerivationHistory, $ctMessageHistory)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CaseTracker();
|
||||
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setCtMapType($ctMapType);
|
||||
$obj->setCtDerivationHistory($ctDerivationHistory);
|
||||
$obj->setCtMessageHistory($ctMessageHistory);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($proUid, $ctMapType, $ctDerivationHistory, $ctMessageHistory)
|
||||
{
|
||||
try {
|
||||
$obj = CaseTrackerPeer::retrieveByPK($proUid);
|
||||
|
||||
$obj->setCtMapType($ctMapType);
|
||||
$obj->setCtDerivationHistory($ctDerivationHistory);
|
||||
$obj->setCtMessageHistory($ctMessageHistory);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($proUid)
|
||||
{
|
||||
$conn = Propel::getConnection(CaseTrackerPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CaseTrackerPeer::retrieveByPK($proUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
125
workflow/engine/services/rest/crud/CaseTrackerObject.php
Normal file
125
workflow/engine/services/rest/crud/CaseTrackerObject.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
class Services_Rest_CaseTrackerObject
|
||||
{
|
||||
/**
|
||||
* Implementation for 'GET' method for Rest API
|
||||
*
|
||||
* @param mixed $ctoUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function get($ctoUid=null)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
if (func_num_args() == 0) {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(CaseTrackerObjectPeer::CTO_UID);
|
||||
$criteria->addSelectColumn(CaseTrackerObjectPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(CaseTrackerObjectPeer::CTO_TYPE_OBJ);
|
||||
$criteria->addSelectColumn(CaseTrackerObjectPeer::CTO_UID_OBJ);
|
||||
$criteria->addSelectColumn(CaseTrackerObjectPeer::CTO_CONDITION);
|
||||
$criteria->addSelectColumn(CaseTrackerObjectPeer::CTO_POSITION);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($dataset->next()) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
} else {
|
||||
$record = CaseTrackerObjectPeer::retrieveByPK($ctoUid);
|
||||
$result = $record->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $ctoUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($ctoUid, $proUid, $ctoTypeObj, $ctoUidObj, $ctoCondition, $ctoPosition)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CaseTrackerObject();
|
||||
|
||||
$obj->setCtoUid($ctoUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setCtoTypeObj($ctoTypeObj);
|
||||
$obj->setCtoUidObj($ctoUidObj);
|
||||
$obj->setCtoCondition($ctoCondition);
|
||||
$obj->setCtoPosition($ctoPosition);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $ctoUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($ctoUid, $proUid, $ctoTypeObj, $ctoUidObj, $ctoCondition, $ctoPosition)
|
||||
{
|
||||
try {
|
||||
$obj = CaseTrackerObjectPeer::retrieveByPK($ctoUid);
|
||||
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setCtoTypeObj($ctoTypeObj);
|
||||
$obj->setCtoUidObj($ctoUidObj);
|
||||
$obj->setCtoCondition($ctoCondition);
|
||||
$obj->setCtoPosition($ctoPosition);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $ctoUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($ctoUid)
|
||||
{
|
||||
$conn = Propel::getConnection(CaseTrackerObjectPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CaseTrackerObjectPeer::retrieveByPK($ctoUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user