diff --git a/Protean Framework.pdf b/Protean Framework.pdf deleted file mode 100644 index 6d42e9c..0000000 Binary files a/Protean Framework.pdf and /dev/null differ diff --git a/README.markdown b/README.markdown index f80e8c1..e0eaafe 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ OVERVIEW ========= -Protean is a PHP5 framework that I began developing in 2005 while flying back from a Debian Linux conference held in Helsinki Finland. Something about the altitude triggered me to realize there must be an easier, better way to deploy PHP5 projects quickly, safely, while leveraging as many existing top-notch packages such as Smarty, PropelORM, PHPUnit, Phing, and others. +Protean is a PHP5 framework that I began developing in 2005 while flying back from a Debian Linux conference held in Helsinki Finland. Something about the altitude triggered me to realize there must be an easier, better way to deploy PHP5 projects quickly, safely, while leveraging as many existing top-notch packages such as Smarty, PropelORM, PHPUnit, Phing, and others. I took the initial base ideas of the framework from Matt Zandstra (now at Yahoo!), who wrote an excellent book on making clean, testable PHP5 code. I had additional requirements, such as one-line testability, support for continuous integration, multi-lingual support, and easy templating for front-end developers. @@ -13,49 +13,49 @@ It's quite simple at it's core--Protean is an MVC-based, inversion-of-control fr How Protean routes: command.xml ------------------------------- -Very simply! Here is a simple route that exposes the /content/hello URI. The name attribute defines what controller is called. The view tags describe what header/footer and body views will be rendered. This gives a lot of flexibility as you can reuse views while having them handled by different controllers if desired. This is essentially an implementation of Martin Fowler's Front Controller design pattern from his seminal Patterns of Enterprise Application Architecture book. +Very simply! Here is a simple route that exposes the /content/hello URI. The name attribute defines what controller is called. The view tags describe what header/footer and body views will be rendered. This gives a lot of flexibility as you can reuse views while having them handled by different controllers if desired. This is essentially an implementation of Martin Fowler's Front Controller design pattern from his seminal Patterns of Enterprise Application Architecture book. - - - - content.header - content.footer - content.hello - - + + + + content.header + content.footer + content.hello + + The controller: hello.class.php ------------------------------- Here is the controller for /content/hello. We always extend the default command, which handles some basic initialization for us. We grab the $page template instance and set a Smarty variable to the user's first name. - createObject('content.userhelper'); + $page = PFRegistry::getInstance()->getPage(); + $page->assign('FIRSTNAME', $user->getUser(1)->getFirstName()); + } + } + ?> - $user = PFFactory::getInstance()->createObject('content.userhelper'); - $page = PFRegistry::getInstance()->getPage(); - $page->assign('FIRSTNAME', $user->getUser(1)->getFirstName()); - } - } - ?> - The view: hello.tpl ------------------- This is a Smarty template file that Protean will auto-render. The PF_HEADER and PF_FOOTER vars will automatically get replaced by whatever header/footer is defined within the command.xml file above. If a site needs different header/footer files for sub-sections of the site, easy-peasy, just change the command.xml. No mucking around with template files. - {$PF_HEADER} + {$PF_HEADER} + +
+

+ Hello {$FIRSTNAME}! +

+
+ + {$PF_FOOTER} -
-

- Hello {$FIRSTNAME}! -

-
- - {$PF_FOOTER} - The model: userhelper.class.php -------------------------------- Protean allows you a lot of flexibility in how closely you wish to couple your controller and your model. You could call raw SQL directly from your controller class above if you wish. However, a best practice recommendation is to create a simple domain object that your controller class can call to get its data. @@ -76,7 +76,7 @@ And while Protean supports any level of helper/domain-object classes that a team FUTURE DIRECTION: ================ -There are so many great frameworks and platforms available five years later, it's difficult to assume Protean is better than the other options. One very compelling framework--if somewhat immature--is Lithium, which takes the best of modern MVC frameworks such as dependency injection, IoC, and others, and implements them by leveraging the lastest features of PHP 5.3. Of course, the Ruby on Rails community is very strong and has some excellent ideas about minimizing the amount of code necessary to deploy a production project. +There are so many great frameworks and platforms available five years later, it's difficult to assume Protean is better than the other options. One very compelling framework--if somewhat immature--is Lithium, which takes the best of modern MVC frameworks such as dependency injection, IoC, and others, and implements them by leveraging the latest features of PHP 5.3. Of course, the Ruby on Rails community is very strong and has some excellent ideas about minimizing the amount of code necessary to deploy a production project. Having done so much architecture in my past, I always keep a back-burner going in my mind regarding performance. PHP5 is probably one of the most tried-and-true platforms for scaling web applications of all that are available. Facebook runs PHP5, both interpreted and compiled, as well as very large amounts of optimizations throughout. Facebook itself is a testament to how well a PHP5 architecture not only performs, but also how well it integrates very cleanly with other systems when it's time to scale out sub-components such as databases or caching/middleware. @@ -90,26 +90,25 @@ Here are the requirements for building and testing Protean: Log ------------------- - pear install Log + pear install Log -Phing 2.4.2 +Phing 2.4.12 ------------------- - pear channel-discover pear.phing.info - sudo pear install -a phing/phing-2.4.2 + pear channel-discover pear.phing.info + sudo pear install -a phing/phing-2.4.12 -Propel 1.5.6 +Propel 1.6.7 ------------------- - pear channel-discover pear.propelorm.org - sudo pear install -a propel/propel_generator-1.5.6 - sudo pear install -a propel/propel_runtime-1.5.6 + pear channel-discover pear.propelorm.org + sudo pear install -a propel/propel_generator-1.6.7 + sudo pear install -a propel/propel_runtime-1.6.7 -PHPUnit 3.4.15 +PHPUnit 3.7.8 ------------------- - pear channel-discover pear.phpunit.de - pear channel-discover components.ez.no - pear channel-discover pear.symfony-project.com - sudo pear install -a phpunit/PHPUnit-3.4.15 - \ No newline at end of file + pear channel-discover pear.phpunit.de + pear channel-discover components.ez.no + pear channel-discover pear.symfony-project.com + sudo pear install -a phpunit/PHPUnit-3.7.8 diff --git a/build/build-dist.properties b/build/build-dist.properties index 899a3ae..ceab86b 100644 --- a/build/build-dist.properties +++ b/build/build-dist.properties @@ -12,6 +12,7 @@ propel.database.password = pass propel.database.name = protean propel.database.classname = DebugPDO +propel.mysql.path = /usr/bin/mysql propel.mysql.tableType = InnoDB propel.generator.buildpath = /usr/lib/php/data/propel_generator diff --git a/build/build.xml b/build/build.xml index dcc6c12..c1efe39 100644 --- a/build/build.xml +++ b/build/build.xml @@ -2,324 +2,512 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Creating miscellaneous directories... - - - - - - - - - - - - - - - Creating new module... - Name of module to create: - - - - - - - - - - - - - - - - - - - - - - - - - - - Enjoy your new module! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creating miscellaneous directories... + + + + + + + + + + + + + + + + + + + + + + + Creating new module... + Name of module to create: + + + + + + + + + + + + + + + + + + + + + + + + + + + Enjoy your new module! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Running JS through {$protean.build.tool.yuicompressor} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/schema-dist.xml b/build/schema-dist.xml index 7144f60..2de16b8 100644 --- a/build/schema-dist.xml +++ b/build/schema-dist.xml @@ -3,1688 +3,1967 @@ - - - - - - - + + + + + + + - - - - - - - - - -
+ + + + + + + + + + + + + + + + + +
- - - - - - - - - -
+ + + + + +
- - - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - -
+ + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + +
- - - - - - - - - - - -
+ + + + + + + + + + + + + + +
- - - - - - - - - - -
+ + + + + + + + + +
- - - - - - - - - - - - - - -
+ + + + + + + + + +
- - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - -
+ + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
+ + + + + + + + + +
- - - - - - - -
+ + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
- - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + +
- - - - -
+ + + + +
- - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + +
- - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - -
+ + + + + + + + + +
- - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + +
- - - - - - - - - - - - - - - - - -
+ + + + + + + + + +
- - - - - - - - - - -
+ + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + +
- - + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + +
diff --git a/config-dist.php b/config-dist.php index 5d821e2..4bd5c6c 100644 --- a/config-dist.php +++ b/config-dist.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2010, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -18,7 +18,8 @@ // BUILD SETTINGS -define('PF_VERSION','3.2'); +define('PF_VERSION','4.0'); +define('PF_ENVIRONMENT', 'development'); // FILE PATHS AND URL SETTINGS @@ -26,21 +27,17 @@ define('PF_URL_SECURE', '%%PHING_PROTEAN_SECUREURL%%'); define('PF_SHORT_URLS', true); -define('PF_ROOT_DIRECTORY', $_SERVER['DOCUMENT_ROOT']); - define('PF_USE_LOCAL_PEAR', false); define('PF_PEAR_BASE', '/usr/local/php5/lib/php'); define('PF_TEMP_PATH', '%%PHING_PROTEAN_BASEDIR%%/tmp'); -define('PF_DEFAULT_COMMAND', 'content.default'); +define('PF_DEFAULT_URI', '/content/default'); // DEBUG SETTINGS -define('PF_APD_PROFILING', false); -define('PF_APD_TRACE_PATH', '%%PHING_PROTEAN_BASEDIR%%/logs'); - -define('PF_DEBUG_ALWAYS_DISPLAY_LOGGER', false); +define('PF_PROFILER', true); +define('PF_PROFILER_RUNS_PATH', '%%PHING_PROTEAN_BASEDIR%%/tmp/profiler'); define('PF_DEBUG_EMAIL', false); define('PF_DEBUG_EMAIL_ADDRESS', '%%PHING_PROTEAN_DEBUG_EMAIL%%'); @@ -54,19 +51,14 @@ define('PF_AJAX_DEBUG', false); define('PF_AJAX_LOG', '%%PHING_PROTEAN_BASEDIR%%/logs/pf_ajax.log'); +define('PF_APP_ROUTER_DEBUG', false); define('PF_APP_CONTROLLER_DEBUG', false); define('PF_ERROR_WORDWRAP_COUNT', 0); define('PF_TEMPLATE_DEBUG', false); - define('PF_MULTI_LANGUAGE_DEBUG', false); -// PROFILER SETTINGS -define('PF_PROFILER', true); -define('PF_PROFILER_MARKS', false); - - // TEMPLATE/FORM SETTINGS define('PF_TEMPLATE_FORCE_RECOMPILE', true); define('PF_FORM_FIELD_ERROR_HIGHLIGHTING', true); @@ -79,11 +71,12 @@ // SESSION SETTINGS define('PF_SESSION_NAME', 'id'); define('PF_SESSION_PERSIST_NAME', 'persist'); +define('PF_SESSION_STORE', 'file'); define('PF_SESSION_PATH', PF_TEMP_PATH); -define('PF_SESSION_EXPIRE', 1440); -define('PF_SESSION_AUTH_EXPIRE', 1440); +define('PF_SESSION_EXPIRE', 31536000); +define('PF_SESSION_AUTH_EXPIRE', 31536000); define('PF_SESSION_UNIQUE_KEY', 'as33#)(J**a3SS:DJLSDFU}*&W'); -define('PF_JSON_UNIQUE_KEY', '$IIJSL)*SSSJ**SDasSS:DJLSDFU}*&W'); +define('PF_SESSION_PASSWORD_HASH_COST', 8); // CACHE SETTINGS @@ -106,12 +99,23 @@ define('PF_EMAIL_SERVER_PASSWORD', ''); define('PF_EMAIL_DB_USERNAME', ''); define('PF_EMAIL_DB_PASSWORD', ''); +define('PF_EMAIL_DEBUG', false); +define('PF_EMAIL_DEBUG_LOG', '%%PHING_PROTEAN_BASEDIR%%b/logs/pf_mailer.log'); define('PF_ADD_NEW_USER_TO_MAILINGLIST', false); -// ANALYTICS SETTINGS -define('PF_ANALYTICS_TRACKING', false); -define('PF_ANALYTICS_ID', 'UA-12345-1'); +// SMS TEXT SETTINGS +define('PF_SMS_TWILIO_CLIENT_ID', 'aaa'); +define('PF_SMS_TWILIO_AUTH_TOKEN', 'aaa'); +define('PF_SMS_FROM_NUMBER', '555-555-1234'); +define('PF_SMS_DEBUG', true); +define('PF_SMS_LOG', '%%PHING_PROTEAN_BASEDIR%%/logs/pf_sms_message.log'); + + +// THIRD-PARTY INCLUDES SETTINGS +define('PF_INCLUDE_GA_TRACKING', false); +define('PF_INCLUDE_SNAPENGAGE', false); +define('PF_INCLUDE_GET_SATISFACTION', false); // SHOP MODULE SETTINGS @@ -123,15 +127,22 @@ define('PF_SHOP_EMAIL_ADMINS', false); define('PF_SHOP_GATEWAY_DEBUG', true); -define('PF_SHOP_GATEWAY_LOG', '%%PHING_PROTEAN_BASEDIR%%/logs/pf_gateway.log'); +define('PF_SHOP_GATEWAY_LOG', '%%PHING_PROTEAN_BASEDIR%%/logs/pf_authnet_gateway.log'); +define('PF_SHOP_CIM_LOG', '%%PHING_PROTEAN_BASEDIR%%/logs/pf_authnet_cim.log'); -define('PF_SHOP_GATEWAY_AUTHNET_LOGIN', ''); -define('PF_SHOP_GATEWAY_AUTHNET_TRAN_KEY', ''); -define('PF_SHOP_GATEWAY_AUTHNET_PASSWORD', ''); define('PF_SHOP_GATEWAY_AUTHNET_TEST_REQUEST', true); -define('PF_SHOP_GATEWAY_AUTHNET_HOST', 'secure.authorize.net'); -define('PF_SHOP_GATEWAY_AUTHNET_PORT', '443'); -define('PF_SHOP_GATEWAY_AUTHNET_PATH', '/gateway/transact.dll'); +define('PF_SHOP_GATEWAY_AUTHNET_LOGIN', 'abc'); +define('PF_SHOP_GATEWAY_AUTHNET_TRAN_KEY', 'abc'); +define('PF_SHOP_GATEWAY_AUTHNET_TEST_LOGIN', 'abc'); +define('PF_SHOP_GATEWAY_AUTHNET_TEST_TRAN_KEY', 'abc'); +define('PF_SHOP_GATEWAY_AUTHNET_CIM_HOST_PRODUCTION', 'api.authorize.net'); +define('PF_SHOP_GATEWAY_AUTHNET_CIM_HOST_TEST', 'apitest.authorize.net'); +define('PF_SHOP_GATEWAY_AUTHNET_CIM_PORT', '443'); +define('PF_SHOP_GATEWAY_AUTHNET_CIM_PATH', '/xml/v1/request.api'); + + +// SITE SPECIFIC DEFINES + require_once 'modules/api/lib/common.php'; ?> diff --git a/index.php b/index.php index de259e7..2da967c 100755 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2010, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -10,4 +10,8 @@ require_once 'config.php'; PFController::run(); -?> \ No newline at end of file + +if (PF_PROFILER) { + PFProfiler::getInstance()->stop(); +} +?> diff --git a/license.txt b/license.txt index 9daedbd..645d611 100644 --- a/license.txt +++ b/license.txt @@ -1,6 +1,6 @@ Protean Framework https://github.com/erictj/protean -Copyright (c) 2006-2010, Loopshot Inc. +Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/modules/api/lang/en/global.lng b/modules/api/lang/en/global.lng index bdf0a17..3935001 100755 --- a/modules/api/lang/en/global.lng +++ b/modules/api/lang/en/global.lng @@ -32,7 +32,7 @@ CIRCULAR_COMMAND_FORWARDING=Circular command forwarding: %s NO_CONTROLLER_MAP=No controller map found FILE_NOT_FOUND=File not found MUST_BE_LOGGED_IN=Please log in to continue -INSUFFICIENT_PRIVILEGES_TO_RUN_COMMAND=You do not have sufficient privileges to run this command +INSUFFICIENT_PRIVILEGES_TO_RUN_COMMAND=You do not have sufficient privileges to view this page ERROR_SAVING_TO_DATABASE=Error saving %s to database ERROR_SENDING_MAIL=There was an error when attempting to send the e-mail ERROR_SENDING_SMS=There was an error when attempting to send a text message diff --git a/modules/api/lib/SAMPLE.class.php b/modules/api/lib/SAMPLE.class.php deleted file mode 100644 index 2f52411..0000000 --- a/modules/api/lib/SAMPLE.class.php +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/modules/api/lib/applicationcontroller.class.php b/modules/api/lib/applicationcontroller.class.php index 362535f..aba3c53 100644 --- a/modules/api/lib/applicationcontroller.class.php +++ b/modules/api/lib/applicationcontroller.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -10,255 +10,259 @@ /** @package api */ -class PFApplicationController { - - private static $STATUS_STRINGS = array ( - 'CMD_DEFAULT', - 'CMD_OK', - 'CMD_ERROR', - 'CMD_INSUFFICIENT_DATA', - 'CMD_FORM_FAILED', - 'CMD_UNAUTHORIZED' - ); - - protected static $baseCommand; - protected $controllerMap = array(); - protected $invoked = array(); - - protected $debug; - - public function __construct(PFControllerMap $map) { - - $this->debug = PF_APP_CONTROLLER_DEBUG; - $defaultApp = PFRequestHelper::getDefaultURIApplication(); - $this->controllerMap[$defaultApp] = $map; - - list($defaultApp, $defaultCmd) = explode('.', $this->controllerMap[$defaultApp]->getCommand(PF_DEFAULT_URI . '|get')); - - if (!self::$baseCommand) { - self::$baseCommand = new ReflectionClass('PFCommand'); - PFFactory::getInstance()->initCommandObject($defaultApp . '.' . $defaultCmd); - } - } - - public function addControllerMap($app) { - - if (array_key_exists($app, $this->controllerMap)) { - return; - } - - $map = PFApplicationHelper::getInstance()->loadControllerMap($app); - $this->controllerMap[$app] = $map; - } - - public function getControllerMap($app) { - if (!array_key_exists($app, $this->controllerMap)) { - $this->addControllerMap($app); - } - return $this->controllerMap[$app]; - } - - public function getView(PFRequest $request) { - list($app, $tpl) = explode('.', $this->getResource($request, 'View')); - if (!empty($tpl)) { - return $tpl . '.tpl'; - } else { - return ''; - } - } - - public function getViewApplication(PFRequest $request) { - - @list($app, $tpl) = explode('.', $this->getResource($request, 'View')); - return $app; - } - - public function getViewHeader(PFRequest $request) { - - @list($app, $tpl) = explode('.', $this->getResource($request, 'ViewHeader')); - - if (!empty($tpl)) { - return $tpl . '.tpl'; - } else { - return ''; - } - } - - public function getViewHeaderApplication(PFRequest $request) { - - @list($app, $tpl) = explode('.', $this->getResource($request, 'ViewHeader')); - return $app; - } - - public function getViewFooter(PFRequest $request) { - - list($app, $tpl) = explode('.', $this->getResource($request, 'ViewFooter')); - if (!empty($tpl)) { - return $tpl . '.tpl'; - } else { - return ''; - } - } - - public function getViewFooterApplication(PFRequest $request) { - - @list($app, $tpl) = explode('.', $this->getResource($request, 'ViewFooter')); - return $app; - } - - public function getForward(PFRequest $request) { - return $this->getResource($request, 'Forward'); - } - - public function getLogin(PFRequest $request) { - return $this->getResource($request, 'Login'); - } - - public function getPermissions(PFRequest $request) { - return $this->getResource($request, 'Permissions'); - } - - public function getTheme(PFRequest $request) { - return $this->getResource($request, 'Theme'); - } - - private function getResource(PFRequest $request, $resource) { - - $uri = PFRequestHelper::getURIPattern($request->get('pf.uri')); - $verb = PFRequestHelper::getHTTPVerbForURIPattern($request->get('pf.uri')); - $app = PFRequestHelper::getURIApplication($uri, $verb); - $cmd = PFRequestHelper::getURICommand($uri, $verb); - $this->addControllerMap($app); - - $cmdString = $uri . '|' . $verb; - $previous = $request->getLastCommandRun(); - - // printr('resource: ' . $resource); - // printr('pf.uri: ' . $request->get('pf.uri')); - // printr('uri: ' . $uri); - // printr('verb: ' . $verb); - // printr('app: ' . $app); - // printr('cmd: ' . $cmd); - - if (is_object($previous)) { - $status = $previous->getStatus(); - } - - if (!isset($status)) { - $status = 0; - } - - $acquire = 'get' . $resource; - // printr('acquire: ' . $acquire); - // printr($cmdString); - // printr($request); - // printr($this->controllerMap); - - $res = $this->controllerMap[$app]->$acquire($cmdString, $status); - - if (!$res) { - $res = $this->controllerMap[$app]->$acquire($cmdString, 0); - } - if (!$res) { - $res = $this->controllerMap[$app]->$acquire(PF_DEFAULT_URI . '|get', $status); - } - if (!$res) { - $res = $this->controllerMap[$app]->$acquire(PF_DEFAULT_URI . '|get', 0); - } - - if ($this->debug) { - printr('appController::getResource: ' . $acquire . '(' . $cmdString . ', ' . $status . ') -> ' . $res); - } - - return $res; - } - - public function getCommand(PFRequest $request) { - - $previous = $request->getLastCommandRun(); - - $app = PFRequestHelper::getCurrentURIApplication(); - $cmd = PFRequestHelper::getCurrentURICommand(); - $this->addControllerMap($app); - - if (!$previous) { - $commandType = 'Running'; - $uri = PFRequestHelper::getCurrentURIPattern(); - $verb = PFRequestHelper::getHTTPVerb(); - - } else { - $commandType = 'Forwarded to'; - $uri = $this->getForward($request); - $verb = PFRequestHelper::getHTTPVerbForURIPattern($uri); - - if (!$uri) { - return NULL; - } - } - - $request->set('pf.uri', $uri . '|' . $verb); - - if ($this->debug) { - $cmd = PFRequestHelper::getURICommand($uri, $verb); - printr('-- ' . $commandType . ' command ' . $uri . '|' . $verb); - } - - $cmdObject = $this->resolveCommand($uri, $verb); - - if (!$cmdObject) { - - $cmdObject = $this->resolveCommand($uri, $verb); - if (!$cmdObject) { - if ($this->debug) { - printr('-- ' . $commandType . ' command ' . 'content' . '.' . 'notfound'); - } - - $cmdObject = $this->resolveCommand('/content/notfound', 'get'); - $request->set('pf.uri', '/content/notfound|get'); - } - } - - $cmdClass = get_class($cmdObject); - @$this->invoked[$cmdClass]++; - - if ($this->invoked[$cmdClass] > 1) { - PFErrorStack::clearErrorStack(); - } - - if ($this->invoked[$cmdClass] > 2) { - throw new PFException('api', array('CIRCULAR_COMMAND_FORWARDING', $cmdClass), E_USER_ERROR); - } - - return $cmdObject; - } - - protected function resolveCommand($uri, $verb) { - - if ($uri == '') { - $uri = PF_DEFAULT_URI; - } - - $app = PFRequestHelper::getURIApplication($uri, $verb); - $cmd = PFRequestHelper::getURICommand($uri, $verb); - - $filepath = PF_BASE . '/modules/' . $app . '/cmd/' . $cmd . '.class.php'; - $classname = 'PF' . ucfirst($cmd) . 'Command'; - - if (file_exists($filepath)) { - - require_once $filepath; - - if (class_exists($classname)) { - - $cmdClass = new reflectionClass($classname); - if ($cmdClass->isSubClassOf(self::$baseCommand)) { - return $cmdClass->newInstance(); - } - } - } - - return NULL; - } +class PFApplicationController { + + private static $STATUS_STRINGS = array ( + 'CMD_DEFAULT', + 'CMD_OK', + 'CMD_ERROR', + 'CMD_INSUFFICIENT_DATA', + 'CMD_FORM_FAILED', + 'CMD_UNAUTHORIZED' + ); + + protected static $baseCommand; + protected $controllerMap = array(); + protected $invoked = array(); + + protected $debug; + + public function __construct(PFControllerMap $map) { + + $this->debug = PF_APP_CONTROLLER_DEBUG; + $defaultApp = PFRequestHelper::getDefaultURIApplication(); + $this->controllerMap[$defaultApp] = $map; + + list($defaultApp, $defaultCmd) = explode('.', $this->controllerMap[$defaultApp]->getCommand(PF_DEFAULT_URI . '|get')); + + if (!self::$baseCommand) { + self::$baseCommand = new ReflectionClass('PFCommand'); + PFFactory::getInstance()->initCommandObject($defaultApp . '.' . $defaultCmd); + } + } + + public function addControllerMap($app) { + + if (array_key_exists($app, $this->controllerMap)) { + return; + } + + $map = PFApplicationHelper::getInstance()->loadControllerMap($app); + $this->controllerMap[$app] = $map; + } + + public function getControllerMap($app) { + if (!array_key_exists($app, $this->controllerMap)) { + $this->addControllerMap($app); + } + return $this->controllerMap[$app]; + } + + public function getView(PFRequest $request) { + list($app, $tpl) = explode('.', $this->getResource($request, 'View')); + if (!empty($tpl)) { + return $tpl . '.tpl'; + } else { + return ''; + } + } + + public function getViewApplication(PFRequest $request) { + + @list($app, $tpl) = explode('.', $this->getResource($request, 'View')); + return $app; + } + + public function getViewHeader(PFRequest $request) { + + @list($app, $tpl) = explode('.', $this->getResource($request, 'ViewHeader')); + + if (!empty($tpl)) { + return $tpl . '.tpl'; + } else { + return ''; + } + } + + public function getViewHeaderApplication(PFRequest $request) { + + @list($app, $tpl) = explode('.', $this->getResource($request, 'ViewHeader')); + return $app; + } + + public function getViewFooter(PFRequest $request) { + + list($app, $tpl) = explode('.', $this->getResource($request, 'ViewFooter')); + if (!empty($tpl)) { + return $tpl . '.tpl'; + } else { + return ''; + } + } + + public function getViewFooterApplication(PFRequest $request) { + + @list($app, $tpl) = explode('.', $this->getResource($request, 'ViewFooter')); + return $app; + } + + public function getForward(PFRequest $request) { + return $this->getResource($request, 'Forward'); + } + + public function getLogin(PFRequest $request) { + return $this->getResource($request, 'Login'); + } + + public function getPermissions(PFRequest $request) { + return $this->getResource($request, 'Permissions'); + } + + public function getTheme(PFRequest $request) { + return $this->getResource($request, 'Theme'); + } + + private function getResource(PFRequest $request, $resource) { + + $uri = PFRequestHelper::getURIPattern($request->get('pf.uri')); + $verb = PFRequestHelper::getHTTPVerbForURIPattern($request->get('pf.uri')); + $app = PFRequestHelper::getURIApplication($uri, $verb); + $cmd = PFRequestHelper::getURICommand($uri, $verb); + $this->addControllerMap($app); + + $uriArray = explode('?', $uri); + $uri = $uriArray[0]; + + $cmdString = $uri . '|' . $verb; + $previous = $request->getLastCommandRun(); + + // printr('resource: ' . $resource); + // printr('pf.uri: ' . $request->get('pf.uri')); + // printr('uri: ' . $uri); + // printr('verb: ' . $verb); + // printr('app: ' . $app); + // printr('cmd: ' . $cmd); + + if (is_object($previous)) { + $status = $previous->getStatus(); + } + + if (!isset($status)) { + $status = 0; + } + + $acquire = 'get' . $resource; + + // printr('acquire: ' . $acquire); + // printr($cmdString); + // printr($request); + // printr($this->controllerMap[$app]); + + $res = $this->controllerMap[$app]->$acquire($cmdString, $status); + + if (!$res) { + $res = $this->controllerMap[$app]->$acquire($cmdString, 0); + } + if (!$res) { + $res = $this->controllerMap[$app]->$acquire(PF_DEFAULT_URI . '|get', $status); + } + if (!$res) { + $res = $this->controllerMap[$app]->$acquire(PF_DEFAULT_URI . '|get', 0); + } + + if ($this->debug) { + printr('appController::getResource: ' . $acquire . '(' . $cmdString . ', ' . $status . ') -> ' . $res); + } + + return $res; + } + + public function getCommand(PFRequest $request) { + + $previous = $request->getLastCommandRun(); + + $app = PFRequestHelper::getCurrentURIApplication(); + $cmd = PFRequestHelper::getCurrentURICommand(); + $this->addControllerMap($app); + + if (!$previous) { + $commandType = 'Running'; + $uri = PFRequestHelper::getCurrentURIPattern(); + $verb = PFRequestHelper::getHTTPVerb(); + + } else { + $commandType = 'Forwarded to'; + $uri = $this->getForward($request); + $verb = PFRequestHelper::getHTTPVerbForURIPattern($uri); + + if (!$uri) { + return NULL; + } + } + + $request->set('pf.uri', $uri . '|' . $verb); + + if ($this->debug) { + $cmd = PFRequestHelper::getURICommand($uri, $verb); + printr('-- ' . $commandType . ' command ' . $uri . '|' . $verb); + } + + $cmdObject = $this->resolveCommand($uri, $verb); + + if (!$cmdObject) { + + $cmdObject = $this->resolveCommand($uri, $verb); + if (!$cmdObject) { + if ($this->debug) { + printr('-- ' . $commandType . ' command ' . 'content' . '.' . 'notfound'); + } + + $cmdObject = $this->resolveCommand('/content/notfound', 'get'); + $request->set('pf.uri', '/content/notfound|get'); + } + } + + $cmdClass = get_class($cmdObject); + @$this->invoked[$cmdClass]++; + + if ($this->invoked[$cmdClass] > 1) { + PFErrorStack::clearErrorStack(); + } + + if ($this->invoked[$cmdClass] > 2) { + throw new PFException('api', array('CIRCULAR_COMMAND_FORWARDING', $cmdClass), E_USER_ERROR); + } + + return $cmdObject; + } + + protected function resolveCommand($uri, $verb) { + + if ($uri == '') { + $uri = PF_DEFAULT_URI; + } + + $app = PFRequestHelper::getURIApplication($uri, $verb); + $cmd = PFRequestHelper::getURICommand($uri, $verb); + + $filepath = PF_BASE . '/modules/' . $app . '/cmd/' . $cmd . '.class.php'; + $classname = 'PF' . ucfirst($cmd) . 'Command'; + + if (file_exists($filepath)) { + + require_once $filepath; + + if (class_exists($classname)) { + + $cmdClass = new reflectionClass($classname); + if ($cmdClass->isSubClassOf(self::$baseCommand)) { + return $cmdClass->newInstance(); + } + } + } + + return NULL; + } } ?> \ No newline at end of file diff --git a/modules/api/lib/applicationhelper.class.php b/modules/api/lib/applicationhelper.class.php index fd93984..a4d8050 100644 --- a/modules/api/lib/applicationhelper.class.php +++ b/modules/api/lib/applicationhelper.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/cache.interface.php b/modules/api/lib/cache.interface.php index c3301b3..b8176e3 100644 --- a/modules/api/lib/cache.interface.php +++ b/modules/api/lib/cache.interface.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/cacheapc.class.php b/modules/api/lib/cacheapc.class.php index 61425ca..308f54c 100644 --- a/modules/api/lib/cacheapc.class.php +++ b/modules/api/lib/cacheapc.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/cachememcache.class.php b/modules/api/lib/cachememcache.class.php index 7623887..f72bbd4 100644 --- a/modules/api/lib/cachememcache.class.php +++ b/modules/api/lib/cachememcache.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/command.class.php b/modules/api/lib/command.class.php index eb1aa7d..4253a6e 100644 --- a/modules/api/lib/command.class.php +++ b/modules/api/lib/command.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/command.interface.php b/modules/api/lib/command.interface.php index d06ffb0..39c419e 100644 --- a/modules/api/lib/command.interface.php +++ b/modules/api/lib/command.interface.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/common.php b/modules/api/lib/common.php index 5dcb1cb..8415d10 100644 --- a/modules/api/lib/common.php +++ b/modules/api/lib/common.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -42,219 +42,228 @@ $ps = PATH_SEPARATOR; // load 3rd-party paths into "include_path". (If run from command line, - // we're probably running unit tests, so manually determine the full path - // from __FILE__. - if (php_sapi_name() == 'cli') { - $explodedPath = explode($ds . 'modules', __FILE__); - $pfRoot = $explodedPath[0]; +// we're probably running unit tests, so manually determine the full path +// from __FILE__. +if (php_sapi_name() == 'cli') { + $explodedPath = explode($ds . 'modules', __FILE__); + $pfRoot = $explodedPath[0]; +} else { + $pfRoot = $_SERVER['DOCUMENT_ROOT']; +} + +// we save the root in a define, for use elsewhere +define('PF_BASE', $pfRoot); + +ini_set('include_path', PF_BASE . $ps . ini_get('include_path')); + +if (PF_PROFILER) { + require_once 'modules/api/lib/profiler.class.php'; + PFProfiler::getInstance()->start(); +} + +// require all interfaces here +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'cache.interface.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'command.interface.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'observable.interface.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'observer.interface.php'; + +// base classes required all over the place +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'controllermap.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'exception.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'errorhandler.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'debugstack.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'factory.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'command.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'mailer.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'smstexter.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'restcommand.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'resourcecommand.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'template.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'jobqueue.class.php'; +require_once 'modules' . $ds . 'registration' . $ds . 'lib' . $ds . 'userhelper.class.php'; + +// set error handling overrides +//$pf_handler = new PFErrorHandler(); +//set_error_handler(array($pf_handler, 'errorHandler'), E_ALL); +//set_exception_handler(array($pf_handler, 'exceptionHandler')); +//ini_set('display_errors', false); +//ini_set('html_errors', false); + +// require all singletons here +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'language.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'session.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'registry.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'controller.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'applicationhelper.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'templatehelper.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'requesthelper.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'imagefile.class.php'; +require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'resthelper.class.php'; +require_once 'modules' . $ds . 'thirdparty' . $ds . 'patForms' . $ds . 'patForms' . $ds . 'Datasource' . $ds . 'Propel.php'; + +if (file_exists(PF_BASE . $ds . 'modules' . $ds . 'shop' . $ds . 'lib' . $ds . 'cart.class.php')) { + require_once 'modules' . $ds . 'shop' . $ds . 'lib' . $ds . 'cart.class.php'; +} + +// load PEAR path +if (PF_USE_LOCAL_PEAR == true) { + $pf_inc = PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'pear' . $ps; +} else { + $pf_inc = PF_PEAR_BASE . $ps; +} + +// Elastica support +function __autoload_elastica ($class) { + $path = str_replace('_', '/', $class); + $fullPath = PF_BASE . '/modules/thirdparty/elastica/lib/' . $path . '.php'; + + if (file_exists($fullPath)) { + require_once($fullPath); + } +} +spl_autoload_register('__autoload_elastica'); + +// add any additional third-party library include paths below +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'smarty' . $ps; +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'smarty' . $ds . 'sysplugins' . $ps; +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'patError' . $ps; +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'patForms' . $ps; +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'patForms' . $ds . 'patForms' . $ps; +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'fpdf' . $ps; + +$pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'db' . $ps; +ini_set('include_path', $pf_inc . $ps . ini_get('include_path')); + +try { + require_once 'propel' . $ds . 'Propel.php'; + require_once 'propel' . $ds . 'om' . $ds . 'BaseObject.php'; + + if (file_exists(PF_BASE . $ds . 'modules' . $ds . 'db' . $ds . 'conf' . $ds . 'protean-conf.php')) { + Propel::init(PF_BASE . $ds . 'modules' . $ds . 'db' . $ds . 'conf' . $ds . 'protean-conf.php'); } else { - $pfRoot = $_SERVER['DOCUMENT_ROOT']; + throw new PFException('', 'Propel failed to load. Config file not found.', E_USER_ERROR); } - // we save the root in a define, for use elsewhere - define('PF_BASE', $pfRoot); - - ini_set('include_path', PF_BASE . $ps . ini_get('include_path')); - - if (PF_PROFILER) { - require_once 'modules/api/lib/profiler.class.php'; - PFProfiler::getInstance()->start(); - } - - // require all interfaces here - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'cache.interface.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'command.interface.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'observable.interface.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'observer.interface.php'; - - // base classes required all over the place - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'controllermap.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'exception.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'errorhandler.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'debugstack.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'factory.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'command.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'mailer.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'smstexter.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'restcommand.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'resourcecommand.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'template.class.php'; - require_once 'modules' . $ds . 'registration' . $ds . 'lib' . $ds . 'userhelper.class.php'; - - // set error handling overrides - $pf_handler = new PFErrorHandler(); - set_error_handler(array($pf_handler, 'errorHandler'), E_ALL); - set_exception_handler(array($pf_handler, 'exceptionHandler')); - ini_set('display_errors', false); - ini_set('html_errors', false); - - // require all singletons here - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'language.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'session.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'registry.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'controller.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'applicationhelper.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'templatehelper.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'requesthelper.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'imagefile.class.php'; - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'resthelper.class.php'; - require_once 'modules' . $ds . 'thirdparty' . $ds . 'patForms' . $ds . 'patForms' . $ds . 'Datasource' . $ds . 'Propel.php'; - - if (PF_CMS_ENABLED == true) { - require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'cmshelper.class.php'; + // handle full query logging if this constant is set true + if (PF_QUERY_DEBUG) { + $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); + $config->setParameter('debugpdo.logging.details.method.enabled', true); + $config->setParameter('debugpdo.logging.details.time.enabled', true); + $config->setParameter('debugpdo.logging.details.mem.enabled', true); } - if (file_exists(PF_BASE . $ds . 'modules' . $ds . 'shop' . $ds . 'lib' . $ds . 'cart.class.php')) { - require_once 'modules' . $ds . 'shop' . $ds . 'lib' . $ds . 'cart.class.php'; - } +} catch (PFException $e) { + $e->handleException(); +} catch (Exception $e) { + PFException::handleVanillaException($e->getMessage(), $e->getCode(), $e->getFile(), $e->getLine()); +} - // load PEAR path - if (PF_USE_LOCAL_PEAR == true) { - $pf_inc = PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'pear' . $ps; - } else { - $pf_inc = PF_PEAR_BASE . $ps; - } +// Memcache Support +if (PF_CACHE_ENABLED) { - // add any additional third-party library include paths below - $pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'smarty' . $ps; - $pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'patError' . $ps; - $pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'patForms' . $ps; - $pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'patForms' . $ds . 'patForms' . $ps; - $pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'thirdparty' . $ds . 'fpdf' . $ps; + try { + PFFactory::getInstance()->initObject('api.cachememcache'); - $pf_inc .= PF_BASE . $ds . 'modules' . $ds . 'db' . $ps; - ini_set('include_path', $pf_inc . $ps . ini_get('include_path')); + if (PF_CACHE_MEMCACHE_SERVER_HOST_1 != false) + PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_1); - try { - require_once 'propel' . $ds . 'Propel.php'; - require_once 'propel' . $ds . 'om' . $ds . 'BaseObject.php'; + if (PF_CACHE_MEMCACHE_SERVER_HOST_2 != false) + PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_2); - if (file_exists(PF_BASE . $ds . 'modules' . $ds . 'db' . $ds . 'conf' . $ds . 'protean-conf.php')) { - Propel::init(PF_BASE . $ds . 'modules' . $ds . 'db' . $ds . 'conf' . $ds . 'protean-conf.php'); - } else { - throw new PFException('', 'Propel failed to load. Config file not found.', E_USER_ERROR); - } + if (PF_CACHE_MEMCACHE_SERVER_HOST_3 != false) + PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_3); - // handle full query logging if this constant is set true - if (PF_QUERY_DEBUG) { - $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); - $config->setParameter('debugpdo.logging.details.method.enabled', true); - $config->setParameter('debugpdo.logging.details.time.enabled', true); - $config->setParameter('debugpdo.logging.details.mem.enabled', true); - } + if (PF_CACHE_MEMCACHE_SERVER_HOST_4 != false) + PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_4); } catch (PFException $e) { - $e->handleException(); + $e->HandleException(); } catch (Exception $e) { - PFException::handleVanillaException($e->getMessage(), $e->getCode(), $e->getFile(), $e->getLine()); + PFException::HandleVanillaException($e->getMessage(), $e->getCode(), $e->getFile(), $e->getLine()); } +} - // Memcache Support - if (PF_CACHE_ENABLED) { - - try { - PFFactory::getInstance()->initObject('api.cachememcache'); - - if (PF_CACHE_MEMCACHE_SERVER_HOST_1 != false) - PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_1); - - if (PF_CACHE_MEMCACHE_SERVER_HOST_2 != false) - PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_2); - - if (PF_CACHE_MEMCACHE_SERVER_HOST_3 != false) - PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_3); +try { + PFLanguage::getInstance(); + $request = PFFactory::getInstance()->createObject('api.request'); - if (PF_CACHE_MEMCACHE_SERVER_HOST_4 != false) - PFCacheMemcache::getInstance()->addServer(PF_CACHE_MEMCACHE_SERVER_HOST_4); + $lang = $request->get('lang'); + $app = $request->get('app'); - } catch (PFException $e) { - $e->HandleException(); - } catch (Exception $e) { - PFException::HandleVanillaException($e->getMessage(), $e->getCode(), $e->getFile(), $e->getLine()); - } + if (isset($lang)) { + PFLanguage::getInstance()->setCurrentLocale($lang); } - try { - PFLanguage::getInstance(); - $request = PFFactory::getInstance()->createObject('api.request'); - - $lang = $request->get('lang'); - $app = $request->get('app'); - - if (isset($lang)) { - PFLanguage::getInstance()->setCurrentLocale($lang); - } - - if (!isset($app)) { - $app = 'content'; - } - } catch (PFException $e) { - $e->handleException(); + if (!isset($app)) { + $app = 'content'; } - - try { - PFLanguage::getInstance()->loadTranslationTable('api', 'global'); - PFLanguage::getInstance()->loadTranslationTable($app, 'global'); - } catch (PFException $e) { - $e->handleException(); +} catch (PFException $e) { + $e->handleException(); +} + +try { + PFLanguage::getInstance()->loadTranslationTable('api', 'global'); + PFLanguage::getInstance()->loadTranslationTable($app, 'global'); +} catch (PFException $e) { + $e->handleException(); +} + +function printr($arr, $buffered=false) { + if (php_sapi_name() != 'cli') { + echo '
';
+		$newLine = '
'; + } else { + $newLine = "\n"; } - - function printr($arr, $buffered=false) { - if (php_sapi_name() != 'cli') { - echo '
';
-			$newLine = '
'; - } else { - $newLine = "\n"; - } - if (!empty($arr)) { - print_r($arr, $buffered); - echo $newLine; - } - if (php_sapi_name() != 'cli') { - echo '
'; - } + if (!empty($arr)) { + print_r($arr, $buffered); + echo $newLine; } - - function printrBuffered($arr) { - return (printr($arr, true)); + if (php_sapi_name() != 'cli') { + echo '
'; + } +} + +function printrBuffered($arr) { + return (printr($arr, true)); +} + +// arrayToXML($array, $rootNodeName, $xml) +// +// Take a multi dimensional array and convert it to a simple XML string. +// Not the most advanced method to do this, but works for fairly basic XML documents. +// Also allows us to keep the code cleaner instead of having XML Strings everywhere. +function arrayToXML($array, $rootNodeName='data', $xml=null){ + if (is_null($xml)){ + $xml = simplexml_load_string("<$rootNodeName />"); } - // arrayToXML($array, $rootNodeName, $xml) - // - // Take a multi dimensional array and convert it to a simple XML string. - // Not the most advanced method to do this, but works for fairly basic XML documents. - // Also allows us to keep the code cleaner instead of having XML Strings everywhere. - function arrayToXML($array, $rootNodeName='data', $xml=null){ - if (is_null($xml)){ - $xml = simplexml_load_string("<$rootNodeName />"); + // loop through the data passed in. + foreach($array as $key => $value){ + // no numeric keys in our xml please! + if (is_numeric($key)){ + $key = "unknownNode_". (string) $key; } - // loop through the data passed in. - foreach($array as $key => $value){ - // no numeric keys in our xml please! - if (is_numeric($key)){ - $key = "unknownNode_". (string) $key; - } - - // delete any char not allowed in XML element names - $key = preg_replace('/[^a-z0-9\-\_\.\:]/i', '', $key); - - // if there is another array found recrusively call this function - if (is_array($value)){ - $node = $xml->addChild($key); - // recrusive call. - arrayToXML($value, $rootNodeName, $node); - } - else { - // add single node. - $value = htmlentities($value); - $xml->addChild($key,$value); - } - } + // delete any char not allowed in XML element names + $key = preg_replace('/[^a-z0-9\-\_\.\:]/i', '', $key); - // pass back as string. or simple xml object if you want! - return $xml->asXML(); + // if there is another array found recrusively call this function + if (is_array($value)){ + $node = $xml->addChild($key); + // recrusive call. + arrayToXML($value, $rootNodeName, $node); + } + else { + // add single node. + $value = htmlentities($value); + $xml->addChild($key,$value); + } } + // pass back as string. or simple xml object if you want! + return $xml->asXML(); +} + - ?> +?> diff --git a/modules/api/lib/controller.class.php b/modules/api/lib/controller.class.php index 0ab2be1..7071fee 100644 --- a/modules/api/lib/controller.class.php +++ b/modules/api/lib/controller.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/controllermap.class.php b/modules/api/lib/controllermap.class.php index 464ad73..ab68876 100644 --- a/modules/api/lib/controllermap.class.php +++ b/modules/api/lib/controllermap.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/debugstack.class.php b/modules/api/lib/debugstack.class.php index 24e416e..d985f9f 100644 --- a/modules/api/lib/debugstack.class.php +++ b/modules/api/lib/debugstack.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/errorhandler.class.php b/modules/api/lib/errorhandler.class.php index 20db0b2..27717a9 100644 --- a/modules/api/lib/errorhandler.class.php +++ b/modules/api/lib/errorhandler.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/errorstack.class.php b/modules/api/lib/errorstack.class.php index b13a4dc..d751501 100644 --- a/modules/api/lib/errorstack.class.php +++ b/modules/api/lib/errorstack.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/exception.class.php b/modules/api/lib/exception.class.php index 0982f90..7b02f2d 100644 --- a/modules/api/lib/exception.class.php +++ b/modules/api/lib/exception.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -36,7 +36,6 @@ public static function enrich(Exception $e) { } else { $code = $e->getCode(); } - return new PFException('', $e->getMessage(), $code); } @@ -315,10 +314,10 @@ static public function handleVanillaException($message, $code, $file='', $line=' public function handleRestException($type='application/json') { if ($type == 'application/json') { - $json = PFRestHelper::makeJSONResponse('error', $this->getCode(), $this->getMessage()); + $json = PFRestHelper::makeResponse('error', $this->getCode(), $this->getMessage()); PFRestHelper::sendResponse(500, $json, $type); } else { - PFRestHelper::sendResponse(500, $this->getSlimError()); + PFRestHelper::sendResponse(500, $this->getSlimError()); } $this->logException(); diff --git a/modules/api/lib/factory.class.php b/modules/api/lib/factory.class.php index 7b7d924..791ba53 100644 --- a/modules/api/lib/factory.class.php +++ b/modules/api/lib/factory.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -46,11 +46,10 @@ public function createObject ($class, $p1='_UNDEF_',$p2='_UNDEF_',$p3='_UNDEF_',$p4='_UNDEF_', $p5='_UNDEF_',$p6='_UNDEF_',$p7='_UNDEF_',$p8='_UNDEF_', $p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_', - $p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_') { + $p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_') { try { list ($appname, $classname) = explode('.', $class); - // load class file if not in third-party directory (since we already added those to the // include_path earlier) if ($appname != 'thirdparty') { @@ -60,7 +59,7 @@ public function createObject ($class, throw new PFException('', PFException::ERR_FILE_NOT_READABLE . ': ' . $filename . '.', E_USER_FATAL); } - require_once($filename); + require_once($filename); } if ($appname == 'api') { diff --git a/modules/api/lib/form.class.php b/modules/api/lib/form.class.php index 3ea6262..cec4d26 100644 --- a/modules/api/lib/form.class.php +++ b/modules/api/lib/form.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -33,7 +33,7 @@ public function __construct($request, $formTemplate, $submitName='submit', $acti $this->parser->setNamespace('PFForm'); if (PFRegistry::getInstance()->isValueSet('pf_override_theme') && - file_exists(PF_BASE . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . PFRegistry::getInstance()->get('pf_override_theme') . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . $formName . '.form.tpl')) { + file_exists(PF_BASE . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . PFRegistry::getInstance()->get('pf_override_theme') . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . $formName . '.form.tpl')) { $theme = PFRegistry::getInstance()->get('pf_override_theme'); } else { $theme = PFRegistry::getInstance()->get('pf_theme'); @@ -48,7 +48,8 @@ public function __construct($request, $formTemplate, $submitName='submit', $acti if (PF_FORM_FIELD_ERROR_HIGHLIGHTING) { $errorAttributes = array( - 'class' => 'errorfield', + // 'class' => 'errorfield', + 'class' => $this->form->getAttribute('class') . ' errorfield', 'description' => 'Please fix me, I\'m erroneous!' ); @@ -98,6 +99,10 @@ public function reportErrors() { public function setAction($action) { $this->form->setAttribute('action', $action); } + + public function getAction() { + $this->form->getAttribute('action'); + } public function setCharset($charset='utf-8') { $this->form->setAttribute('accept-charset', $action); diff --git a/modules/api/lib/htmllogger.class.php b/modules/api/lib/htmllogger.class.php deleted file mode 100644 index 6d6902e..0000000 --- a/modules/api/lib/htmllogger.class.php +++ /dev/null @@ -1,41 +0,0 @@ -Assign('PF_HTML_LOGGER_HEADER', 'Protean Logger'); - - if ($page->get_template_vars('PF_HTML_LOGGER_BODY') == '') { - $page->assign('PF_HTML_LOGGER_BODY', ''); - } - - $footer = 'Protean Framework v' . PF_VERSION; - - if (isset($_SERVER['SERVER_NAME'])) { - $footer .= ' running on ' . @$_SERVER['SERVER_NAME']; - } - - $page->assign('PF_HTML_LOGGER_FOOTER', $footer); - } - - public function update(PFObservable $observer) { - - $debugStack = $observer->getDebugStack(); - - $lastMsg = end($debugStack); - PFTemplateHelper::getInstance()->append('PF_HTML_LOGGER_BODY', $lastMsg['message'] . '
at ' . basename($lastMsg['file']) . ':' . $lastMsg['line'] . '

'); - } -} - -?> \ No newline at end of file diff --git a/modules/api/lib/imagefile.class.php b/modules/api/lib/imagefile.class.php index 0bc6ba0..b89f823 100644 --- a/modules/api/lib/imagefile.class.php +++ b/modules/api/lib/imagefile.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -35,14 +35,14 @@ static public function convertNonstandardImageToJpeg($filePath) { switch ($type) { case IMAGETYPE_JPEG: - return basename(self::stripFileExtension($filePath) . '.jpg'); - break; + return basename(self::stripFileExtension($filePath) . '.jpg'); + break; case IMAGETYPE_GIF: - return basename(self::stripFileExtension($filePath) . '.gif'); - break; + return basename(self::stripFileExtension($filePath) . '.gif'); + break; case IMAGETYPE_PNG: - return basename(self::stripFileExtension($filePath) . '.png'); - break; + return basename(self::stripFileExtension($filePath) . '.png'); + break; } } @@ -66,17 +66,17 @@ public static function createThumbnail($name, $filename, $newWidth, $newHeight) $type = self::getCommandLineImageMimetype($name); switch ($type) { case IMAGETYPE_JPEG: - $sourceImage = imagecreatefromjpeg($name); - break; + $sourceImage = imagecreatefromjpeg($name); + break; case IMAGETYPE_GIF: - $sourceImage = imagecreatefromgif($name); - break; + $sourceImage = imagecreatefromgif($name); + break; case IMAGETYPE_PNG: - $sourceImage = imagecreatefrompng($name); - break; + $sourceImage = imagecreatefrompng($name); + break; default: - throw new PFException('api', 'IMAGE_TYPE_MUST_BE_JPG_GIF_PNG', E_USER_WARNING); - break; + throw new PFException('api', 'IMAGE_TYPE_MUST_BE_JPG_GIF_PNG', E_USER_WARNING); + break; } if (!isset($sourceImage)) { @@ -106,17 +106,17 @@ public static function createThumbnail($name, $filename, $newWidth, $newHeight) switch ($type) { case IMAGETYPE_JPEG: - imagejpeg($destinationImage, $filename, 95); - break; + imagejpeg($destinationImage, $filename, 95); + break; case IMAGETYPE_GIF: - imagegif($destinationImage, $filename); - break; + imagegif($destinationImage, $filename); + break; case IMAGETYPE_PNG: - imagepng($destinationImage, $filename); - break; + imagepng($destinationImage, $filename); + break; default: - throw new PFException('api', 'IMAGE_TYPE_MUST_BE_JPG_GIF_PNG', E_USER_WARNING); - break; + throw new PFException('api', 'IMAGE_TYPE_MUST_BE_JPG_GIF_PNG', E_USER_WARNING); + break; } imagedestroy($destinationImage); diff --git a/modules/api/lib/language.class.php b/modules/api/lib/language.class.php index ff5525e..b4a1990 100644 --- a/modules/api/lib/language.class.php +++ b/modules/api/lib/language.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/mailer.class.php b/modules/api/lib/mailer.class.php index b456081..a3f5122 100644 --- a/modules/api/lib/mailer.class.php +++ b/modules/api/lib/mailer.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/observable.interface.php b/modules/api/lib/observable.interface.php index 5cedc01..3c9ebd7 100644 --- a/modules/api/lib/observable.interface.php +++ b/modules/api/lib/observable.interface.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/observer.interface.php b/modules/api/lib/observer.interface.php index 3acb215..2aa7af0 100644 --- a/modules/api/lib/observer.interface.php +++ b/modules/api/lib/observer.interface.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/profiler.class.php b/modules/api/lib/profiler.class.php index 29d3744..882b113 100644 --- a/modules/api/lib/profiler.class.php +++ b/modules/api/lib/profiler.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -10,51 +10,50 @@ /** @package api */ -class PFProfiler { - - static private $instance; - static private $enabled; - - private function __construct() { - self::init(); - self::$enabled = PF_PROFILER; - } - - static public function getInstance() { - - if(self::$instance == NULL) { - self::$instance = new PFProfiler(); - } - - return self::$instance; - } - - static public function init() { - - if (!extension_loaded('xhprof')) { - die(sprintf('xhprof extension must be installed to use profiling')); - } - } - - static public function start() { - if (self::$enabled) { - xhprof_enable(); - } - } - - static public function stop() { - if (self::$enabled) { - $data = xhprof_disable(); - - if (!is_dir(PF_PROFILER_RUNS_PATH)) { - mkdir(PF_PROFILER_RUNS_PATH); - } - - include_once PF_BASE . '/modules/thirdparty/xhprof/xhprof_lib/utils/xhprof_lib.php'; - include_once PF_BASE . '/modules/thirdparty/xhprof/xhprof_lib/utils/xhprof_runs.php'; - $xhprof_runs = new XHProfRuns_Default(PF_PROFILER_RUNS_PATH); - $run_id = $xhprof_runs->save_run($data, 'xhprof'); - } - } +class PFProfiler { + + static private $instance; + static private $enabled; + + private function __construct() { + self::init(); + self::$enabled = PF_PROFILER; + } + + static public function getInstance() { + if(self::$instance == NULL) { + self::$instance = new PFProfiler(); + } + + return self::$instance; + } + + static public function init() { + if (!extension_loaded('xhprof')) { + die(sprintf('xhprof extension must be installed to use profiling')); + } + } + + static public function start() { + if (self::$enabled) { + xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); + } + } + + static public function stop() { + if (self::$enabled) { + $data = xhprof_disable(); + + if (!is_dir(PF_PROFILER_RUNS_PATH)) { + mkdir(PF_PROFILER_RUNS_PATH); + } + + include_once PF_BASE . '/modules/thirdparty/xhprof/xhprof_lib/utils/xhprof_lib.php'; + include_once PF_BASE . '/modules/thirdparty/xhprof/xhprof_lib/utils/xhprof_runs.php'; + $xhprofRuns = new XHProfRuns_Default(PF_PROFILER_RUNS_PATH); + $runId = $xhprofRuns->save_run($data, 'xhprof'); + printr('Profiler'); + } + } } ?> \ No newline at end of file diff --git a/modules/api/lib/registry.class.php b/modules/api/lib/registry.class.php index b3a4215..05db624 100644 --- a/modules/api/lib/registry.class.php +++ b/modules/api/lib/registry.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/request.class.php b/modules/api/lib/request.class.php index 16af186..cc8784d 100644 --- a/modules/api/lib/request.class.php +++ b/modules/api/lib/request.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -49,6 +49,13 @@ public function init() { } public function getProperty($key) { + if ( isset($this->properties[$key]) && is_array($this->properties[$key]) ){ + $new_array = $this->properties[$key]; + foreach ($this->properties[$key] as $index => $value){ + $new_array[$index] = @html_entity_decode($value, ENT_QUOTES, 'UTF-8'); + } + return $new_array; + } return @html_entity_decode($this->properties[$key], ENT_QUOTES, 'UTF-8'); } diff --git a/modules/api/lib/requesthelper.class.php b/modules/api/lib/requesthelper.class.php index b14f5f2..4600149 100644 --- a/modules/api/lib/requesthelper.class.php +++ b/modules/api/lib/requesthelper.class.php @@ -2,145 +2,158 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ /** @package api -*/ -class PFRequestHelper { - - public static function getDefaultURIApplication() { - $default = explode('/', PF_DEFAULT_URI); - return $default[1]; - } - - public static function getCurrentURIApplication() { - return self::getURIApplication(self::getCurrentURIPattern(), self::getHTTPVerb()); - } - - public static function getURIApplication($uri, $verb) { - - if (empty($uri)) { - $uri = PF_DEFAULT_URI; - } - - if (empty($verb)) { - $verb = 'get'; - } - - $uriArray = explode('/', $uri); - $app = $uriArray[1]; - - $appController = PFApplicationHelper::getInstance()->appController(); - $controllerMap = $appController->getControllerMap($app); - $uriArray = explode('.', $controllerMap->getCommand($uri . '|' . $verb)); - - return @$uriArray[0]; - } - - public static function getDefaultURICommand() { - $default = explode('/', PF_DEFAULT_URI); - return $default[2]; - } - - public static function getCurrentURICommand() { - return self::getURICommand(self::getCurrentURIPattern(), self::getHTTPVerb()); - } - - public static function getURICommand($uri, $verb) { - - if (empty($uri)) { - $uri = PF_DEFAULT_URI; - } - - if (empty($verb)) { - $verb = 'get'; - } - - $uriArray = explode('/', $uri); - $app = $uriArray[1]; - - $controllerMap = PFApplicationHelper::getInstance()->appController()->getControllerMap($app); - $uriArray = explode('.', $controllerMap->getCommand($uri . '|' . $verb)); - - return @$uriArray[1]; - } - - public static function getCurrentURIPattern() { - return self::getURIPattern(@$_SERVER['REQUEST_URI']); - } - - public static function getURIPattern($uri) { - $uri = explode('|', $uri); - $uriArray = explode('/', $uri[0]); - - $uriQueryStringArray = explode('?', @$uriArray[count($uriArray)-1]); - $uriArray[count($uriArray)-1] = $uriQueryStringArray[0]; - if (empty($uriQueryStringArray[0])) { - array_pop($uriArray); - } - array_shift($uriArray); - - $uri = '/'; - - foreach ($uriArray as $uriElement) { - if (is_numeric($uriElement)) { - $uri .= ':integer:/'; - } else { - $uri .= $uriElement . '/'; - } - } - - return substr($uri, 0, -1); - } - - public static function getCurrentURI() { - $uriArray = explode('?', @$_SERVER['REQUEST_URI']); - $uri = $uriArray[0]; - - if (substr($uri, -1) == '/') { - $uri = substr($uri, 0, -1); - } - return $uri; - } - - public static function getRESTSlot($indexOffset) { - $uriArray = explode('/', @$_SERVER['REQUEST_URI']); - $uriArray = explode('?', @$uriArray[2 + $indexOffset]); - return @$uriArray[0]; - } - - public static function getRESTSlotForURIPattern($indexOffset, &$request) { - $uriArray = $request->get('pf.uri'); - $uriArray = explode('|', $uriArray); - $uriArray = explode('/', $uriArray[0]); - $uriArray = explode('?', @$uriArray[2 + $indexOffset]); - return @$uriArray[0]; - } - - public static function getHTTPVerb() { - $verb = @strtolower($_SERVER['REQUEST_METHOD']); - if (empty($verb)) { - $verb = 'get'; - } - return $verb; - } - - public static function resetHTTPVerb() { - $_SERVER['REQUEST_METHOD'] = 'get'; - } - - public static function getHTTPVerbForURIPattern($uri) { - - @list($uri, $verb) = explode('|', $uri); - if (empty($verb)) { - $verb = 'get'; - } - return $verb; - } +*/ +class PFRequestHelper { + + public static function getDefaultURIApplication() { + $default = explode('/', PF_DEFAULT_URI); + return $default[1]; + } + + public static function getCurrentURIApplication() { + return self::getURIApplication(self::getCurrentURIPattern(), self::getHTTPVerb()); + } + + public static function getURIApplication($uri, $verb) { + + if (empty($uri)) { + $uri = PF_DEFAULT_URI; + } + + if (empty($verb)) { + $verb = 'get'; + } + + $uriArray = explode('/', $uri); + $app = $uriArray[1]; + + $appController = PFApplicationHelper::getInstance()->appController(); + $controllerMap = $appController->getControllerMap($app); + $uriArray = explode('.', $controllerMap->getCommand($uri . '|' . $verb)); + + return @$uriArray[0]; + } + + public static function getDefaultURICommand() { + $default = explode('/', PF_DEFAULT_URI); + return $default[2]; + } + + public static function getCurrentURICommand() { + return self::getURICommand(self::getCurrentURIPattern(), self::getHTTPVerb()); + } + + public static function getURICommand($uri, $verb) { + + if (empty($uri)) { + $uri = PF_DEFAULT_URI; + } + + if (empty($verb)) { + $verb = 'get'; + } + + $urlArray = explode('?', $uri); + $uri = $urlArray[0]; + + $uriArray = explode('/', $uri); + $app = $uriArray[1]; + + $controllerMap = PFApplicationHelper::getInstance()->appController()->getControllerMap($app); + $uriArray = explode('.', $controllerMap->getCommand($uri . '|' . $verb)); + + return @$uriArray[1]; + } + + public static function getCurrentURIPattern() { + if (array_key_exists('REQUEST_URI', $_SERVER)) { + $uriArray = explode('?', $_SERVER['REQUEST_URI']); + $uri = @$uriArray[0]; + } else { + $uri = @$_SERVER['REQUEST_URI']; + } + + // FIXME: suuuucks doing this, but we gotta get it working, and can't refactor wildcards into protean core right now + $uri = preg_replace('/\/shop\/detail\/(\d+)\/(.*)/', '/shop/detail/$1', $uri); + + return self::getURIPattern(@$uri . '|' . self::getHTTPVerb()); + } + + public static function getURIPattern($uri) { + $uri = explode('|', $uri); + $uriArray = explode('/', $uri[0]); + + $uriQueryStringArray = explode('?', @$uriArray[count($uriArray)-1]); + $uriArray[count($uriArray)-1] = $uriQueryStringArray[0]; + if (empty($uriQueryStringArray[0])) { + array_pop($uriArray); + } + array_shift($uriArray); + + $uri = '/'; + + foreach ($uriArray as $uriElement) { + if (is_numeric($uriElement)) { + $uri .= ':integer:/'; + } else { + $uri .= $uriElement . '/'; + } + } + + return substr($uri, 0, -1); + } + + public static function getCurrentURI() { + $uriArray = explode('?', @$_SERVER['REQUEST_URI']); + $uri = $uriArray[0]; + + if (substr($uri, -1) == '/') { + $uri = substr($uri, 0, -1); + } + return $uri; + } + + public static function getRESTSlot($indexOffset) { + $uriArray = explode('/', @$_SERVER['REQUEST_URI']); + $uriArray = explode('?', @$uriArray[2 + $indexOffset]); + return @$uriArray[0]; + } + + public static function getRESTSlotForURIPattern($indexOffset, &$request) { + $uriArray = $request->get('pf.uri'); + $uriArray = explode('|', $uriArray); + $uriArray = explode('/', $uriArray[0]); + $uriArray = explode('?', @$uriArray[2 + $indexOffset]); + return @$uriArray[0]; + } + + public static function getHTTPVerb() { + $verb = @strtolower($_SERVER['REQUEST_METHOD']); + if (empty($verb)) { + $verb = 'get'; + } + return $verb; + } + + public static function resetHTTPVerb() { + $_SERVER['REQUEST_METHOD'] = 'get'; + } + + public static function getHTTPVerbForURIPattern($uri) { + + @list($uri, $verb) = explode('|', $uri); + if (empty($verb)) { + $verb = 'get'; + } + return $verb; + } } ?> \ No newline at end of file diff --git a/modules/api/lib/resourcecommand.class.php b/modules/api/lib/resourcecommand.class.php index 6525d99..ec54a14 100644 --- a/modules/api/lib/resourcecommand.class.php +++ b/modules/api/lib/resourcecommand.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/restcommand.class.php b/modules/api/lib/restcommand.class.php index f1feecd..a88a9b1 100755 --- a/modules/api/lib/restcommand.class.php +++ b/modules/api/lib/restcommand.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -14,35 +14,41 @@ class PFRestCommand extends PFDefaultCommand { - public function doExecute(PFRequest $request) { - try { - parent::doExecute($request); - $this->response = PFRestHelper::processRequest($request); - $method = 'handle' . $this->response->getMethod(); - return $this->$method($request); - } catch (PFException $e) { - $e->handleRestException(); - } - } - - protected function notImplemented() { - PFRestHelper::sendResponse(501, '{"status":"error","code":"notimplemented","message":"Not Implemented"}', 'application/json'); - } - - public function handleGet(PFRequest $request) { - return $this->notImplemented(); - } - - public function handlePost(PFRequest $request) { - return $this->notImplemented(); - } - - public function handlePut(PFRequest $request) { - return $this->notImplemented(); - } - - public function handleDelete(PFRequest $request) { - return $this->notImplemented(); - } + protected $response; + + public function doExecute(PFRequest $request) { + try { + parent::doExecute($request); + $this->response = PFRestHelper::processRequest($request); + $method = 'handle' . $this->response->getMethod(); + return $this->$method($request); + } catch (PFException $e) { + $e->handleRestException(); + } + } + + protected function getResponseVars() { + return $this->response->getRequestVars(); + } + + protected function notImplemented() { + PFRestHelper::sendResponse(501, '{"status":"error","code":"notimplemented","message":"Not Implemented"}', 'application/json'); + } + + public function handleGet(PFRequest $request) { + return $this->notImplemented(); + } + + public function handlePost(PFRequest $request) { + return $this->notImplemented(); + } + + public function handlePut(PFRequest $request) { + return $this->notImplemented(); + } + + public function handleDelete(PFRequest $request) { + return $this->notImplemented(); + } } ?> \ No newline at end of file diff --git a/modules/api/lib/resthelper.class.php b/modules/api/lib/resthelper.class.php index 5c76525..f1e8278 100644 --- a/modules/api/lib/resthelper.class.php +++ b/modules/api/lib/resthelper.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -18,15 +18,15 @@ public static function processRequest($request) { $data = array(); switch ($requestMethod) { case 'get': - $data = $_GET; - break; + $data = $_GET; + break; case 'post': - $data = $_POST; - break; + $data = $_POST; + break; case 'put': - parse_str(file_get_contents('php://input'), $putVars); - $data = $putVars; - break; + parse_str(file_get_contents('php://input'), $putVars); + $data = $putVars; + break; } $returnObject->setMethod($requestMethod); @@ -39,13 +39,18 @@ public static function processRequest($request) { return $returnObject; } - public static function sendResponse($status=200, $content='', $contentType='text/html') { + public static function sendResponse($status=200, $content=array(), $contentType='application/json') { $statusHeader = 'HTTP/1.1 ' . $status . ' ' . PFRestHelper::getStatusCodeMessage($status); header($statusHeader); header('Content-type: ' . $contentType . '; charset=utf-8'); - if ($contentType != 'text/html') { + if ($contentType == 'application/json') { + echo json_encode($content); + ob_flush(); + exit; + } else if ($contentType != 'text/html') { echo $content; + ob_flush(); exit; } else { @@ -53,20 +58,20 @@ public static function sendResponse($status=200, $content='', $contentType='text switch ($status) { case 400: - $message = 'A bad request was made to the URL ' . $_SERVER['REQUEST_URI'] . '.'; - break; + $message = 'A bad request was made to the URL ' . $_SERVER['REQUEST_URI'] . '.'; + break; case 401: - $message = 'You must be authorized to view this page.'; - break; + $message = 'You must be authorized to view this page.'; + break; case 404: - $message = 'The requested URL ' . $_SERVER['REQUEST_URI'] . ' was not found.'; - break; + $message = 'The requested URL ' . $_SERVER['REQUEST_URI'] . ' was not found.'; + break; case 500: - $message = 'The server encountered an error processing your request.'; - break; + $message = 'The server encountered an error processing your request.'; + break; case 501: - $message = 'The requested method is not implemented.'; - break; + $message = 'The requested method is not implemented.'; + break; } $signature = ($_SERVER['SERVER_SIGNATURE'] == '') ? $_SERVER['SERVER_SOFTWARE'] . ' Server at ' . $_SERVER['SERVER_NAME'] . ' Port ' . $_SERVER['SERVER_PORT'] : $_SERVER['SERVER_SIGNATURE']; @@ -91,16 +96,19 @@ public static function sendResponse($status=200, $content='', $contentType='text } } - public static function makeJSONResponse($status, $code, $message) { + public static function makeResponse($status, $code, $message, $arr=array()) { $m = explode(' ', microtime()); $utime = $m[1] . (int)round($m[0]*1000,3); - $json->status = $status; - $json->code = $code; - $json->message = $message; - $json->timestamp = $utime; - - return json_encode($json); + $res['status'] = $status; + $res['code'] = $code; + $res['message'] = $message; + $res['timestamp'] = $utime; + if (is_array($arr)) { + $res = array_merge($res, $arr); + } + + return $res; } public static function getStatusCodeMessage($status) { diff --git a/modules/api/lib/restrequest.class.php b/modules/api/lib/restrequest.class.php index 732f5c5..70c70fd 100644 --- a/modules/api/lib/restrequest.class.php +++ b/modules/api/lib/restrequest.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -20,7 +20,7 @@ class PFRestRequest { public function __construct() { $this->requestVars = array(); $this->data = ''; - $this->httpAccept = (strpos($_SERVER['HTTP_ACCEPT'], 'json')) ? 'json' : 'xml'; + $this->httpAccept = (strpos(@$_SERVER['HTTP_ACCEPT'], 'json')) ? 'json' : 'xml'; $this->method = 'get'; } diff --git a/modules/api/lib/session.class.php b/modules/api/lib/session.class.php index 4b60c38..b3465e8 100644 --- a/modules/api/lib/session.class.php +++ b/modules/api/lib/session.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -27,14 +27,14 @@ private function __construct($session_expire='', $session_auth_expire='') { } else { ini_set('session.save_handler', 'files'); - if (defined('PF_SESSION_PATH') && PF_SESSION_PATH != '') { - if (!is_dir(PF_SESSION_PATH . '/sessions') && is_writable(PF_SESSION_PATH)) { - mkdir(PF_SESSION_PATH . '/sessions', 0770); + if (defined('PF_SESSION_PATH') && PF_SESSION_PATH != '') { + if (!is_dir(PF_SESSION_PATH . '/sessions') && is_writable(PF_SESSION_PATH)) { + mkdir(PF_SESSION_PATH . '/sessions', 0770); + } + session_save_path(PF_SESSION_PATH . '/sessions'); } - session_save_path(PF_SESSION_PATH . '/sessions'); } - } - + if ($session_expire != '') { session_set_cookie_params($session_expire * 60); session_cache_expire($session_expire); @@ -54,8 +54,7 @@ private function __construct($session_expire='', $session_auth_expire='') { } if (php_sapi_name() != 'cli') { - session_start(); - + session_start(); } $fingerprint = PF_SESSION_UNIQUE_KEY . @$_SERVER['HTTP_USER_AGENT']; diff --git a/modules/api/lib/smstexter.class.php b/modules/api/lib/smstexter.class.php index 3fd04ee..fa4767c 100644 --- a/modules/api/lib/smstexter.class.php +++ b/modules/api/lib/smstexter.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/lib/template.class.php b/modules/api/lib/template.class.php index 10c1def..cf74c6d 100644 --- a/modules/api/lib/template.class.php +++ b/modules/api/lib/template.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2010, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * @@ -35,9 +35,9 @@ function _compile_lang($key) { } /** -* Protean register resource functions, to support application-prepended file names -* -*/ + * Protean register resource functions, to support application-prepended file names + * + */ function protean_get_template($tplName, &$tplSource, &$smarty) { list($appName, $tplFile) = explode('.', $tplName, 2); @@ -76,29 +76,39 @@ function protean_get_secure($tpl_name, &$smarty) { function protean_get_trusted($tpl_name, &$smarty) { } +/** +@package api +*/ class PFTemplate extends Smarty { protected $appName; + protected $controllerMap; protected $debug; - protected $more_template_dir = array(); public function __construct($appName, $languageTable='global') { - $this->error_reporting = null; + parent::__construct(); + $this->error_reporting = E_ALL & ~E_NOTICE; if (PFRegistry::getInstance()->isValueSet('pf_theme') == false) { PFRegistry::getInstance()->set('pf_theme', 'default'); } + $this->template_dir = null; + $this->appName = $appName; + $this->controllerMap = PFRegistry::getControllerMap(); + if (PF_TEMPLATE_DEBUG) { $this->debug = true; + $this->debugging = true; } else { $this->debug = false; + $this->debugging = false; } PFRegistry::getInstance()->set('APPNAME', $this->appName); - $this->template_dir = PF_BASE . '/modules/' . $this->appName . '/tpl/' . PFRegistry::getInstance()->get('pf_theme') . '/html/'; + $this->addTemplateDir(PF_BASE . '/modules/' . $this->appName . '/tpl/' . PFRegistry::getInstance()->get('pf_theme') . '/html/'); $this->addTemplateDir(PF_BASE); if (!is_dir(PF_TEMP_PATH . '/tpl_cmp') && is_writable(PF_TEMP_PATH)) { @@ -116,8 +126,10 @@ public function __construct($appName, $languageTable='global') { } $this->cache_dir = PF_TEMP_PATH . '/tpl_cch'; - parent::smarty(); - + if (PF_CACHE_ENABLED == true && PF_CACHE_TEMPLATES == true) { + $this->loadCacheResource('apc'); + $this->setCaching(true); + } /* Change this line if translation of dynamic data is needed ;-) $this->register_prefilter("smarty_prefilter_i18n"); @@ -125,9 +137,9 @@ public function __construct($appName, $languageTable='global') { $this->register_outputfilter("smarty_prefilter_i18n"); this change makes it possible even to translate dynamic data e.g. options because translation is done after compilation of template [xaos, 20050206] */ - $this->register_prefilter('smarty_prefilter_i18n'); + $this->registerFilter('pre', 'smarty_prefilter_i18n'); - $this->register_resource('protean', array('protean_get_template', + $this->registerResource('protean', array('protean_get_template', 'protean_get_timestamp', 'protean_get_secure', 'protean_get_trusted')); @@ -161,12 +173,12 @@ public function clearAssign($tpl_var) { } public function display($appName, $tplName) { - $header = $this->get_template_vars('PF_HEADER'); + $header = $this->tpl_vars['PF_HEADER']; if (empty($header)) { $this->setHeader(); } - $footer = $this->get_template_vars('PF_FOOTER'); + $footer = $this->tpl_vars['PF_FOOTER']; if (empty($footer)) { $this->setFooter(); } @@ -192,28 +204,35 @@ public function fetch($appName, $tplName, $display=false, $templateDir='') { } if (empty($templateDir)) { - $this->template_dir = PF_BASE . '/modules/' . $appName . '/tpl/' . PFRegistry::getInstance()->get('pf_theme') . '/html/'; + $this->setTemplateDir(PF_BASE . '/modules/' . $appName . '/tpl/' . PFRegistry::getInstance()->get('pf_theme') . '/html/');; } else { - $this->template_dir = $templateDir; + $this->setTemplateDir($templateDir); } - $this->template_dir = array_merge(array($this->template_dir), $this->more_template_dir); - - if (parent::template_exists($tplName)) { - $ret = parent::fetch($tplName, $cache_id, $compile_id, $display); + if (parent::templateExists($tplName)) { + $ret = parent::fetch($tplName, $cache_id, $compile_id, null, $display); } else { throw new PFException('api', array('TEMPLATE_DOES_NOT_EXIST', $this->template_dir[0] . $tplName), E_USER_ERROR); } - $this->template_dir = $curTemplateDir; + $this->setTemplateDir($curTemplateDir); return $ret; } + public function getTemplatePath($appName, $tplName) { + + if (PFRegistry::getInstance()->isValueSet('pf_theme') == false) { + PFRegistry::getInstance()->set('pf_theme', 'default'); + } + + return PF_BASE . '/modules/' . $appName . '/tpl/' . PFRegistry::getInstance()->get('pf_theme') . '/html/' . $tplName; + } + public function smartyFetch($tplName, $display=false) { $this->setLanguageIDs($cache_id, $compile_id); - if (parent::template_exists($tplName)) { - $ret = parent::fetch($tplName, $cache_id, $compile_id, $display); + if (parent::templateExists($tplName)) { + $ret = parent::fetch($tplName, $cache_id, $compile_id, null, $display); } else { throw new PFException('api', array('TEMPLATE_DOES_NOT_EXIST', $this->template_dir . $tplName), E_USER_ERROR); } @@ -233,7 +252,7 @@ public function isCached($tpl_file, $cache_id=null, $compile_id=null) { } public function setHeader($appName='', $tplName='header.tpl') { - list($defaultApp, $defaultCmd) = explode('.', PF_DEFAULT_COMMAND); + list(, $defaultApp, ) = explode('/', PF_DEFAULT_URI); if (empty($appName)) { $appName = $defaultApp; @@ -244,12 +263,13 @@ public function setHeader($appName='', $tplName='header.tpl') { } $this->assign('PF_ERRORSTACK', PFErrorstack::getErrorStackAsFormattedString()); - $header = $this->fetch($appName, $tplName); - $this->assign('PF_HEADER', $header); + + //$header = $this->fetch($appName, $tplName); + $this->assign('PF_HEADER', $this->getTemplatePath($appName, $tplName)); } public function setFooter($appName='', $tplName='footer.tpl') { - list($defaultApp, $defaultCmd) = explode('.', PF_DEFAULT_COMMAND); + list(, $defaultApp, ) = explode('/', PF_DEFAULT_URI); if (empty($appName)) { $appName = $defaultApp; @@ -259,8 +279,8 @@ public function setFooter($appName='', $tplName='footer.tpl') { $tplName = 'footer.tpl'; } - $footer = $this->fetch($appName, $tplName); - $this->assign('PF_FOOTER', $footer); + //$this->assign('PF_FOOTER', $this->fetch($appName, $tplName)); + $this->assign('PF_FOOTER', $this->getTemplatePath($appName, $tplName)); } public function trigger_error($error_msg, $error_type = E_USER_WARNING) { @@ -275,67 +295,6 @@ public function setLanguageIDs(&$cache_id, &$compile_id) { $cache_id = $compile_id = $this->appName . '-' . PFLanguage::getInstance($this->appName)->getCurrentLanguage(); } - public function _process_template($tpl_file, $compile_path) { - if ($this->debug) { - PFDebugStack::append('Template File: ' . $tpl_file . '
Compile Path: ' . $compile_path, __FILE__, __LINE__); - } - - if (!$this->force_compile && file_exists($compile_path)) { - if (!$this->compile_check) { - return true; - } else { - if (!$this->_fetch_template_info($tpl_file, $template_source, $template_timestamp)) { - if ($this->debug) { - PFDebugStack::append('Failed fetching template info: ' . $tpl_file, __FILE__, __LINE__); - } - return false; - } - if ($template_timestamp > filemtime($compile_path) || $this->languageFilesAreModified($compile_path, $lang_path)) { - - if ($this->debug) { - PFDebugStack::append('Compiled template: ' . $tpl_fil, __FILE__, __LINE__); - } - - if ($template_timestamp >= filemtime($lang_path)) { - $timestamp = $template_timestamp; - } else { - $timestamp = filemtime($lang_path); - } - - $this->_compile_template($tpl_file, $template_source, $template_compiled); - $this->_write_compiled_template($compile_path, $template_compiled, $timestamp); - return true; - } else { - if ($this->debug) { - PFDebugStack::append('Did not compile template: ' . $tpl_file, __FILE__, __LINE__); - } - return true; - } - } - } else { - - if ($this->force_compile) { - $this->clear_cache(); - } - - if (!$this->_fetch_template_info($tpl_file, $template_source, $template_timestamp)) { - if ($this->debug) { - PFDebugStack::append('Failed fetching template info (2): ' . $tpl_file, __FILE__, __LINE__); - } - return false; - } - - if ($this->debug) { - PFDebugStack::append('Force-compiled template: ' . $tpl_file, __FILE__, __LINE__); - } - - $this->_compile_template($tpl_file, $template_source, $template_compiled); - $this->_write_compiled_template($compile_path, $template_compiled, $template_timestamp); - - return true; - } - } - protected function languageFilesAreModified($compilePath, &$langPath) { $tableDirectory = PFLanguage::getInstance()->getLanguageTableFileDirectory($this->appName); @@ -363,18 +322,10 @@ protected function languageFilesAreModified($compilePath, &$langPath) { return false; } - public function addTemplateDir($dir) { - $this->more_template_dir[] = $dir; - } - - public function getTemplateDir() { + public function getTemplateDirs() { return $this->template_dir; } - public function getMoreTemplateDir() { - return $this->more_template_dir; - } - public function getCompileDir() { return $this->compile_dir; } @@ -387,10 +338,6 @@ public function getCacheDir() { return $this->cache_dir; } - public function setTemplateDir($dir) { - return $this->template_dir = $dir; - } - public function setCompileDir($dir) { return $this->compile_dir = $dir; } @@ -408,4 +355,4 @@ public function getAppName() { } } -?> +?> \ No newline at end of file diff --git a/modules/api/lib/templatehelper.class.php b/modules/api/lib/templatehelper.class.php index 8e086fe..b9f71ab 100644 --- a/modules/api/lib/templatehelper.class.php +++ b/modules/api/lib/templatehelper.class.php @@ -2,7 +2,7 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * diff --git a/modules/api/test/fake/command.xml b/modules/api/test/fake/command.xml old mode 100644 new mode 100755 index eb20f6b..71cf0c6 --- a/modules/api/test/fake/command.xml +++ b/modules/api/test/fake/command.xml @@ -91,4 +91,11 @@ /content/addressbook/:integer:/edit + + + content.detail + content.header + content.footer + content.account-addresses + diff --git a/modules/api/test/unit/ApplicationControllerTest.class.php b/modules/api/test/unit/ApplicationControllerTest.class.php old mode 100644 new mode 100755 index 44369b8..c31bb87 --- a/modules/api/test/unit/ApplicationControllerTest.class.php +++ b/modules/api/test/unit/ApplicationControllerTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/applicationcontroller.class.php'; require_once 'modules/api/lib/applicationhelper.class.php'; require_once 'modules/content/cmd/default.class.php'; @@ -100,7 +99,7 @@ public function testGetForward() { } public function testGetPermissions() { - + // test a command statement with no permissions $permissions = $this->appController->getPermissions($this->request); $this->assertTrue(count($permissions) == 0); diff --git a/modules/api/test/unit/ApplicationHelperTest.class.php b/modules/api/test/unit/ApplicationHelperTest.class.php old mode 100644 new mode 100755 index 72b8bf8..93e7143 --- a/modules/api/test/unit/ApplicationHelperTest.class.php +++ b/modules/api/test/unit/ApplicationHelperTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/applicationhelper.class.php'; require_once 'modules/api/lib/registry.class.php'; @@ -29,7 +28,7 @@ public function tearDown() { public function testControllerMapCreation() { $map = PFRegistry::getInstance()->getControllerMap(); - + $mapClass = new ReflectionClass('PFControllerMap'); $this->assertTrue($mapClass->isInstance($map), 'Controller map not instantiated correctly.'); } diff --git a/modules/api/test/unit/CacheAPCTest.class.php b/modules/api/test/unit/CacheAPCTest.class.php old mode 100644 new mode 100755 index 99cc86b..e60e84c --- a/modules/api/test/unit/CacheAPCTest.class.php +++ b/modules/api/test/unit/CacheAPCTest.class.php @@ -2,13 +2,12 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ -require_once 'PHPUnit/Framework.php'; require_once 'config.php'; require_once 'modules/api/lib/cacheapc.class.php'; diff --git a/modules/api/test/unit/ControllerMapTest.class.php b/modules/api/test/unit/ControllerMapTest.class.php old mode 100644 new mode 100755 index 089b5c5..ef51528 --- a/modules/api/test/unit/ControllerMapTest.class.php +++ b/modules/api/test/unit/ControllerMapTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/controllermap.class.php'; class ControllerMapTest extends PHPUnit_Framework_TestCase { diff --git a/modules/api/test/unit/ControllerTest.class.php b/modules/api/test/unit/ControllerTest.class.php old mode 100644 new mode 100755 index 21d39f1..576975f --- a/modules/api/test/unit/ControllerTest.class.php +++ b/modules/api/test/unit/ControllerTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/controller.class.php'; class ControllerTest extends PHPUnit_Framework_TestCase { diff --git a/modules/api/test/unit/ErrorstackTest.class.php b/modules/api/test/unit/ErrorstackTest.class.php old mode 100644 new mode 100755 index c1bcedb..f66f3a6 --- a/modules/api/test/unit/ErrorstackTest.class.php +++ b/modules/api/test/unit/ErrorstackTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/errorstack.class.php'; require_once 'modules/api/lib/exception.class.php'; diff --git a/modules/api/test/unit/ExceptionTest.class.php b/modules/api/test/unit/ExceptionTest.class.php old mode 100644 new mode 100755 index 9d6eb35..762ef5c --- a/modules/api/test/unit/ExceptionTest.class.php +++ b/modules/api/test/unit/ExceptionTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/exception.class.php'; class ExceptionTest extends PHPUnit_Framework_TestCase { diff --git a/modules/api/test/unit/FactoryTest.class.php b/modules/api/test/unit/FactoryTest.class.php old mode 100644 new mode 100755 index 0dcea90..2b5fa8d --- a/modules/api/test/unit/FactoryTest.class.php +++ b/modules/api/test/unit/FactoryTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/factory.class.php'; require_once 'modules/api/lib/request.class.php'; require_once 'modules/content/cmd/default.class.php'; @@ -34,6 +33,14 @@ public function testCreateObject() { $this->assertEquals($req2, $req); } + public function testCreateExistingObject() { + + $req = PFFactory::getInstance()->createObject('api.request'); + $req2 = PFFactory::getInstance()->createObject('api.request'); + + $this->assertEquals($req2, $req); + } + public function testCreateCommandObject() { $cmd = PFFactory::getInstance()->createCommandObject('content.default'); diff --git a/modules/api/test/unit/FormTest.class.php b/modules/api/test/unit/FormTest.class.php old mode 100644 new mode 100755 index 7ea098b..493f290 --- a/modules/api/test/unit/FormTest.class.php +++ b/modules/api/test/unit/FormTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/form.class.php'; require_once 'modules/api/lib/request.class.php'; require_once 'modules/content/cmd/default.class.php'; diff --git a/modules/api/test/unit/ImageFileTest.class.php b/modules/api/test/unit/ImageFileTest.class.php old mode 100644 new mode 100755 index b3f897b..0d6d685 --- a/modules/api/test/unit/ImageFileTest.class.php +++ b/modules/api/test/unit/ImageFileTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/imagefile.class.php'; class ImageFileTest extends PHPUnit_Framework_TestCase { diff --git a/modules/api/test/unit/LanguageTest.class.php b/modules/api/test/unit/LanguageTest.class.php old mode 100644 new mode 100755 index d3f0fef..7e95959 --- a/modules/api/test/unit/LanguageTest.class.php +++ b/modules/api/test/unit/LanguageTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/factory.class.php'; require_once 'modules/api/lib/request.class.php'; require_once 'modules/content/cmd/default.class.php'; @@ -45,7 +44,7 @@ public function testTranslation() { $this->assertTrue($this->language->loadTranslationTable('api'), 'Failed loading translation table'); - $prot = $this->language->getTranslation('api', PROTEAN_FRAMEWORK); + $prot = $this->language->getTranslation('api', 'PROTEAN_FRAMEWORK'); $this->assertEquals('Protean Framework', $prot, '$language->getTranslation() failed:'); } diff --git a/modules/api/test/unit/RegistryTest.class.php b/modules/api/test/unit/RegistryTest.class.php old mode 100644 new mode 100755 index cc0e7d6..ed7503a --- a/modules/api/test/unit/RegistryTest.class.php +++ b/modules/api/test/unit/RegistryTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/registry.class.php'; class RegistryTest extends PHPUnit_Framework_TestCase { @@ -51,12 +50,12 @@ public function testSetControllerMap() { } public function testSetPage() { - + $page = PFFactory::getInstance()->createObject('api.template', 'api'); - + $this->registry->setPage($page); $newPage = PFRegistry::getPage(); - + $this->assertSame($page, $newPage); } } diff --git a/modules/api/test/unit/RequestHelperTest.class.php b/modules/api/test/unit/RequestHelperTest.class.php index 5caf6ef..523ff94 100644 --- a/modules/api/test/unit/RequestHelperTest.class.php +++ b/modules/api/test/unit/RequestHelperTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/requesthelper.class.php'; class RequestHelperTest extends PHPUnit_Framework_TestCase { @@ -59,6 +58,10 @@ public function testGetURIApplication() { $uri = '/content/staticpage'; $verb = 'get'; $this->assertEquals('content', PFRequestHelper::getCurrentURIApplication($uri, $verb)); + + $uri = '/content/default?somevar=withslashses/in/it'; + $verb = 'get'; + $this->assertEquals('content', PFRequestHelper::getCurrentURIApplication($uri, $verb)); } public function testGetCurrentURICommand() { @@ -74,6 +77,14 @@ public function testGetCurrentURICommand() { $_SERVER['REQUEST_URI'] = '/content/staticpage'; $_SERVER['REQUEST_METHOD'] = 'GET'; $this->assertEquals('static', PFRequestHelper::getCurrentURICommand()); + + $_SERVER['REQUEST_URI'] = '/content/default?somevar=withslashses/in/it'; + $_SERVER['REQUEST_METHOD'] = 'GET'; + $this->assertEquals('default', PFRequestHelper::getCurrentURICommand()); + + $_SERVER['REQUEST_URI'] = '/content/staticpage?shortcode=GM7KW&amount=9.69&origin=https%3A//some.domain.com'; + $_SERVER['REQUEST_METHOD'] = 'GET'; + $this->assertEquals('static', PFRequestHelper::getCurrentURICommand()); } public function testGetURICommand() { @@ -89,6 +100,10 @@ public function testGetURICommand() { $uri = '/content/staticpage'; $verb = 'get'; $this->assertEquals('static', PFRequestHelper::getURICommand($uri, $verb)); + + $uri = '/content/staticpage?shortcode=GM7KW&amount=9.69&origin=https%3A//some.domain.com'; + $verb = 'get'; + $this->assertEquals('static', PFRequestHelper::getURICommand($uri, $verb)); } public function testGetCurrentURIPattern() { @@ -101,6 +116,9 @@ public function testGetCurrentURIPattern() { $_SERVER['REQUEST_URI'] = '/content/default/15432/edit'; $this->assertEquals('/content/default/:integer:/edit', PFRequestHelper::getCurrentURIPattern()); + + $_SERVER['REQUEST_URI'] = '/content/staticpage?shortcode=GM7KW&amount=9.69&origin=https%3A//some.domain.com'; + $this->assertEquals('/content/staticpage', PFRequestHelper::getCurrentURIPattern()); } public function testGetURIPattern() { diff --git a/modules/api/test/unit/RequestTest.class.php b/modules/api/test/unit/RequestTest.class.php old mode 100644 new mode 100755 index 3bb48e5..fea295e --- a/modules/api/test/unit/RequestTest.class.php +++ b/modules/api/test/unit/RequestTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/request.class.php'; class RequestTest extends PHPUnit_Framework_TestCase { diff --git a/modules/api/test/unit/SessionTest.class.php b/modules/api/test/unit/SessionTest.class.php old mode 100644 new mode 100755 index 7bd9eea..2f1d8da --- a/modules/api/test/unit/SessionTest.class.php +++ b/modules/api/test/unit/SessionTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/session.class.php'; class SessionTest extends PHPUnit_Framework_TestCase { diff --git a/modules/api/test/unit/TemplateTest.class.php b/modules/api/test/unit/TemplateTest.class.php old mode 100644 new mode 100755 index 883b6f3..7d19e78 --- a/modules/api/test/unit/TemplateTest.class.php +++ b/modules/api/test/unit/TemplateTest.class.php @@ -2,14 +2,13 @@ /**************************************************************************\ * Protean Framework * * https://github.com/erictj/protean * -* Copyright (c) 2006-2011, Loopshot Inc. All rights reserved. * +* Copyright (c) 2006-2012, Eric Jennings. All rights reserved. * * ------------------------------------------------------------------------ * * This program is free software; you can redistribute it and/or modify it * * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ require_once 'config.php'; -require_once 'PHPUnit/Framework.php'; require_once 'modules/api/lib/template.class.php'; class TemplateTest extends PHPUnit_Framework_TestCase { diff --git a/modules/content/cmd/default.class.php b/modules/content/cmd/default.class.php index a2a4165..885e29c 100644 --- a/modules/content/cmd/default.class.php +++ b/modules/content/cmd/default.class.php @@ -32,7 +32,19 @@ public function assignDefaults(PFRequest $request) { $this->templateHelper->assign('PF_BASE_JAVASCRIPT_PATH', $this->session->getJSPath('content')); $this->templateHelper->assign('PF_VERSION', PF_VERSION); $this->templateHelper->assign('PF_SERVER_NAME', @$_SERVER['SERVER_NAME']); - $this->templateHelper->assign('PF_CONTENT_IMAGE_PATH', $this->session->getImagePath('content')); + + if (PF_ENVIRONMENT == 'development') { + $this->templateHelper->addCSSInclude('/modules/content/tpl/default/css/html5boilerplate.css'); + $this->templateHelper->addCSSInclude('/modules/content/tpl/default/css/960.css'); + $this->templateHelper->addCSSInclude('/modules/content/tpl/default/css/protean.css'); + } else { + $this->templateHelper->addCSSInclude('/modules/content/tpl/default/css/style.min.css'); + $this->templateHelper->addJavascriptInclude('/modules/content/tpl/default/js/script.min.js'); + } + + $this->templateHelper->assign('CURRENTLY_LOGGED_IN', $this->session->isLoggedIn()); + $this->templateHelper->assign('PF_URL', PF_URL); + $this->templateHelper->assign('PF_URL_SECURE', PF_URL_SECURE); } public function assignHeaderPaths() { diff --git a/modules/content/tpl/default/css/960-reset-text.css b/modules/content/tpl/default/css/960-reset-text.css deleted file mode 100644 index 9e5eaec..0000000 --- a/modules/content/tpl/default/css/960-reset-text.css +++ /dev/null @@ -1 +0,0 @@ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outline:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}body{font:13px/1.5 Helvetica,Arial,'Liberation Sans',FreeSans,sans-serif}a:focus{outline:#000 dotted 1px}hr{border-color:#ccc;border-style:solid;border-width:1px 0 0;clear:both;height:0}h1{font-size:25px}h2{font-size:23px}h3{font-size:21px}h4{font-size:19px}h5{font-size:17px}h6{font-size:15px}ol{list-style:decimal}ul{list-style:square}li{margin-left:30px}p,dl,hr,h1,h2,h3,h4,h5,h6,ol,ul,pre,table,address,fieldset{margin-bottom:20px}.container_12,.container_16{margin-left:auto;margin-right:auto;width:960px}.grid_1,.grid_2,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9,.grid_10,.grid_11,.grid_12,.grid_13,.grid_14,.grid_15,.grid_16{display:inline;float:left;margin-left:10px;margin-right:10px}.container_12 .grid_3,.container_16 .grid_4{width:220px}.container_12 .grid_6,.container_16 .grid_8{width:460px}.container_12 .grid_9,.container_16 .grid_12{width:700px}.container_12 .grid_12,.container_16 .grid_16{width:940px}.alpha{margin-left:0}.omega{margin-right:0}.right{text-align: right}.container_12 .grid_1{width:60px}.container_12 .grid_2{width:140px}.container_12 .grid_4{width:300px}.container_12 .grid_5{width:380px}.container_12 .grid_7{width:540px}.container_12 .grid_8{width:620px}.container_12 .grid_10{width:780px}.container_12 .grid_11{width:860px}.container_16 .grid_1{width:40px}.container_16 .grid_2{width:100px}.container_16 .grid_3{width:160px}.container_16 .grid_5{width:280px}.container_16 .grid_6{width:340px}.container_16 .grid_7{width:400px}.container_16 .grid_9{width:520px}.container_16 .grid_10{width:580px}.container_16 .grid_11{width:640px}.container_16 .grid_13{width:760px}.container_16 .grid_14{width:820px}.container_16 .grid_15{width:880px}.container_12 .prefix_3,.container_16 .prefix_4{padding-left:240px}.container_12 .prefix_6,.container_16 .prefix_8{padding-left:480px}.container_12 .prefix_9,.container_16 .prefix_12{padding-left:720px}.container_12 .prefix_1{padding-left:80px}.container_12 .prefix_2{padding-left:160px}.container_12 .prefix_4{padding-left:320px}.container_12 .prefix_5{padding-left:400px}.container_12 .prefix_7{padding-left:560px}.container_12 .prefix_8{padding-left:640px}.container_12 .prefix_10{padding-left:800px}.container_12 .prefix_11{padding-left:880px}.container_16 .prefix_1{padding-left:60px}.container_16 .prefix_2{padding-left:120px}.container_16 .prefix_3{padding-left:180px}.container_16 .prefix_5{padding-left:300px}.container_16 .prefix_6{padding-left:360px}.container_16 .prefix_7{padding-left:420px}.container_16 .prefix_9{padding-left:540px}.container_16 .prefix_10{padding-left:600px}.container_16 .prefix_11{padding-left:660px}.container_16 .prefix_13{padding-left:780px}.container_16 .prefix_14{padding-left:840px}.container_16 .prefix_15{padding-left:900px}.container_12 .suffix_3,.container_16 .suffix_4{padding-right:240px}.container_12 .suffix_6,.container_16 .suffix_8{padding-right:480px}.container_12 .suffix_9,.container_16 .suffix_12{padding-right:720px}.container_12 .suffix_1{padding-right:80px}.container_12 .suffix_2{padding-right:160px}.container_12 .suffix_4{padding-right:320px}.container_12 .suffix_5{padding-right:400px}.container_12 .suffix_7{padding-right:560px}.container_12 .suffix_8{padding-right:640px}.container_12 .suffix_10{padding-right:800px}.container_12 .suffix_11{padding-right:880px}.container_16 .suffix_1{padding-right:60px}.container_16 .suffix_2{padding-right:120px}.container_16 .suffix_3{padding-right:180px}.container_16 .suffix_5{padding-right:300px}.container_16 .suffix_6{padding-right:360px}.container_16 .suffix_7{padding-right:420px}.container_16 .suffix_9{padding-right:540px}.container_16 .suffix_10{padding-right:600px}.container_16 .suffix_11{padding-right:660px}.container_16 .suffix_13{padding-right:780px}.container_16 .suffix_14{padding-right:840px}.container_16 .suffix_15{padding-right:900px}html body div.clear,html body span.clear{background:none;border:0;clear:both;display:block;float:none;font-size:0;margin:0;padding:0;overflow:hidden;visibility:hidden;width:0;height:0}.clearfix:after{clear:both;content:'.';display:block;visibility:hidden;height:0}.clearfix{display:inline-block}* html .clearfix{height:1%}.clearfix{display:block} \ No newline at end of file diff --git a/modules/content/tpl/default/css/style.css b/modules/content/tpl/default/css/style.css index f23f8d7..75e40b2 100644 --- a/modules/content/tpl/default/css/style.css +++ b/modules/content/tpl/default/css/style.css @@ -1,42 +1,134 @@ -/**************************************************************************\ -* Protean Framework * -* https://github.com/erictj/protean * -* Copyright (c) 2006-2010, Loopshot Inc. All rights reserved. * -* ------------------------------------------------------------------------ * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the BSD License as described in license.txt. * -\**************************************************************************/ - -/* @group Universal Selectors */ -/* @end */ +/* HTML5 Boilerplate */ -/* @group Element Selectors */ -strong { - font-weight: bold; -} -em { - font-style: italic; -} -a:visited { - color: #660000; -} -a:hover { - color: #CC0000; -} -a:active { - color: #660000; -} -a:link { - color: #660000; +html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, +abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, +small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, figcaption, figure, footer, header, hgroup, +menu, nav, section, summary, time, mark, audio, video { + margin:0; + padding:0; + border:0; + outline:0; + font-size:100%; + vertical-align:baseline; + background:transparent; +} +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display:block; +} +nav ul { list-style:none; } +blockquote, q { quotes:none; } +blockquote:before, blockquote:after, +q:before, q:after { content:''; content:none; } +a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; } +ins { background-color:#ff9; color:#000; text-decoration:none; } +mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; } +del { text-decoration: line-through; } +abbr[title], dfn[title] { border-bottom:1px dotted; cursor:help; } +table { border-collapse:collapse; border-spacing:0; } +hr { display:block; height:1px; border:0; border-top:1px solid #333; margin:1em 0; padding:0; } +input, select { vertical-align:middle; } + + +body { font:13px/1.231 sans-serif; *font-size:small; } +select, input, textarea, button { font:99% sans-serif; } +pre, code, kbd, samp { font-family: monospace, sans-serif; } + +body, select, input, textarea { color: #444; } +h1,h2,h3,h4,h5,h6 { font-weight: bold; } +html { overflow-y: scroll; } + +a:hover, a:active { outline: none; } +a, a:active, a:visited { color: #607890; } +a:hover { color: #036; } + +ul, ol { margin: 0; } +ol { list-style-type: decimal; } + +nav ul, nav li { margin: 0; } +small { font-size: 85%; } +strong, th { font-weight: bold; } +td, td img { vertical-align: top; } +sub { vertical-align: sub; font-size: smaller; } +sup { vertical-align: super; font-size: smaller; } +pre { padding: 15px; white-space: pre; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; } +textarea { overflow: auto; } +.ie6 legend, .ie7 legend { margin-left: -7px; } +input[type="radio"] { vertical-align: text-bottom; } +input[type="checkbox"] { vertical-align: bottom; } +.ie7 input[type="checkbox"] { vertical-align: baseline; } +.ie6 input { vertical-align: text-bottom; } +input[type=button], input[type=submit], button { cursor: pointer; } +button, input, select, textarea { margin: 0; } +input:valid, textarea:valid { } +input:invalid, textarea:invalid { border-radius: 1px; -moz-box-shadow: 0px 0px 5px red; -webkit-box-shadow: 0px 0px 5px red; box-shadow: 0px 0px 5px red; } +.no-boxshadow input:invalid, +.no-boxshadow textarea:invalid { background-color: #f0dddd; } + +::-moz-selection{ background: #FF5E99; color:#fff; text-shadow: none; } +::selection { background:#FF5E99; color:#fff; text-shadow: none; } +a:link { -webkit-tap-highlight-color: #FF5E99; } + +button { width: auto; overflow: visible; } +.ie7 img { -ms-interpolation-mode: bicubic; } + +.ir { display: block; text-indent: -999em; overflow: hidden; background-repeat: no-repeat; text-align: left; direction: ltr; } +.hidden { display: none; visibility: hidden; } +.visuallyhidden { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px); } +.invisible { visibility: hidden; } +.clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; visibility: hidden; } +.clearfix:after { clear: both; } +.clearfix { zoom: 1; } + + + /* Primary Styles + Author: + */ + + + + + + + + + + + + + + +@media all and (orientation:portrait) { + } -input, option, select, textarea { - font-family:Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; - margin: 3px; + +@media all and (orientation:landscape) { + } -label { - color: #333333; + +@media screen and (max-device-width: 480px) { + + + /* html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; } */ } + +@media print { + * { background: transparent !important; color: #444 !important; text-shadow: none !important; } + a, a:visited { color: #444 !important; text-decoration: underline; } + a:after { content: " (" attr(href) ")"; } + abbr:after { content: " (" attr(title) ")"; } + .ir a:after { content: ""; } + pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } + thead { display: table-header-group; } + tr, img { page-break-inside: avoid; } + @page { margin: 0.5cm; } + p, h2, h3 { orphans: 3; widows: 3; } + h2, h3{ page-break-after: avoid; } +}.container_12,.container_16{margin-left:auto;margin-right:auto;width:960px}.grid_1,.grid_2,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9,.grid_10,.grid_11,.grid_12,.grid_13,.grid_14,.grid_15,.grid_16{display:inline;float:left;margin-left:10px;margin-right:10px}.container_12 .grid_3,.container_16 .grid_4{width:220px}.container_12 .grid_6,.container_16 .grid_8{width:460px}.container_12 .grid_9,.container_16 .grid_12{width:700px}.container_12 .grid_12,.container_16 .grid_16{width:940px}.alpha{margin-left:0}.omega{margin-right:0}.container_12 .grid_1{width:60px}.container_12 .grid_2{width:140px}.container_12 .grid_4{width:300px}.container_12 .grid_5{width:380px}.container_12 .grid_7{width:540px}.container_12 .grid_8{width:620px}.container_12 .grid_10{width:780px}.container_12 .grid_11{width:860px}.container_16 .grid_1{width:40px}.container_16 .grid_2{width:100px}.container_16 .grid_3{width:160px}.container_16 .grid_5{width:280px}.container_16 .grid_6{width:340px}.container_16 .grid_7{width:400px}.container_16 .grid_9{width:520px}.container_16 .grid_10{width:580px}.container_16 .grid_11{width:640px}.container_16 .grid_13{width:760px}.container_16 .grid_14{width:820px}.container_16 .grid_15{width:880px}.container_12 .prefix_3,.container_16 .prefix_4{padding-left:240px}.container_12 .prefix_6,.container_16 .prefix_8{padding-left:480px}.container_12 .prefix_9,.container_16 .prefix_12{padding-left:720px}.container_12 .prefix_1{padding-left:80px}.container_12 .prefix_2{padding-left:160px}.container_12 .prefix_4{padding-left:320px}.container_12 .prefix_5{padding-left:400px}.container_12 .prefix_7{padding-left:560px}.container_12 .prefix_8{padding-left:640px}.container_12 .prefix_10{padding-left:800px}.container_12 .prefix_11{padding-left:880px}.container_16 .prefix_1{padding-left:60px}.container_16 .prefix_2{padding-left:120px}.container_16 .prefix_3{padding-left:180px}.container_16 .prefix_5{padding-left:300px}.container_16 .prefix_6{padding-left:360px}.container_16 .prefix_7{padding-left:420px}.container_16 .prefix_9{padding-left:540px}.container_16 .prefix_10{padding-left:600px}.container_16 .prefix_11{padding-left:660px}.container_16 .prefix_13{padding-left:780px}.container_16 .prefix_14{padding-left:840px}.container_16 .prefix_15{padding-left:900px}.container_12 .suffix_3,.container_16 .suffix_4{padding-right:240px}.container_12 .suffix_6,.container_16 .suffix_8{padding-right:480px}.container_12 .suffix_9,.container_16 .suffix_12{padding-right:720px}.container_12 .suffix_1{padding-right:80px}.container_12 .suffix_2{padding-right:160px}.container_12 .suffix_4{padding-right:320px}.container_12 .suffix_5{padding-right:400px}.container_12 .suffix_7{padding-right:560px}.container_12 .suffix_8{padding-right:640px}.container_12 .suffix_10{padding-right:800px}.container_12 .suffix_11{padding-right:880px}.container_16 .suffix_1{padding-right:60px}.container_16 .suffix_2{padding-right:120px}.container_16 .suffix_3{padding-right:180px}.container_16 .suffix_5{padding-right:300px}.container_16 .suffix_6{padding-right:360px}.container_16 .suffix_7{padding-right:420px}.container_16 .suffix_9{padding-right:540px}.container_16 .suffix_10{padding-right:600px}.container_16 .suffix_11{padding-right:660px}.container_16 .suffix_13{padding-right:780px}.container_16 .suffix_14{padding-right:840px}.container_16 .suffix_15{padding-right:900px}html body div.clear,html body span.clear{background:none;border:0;clear:both;display:block;float:none;font-size:0;margin:0;padding:0;overflow:hidden;visibility:hidden;width:0;height:0}.clearfix:after{clear:both;content:'.';display:block;visibility:hidden;height:0}.clearfix{display:inline-block}* html .clearfix{height:1%}.clearfix{display:block}/* @group Universal Selectors */ +/* @end */ + +/* @group Element Selectors */ /* @end */ /* @group Class, Attribute, and Pseudo Selectors */ @@ -53,18 +145,32 @@ label { .no { color: #990000; } +.notice { + color: #968672; + font-weight: bold; + margin: 0 0 10px; +} .error { color: #F00; font-weight: bold; + margin: 0 0 10px; } .errorfield { - background: #ffb47d; + background: #f3d3c7; color: #333333; } .required { color: #ff6f00; font-weight: bold; } +.left { + float: left; + text-align: left; +} +.right { + float: right; + text-align: right; +} /* @end */ /* @group ID Selectors */ diff --git a/modules/content/tpl/default/html/404.tpl b/modules/content/tpl/default/html/404.tpl index 782cddb..466b67b 100644 --- a/modules/content/tpl/default/html/404.tpl +++ b/modules/content/tpl/default/html/404.tpl @@ -1,7 +1,7 @@ {include file=$PF_HEADER} -
-
+
+

We're sorry. The page you're trying to reach does not exist.

diff --git a/modules/content/tpl/default/html/errorstack.tpl b/modules/content/tpl/default/html/errorstack.tpl index 90cdc56..5ad14c8 100644 --- a/modules/content/tpl/default/html/errorstack.tpl +++ b/modules/content/tpl/default/html/errorstack.tpl @@ -1,7 +1,5 @@ {if $PF_ERRORSTACK} -
-
- {$PF_ERRORSTACK} -
+
+ {$PF_ERRORSTACK}
{/if} \ No newline at end of file diff --git a/modules/content/tpl/default/html/footer.tpl b/modules/content/tpl/default/html/footer.tpl index 500944f..ae3c7c7 100644 --- a/modules/content/tpl/default/html/footer.tpl +++ b/modules/content/tpl/default/html/footer.tpl @@ -12,19 +12,10 @@
{$PF_JAVASCRIPT_INCLUDES} {$PF_FOOTER_JAVASCRIPT} -{if $smarty.const.PF_ANALYTICS_TRACKING} -{literal} - -{/literal} -{/if} + +{if $smarty.const.PF_INCLUDE_GA_TRACKING}{include file='modules/content/tpl/default/html/ga-js.tpl'}{/if} +{if $smarty.const.PF_INCLUDE_SNAPENGAGE}{include file='modules/content/tpl/default/html/snapengage-js.tpl'}{/if} +{if $smarty.const.PF_INCLUDE_GET_SATISFACTION}{include file='modules/content/tpl/default/html/getsatisfaction-js.tpl'}{/if} + \ No newline at end of file diff --git a/modules/content/tpl/default/html/header.tpl b/modules/content/tpl/default/html/header.tpl index 1c1dd15..212d9b8 100644 --- a/modules/content/tpl/default/html/header.tpl +++ b/modules/content/tpl/default/html/header.tpl @@ -1,19 +1,27 @@ - - - - Protean Framework - - - + + + {$PF_PAGE_TITLE|default:$smarty.const.PF_SITE_NAME} + + + + + + + {$PF_HEAD_CSS_INCLUDES} + -
-
-
+
+
+

+ JavaScript is currently disabled. This site requires JavaScript to function correctly.
+ Please enable JavaScript in your browser! +

+
@@ -25,5 +33,5 @@ Login {/if}
-
- {include file=$ERRORSTACK_TPL} \ No newline at end of file + {include file='modules/content/tpl/default/html/errorstack.tpl'} + \ No newline at end of file diff --git a/modules/content/tpl/default/html/login.tpl b/modules/content/tpl/default/html/login.tpl index 56eb552..d8cb114 100644 --- a/modules/content/tpl/default/html/login.tpl +++ b/modules/content/tpl/default/html/login.tpl @@ -1,4 +1,4 @@ -{$PF_HEADER} +{include file=$PF_HEADER}

@@ -14,4 +14,4 @@

-{$PF_FOOTER} \ No newline at end of file +{include file=$PF_FOOTER} \ No newline at end of file diff --git a/modules/thirdparty/jquery/datatables/css/demo_page.css b/modules/thirdparty/jquery/datatables/css/demo_page.css index 57acbae..ba5b2a6 100644 --- a/modules/thirdparty/jquery/datatables/css/demo_page.css +++ b/modules/thirdparty/jquery/datatables/css/demo_page.css @@ -81,7 +81,7 @@ } #dt_example ul { - color: #B0BED9; + color: #4E6CA3; } .css_right { @@ -90,4 +90,33 @@ .css_left { float: left; -} \ No newline at end of file +} + +.demo_links { + float: left; + width: 50%; + margin-bottom: 1em; +} + +#demo_info { + padding: 5px; + border: 1px solid #B0BED9; + height: 100px; + width: 100%; + overflow: auto; +} + +#dt_example code { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + padding: 2px 4px !important; + white-space: nowrap; + font-size: 0.9em; + + color: #D14; + background-color: #F7F7F9; + + border: 1px solid #E1E1E8; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} diff --git a/modules/thirdparty/jquery/datatables/css/demo_table.css b/modules/thirdparty/jquery/datatables/css/demo_table.css index b928866..12f352d 100644 --- a/modules/thirdparty/jquery/datatables/css/demo_table.css +++ b/modules/thirdparty/jquery/datatables/css/demo_table.css @@ -32,22 +32,24 @@ .dataTables_wrapper { position: relative; - min-height: 302px; - _height: 302px; clear: both; + zoom: 1; /* Feeling sorry for IE */ } .dataTables_processing { position: absolute; - top: 0px; - /*left: 50%;*/ + top: 50%; + left: 50%; width: 250px; - /*margin-left: -125px;*/ + height: 30px; + margin-left: -125px; + margin-top: -15px; + padding: 14px 0 2px 0; border: 1px solid #ddd; text-align: center; color: #999; - font-size: 11px; - padding: 2px 0; + font-size: 14px; + background-color: white; } .dataTables_length { @@ -67,34 +69,60 @@ } .dataTables_paginate { - width: 44px; - * width: 50px; float: right; text-align: right; } /* Pagination nested */ -.paginate_disabled_previous, .paginate_enabled_previous, .paginate_disabled_next, .paginate_enabled_next { +.paginate_disabled_previous, .paginate_enabled_previous, +.paginate_disabled_next, .paginate_enabled_next { height: 19px; - width: 19px; - margin-left: 3px; float: left; + cursor: pointer; + *cursor: hand; + color: #111 !important; +} +.paginate_disabled_previous:hover, .paginate_enabled_previous:hover, +.paginate_disabled_next:hover, .paginate_enabled_next:hover { + text-decoration: none !important; +} +.paginate_disabled_previous:active, .paginate_enabled_previous:active, +.paginate_disabled_next:active, .paginate_enabled_next:active { + outline: none; +} + +.paginate_disabled_previous, +.paginate_disabled_next { + color: #666 !important; +} +.paginate_disabled_previous, .paginate_enabled_previous { + padding-left: 23px; +} +.paginate_disabled_next, .paginate_enabled_next { + padding-right: 23px; + margin-left: 10px; } .paginate_disabled_previous { - background-image: url('../images/back_disabled.jpg'); + background: url('../images/back_disabled.png') no-repeat top left; } .paginate_enabled_previous { - background-image: url('../images/back_enabled.jpg'); + background: url('../images/back_enabled.png') no-repeat top left; +} +.paginate_enabled_previous:hover { + background: url('../images/back_enabled_hover.png') no-repeat top left; } .paginate_disabled_next { - background-image: url('../images/forward_disabled.jpg'); + background: url('../images/forward_disabled.png') no-repeat top right; } .paginate_enabled_next { - background-image: url('../images/forward_enabled.jpg'); + background: url('../images/forward_enabled.png') no-repeat top right; +} +.paginate_enabled_next:hover { + background: url('../images/forward_enabled_hover.png') no-repeat top right; } @@ -104,21 +132,33 @@ */ table.display { margin: 0 auto; - width: 100%; clear: both; + width: 100%; + + /* Note Firefox 3.5 and before have a bug with border-collapse + * ( https://bugzilla.mozilla.org/show%5Fbug.cgi?id=155955 ) + * border-spacing: 0; is one possible option. Conditional-css.com is + * useful for this kind of thing + * + * Further note IE 6/7 has problems when calculating widths with border width. + * It subtracts one px relative to the other browsers from the first column, and + * adds one to the end... + * + * If you want that effect I'd suggest setting a border-top/left on th/td's and + * then filling in the gaps with other borders. + */ } table.display thead th { padding: 3px 18px 3px 10px; - /*border-bottom: 1px solid black;*/ - border: 1px solid #e4e5d7; + border-bottom: 1px solid black; font-weight: bold; cursor: pointer; * cursor: hand; } table.display tfoot th { - padding: 3px 10px; + padding: 3px 18px 3px 10px; border-top: 1px solid black; font-weight: bold; } @@ -142,25 +182,29 @@ table.display td.center { */ .sorting_asc { - background: url('../images/sort_asc.jpg') no-repeat center right; + background: url('../images/sort_asc.png') no-repeat center right; } .sorting_desc { - background: url('../images/sort_desc.jpg') no-repeat center right; + background: url('../images/sort_desc.png') no-repeat center right; } .sorting { - background: url('../images/sort_both.jpg') no-repeat center right; + background: url('../images/sort_both.png') no-repeat center right; } .sorting_asc_disabled { - background: url('../images/sort_asc_disabled.jpg') no-repeat center right; + background: url('../images/sort_asc_disabled.png') no-repeat center right; } .sorting_desc_disabled { - background: url('../images/sort_desc_disabled.jpg') no-repeat center right; + background: url('../images/sort_desc_disabled.png') no-repeat center right; +} + +table.display thead th:active, +table.display thead td:active { + outline: none; } - @@ -176,17 +220,6 @@ table.display tr.even.gradeA { background-color: #eeffee; } - - - -table.display tr.odd.gradeA { - background-color: #ddffdd; -} - -table.display tr.even.gradeA { - background-color: #eeffee; -} - table.display tr.odd.gradeC { background-color: #ddddff; } @@ -227,6 +260,15 @@ tr.even { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Misc */ +.dataTables_scroll { + clear: both; +} + +.dataTables_scrollBody { + *margin-top: -1px; + -webkit-overflow-scrolling: touch; +} + .top, .bottom { padding: 15px; background-color: #F5F5F5; @@ -277,8 +319,16 @@ td.details { line-height: 22px; } -.paging_full_numbers span.paginate_button, - .paging_full_numbers span.paginate_active { +.paging_full_numbers a:active { + outline: none +} + +.paging_full_numbers a:hover { + text-decoration: none; +} + +.paging_full_numbers a.paginate_button, + .paging_full_numbers a.paginate_active { border: 1px solid #aaa; -webkit-border-radius: 5px; -moz-border-radius: 5px; @@ -286,17 +336,19 @@ td.details { margin: 0 3px; cursor: pointer; *cursor: hand; + color: #333 !important; } -.paging_full_numbers span.paginate_button { +.paging_full_numbers a.paginate_button { background-color: #ddd; } -.paging_full_numbers span.paginate_button:hover { +.paging_full_numbers a.paginate_button:hover { background-color: #ccc; + text-decoration: none !important; } -.paging_full_numbers span.paginate_active { +.paging_full_numbers a.paginate_active { background-color: #99B3FF; } @@ -455,3 +507,71 @@ tr.even.gradeU td.sorting_3 { .ex_highlight #example tbody tr.odd:hover, #example tbody tr.odd td.highlighted { background-color: #E6FF99; } + +.ex_highlight_row #example tr.even:hover { + background-color: #ECFFB3; +} + +.ex_highlight_row #example tr.even:hover td.sorting_1 { + background-color: #DDFF75; +} + +.ex_highlight_row #example tr.even:hover td.sorting_2 { + background-color: #E7FF9E; +} + +.ex_highlight_row #example tr.even:hover td.sorting_3 { + background-color: #E2FF89; +} + +.ex_highlight_row #example tr.odd:hover { + background-color: #E6FF99; +} + +.ex_highlight_row #example tr.odd:hover td.sorting_1 { + background-color: #D6FF5C; +} + +.ex_highlight_row #example tr.odd:hover td.sorting_2 { + background-color: #E0FF84; +} + +.ex_highlight_row #example tr.odd:hover td.sorting_3 { + background-color: #DBFF70; +} + + +/* + * KeyTable + */ +table.KeyTable td { + border: 3px solid transparent; +} + +table.KeyTable td.focus { + border: 3px solid #3366FF; +} + +table.display tr.gradeA { + background-color: #eeffee; +} + +table.display tr.gradeC { + background-color: #ddddff; +} + +table.display tr.gradeX { + background-color: #ffdddd; +} + +table.display tr.gradeU { + background-color: #ddd; +} + +div.box { + height: 100px; + padding: 10px; + overflow: auto; + border: 1px solid #8080FF; + background-color: #E5E5FF; +} diff --git a/modules/thirdparty/jquery/datatables/css/demo_table_jui.css b/modules/thirdparty/jquery/datatables/css/demo_table_jui.css index 023e403..a210af5 100644 --- a/modules/thirdparty/jquery/datatables/css/demo_table_jui.css +++ b/modules/thirdparty/jquery/datatables/css/demo_table_jui.css @@ -31,23 +31,29 @@ * jQuery UI specific styling */ -.paging_two_button .fg-button { +.paging_two_button .ui-button { float: left; cursor: pointer; * cursor: hand; } -.paging_full_numbers .fg-button { +.paging_full_numbers .ui-button { padding: 2px 6px; + margin: 0; cursor: pointer; * cursor: hand; + color: #333 !important; +} + +.dataTables_paginate .ui-button { + margin-right: -0.1em !important; } .paging_full_numbers { width: 350px !important; } -.fg-toolbar { +.dataTables_wrapper .ui-toolbar { padding: 5px; } @@ -55,12 +61,38 @@ width: auto; } +.dataTables_info { + padding-top: 3px; +} + table.display thead th { padding: 3px 0px 3px 10px; cursor: pointer; * cursor: hand; } +div.dataTables_wrapper .ui-widget-header { + font-weight: normal; +} + + +/* + * Sort arrow icon positioning + */ +table.display thead th div.DataTables_sort_wrapper { + position: relative; + padding-right: 20px; +} + +table.display thead th div.DataTables_sort_wrapper span { + position: absolute; + top: 50%; + margin-top: -8px; + right: 0; +} + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -77,17 +109,15 @@ table.display thead th { .dataTables_wrapper { position: relative; - min-height: 302px; - _height: 302px; clear: both; } .dataTables_processing { position: absolute; top: 0px; - /*left: 50%;*/ + left: 50%; width: 250px; - /*margin-left: -125px;*/ + margin-left: -125px; border: 1px solid #ddd; text-align: center; color: #999; @@ -116,45 +146,22 @@ table.display thead th { text-align: right; } -/* Pagination nested */ -.paginate_disabled_previous, .paginate_enabled_previous, .paginate_disabled_next, .paginate_enabled_next { - height: 19px; - width: 19px; - margin-left: 3px; - float: left; -} - -.paginate_disabled_previous { - background-image: url('../images/back_disabled.jpg'); -} - -.paginate_enabled_previous { - background-image: url('../images/back_enabled.jpg'); -} - -.paginate_disabled_next { - background-image: url('../images/forward_disabled.jpg'); -} - -.paginate_enabled_next { - background-image: url('../images/forward_enabled.jpg'); -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * DataTables display */ table.display { - margin: 10px 0; + margin: 0 auto; width: 100%; clear: both; + border-collapse: collapse; } table.display tfoot th { - padding: 3px 10px; - border-top: 1px solid black; + padding: 3px 0px 3px 10px; font-weight: bold; + font-weight: normal; } table.display tr.heading2 td { @@ -176,15 +183,23 @@ table.display td.center { */ .sorting_asc { - background: url('../images/sort_asc.jpg') no-repeat center right; + background: url('../images/sort_asc.png') no-repeat center right; } .sorting_desc { - background: url('../images/sort_desc.jpg') no-repeat center right; + background: url('../images/sort_desc.png') no-repeat center right; } .sorting { - background: url('../images/sort_both.jpg') no-repeat center right; + background: url('../images/sort_both.png') no-repeat center right; +} + +.sorting_asc_disabled { + background: url('../images/sort_asc_disabled.png') no-repeat center right; +} + +.sorting_desc_disabled { + background: url('../images/sort_desc_disabled.png') no-repeat center right; } @@ -252,6 +267,14 @@ tr.even { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Misc */ +.dataTables_scroll { + clear: both; +} + +.dataTables_scrollBody { + -webkit-overflow-scrolling: touch; +} + .top, .bottom { padding: 15px; background-color: #F5F5F5; @@ -296,8 +319,8 @@ td.details { width: 40%; } -.paging_full_numbers span.paginate_button, - .paging_full_numbers span.paginate_active { +.paging_full_numbers a.paginate_button, + .paging_full_numbers a.paginate_active { border: 1px solid #aaa; -webkit-border-radius: 5px; -moz-border-radius: 5px; @@ -305,17 +328,19 @@ td.details { margin: 0 3px; cursor: pointer; *cursor: hand; + color: #333 !important; } -.paging_full_numbers span.paginate_button { +.paging_full_numbers a.paginate_button { background-color: #ddd; } -.paging_full_numbers span.paginate_button:hover { +.paging_full_numbers a.paginate_button:hover { background-color: #ccc; + text-decoration: none !important; } -.paging_full_numbers span.paginate_active { +.paging_full_numbers a.paginate_active { background-color: #99B3FF; } diff --git a/modules/thirdparty/jquery/datatables/extras/FixedHeader/FixedHeader.js b/modules/thirdparty/jquery/datatables/extras/FixedHeader/FixedHeader.js deleted file mode 100644 index cd622bc..0000000 --- a/modules/thirdparty/jquery/datatables/extras/FixedHeader/FixedHeader.js +++ /dev/null @@ -1,262 +0,0 @@ -/* - * File: FixedHeader.js - * Version: 1.0.2 - * CVS: $Id$ - * Description: "Fix" a header at the top of the table, so it scrolls with the table - * Author: Allan Jardine (www.sprymedia.co.uk) - * Created: Wed 16 Sep 2009 19:46:30 BST - * Modified: $Date$ by $Author$ - * Language: Javascript - * License: LGPL - * Project: Just a little bit of fun :-) - * Contact: www.sprymedia.co.uk/contact - * - * Copyright 2009 Allan Jardine, all rights reserved. - * - */ - - -(function($) { - -/* - * Function: $.fn.dataTableExt.FixedHeader - * Purpose: FixedHeader "class" - * Returns: same as _fnInit - * Inputs: same as _fnInit - */ -$.fn.dataTableExt.FixedHeader = function ( oTable ) -{ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Public functions - */ - - /* - * Function: fnUpdate - * Purpose: Update the floating header from the current state of the DataTable - * Returns: - - * Inputs: bool:bUpdateDom - Update offset information (provided for speed options) - default true - * Notes: This would be used when the DataTables state is changed. For example using - * fnSetColumnVis() to change the number of visible columns. - */ - this.fnUpdate = function ( bUpdateDom ) - { - if ( typeof bUpdateDom == 'undefined' ) - { - bUpdateDom = true; - } - - _fnCloneThead(); - - if ( bUpdateDom ) - { - _iStart = $(_oSettings.nTable).offset().top; - _iStartLeft = $(_oSettings.nTable).offset().left; - } - } - - - - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Private variables - */ - - /* The DataTables object */ - var _oTable; - - /* The DataTables settings object - easy access */ - var _oSettings; - - /* The cloned table node */ - var _nCTable; - - /* The starting x-position of the table on the document */ - var _iStart; - - /* The starting x-position of the table relative to it's parent */ - var _iOffset; - - /* Current display information, cached so we don't have to query the DOM */ - var _oCache = { - "sPosition": "", - "sTop": "", - "sLeft": "" - }; - - var _bIsIE6; - - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Private functions - */ - - /* - * Function: _fnCloneTable - * Purpose: Clone the table node and do basic initialisation - * Returns: - - * Inputs: - - */ - function _fnCloneTable () - { - var nOrigTable = _oSettings.nTable; - - /* We know that the table _MUST_ has a DIV wrapped around it, because this is simply how - * DataTables works. Therefore, we can set this to be relatively position (if it is not - * alreadu absolute, and use this as the base point for the cloned header - */ - if ( $(nOrigTable.parentNode).css('position') != "absolute" ) - { - nOrigTable.parentNode.style.position = "relative"; - } - - /* Need to know the table's position relative to the other elements */ - _iOffset = nOrigTable.offsetTop; - - /* Just a shallow clone will do - we only want the table node */ - _nCTable = nOrigTable.cloneNode( false ); - _nCTable.style.position = "absolute"; - _nCTable.style.top = _iOffset+"px"; - _nCTable.style.left = nOrigTable.offsetLeft+"px"; - _nCTable.className += " FixedHeader_Cloned"; - _nCTable.id += "_Cloned"; - - /* Insert the newly cloned table into the DOM, on top of the "real" header */ - nOrigTable.parentNode.insertBefore( _nCTable, nOrigTable ); - - /* Dev note: for some mental reason we can't use the offset of '_nCTable' in IE. The original - * table will do us nicely though - */ - _iStart = $(_oSettings.nTable).offset().top; - _iStartLeft = $(_oSettings.nTable).offset().left; - - /* Add the scroll event handler to move the table header */ - $(window).scroll( function () { - var iWindow = $(window).scrollTop(); - - if ( _bIsIE6 ) - { - if ( _iStart < iWindow ) - { - var iNew = iWindow-_iStart+_iOffset; - var iTbodyHeight = _oSettings.nTable.getElementsByTagName('tbody')[0].offsetHeight; - - if ( iNew < _iOffset+iTbodyHeight ) - { - /* In the middle of the table */ - _fnUpdateCache( 'sTop', iNew+"px", 'top', _nCTable.style ); - } - else - { - /* At the bottom of the table */ - _fnUpdateCache( 'sTop', (_iOffset+iTbodyHeight)+"px", 'top', _nCTable.style ); - } - } - else - { - /* Above the table */ - _fnUpdateCache( 'sTop', _iOffset+"px", 'top', _nCTable.style ); - } - } - else - { - if ( _iStart < iWindow ) - { - var iNew = iWindow-_iStart+_iOffset; - var iTbodyHeight = _oSettings.nTable.getElementsByTagName('tbody')[0].offsetHeight; - - if ( iNew < _iOffset+iTbodyHeight ) - { - /* In the middle of the table */ - _fnUpdateCache( 'sPosition', 'fixed', 'position', _nCTable.style ); - _fnUpdateCache( 'sTop', "0px", 'top', _nCTable.style ); - _fnUpdateCache( 'sLeft', _iStartLeft+"px", 'left', _nCTable.style ); - } - else - { - /* At the bottom of the table */ - _fnUpdateCache( 'sPosition', 'absolute', 'position', _nCTable.style ); - _fnUpdateCache( 'sTop', _iOffset+iTbodyHeight+"px", 'top', _nCTable.style ); - _fnUpdateCache( 'sLeft', "0px", 'left', _nCTable.style ); - } - } - else - { - /* Above the table */ - _fnUpdateCache( 'sPosition', 'absolute', 'position', _nCTable.style ); - _fnUpdateCache( 'sTop', _iOffset+"px", 'top', _nCTable.style ); - _fnUpdateCache( 'sLeft', "0px", 'left', _nCTable.style ); - } - } - } ); - } - - /* - * Function: _fnUpdateCache - * Purpose: Check the cache and update cache and value if needed - * Returns: - - * Inputs: string:sCache - cache property - * string:sSet - value to set - * string:sProperty - object property to set - * object:oObj - object to update - */ - function _fnUpdateCache ( sCache, sSet, sProperty, oObj ) - { - if ( _oCache[sCache] != sSet ) - { - oObj[sProperty] = sSet; - _oCache[sCache] = sSet; - } - } - - /* - * Function: _fnCloneThead - * Purpose: Clone the THEAD element used in the DataTable and add required event listeners - * Returns: - - * Inputs: - - */ - function _fnCloneThead () - { - /* Remove any children the cloned table has */ - while ( _nCTable.childNodes.length > 0 ) - { - $('thead th', _nCTable).unbind( 'click' ); - _nCTable.removeChild( _nCTable.childNodes[0] ); - } - - /* Clone the DataTables header */ - var nThead = $('thead', _oSettings.nTable).clone(false)[0]; - _nCTable.appendChild( nThead ); - - /* Copy the widths across - apparently a clone isn't good enough for this */ - $("thead:eq(0)>tr th", _oSettings.nTable).each( function (i) { - $("thead:eq(0)>tr th:eq("+i+")", _nCTable).width( $(this).width() ); - } ); - - $("thead:eq(0)>tr td", _oSettings.nTable).each( function (i) { - $("thead:eq(0)>tr th:eq("+i+")", _nCTable)[0].style.width( $(this).width() ); - } ); - - /* Add the event handlers for sorting */ - $('thead th', _nCTable).click( function (e) { - /* Don't try and do the sort ourselves - let DataTables take care of the logic */ - var iTrigger = $('thead th', _nCTable).index(this); - $('thead th:eq('+iTrigger+')', _oSettings.nTable).click(); - _fnCloneThead(); - } ); - } - - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Initialisation - */ - _oTable = oTable; - _oSettings = _oTable.fnSettings(); - - //_bIsIE6 = ($.browser.msie && $.browser.version=="6.0"); - _bIsIE6 = ($.browser.msie && ($.browser.version=="6.0"||$.browser.version=="7.0")); - - _fnCloneTable(); - _fnCloneThead(); -} - -})(jQuery); diff --git a/modules/thirdparty/jquery/datatables/extras/FixedHeader/index.html b/modules/thirdparty/jquery/datatables/extras/FixedHeader/index.html index f87e602..fe9d896 100644 --- a/modules/thirdparty/jquery/datatables/extras/FixedHeader/index.html +++ b/modules/thirdparty/jquery/datatables/extras/FixedHeader/index.html @@ -8,16 +8,15 @@ - + @@ -465,8 +464,17 @@

Live example

Initialisation code

$(document).ready( function () {
 	var oTable = $('#example').dataTable();
-	$.fn.dataTableExt.FixedHeader( oTable );
+	new FixedHeader( oTable );
 } );
+ +

Examples

+

Empty paragraphs to force scrolling!...

 

diff --git a/modules/thirdparty/jquery/datatables/extras/TableTools/index.html b/modules/thirdparty/jquery/datatables/extras/TableTools/index.html old mode 100644 new mode 100755 index 216093c..06a2442 --- a/modules/thirdparty/jquery/datatables/extras/TableTools/index.html +++ b/modules/thirdparty/jquery/datatables/extras/TableTools/index.html @@ -12,7 +12,7 @@ - + +{capture name='_smarty_debug' assign=debug_output} + + + + Smarty Debug Console + + + + +

Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}

+ +{if !empty($template_data)} +

included templates & config files (load time in seconds)

+ +
+{foreach $template_data as $template} + {$template.name} + + (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) + +
+{/foreach} +
{/if} + +

assigned template variables

+ + + {foreach $assigned_vars as $vars} + + + + {/foreach} +
${$vars@key|escape:'html'}{$vars|debug_print_var}
+ +

assigned config file variables (outer template scope)

+ + + {foreach $config_vars as $vars} + + + + {/foreach} + +
{$vars@key|escape:'html'}{$vars|debug_print_var}
+ + +{/capture} + diff --git a/modules/thirdparty/smarty/internals/core.assemble_plugin_filepath.php b/modules/thirdparty/smarty/internals/core.assemble_plugin_filepath.php deleted file mode 100644 index 690d3dd..0000000 --- a/modules/thirdparty/smarty/internals/core.assemble_plugin_filepath.php +++ /dev/null @@ -1,67 +0,0 @@ -plugins_dir as $_plugin_dir) { - - $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; - - // see if path is relative - if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) { - $_relative_paths[] = $_plugin_dir; - // relative path, see if it is in the SMARTY_DIR - if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { - $_return = SMARTY_DIR . $_plugin_filepath; - break; - } - } - // try relative to cwd (or absolute) - if (@is_readable($_plugin_filepath)) { - $_return = $_plugin_filepath; - break; - } - } - - if($_return === false) { - // still not found, try PHP include_path - if(isset($_relative_paths)) { - foreach ((array)$_relative_paths as $_plugin_dir) { - - $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; - - $_params = array('file_path' => $_plugin_filepath); - require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $smarty)) { - $_return = $_params['new_file_path']; - break; - } - } - } - } - $_filepaths_cache[$_plugin_filename] = $_return; - return $_return; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.assign_smarty_interface.php b/modules/thirdparty/smarty/internals/core.assign_smarty_interface.php deleted file mode 100644 index 7e65a73..0000000 --- a/modules/thirdparty/smarty/internals/core.assign_smarty_interface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * Name: assign_smarty_interface
- * Purpose: assign the $smarty interface variable - * @param array Format: null - * @param Smarty - */ -function smarty_core_assign_smarty_interface($params, &$smarty) -{ - if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) { - return; - } - - $_globals_map = array('g' => 'HTTP_GET_VARS', - 'p' => 'HTTP_POST_VARS', - 'c' => 'HTTP_COOKIE_VARS', - 's' => 'HTTP_SERVER_VARS', - 'e' => 'HTTP_ENV_VARS'); - - $_smarty_vars_request = array(); - - foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) { - if (isset($_globals_map[$_c])) { - $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); - } - } - $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); - - $smarty->_smarty_vars['request'] = $_smarty_vars_request; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.create_dir_structure.php b/modules/thirdparty/smarty/internals/core.create_dir_structure.php deleted file mode 100644 index 3eecc49..0000000 --- a/modules/thirdparty/smarty/internals/core.create_dir_structure.php +++ /dev/null @@ -1,79 +0,0 @@ -_dir_perms) && !is_dir($_new_dir)) { - $smarty->trigger_error("problem creating directory '" . $_new_dir . "'"); - return false; - } - $_new_dir .= '/'; - } - } -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.display_debug_console.php b/modules/thirdparty/smarty/internals/core.display_debug_console.php deleted file mode 100644 index 1a80f39..0000000 --- a/modules/thirdparty/smarty/internals/core.display_debug_console.php +++ /dev/null @@ -1,61 +0,0 @@ - - * Name: display_debug_console
- * Purpose: display the javascript debug console window - * @param array Format: null - * @param Smarty - */ -function smarty_core_display_debug_console($params, &$smarty) -{ - // we must force compile the debug template in case the environment - // changed between separate applications. - - if(empty($smarty->debug_tpl)) { - // set path to debug template from SMARTY_DIR - $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; - if($smarty->security && is_file($smarty->debug_tpl)) { - $smarty->secure_dir[] = realpath($smarty->debug_tpl); - } - $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; - } - - $_ldelim_orig = $smarty->left_delimiter; - $_rdelim_orig = $smarty->right_delimiter; - - $smarty->left_delimiter = '{'; - $smarty->right_delimiter = '}'; - - $_compile_id_orig = $smarty->_compile_id; - $smarty->_compile_id = null; - - $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); - if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) - { - ob_start(); - $smarty->_include($_compile_path); - $_results = ob_get_contents(); - ob_end_clean(); - } else { - $_results = ''; - } - - $smarty->_compile_id = $_compile_id_orig; - - $smarty->left_delimiter = $_ldelim_orig; - $smarty->right_delimiter = $_rdelim_orig; - - return $_results; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.get_include_path.php b/modules/thirdparty/smarty/internals/core.get_include_path.php deleted file mode 100644 index 4343241..0000000 --- a/modules/thirdparty/smarty/internals/core.get_include_path.php +++ /dev/null @@ -1,44 +0,0 @@ - diff --git a/modules/thirdparty/smarty/internals/core.get_microtime.php b/modules/thirdparty/smarty/internals/core.get_microtime.php deleted file mode 100644 index f1a28e0..0000000 --- a/modules/thirdparty/smarty/internals/core.get_microtime.php +++ /dev/null @@ -1,23 +0,0 @@ - diff --git a/modules/thirdparty/smarty/internals/core.get_php_resource.php b/modules/thirdparty/smarty/internals/core.get_php_resource.php deleted file mode 100644 index 786d4e7..0000000 --- a/modules/thirdparty/smarty/internals/core.get_php_resource.php +++ /dev/null @@ -1,80 +0,0 @@ -trusted_dir; - $smarty->_parse_resource_name($params, $smarty); - - /* - * Find out if the resource exists. - */ - - if ($params['resource_type'] == 'file') { - $_readable = false; - if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) { - $_readable = true; - } else { - // test for file in include_path - $_params = array('file_path' => $params['resource_name']); - require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); - if(smarty_core_get_include_path($_params, $smarty)) { - $_include_path = $_params['new_file_path']; - $_readable = true; - } - } - } else if ($params['resource_type'] != 'file') { - $_template_source = null; - $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0]) - && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0], - array($params['resource_name'], &$_template_source, &$smarty)); - } - - /* - * Set the error function, depending on which class calls us. - */ - if (method_exists($smarty, '_syntax_error')) { - $_error_funcc = '_syntax_error'; - } else { - $_error_funcc = 'trigger_error'; - } - - if ($_readable) { - if ($smarty->security) { - require_once(SMARTY_CORE_DIR . 'core.is_trusted.php'); - if (!smarty_core_is_trusted($params, $smarty)) { - $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); - return false; - } - } - } else { - $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); - return false; - } - - if ($params['resource_type'] == 'file') { - $params['php_resource'] = $params['resource_name']; - } else { - $params['php_resource'] = $_template_source; - } - return true; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.is_secure.php b/modules/thirdparty/smarty/internals/core.is_secure.php deleted file mode 100644 index d54abd4..0000000 --- a/modules/thirdparty/smarty/internals/core.is_secure.php +++ /dev/null @@ -1,59 +0,0 @@ -security || $smarty->security_settings['INCLUDE_ANY']) { - return true; - } - - if ($params['resource_type'] == 'file') { - $_rp = realpath($params['resource_name']); - if (isset($params['resource_base_path'])) { - foreach ((array)$params['resource_base_path'] as $curr_dir) { - if ( ($_cd = realpath($curr_dir)) !== false && - strncmp($_rp, $_cd, strlen($_cd)) == 0 && - substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { - return true; - } - } - } - if (!empty($smarty->secure_dir)) { - foreach ((array)$smarty->secure_dir as $curr_dir) { - if ( ($_cd = realpath($curr_dir)) !== false) { - if($_cd == $_rp) { - return true; - } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && - substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { - return true; - } - } - } - } - } else { - // resource is not on local file system - return call_user_func_array( - $smarty->_plugins['resource'][$params['resource_type']][0][2], - array($params['resource_name'], &$smarty)); - } - - return false; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.is_trusted.php b/modules/thirdparty/smarty/internals/core.is_trusted.php deleted file mode 100644 index 4299731..0000000 --- a/modules/thirdparty/smarty/internals/core.is_trusted.php +++ /dev/null @@ -1,47 +0,0 @@ -trusted_dir)) { - $_rp = realpath($params['resource_name']); - foreach ((array)$smarty->trusted_dir as $curr_dir) { - if (!empty($curr_dir) && is_readable ($curr_dir)) { - $_cd = realpath($curr_dir); - if (strncmp($_rp, $_cd, strlen($_cd)) == 0 - && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { - $_smarty_trusted = true; - break; - } - } - } - } - - } else { - // resource is not on local file system - $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], - array($params['resource_name'], $smarty)); - } - - return $_smarty_trusted; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.load_plugins.php b/modules/thirdparty/smarty/internals/core.load_plugins.php deleted file mode 100644 index 6db1dc5..0000000 --- a/modules/thirdparty/smarty/internals/core.load_plugins.php +++ /dev/null @@ -1,125 +0,0 @@ -_plugins[$_type][$_name]; - - /* - * We do not load plugin more than once for each instance of Smarty. - * The following code checks for that. The plugin can also be - * registered dynamically at runtime, in which case template file - * and line number will be unknown, so we fill them in. - * - * The final element of the info array is a flag that indicates - * whether the dynamically registered plugin function has been - * checked for existence yet or not. - */ - if (isset($_plugin)) { - if (empty($_plugin[3])) { - if (!is_callable($_plugin[0])) { - $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__); - } else { - $_plugin[1] = $_tpl_file; - $_plugin[2] = $_tpl_line; - $_plugin[3] = true; - if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */ - } - } - continue; - } else if ($_type == 'insert') { - /* - * For backwards compatibility, we check for insert functions in - * the symbol table before trying to load them as a plugin. - */ - $_plugin_func = 'insert_' . $_name; - if (function_exists($_plugin_func)) { - $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false); - continue; - } - } - - $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name); - - if (! $_found = ($_plugin_file != false)) { - $_message = "could not load plugin file '$_type.$_name.php'\n"; - } - - /* - * If plugin file is found, it -must- provide the properly named - * plugin function. In case it doesn't, simply output the error and - * do not fall back on any other method. - */ - if ($_found) { - include_once $_plugin_file; - - $_plugin_func = 'smarty_' . $_type . '_' . $_name; - if (!function_exists($_plugin_func)) { - $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); - continue; - } - } - /* - * In case of insert plugins, their code may be loaded later via - * 'script' attribute. - */ - else if ($_type == 'insert' && $_delayed_loading) { - $_plugin_func = 'smarty_' . $_type . '_' . $_name; - $_found = true; - } - - /* - * Plugin specific processing and error checking. - */ - if (!$_found) { - if ($_type == 'modifier') { - /* - * In case modifier falls back on using PHP functions - * directly, we only allow those specified in the security - * context. - */ - if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) { - $_message = "(secure mode) modifier '$_name' is not allowed"; - } else { - if (!function_exists($_name)) { - $_message = "modifier '$_name' is not implemented"; - } else { - $_plugin_func = $_name; - $_found = true; - } - } - } else if ($_type == 'function') { - /* - * This is a catch-all situation. - */ - $_message = "unknown tag - '$_name'"; - } - } - - if ($_found) { - $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true); - } else { - // output error - $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); - } - } -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.load_resource_plugin.php b/modules/thirdparty/smarty/internals/core.load_resource_plugin.php deleted file mode 100644 index a7d37d1..0000000 --- a/modules/thirdparty/smarty/internals/core.load_resource_plugin.php +++ /dev/null @@ -1,74 +0,0 @@ -_plugins['resource'][$params['type']]; - if (isset($_plugin)) { - if (!$_plugin[1] && count($_plugin[0])) { - $_plugin[1] = true; - foreach ($_plugin[0] as $_plugin_func) { - if (!is_callable($_plugin_func)) { - $_plugin[1] = false; - break; - } - } - } - - if (!$_plugin[1]) { - $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); - } - - return; - } - - $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']); - $_found = ($_plugin_file != false); - - if ($_found) { /* - * If the plugin file is found, it -must- provide the properly named - * plugin functions. - */ - include_once($_plugin_file); - - /* - * Locate functions that we require the plugin to provide. - */ - $_resource_ops = array('source', 'timestamp', 'secure', 'trusted'); - $_resource_funcs = array(); - foreach ($_resource_ops as $_op) { - $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op; - if (!function_exists($_plugin_func)) { - $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); - return; - } else { - $_resource_funcs[] = $_plugin_func; - } - } - - $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true); - } -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.process_cached_inserts.php b/modules/thirdparty/smarty/internals/core.process_cached_inserts.php deleted file mode 100644 index 1d78edd..0000000 --- a/modules/thirdparty/smarty/internals/core.process_cached_inserts.php +++ /dev/null @@ -1,71 +0,0 @@ -_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis', - $params['results'], $match); - list($cached_inserts, $insert_args) = $match; - - for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $debug_start_time = smarty_core_get_microtime($_params, $smarty); - } - - $args = unserialize($insert_args[$i]); - $name = $args['name']; - - if (isset($args['script'])) { - $_params = array('resource_name' => $smarty->_dequote($args['script'])); - require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); - if(!smarty_core_get_php_resource($_params, $smarty)) { - return false; - } - $resource_type = $_params['resource_type']; - $php_resource = $_params['php_resource']; - - - if ($resource_type == 'file') { - $smarty->_include($php_resource, true); - } else { - $smarty->_eval($php_resource); - } - } - - $function_name = $smarty->_plugins['insert'][$name][0]; - if (empty($args['assign'])) { - $replace = $function_name($args, $smarty); - } else { - $smarty->assign($args['assign'], $function_name($args, $smarty)); - $replace = ''; - } - - $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[] = array('type' => 'insert', - 'filename' => 'insert_'.$name, - 'depth' => $smarty->_inclusion_depth, - 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); - } - } - - return $params['results']; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.process_compiled_include.php b/modules/thirdparty/smarty/internals/core.process_compiled_include.php deleted file mode 100644 index d539423..0000000 --- a/modules/thirdparty/smarty/internals/core.process_compiled_include.php +++ /dev/null @@ -1,37 +0,0 @@ -_cache_including; - $smarty->_cache_including = true; - - $_return = $params['results']; - - foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { - $smarty->_include($_include_file_path, true); - } - - foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) { - $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', - array(&$smarty, '_process_compiled_include_callback'), - $_return); - } - $smarty->_cache_including = $_cache_including; - return $_return; -} - -?> diff --git a/modules/thirdparty/smarty/internals/core.read_cache_file.php b/modules/thirdparty/smarty/internals/core.read_cache_file.php deleted file mode 100644 index c60e113..0000000 --- a/modules/thirdparty/smarty/internals/core.read_cache_file.php +++ /dev/null @@ -1,101 +0,0 @@ -force_compile) { - // force compile enabled, always regenerate - return false; - } - - if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) { - list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; - return true; - } - - if (!empty($smarty->cache_handler_func)) { - // use cache_handler function - call_user_func_array($smarty->cache_handler_func, - array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null)); - } else { - // use local cache file - $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); - $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); - $params['results'] = $smarty->_read_file($_cache_file); - } - - if (empty($params['results'])) { - // nothing to parse (error?), regenerate cache - return false; - } - - $_contents = $params['results']; - $_info_start = strpos($_contents, "\n") + 1; - $_info_len = (int)substr($_contents, 0, $_info_start - 1); - $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len)); - $params['results'] = substr($_contents, $_info_start + $_info_len); - - if ($smarty->caching == 2 && isset ($_cache_info['expires'])){ - // caching by expiration time - if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) { - // cache expired, regenerate - return false; - } - } else { - // caching by lifetime - if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) { - // cache expired, regenerate - return false; - } - } - - if ($smarty->compile_check) { - $_params = array('get_source' => false, 'quiet'=>true); - foreach (array_keys($_cache_info['template']) as $_template_dep) { - $_params['resource_name'] = $_template_dep; - if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { - // template file has changed, regenerate cache - return false; - } - } - - if (isset($_cache_info['config'])) { - $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true); - foreach (array_keys($_cache_info['config']) as $_config_dep) { - $_params['resource_name'] = $_config_dep; - if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { - // config file has changed, regenerate cache - return false; - } - } - } - } - - $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info); - - $smarty->_cache_info = $_cache_info; - return true; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.rm_auto.php b/modules/thirdparty/smarty/internals/core.rm_auto.php deleted file mode 100644 index b251f64..0000000 --- a/modules/thirdparty/smarty/internals/core.rm_auto.php +++ /dev/null @@ -1,71 +0,0 @@ - $params['auto_base'], - 'level' => 0, - 'exp_time' => $params['exp_time'] - ); - require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); - $_res = smarty_core_rmdir($_params, $smarty); - } else { - $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); - - if(isset($params['auto_source'])) { - if (isset($params['extensions'])) { - $_res = false; - foreach ((array)$params['extensions'] as $_extension) - $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']); - } else { - $_res = $smarty->_unlink($_tname, $params['exp_time']); - } - } elseif ($smarty->use_sub_dirs) { - $_params = array( - 'dirname' => $_tname, - 'level' => 1, - 'exp_time' => $params['exp_time'] - ); - require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); - $_res = smarty_core_rmdir($_params, $smarty); - } else { - // remove matching file names - $_handle = opendir($params['auto_base']); - $_res = true; - while (false !== ($_filename = readdir($_handle))) { - if($_filename == '.' || $_filename == '..') { - continue; - } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { - $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); - } - } - } - } - - return $_res; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.rmdir.php b/modules/thirdparty/smarty/internals/core.rmdir.php deleted file mode 100644 index 2166c44..0000000 --- a/modules/thirdparty/smarty/internals/core.rmdir.php +++ /dev/null @@ -1,54 +0,0 @@ - keep root) - * WARNING: no tests, it will try to remove what you tell it! - * - * @param string $dirname - * @param integer $level - * @param integer $exp_time - * @return boolean - */ - -// $dirname, $level = 1, $exp_time = null - -function smarty_core_rmdir($params, &$smarty) -{ - if(!isset($params['level'])) { $params['level'] = 1; } - if(!isset($params['exp_time'])) { $params['exp_time'] = null; } - - if($_handle = @opendir($params['dirname'])) { - - while (false !== ($_entry = readdir($_handle))) { - if ($_entry != '.' && $_entry != '..') { - if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { - $_params = array( - 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, - 'level' => $params['level'] + 1, - 'exp_time' => $params['exp_time'] - ); - smarty_core_rmdir($_params, $smarty); - } - else { - $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); - } - } - } - closedir($_handle); - } - - if ($params['level']) { - return @rmdir($params['dirname']); - } - return (bool)$_handle; - -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.run_insert_handler.php b/modules/thirdparty/smarty/internals/core.run_insert_handler.php deleted file mode 100644 index 71c3845..0000000 --- a/modules/thirdparty/smarty/internals/core.run_insert_handler.php +++ /dev/null @@ -1,71 +0,0 @@ -debugging) { - $_params = array(); - $_debug_start_time = smarty_core_get_microtime($_params, $smarty); - } - - if ($smarty->caching) { - $_arg_string = serialize($params['args']); - $_name = $params['args']['name']; - if (!isset($smarty->_cache_info['insert_tags'][$_name])) { - $smarty->_cache_info['insert_tags'][$_name] = array('insert', - $_name, - $smarty->_plugins['insert'][$_name][1], - $smarty->_plugins['insert'][$_name][2], - !empty($params['args']['script']) ? true : false); - } - return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; - } else { - if (isset($params['args']['script'])) { - $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); - require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); - if(!smarty_core_get_php_resource($_params, $smarty)) { - return false; - } - - if ($_params['resource_type'] == 'file') { - $smarty->_include($_params['php_resource'], true); - } else { - $smarty->_eval($_params['php_resource']); - } - unset($params['args']['script']); - } - - $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; - $_content = $_funcname($params['args'], $smarty); - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[] = array('type' => 'insert', - 'filename' => 'insert_'.$params['args']['name'], - 'depth' => $smarty->_inclusion_depth, - 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); - } - - if (!empty($params['args']["assign"])) { - $smarty->assign($params['args']["assign"], $_content); - } else { - return $_content; - } - } -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.smarty_include_php.php b/modules/thirdparty/smarty/internals/core.smarty_include_php.php deleted file mode 100644 index 30c6e76..0000000 --- a/modules/thirdparty/smarty/internals/core.smarty_include_php.php +++ /dev/null @@ -1,50 +0,0 @@ - $params['smarty_file']); - require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); - smarty_core_get_php_resource($_params, $smarty); - $_smarty_resource_type = $_params['resource_type']; - $_smarty_php_resource = $_params['php_resource']; - - if (!empty($params['smarty_assign'])) { - ob_start(); - if ($_smarty_resource_type == 'file') { - $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); - } else { - $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); - } - $smarty->assign($params['smarty_assign'], ob_get_contents()); - ob_end_clean(); - } else { - if ($_smarty_resource_type == 'file') { - $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); - } else { - $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); - } - } -} - - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.write_cache_file.php b/modules/thirdparty/smarty/internals/core.write_cache_file.php deleted file mode 100644 index 72f785b..0000000 --- a/modules/thirdparty/smarty/internals/core.write_cache_file.php +++ /dev/null @@ -1,96 +0,0 @@ -_cache_info['timestamp'] = time(); - if ($smarty->cache_lifetime > -1){ - // expiration set - $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime; - } else { - // cache will never expire - $smarty->_cache_info['expires'] = -1; - } - - // collapse nocache.../nocache-tags - if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) { - // remove everything between every pair of outermost noache.../nocache-tags - // and replace it by a single nocache-tag - // this new nocache-tag will be replaced by dynamic contents in - // smarty_core_process_compiled_includes() on a cache-read - - $match_count = count($match[0]); - $results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE); - - $level = 0; - $j = 0; - for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) { - if ($results[$i] == $match[0][$j]) { - // nocache tag - if ($match[1][$j]) { // closing tag - $level--; - unset($results[$i]); - } else { // opening tag - if ($level++ > 0) unset($results[$i]); - } - $j++; - } elseif ($level > 0) { - unset($results[$i]); - } - } - $params['results'] = implode('', $results); - } - $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; - - // prepend the cache header info into cache file - $_cache_info = serialize($smarty->_cache_info); - $params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results']; - - if (!empty($smarty->cache_handler_func)) { - // use cache_handler function - call_user_func_array($smarty->cache_handler_func, - array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null)); - } else { - // use local cache file - - if(!@is_writable($smarty->cache_dir)) { - // cache_dir not writable, see if it exists - if(!@is_dir($smarty->cache_dir)) { - $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); - return false; - } - $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); - return false; - } - - $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); - $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); - $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); - require_once(SMARTY_CORE_DIR . 'core.write_file.php'); - smarty_core_write_file($_params, $smarty); - return true; - } -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.write_compiled_include.php b/modules/thirdparty/smarty/internals/core.write_compiled_include.php deleted file mode 100644 index c14adb5..0000000 --- a/modules/thirdparty/smarty/internals/core.write_compiled_include.php +++ /dev/null @@ -1,91 +0,0 @@ -caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;'; - $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;'; - - preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', - $params['compiled_content'], $_match_source, PREG_SET_ORDER); - - // no nocache-parts found: done - if (count($_match_source)==0) return; - - // convert the matched php-code to functions - $_include_compiled = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; - $_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n"; - - $_compile_path = $params['include_file_path']; - - $smarty->_cache_serials[$_compile_path] = $params['cache_serial']; - $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>"; - - $_include_compiled .= $params['plugins_code']; - $_include_compiled .= "= 5.0) ? '_smarty' : 'this'; - for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) { - $_match =& $_match_source[$_i]; - $source = $_match[4]; - if ($this_varname == '_smarty') { - /* rename $this to $_smarty in the sourcecode */ - $tokens = token_get_all('\n"; - - $_params = array('filename' => $_compile_path, - 'contents' => $_include_compiled, 'create_dirs' => true); - - require_once(SMARTY_CORE_DIR . 'core.write_file.php'); - smarty_core_write_file($_params, $smarty); - return true; -} - - -?> diff --git a/modules/thirdparty/smarty/internals/core.write_compiled_resource.php b/modules/thirdparty/smarty/internals/core.write_compiled_resource.php deleted file mode 100644 index b902eff..0000000 --- a/modules/thirdparty/smarty/internals/core.write_compiled_resource.php +++ /dev/null @@ -1,35 +0,0 @@ -compile_dir)) { - // compile_dir not writable, see if it exists - if(!@is_dir($smarty->compile_dir)) { - $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); - return false; - } - $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); - return false; - } - - $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true); - require_once(SMARTY_CORE_DIR . 'core.write_file.php'); - smarty_core_write_file($_params, $smarty); - return true; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/internals/core.write_file.php b/modules/thirdparty/smarty/internals/core.write_file.php deleted file mode 100644 index 8a3a3b3..0000000 --- a/modules/thirdparty/smarty/internals/core.write_file.php +++ /dev/null @@ -1,54 +0,0 @@ - $_dirname); - require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php'); - smarty_core_create_dir_structure($_params, $smarty); - } - - // write to tmp file, then rename it to avoid file locking race condition - $_tmp_file = tempnam($_dirname, 'wrt'); - - if (!($fd = @fopen($_tmp_file, 'wb'))) { - $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt'); - if (!($fd = @fopen($_tmp_file, 'wb'))) { - $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); - return false; - } - } - - fwrite($fd, $params['contents']); - fclose($fd); - - if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) { - // On platforms and filesystems that cannot overwrite with rename() - // delete the file before renaming it -- because windows always suffers - // this, it is short-circuited to avoid the initial rename() attempt - @unlink($params['filename']); - @rename($_tmp_file, $params['filename']); - } - @chmod($params['filename'], $smarty->_file_perms); - - return true; -} - -/* vim: set expandtab: */ - -?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/block.textformat.php b/modules/thirdparty/smarty/plugins/block.textformat.php old mode 100644 new mode 100755 index 8cd010a..517fd62 --- a/modules/thirdparty/smarty/plugins/block.textformat.php +++ b/modules/thirdparty/smarty/plugins/block.textformat.php @@ -1,38 +1,41 @@ * Name: textformat
* Purpose: format text a certain way with preset styles - * or custom wrap/indent settings
+ * or custom wrap/indent settings
+ * * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} * (Smarty online manual) - * @param array + * @param array $params parameters *
  * Params:   style: string (email)
- *           indent: integer (0)
- *           wrap: integer (80)
- *           wrap_char string ("\n")
- *           indent_char: string (" ")
- *           wrap_boundary: boolean (true)
+ *            indent: integer (0)
+ *            wrap: integer (80)
+ *            wrap_char string ("\n")
+ *            indent_char: string (" ")
+ *            wrap_boundary: boolean (true)
  * 
- * @author Monte Ohrt - * @param string contents of the block - * @param Smarty clever simulation of a method - * @return string string $content re-formatted + * @author Monte Ohrt + * @param string $content contents of the block + * @param object $template template object + * @param boolean &$repeat repeat flag + * @return string content re-formatted */ -function smarty_block_textformat($params, $content, &$smarty) +function smarty_block_textformat($params, $content, $template, &$repeat) { if (is_null($content)) { return; - } + } $style = null; $indent = 0; @@ -42,7 +45,7 @@ function smarty_block_textformat($params, $content, &$smarty) $wrap_char = "\n"; $wrap_cut = false; $assign = null; - + foreach ($params as $_key => $_val) { switch ($_key) { case 'style': @@ -63,41 +66,37 @@ function smarty_block_textformat($params, $content, &$smarty) break; default: - $smarty->trigger_error("textformat: unknown attribute '$_key'"); - } - } + trigger_error("textformat: unknown attribute '$_key'"); + } + } if ($style == 'email') { $wrap = 72; - } - + } // split into paragraphs - $_paragraphs = preg_split('![\r\n][\r\n]!',$content); + $_paragraphs = preg_split('![\r\n][\r\n]!', $content); $_output = ''; for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { if ($_paragraphs[$_x] == '') { continue; - } + } // convert mult. spaces & special chars to single space - $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]); + $_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]); // indent first line - if($indent_first > 0) { + if ($indent_first > 0) { $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; - } + } // wordwrap sentences - $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); + $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); // indent lines - if($indent > 0) { + if ($indent > 0) { $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); - } - } + } + } $_output = implode($wrap_char . $wrap_char, $_paragraphs); + + return $assign ? $template->assign($assign, $_output) : $_output; +} - return $assign ? $smarty->assign($assign, $_output) : $_output; - -} - -/* vim: set expandtab: */ - -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/compiler.assign.php b/modules/thirdparty/smarty/plugins/compiler.assign.php deleted file mode 100644 index abef377..0000000 --- a/modules/thirdparty/smarty/plugins/compiler.assign.php +++ /dev/null @@ -1,40 +0,0 @@ - - * Name: assign
- * Purpose: assign a value to a template variable - * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign} - * (Smarty online manual) - * @author Monte Ohrt (initial author) - * @author messju mohr (conversion to compiler function) - * @param string containing var-attribute and value-attribute - * @param Smarty_Compiler - */ -function smarty_compiler_assign($tag_attrs, &$compiler) -{ - $_params = $compiler->_parse_attrs($tag_attrs); - - if (!isset($_params['var'])) { - $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING); - return; - } - - if (!isset($_params['value'])) { - $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING); - return; - } - - return "\$this->assign({$_params['var']}, {$_params['value']});"; -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/plugins/function.assign.php b/modules/thirdparty/smarty/plugins/function.assign.php deleted file mode 100644 index 0eb2960..0000000 --- a/modules/thirdparty/smarty/plugins/function.assign.php +++ /dev/null @@ -1,30 +0,0 @@ -trigger_error("assign: missing 'var' parameter"); - return; - } - - if (!in_array('value', array_keys($params))) { - $smarty->trigger_error("assign: missing 'value' parameter"); - return; - } - - $smarty->assign($var, $value); -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/plugins/function.assign_debug_info.php b/modules/thirdparty/smarty/plugins/function.assign_debug_info.php deleted file mode 100644 index 6540498..0000000 --- a/modules/thirdparty/smarty/plugins/function.assign_debug_info.php +++ /dev/null @@ -1,40 +0,0 @@ - - * Name: assign_debug_info
- * Purpose: assign debug info to the template
- * @author Monte Ohrt - * @param array unused in this plugin, this plugin uses {@link Smarty::$_config}, - * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info} - * @param Smarty - */ -function smarty_function_assign_debug_info($params, &$smarty) -{ - $assigned_vars = $smarty->_tpl_vars; - ksort($assigned_vars); - if (@is_array($smarty->_config[0])) { - $config_vars = $smarty->_config[0]; - ksort($config_vars); - $smarty->assign("_debug_config_keys", array_keys($config_vars)); - $smarty->assign("_debug_config_vals", array_values($config_vars)); - } - - $included_templates = $smarty->_smarty_debug_info; - - $smarty->assign("_debug_keys", array_keys($assigned_vars)); - $smarty->assign("_debug_vals", array_values($assigned_vars)); - - $smarty->assign("_debug_tpls", $included_templates); -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/plugins/function.config_load.php b/modules/thirdparty/smarty/plugins/function.config_load.php deleted file mode 100644 index db89f63..0000000 --- a/modules/thirdparty/smarty/plugins/function.config_load.php +++ /dev/null @@ -1,142 +0,0 @@ - - * Name: config_load
- * Purpose: load config file vars - * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load} - * (Smarty online manual) - * @author Monte Ohrt - * @author messju mohr (added use of resources) - * @param array Format: - *
- * array('file' => required config file name,
- *       'section' => optional config file section to load
- *       'scope' => local/parent/global
- *       'global' => overrides scope, setting to parent if true)
- * 
- * @param Smarty - */ -function smarty_function_config_load($params, &$smarty) -{ - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $_debug_start_time = smarty_core_get_microtime($_params, $smarty); - } - - $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null; - $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null; - $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global'; - $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false; - - if (!isset($_file) || strlen($_file) == 0) { - $smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__); - } - - if (isset($_scope)) { - if ($_scope != 'local' && - $_scope != 'parent' && - $_scope != 'global') { - $smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__); - } - } else { - if ($_global) { - $_scope = 'parent'; - } else { - $_scope = 'local'; - } - } - - $_params = array('resource_name' => $_file, - 'resource_base_path' => $smarty->config_dir, - 'get_source' => false); - $smarty->_parse_resource_name($_params); - $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; - if (isset($_section)) - $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); - else - $_compile_file = $smarty->_get_compile_path($_file_path); - - if($smarty->force_compile || !file_exists($_compile_file)) { - $_compile = true; - } elseif ($smarty->compile_check) { - $_params = array('resource_name' => $_file, - 'resource_base_path' => $smarty->config_dir, - 'get_source' => false); - $_compile = $smarty->_fetch_resource_info($_params) && - $_params['resource_timestamp'] > filemtime($_compile_file); - } else { - $_compile = false; - } - - if($_compile) { - // compile config file - if(!is_object($smarty->_conf_obj)) { - require_once SMARTY_DIR . $smarty->config_class . '.class.php'; - $smarty->_conf_obj = new $smarty->config_class(); - $smarty->_conf_obj->overwrite = $smarty->config_overwrite; - $smarty->_conf_obj->booleanize = $smarty->config_booleanize; - $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden; - $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines; - } - - $_params = array('resource_name' => $_file, - 'resource_base_path' => $smarty->config_dir, - $_params['get_source'] = true); - if (!$smarty->_fetch_resource_info($_params)) { - return; - } - $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']); - $_config_vars = array_merge($smarty->_conf_obj->get($_file), - $smarty->_conf_obj->get($_file, $_section)); - if(function_exists('var_export')) { - $_output = ''; - } else { - $_output = ''\\\'', '\\'=>'\\\\')) . '\'); ?>'; - } - $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp'])); - require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php'); - smarty_core_write_compiled_resource($_params, $smarty); - } else { - include($_compile_file); - } - - if ($smarty->caching) { - $smarty->_cache_info['config'][$_file] = true; - } - - $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars); - $smarty->_config[0]['files'][$_file] = true; - - if ($_scope == 'parent') { - $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars); - $smarty->_config[1]['files'][$_file] = true; - } else if ($_scope == 'global') { - for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) { - $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars); - $smarty->_config[$i]['files'][$_file] = true; - } - } - - if ($smarty->debugging) { - $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[] = array('type' => 'config', - 'filename' => $_file.' ['.$_section.'] '.$_scope, - 'depth' => $smarty->_inclusion_depth, - 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); - } - -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/plugins/function.counter.php b/modules/thirdparty/smarty/plugins/function.counter.php old mode 100644 new mode 100755 index 1f26db5..7c50bd4 --- a/modules/thirdparty/smarty/plugins/function.counter.php +++ b/modules/thirdparty/smarty/plugins/function.counter.php @@ -2,10 +2,9 @@ /** * Smarty plugin * @package Smarty - * @subpackage plugins + * @subpackage PluginsFunction */ - /** * Smarty {counter} function plugin * @@ -17,9 +16,10 @@ * (Smarty online manual) * @param array parameters * @param Smarty + * @param object $template template object * @return string|null */ -function smarty_function_counter($params, &$smarty) +function smarty_function_counter($params, $template) { static $counters = array(); @@ -43,7 +43,7 @@ function smarty_function_counter($params, &$smarty) } if (isset($counter['assign'])) { - $smarty->assign($counter['assign'], $counter['count']); + $template->assign($counter['assign'], $counter['count']); } if (isset($params['print'])) { @@ -75,6 +75,4 @@ function smarty_function_counter($params, &$smarty) } -/* vim: set expandtab: */ - -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/function.cycle.php b/modules/thirdparty/smarty/plugins/function.cycle.php old mode 100644 new mode 100755 index fe78bb8..98e3e28 --- a/modules/thirdparty/smarty/plugins/function.cycle.php +++ b/modules/thirdparty/smarty/plugins/function.cycle.php @@ -1,8 +1,9 @@ * @version 1.3 * @param array - * @param Smarty + * @param object $template template object * @return string|null */ -function smarty_function_cycle($params, &$smarty) + +function smarty_function_cycle($params, $template) { static $cycle_vars; @@ -52,7 +54,7 @@ function smarty_function_cycle($params, &$smarty) if (!in_array('values', array_keys($params))) { if(!isset($cycle_vars[$name]['values'])) { - $smarty->trigger_error("cycle: missing 'values' parameter"); + trigger_error("cycle: missing 'values' parameter"); return; } } else { @@ -63,7 +65,11 @@ function smarty_function_cycle($params, &$smarty) $cycle_vars[$name]['values'] = $params['values']; } - $cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ','; + if (isset($params['delimiter'])) { + $cycle_vars[$name]['delimiter'] = $params['delimiter']; + } elseif (!isset($cycle_vars[$name]['delimiter'])) { + $cycle_vars[$name]['delimiter'] = ','; + } if(is_array($cycle_vars[$name]['values'])) { $cycle_array = $cycle_vars[$name]['values']; @@ -77,7 +83,7 @@ function smarty_function_cycle($params, &$smarty) if (isset($params['assign'])) { $print = false; - $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); + $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); } if($print) { @@ -97,6 +103,4 @@ function smarty_function_cycle($params, &$smarty) return $retval; } -/* vim: set expandtab: */ - -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/function.debug.php b/modules/thirdparty/smarty/plugins/function.debug.php deleted file mode 100644 index 4345230..0000000 --- a/modules/thirdparty/smarty/plugins/function.debug.php +++ /dev/null @@ -1,35 +0,0 @@ - - * Name: debug
- * Date: July 1, 2002
- * Purpose: popup debug window - * @link http://smarty.php.net/manual/en/language.function.debug.php {debug} - * (Smarty online manual) - * @author Monte Ohrt - * @version 1.0 - * @param array - * @param Smarty - * @return string output from {@link Smarty::_generate_debug_output()} - */ -function smarty_function_debug($params, &$smarty) -{ - if (isset($params['output'])) { - $smarty->assign('_smarty_debug_output', $params['output']); - } - require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); - return smarty_core_display_debug_console(null, $smarty); -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/plugins/function.eval.php b/modules/thirdparty/smarty/plugins/function.eval.php deleted file mode 100644 index ff0472d..0000000 --- a/modules/thirdparty/smarty/plugins/function.eval.php +++ /dev/null @@ -1,49 +0,0 @@ - - * Name: eval
- * Purpose: evaluate a template variable as a template
- * @link http://smarty.php.net/manual/en/language.function.eval.php {eval} - * (Smarty online manual) - * @author Monte Ohrt - * @param array - * @param Smarty - */ -function smarty_function_eval($params, &$smarty) -{ - - if (!isset($params['var'])) { - $smarty->trigger_error("eval: missing 'var' parameter"); - return; - } - - if($params['var'] == '') { - return; - } - - $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled); - - ob_start(); - $smarty->_eval('?>' . $_var_compiled); - $_contents = ob_get_contents(); - ob_end_clean(); - - if (!empty($params['assign'])) { - $smarty->assign($params['assign'], $_contents); - } else { - return $_contents; - } -} - -/* vim: set expandtab: */ - -?> diff --git a/modules/thirdparty/smarty/plugins/function.fetch.php b/modules/thirdparty/smarty/plugins/function.fetch.php old mode 100644 new mode 100755 index 81b1bfc..2b09fb9 --- a/modules/thirdparty/smarty/plugins/function.fetch.php +++ b/modules/thirdparty/smarty/plugins/function.fetch.php @@ -1,11 +1,11 @@ - * @param array - * @param Smarty + * @param array $params parameters + * @param object $template template object * @return string|null if the assign parameter is passed, Smarty assigns the * result to a template variable */ -function smarty_function_fetch($params, &$smarty) +function smarty_function_fetch($params, $template) { if (empty($params['file'])) { - $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty"); + trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); return; } $content = ''; - if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) { - $_params = array('resource_type' => 'file', 'resource_name' => $params['file']); - require_once(SMARTY_CORE_DIR . 'core.is_secure.php'); - if(!smarty_core_is_secure($_params, $smarty)) { - $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed'); + if (isset($template->security_policy) && !preg_match('!^(http|ftp)://!i', $params['file'])) { + if(!$template->security_policy->isTrustedResourceDir($params['file'])) { return; } @@ -43,7 +40,7 @@ function smarty_function_fetch($params, &$smarty) } fclose($fp); } else { - $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\''); + trigger_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'',E_USER_NOTICE); return; } } else { @@ -55,7 +52,7 @@ function smarty_function_fetch($params, &$smarty) $host = $server_name = $uri_parts['host']; $timeout = 30; $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine ".$smarty->_version; + $agent = "Smarty Template Engine ".$template->_version; $referer = ""; $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; @@ -96,7 +93,7 @@ function smarty_function_fetch($params, &$smarty) case "header": if(!empty($param_value)) { if(!preg_match('![\w\d-]+: .+!',$param_value)) { - $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'"); + trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE); return; } else { $extra_headers[] = $param_value; @@ -112,7 +109,7 @@ function smarty_function_fetch($params, &$smarty) if(!preg_match('!\D!', $param_value)) { $proxy_port = (int) $param_value; } else { - $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); + trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); return; } break; @@ -130,12 +127,12 @@ function smarty_function_fetch($params, &$smarty) if(!preg_match('!\D!', $param_value)) { $timeout = (int) $param_value; } else { - $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); + trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); return; } break; default: - $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'"); + trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); return; } } @@ -147,7 +144,7 @@ function smarty_function_fetch($params, &$smarty) } if(!$fp) { - $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)"); + trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); return; } else { if($_is_proxy) { @@ -181,16 +178,16 @@ function smarty_function_fetch($params, &$smarty) $content .= fgets($fp,4096); } fclose($fp); - $csplit = split("\r\n\r\n",$content,2); + $csplit = preg_split("!\r\n\r\n!",$content,2); $content = $csplit[1]; if(!empty($params['assign_headers'])) { - $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0])); + $template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); } } } else { - $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax"); + trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); return; } } else { @@ -201,7 +198,7 @@ function smarty_function_fetch($params, &$smarty) } fclose($fp); } else { - $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\''); + trigger_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'',E_USER_NOTICE); return; } } @@ -210,12 +207,10 @@ function smarty_function_fetch($params, &$smarty) if (!empty($params['assign'])) { - $smarty->assign($params['assign'],$content); + $template->assign($params['assign'],$content); } else { return $content; } } -/* vim: set expandtab: */ - -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/function.html_checkboxes.php b/modules/thirdparty/smarty/plugins/function.html_checkboxes.php old mode 100644 new mode 100755 index ed8ad7f..6a1a3ff --- a/modules/thirdparty/smarty/plugins/function.html_checkboxes.php +++ b/modules/thirdparty/smarty/plugins/function.html_checkboxes.php @@ -1,11 +1,11 @@ * Date: 24.Feb.2003
* Purpose: Prints out a list of checkbox input types
- * Input:
- * - name (optional) - string default "checkbox" - * - values (required) - array - * - options (optional) - associative array - * - checked (optional) - array default not set - * - separator (optional) - ie
or   - * - output (optional) - the output next to each checkbox - * - assign (optional) - assign the output as an array to this variable * Examples: *
  * {html_checkboxes values=$ids output=$names}
@@ -33,14 +25,22 @@
  * @author     Christopher Kvarme 
  * @author credits to Monte Ohrt 
  * @version    1.0
- * @param array
- * @param Smarty
+ * @param array $params parameters
+ * Input:
+ * - name (optional) - string default "checkbox" + * - values (required) - array + * - options (optional) - associative array + * - checked (optional) - array default not set + * - separator (optional) - ie
or   + * - output (optional) - the output next to each checkbox + * - assign (optional) - assign the output as an array to this variable + * @param object $template template object * @return string * @uses smarty_function_escape_special_chars() */ -function smarty_function_html_checkboxes($params, &$smarty) +function smarty_function_html_checkboxes($params, $template) { - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); $name = 'checkbox'; $values = null; @@ -78,7 +78,7 @@ function smarty_function_html_checkboxes($params, &$smarty) break; case 'checkboxes': - $smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); + trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); $options = (array)$_val; break; @@ -89,7 +89,7 @@ function smarty_function_html_checkboxes($params, &$smarty) if(!is_array($_val)) { $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; } else { - $smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); } break; } @@ -116,7 +116,7 @@ function smarty_function_html_checkboxes($params, &$smarty) } if(!empty($params['assign'])) { - $smarty->assign($params['assign'], $_html_result); + $template->assign($params['assign'], $_html_result); } else { return implode("\n",$_html_result); } @@ -140,4 +140,4 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte return $_output; } -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/function.html_image.php b/modules/thirdparty/smarty/plugins/function.html_image.php old mode 100644 new mode 100755 index 9abae72..abb7b57 --- a/modules/thirdparty/smarty/plugins/function.html_image.php +++ b/modules/thirdparty/smarty/plugins/function.html_image.php @@ -1,43 +1,42 @@ * Name: html_image
* Date: Feb 24, 2003
* Purpose: format HTML tags for the image
- * Input:
- * - file = file (and path) of image (required) - * - height = image height (optional, default actual height) - * - width = image width (optional, default actual width) - * - basedir = base directory for absolute paths, default - * is environment variable DOCUMENT_ROOT - * - path_prefix = prefix for path output (optional, default empty) - * * Examples: {html_image file="/images/masthead.gif"} * Output: + * * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} * (Smarty online manual) - * @author Monte Ohrt - * @author credits to Duda - wrote first image function - * in repository, helped with lots of functionality - * @version 1.0 - * @param array - * @param Smarty - * @return string + * @author Monte Ohrt + * @author credits to Duda + * @version 1.0 + * @param array $params parameters + * Input:
+ * - file = file (and path) of image (required) + * - height = image height (optional, default actual height) + * - width = image width (optional, default actual width) + * - basedir = base directory for absolute paths, default + * is environment variable DOCUMENT_ROOT + * - path_prefix = prefix for path output (optional, default empty) + * @param object $template template object + * @return string * @uses smarty_function_escape_special_chars() */ -function smarty_function_html_image($params, &$smarty) +function smarty_function_html_image($params, $template) { - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); - + require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); + $alt = ''; $file = ''; $height = ''; @@ -46,10 +45,10 @@ function smarty_function_html_image($params, &$smarty) $prefix = ''; $suffix = ''; $path_prefix = ''; - $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; + $server_vars = $_SERVER; $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; foreach($params as $_key => $_val) { - switch($_key) { + switch ($_key) { case 'file': case 'height': case 'width': @@ -60,11 +59,11 @@ function smarty_function_html_image($params, &$smarty) break; case 'alt': - if(!is_array($_val)) { + if (!is_array($_val)) { $$_key = smarty_function_escape_special_chars($_val); } else { - $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } + throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } break; case 'link': @@ -74,69 +73,65 @@ function smarty_function_html_image($params, &$smarty) break; default: - if(!is_array($_val)) { - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + if (!is_array($_val)) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; } else { - $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } + throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } break; - } - } + } + } if (empty($file)) { - $smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); + trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); return; - } + } - if (substr($file,0,1) == '/') { + if (substr($file, 0, 1) == '/') { $_image_path = $basedir . $file; } else { $_image_path = $file; - } - - if(!isset($params['width']) || !isset($params['height'])) { - if(!$_image_data = @getimagesize($_image_path)) { - if(!file_exists($_image_path)) { - $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); + } + + if (!isset($params['width']) || !isset($params['height'])) { + if (!$_image_data = @getimagesize($_image_path)) { + if (!file_exists($_image_path)) { + trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); return; - } else if(!is_readable($_image_path)) { - $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); + } else if (!is_readable($_image_path)) { + trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); return; } else { - $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); + trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); return; - } - } - if ($smarty->security && - ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && - (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) && - (!smarty_core_is_secure($_params, $smarty)) ) { - $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); - } - - if(!isset($params['width'])) { + } + } + if (isset($template->security_policy)) { + if (!$template->security_policy->isTrustedResourceDir($_image_path)) { + return; + } + } + + if (!isset($params['width'])) { $width = $_image_data[0]; - } - if(!isset($params['height'])) { + } + if (!isset($params['height'])) { $height = $_image_data[1]; - } + } + } - } - - if(isset($params['dpi'])) { - if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { + if (isset($params['dpi'])) { + if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { $dpi_default = 72; } else { $dpi_default = 96; - } - $_resize = $dpi_default/$params['dpi']; + } + $_resize = $dpi_default / $params['dpi']; $width = round($width * $_resize); $height = round($height * $_resize); - } - - return $prefix . ''.$alt.'' . $suffix; -} + } -/* vim: set expandtab: */ + return $prefix . '' . $alt . '' . $suffix; +} -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/function.html_options.php b/modules/thirdparty/smarty/plugins/function.html_options.php old mode 100644 new mode 100755 index cebadde..7ac0390 --- a/modules/thirdparty/smarty/plugins/function.html_options.php +++ b/modules/thirdparty/smarty/plugins/function.html_options.php @@ -1,54 +1,60 @@ * Name: html_options
- * Input:
- * - name (optional) - string default "select" - * - values (required if no options supplied) - array - * - options (required if no values supplied) - associative array - * - selected (optional) - string default not set - * - output (required if not options supplied) - array * Purpose: Prints the list of
!is", $source, $match); $_pre_blocks = $match[0]; - $source = preg_replace("!
.*?
!is", + $source = preg_replace("!]*?>.*?!is", '@@@SMARTY:TRIM:PRE@@@', $source); - + // Pull out the textarea blocks - preg_match_all("!]+>.*?!is", $source, $match); + preg_match_all("!]*?>.*?!is", $source, $match); $_textarea_blocks = $match[0]; - $source = preg_replace("!]+>.*?!is", + $source = preg_replace("!]*?>.*?!is", '@@@SMARTY:TRIM:TEXTAREA@@@', $source); // remove all leading spaces, tabs and carriage returns NOT @@ -72,4 +74,4 @@ function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$sub } -?> +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/shared.escape_special_chars.php b/modules/thirdparty/smarty/plugins/shared.escape_special_chars.php old mode 100644 new mode 100755 index c07ce31..e36b2c8 --- a/modules/thirdparty/smarty/plugins/shared.escape_special_chars.php +++ b/modules/thirdparty/smarty/plugins/shared.escape_special_chars.php @@ -1,11 +1,11 @@ +?> \ No newline at end of file diff --git a/modules/thirdparty/smarty/plugins/shared.make_timestamp.php b/modules/thirdparty/smarty/plugins/shared.make_timestamp.php old mode 100644 new mode 100755 index b42eb11..9789f53 --- a/modules/thirdparty/smarty/plugins/shared.make_timestamp.php +++ b/modules/thirdparty/smarty/plugins/shared.make_timestamp.php @@ -1,46 +1,43 @@ * Purpose: used by other smarty functions to make a timestamp * from a string. * @author Monte Ohrt - * @param string + * @param string $string * @return string */ + function smarty_make_timestamp($string) { if(empty($string)) { // use "now": - $time = time(); - - } elseif (preg_match('/^\d{14}$/', $string)) { + return time(); + } elseif ($string instanceof DateTime) { + return $string->getTimestamp(); + } elseif (strlen($string)==14 && ctype_digit($string)) { // it is mysql timestamp format of YYYYMMDDHHMMSS? - $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), + return mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4)); - } elseif (is_numeric($string)) { // it is a numeric string, we handle it as timestamp - $time = (int)$string; - + return (int)$string; } else { // strtotime should handle it $time = strtotime($string); if ($time == -1 || $time === false) { // strtotime() was not able to parse $string, use "now": - $time = time(); + return time(); } + return $time; } - return $time; - } -/* vim: set expandtab: */ - ?> diff --git a/modules/thirdparty/stonecrypt/test.php b/modules/thirdparty/stonecrypt/test.php index 9b6036e..e9ac9f3 100755 --- a/modules/thirdparty/stonecrypt/test.php +++ b/modules/thirdparty/stonecrypt/test.php @@ -7,7 +7,7 @@ - +