Permalink
Browse files

Merge pull request #361 from haraldpdl/sites

Sites
  • Loading branch information...
2 parents 74a4e9b + 476fe57 commit 77e87dd3f8a2af8a0f59d88a9df8b34a6e2e9c4b @haraldpdl haraldpdl committed Jul 22, 2015
Showing with 1,745 additions and 1,118 deletions.
  1. +1 −1 .gitignore
  2. +1 −1 catalog/account.php
  3. +1 −1 catalog/account_edit.php
  4. +1 −1 catalog/account_history.php
  5. +1 −1 catalog/account_history_info.php
  6. +1 −1 catalog/account_newsletters.php
  7. +1 −1 catalog/account_notifications.php
  8. +1 −1 catalog/account_password.php
  9. +1 −1 catalog/address_book.php
  10. +1 −1 catalog/address_book_process.php
  11. +0 −26 catalog/admin/apps.php
  12. +4 −181 catalog/admin/includes/application_top.php
  13. +1 −1 catalog/admin/includes/column_left.php
  14. +15 −103 catalog/admin/index.php
  15. +1 −6 catalog/admin/modules.php
  16. +12 −14 catalog/admin/modules_content.php
  17. +2 −2 catalog/admin/modules_hooks.php
  18. +1 −1 catalog/checkout_confirmation.php
  19. +1 −1 catalog/checkout_payment.php
  20. +1 −1 catalog/checkout_payment_address.php
  21. +1 −1 catalog/checkout_process.php
  22. +1 −1 catalog/checkout_shipping.php
  23. +1 −1 catalog/checkout_shipping_address.php
  24. +1 −1 catalog/cookie_usage.php
  25. +1 −1 catalog/create_account.php
  26. +1 −1 catalog/ext/modules/content/account/braintree/cards.php
  27. +1 −1 catalog/ext/modules/content/account/sage_pay/cards.php
  28. +1 −1 catalog/ext/modules/content/account/set_password.php
  29. +1 −1 catalog/ext/modules/payment/sage_pay/checkout.php
  30. +1 −1 catalog/ext/modules/payment/sage_pay/direct_3dauth.php
  31. +1 −1 catalog/ext/modules/payment/sage_pay/redirect.php
  32. +56 −3 catalog/includes/OSC/OM/AppAbstract.php
  33. +100 −26 catalog/includes/OSC/OM/Apps.php
  34. +4 −2 catalog/includes/OSC/OM/HTTP.php
  35. +3 −3 catalog/includes/OSC/OM/Modules/AdminDashboard.php
  36. +3 −3 catalog/includes/OSC/OM/Modules/AdminMenu.php
  37. +3 −3 catalog/includes/OSC/OM/Modules/Content.php
  38. +3 −3 catalog/includes/OSC/OM/Modules/Hooks.php
  39. +3 −3 catalog/includes/OSC/OM/Modules/Payment.php
  40. +1 −1 catalog/includes/OSC/OM/ModulesAbstract.php
  41. +36 −8 catalog/includes/OSC/OM/OSCOM.php
  42. +101 −0 catalog/includes/OSC/OM/PagesAbstract.php
  43. +25 −0 catalog/includes/OSC/OM/PagesActionsAbstract.php
  44. +15 −0 catalog/includes/OSC/OM/PagesActionsInterface.php
  45. +15 −0 catalog/includes/OSC/OM/PagesInterface.php
  46. +50 −0 catalog/includes/OSC/OM/SitesAbstract.php
  47. +16 −0 catalog/includes/OSC/OM/SitesInterface.php
  48. +214 −0 catalog/includes/OSC/Sites/Admin/Admin.php
  49. +13 −0 catalog/includes/OSC/Sites/Admin/Pages/Dashboard/Dashboard.php
  50. +108 −0 catalog/includes/OSC/Sites/Admin/Pages/Dashboard/templates/main.php
  51. +13 −0 catalog/includes/OSC/Sites/Shop/Pages/Account/Account.php
  52. +46 −0 catalog/includes/OSC/Sites/Shop/Pages/Account/Actions/LogIn.php
  53. +58 −0 catalog/includes/OSC/Sites/Shop/Pages/Account/Actions/LogIn/Process.php
  54. +39 −0 catalog/includes/OSC/Sites/Shop/Pages/Account/templates/login.php
  55. +13 −0 catalog/includes/OSC/Sites/Shop/Pages/Home/Home.php
  56. +341 −0 catalog/includes/OSC/Sites/Shop/Pages/Home/templates/main.php
  57. +295 −0 catalog/includes/OSC/Sites/Shop/Shop.php
  58. +24 −246 catalog/includes/application_top.php
  59. +27 −5 catalog/includes/classes/order.php
  60. +25 −0 catalog/includes/error_documents/404.php
  61. +1 −1 catalog/includes/functions/general.php
  62. +0 −1 catalog/includes/modules/boxes/bm_languages.php
  63. +4 −4 catalog/includes/modules/content/footer/cm_footer_account.php
  64. +3 −2 catalog/includes/modules/content/login/cm_login_form.php
  65. +5 −5 catalog/includes/modules/content/login/templates/login_form.php
  66. +1 −2 catalog/includes/modules/content/navigation/templates/navbar.php
  67. +0 −1 catalog/includes/modules/header_tags/ht_google_adwords_conversion.php
  68. +0 −1 catalog/includes/modules/social_bookmarks/sb_google_plus_one.php
  69. +0 −1 catalog/includes/modules/social_bookmarks/sb_google_plus_share.php
  70. +15 −336 catalog/index.php
  71. +0 −94 catalog/login.php
  72. +2 −2 catalog/password_forgotten.php
  73. +2 −2 catalog/password_reset.php
  74. +1 −1 catalog/product_reviews_write.php
  75. +1 −1 catalog/ssl_check.php
  76. +1 −1 catalog/tell_a_friend.php
View
2 .gitignore
@@ -2,5 +2,5 @@ catalog/includes/local/configure.php
catalog/admin/includes/local/configure.php
catalog/includes/work/*
catalog/admin/images/graphs/*.png
-catalog/includes/Apps/*
+catalog/includes/OSC/Apps/*
catalog/public/Apps/*
View
2 catalog/account.php
@@ -16,7 +16,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
require(DIR_WS_LANGUAGES . $_SESSION['language'] . '/account.php');
View
2 catalog/account_edit.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// needs to be included earlier to set the success message in the messageStack
View
2 catalog/account_history.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
require(DIR_WS_LANGUAGES . $_SESSION['language'] . '/account_history.php');
View
2 catalog/account_history_info.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
if (!isset($_GET['order_id']) || !is_numeric($_GET['order_id'])) {
View
2 catalog/account_newsletters.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// needs to be included earlier to set the success message in the messageStack
View
2 catalog/account_notifications.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// needs to be included earlier to set the success message in the messageStack
View
2 catalog/account_password.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// needs to be included earlier to set the success message in the messageStack
View
2 catalog/address_book.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
require(DIR_WS_LANGUAGES . $_SESSION['language'] . '/address_book.php');
View
2 catalog/address_book_process.php
@@ -17,7 +17,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// needs to be included earlier to set the success message in the messageStack
View
26 catalog/admin/apps.php
@@ -1,26 +0,0 @@
-<?php
-/**
- * osCommerce Online Merchant
- *
- * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
- * @license GPL; http://www.oscommerce.com/gpllicense.txt
- */
-
-use OSC\OM\Apps;
-use OSC\OM\OSCOM;
-
-require('includes/application_top.php');
-
-if (empty($_GET)) {
- OSCOM::redirect('index.php');
-}
-
-$app = basename(array_keys($_GET)[0]);
-
-if (Apps::exists($app) && file_exists(OSCOM::BASE_DIR . 'Apps/' . $app . '/admin/content.php')) {
- include(OSCOM::BASE_DIR . 'Apps/' . $app . '/admin/content.php');
-} else {
- OSCOM::redirect('index.php');
-}
-
-require('includes/application_bottom.php');
View
185 catalog/admin/includes/application_top.php
@@ -10,11 +10,7 @@
Released under the GNU General Public License
*/
- use OSC\OM\Cache;
- use OSC\OM\Db;
- use OSC\OM\Hooks;
use OSC\OM\OSCOM;
- use OSC\OM\Registry;
// Start the clock for the page parse time log
define('PAGE_PARSE_START_TIME', microtime());
@@ -33,196 +29,29 @@
require(OSCOM_BASE_DIR . 'OSC/OM/OSCOM.php');
spl_autoload_register('OSC\OM\OSCOM::autoload');
- OSCOM::initialize();
- OSCOM::setSite('Admin');
-
-// set the type of request (secure or not)
- if ( (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on')) || (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == 443)) ) {
- $request_type = 'SSL';
-// set the cookie domain
- $cookie_domain = HTTPS_COOKIE_DOMAIN;
- $cookie_path = HTTPS_COOKIE_PATH;
- } else {
- $request_type = 'NONSSL';
- $cookie_domain = HTTP_COOKIE_DOMAIN;
- $cookie_path = HTTP_COOKIE_PATH;
- }
-
-// set php_self in the local scope
- $req = parse_url($_SERVER['SCRIPT_NAME']);
- $PHP_SELF = substr($req['path'], ($request_type == 'SSL') ? strlen(DIR_WS_HTTPS_ADMIN) : strlen(DIR_WS_ADMIN));
-
-// Used in the "Backup Manager" to compress backups
- define('LOCAL_EXE_GZIP', 'gzip');
- define('LOCAL_EXE_GUNZIP', 'gunzip');
- define('LOCAL_EXE_ZIP', 'zip');
- define('LOCAL_EXE_UNZIP', 'unzip');
-
-// include the list of project filenames
require(DIR_WS_INCLUDES . 'filenames.php');
-
-// include the list of project database tables
require(DIR_WS_INCLUDES . 'database_tables.php');
-
-// Define how do we update currency exchange rates
-// Possible values are 'oanda' 'xe' or ''
- define('CURRENCY_SERVER_PRIMARY', 'oanda');
- define('CURRENCY_SERVER_BACKUP', 'xe');
-
-// include the database functions
require(DIR_WS_FUNCTIONS . 'database.php');
-
-// make a connection to the database... now
- tep_db_connect() or die('Unable to connect to database server!');
-
- Registry::set('Cache', new Cache());
- Registry::set('Db', Db::initialize());
- $OSCOM_Db = Registry::get('Db');
-
-// set the application parameters
- $Qcfg = $OSCOM_Db->get('configuration', ['configuration_key as k', 'configuration_value as v']);//, null, null, null, 'configuration'); // TODO add cache when supported by admin
-
- while ($Qcfg->fetch()) {
- define($Qcfg->value('k'), $Qcfg->value('v'));
- }
-
-// define our general functions used application-wide
require(DIR_WS_FUNCTIONS . 'general.php');
require(DIR_WS_FUNCTIONS . 'html_output.php');
-
-// initialize the logger class
require(DIR_WS_CLASSES . 'logger.php');
-
-// include shopping cart class
require(DIR_WS_CLASSES . 'shopping_cart.php');
-
-// define how the session functions will be used
require(DIR_WS_FUNCTIONS . 'sessions.php');
-
-// set the session name and save path
- tep_session_name('osCAdminID');
- tep_session_save_path(SESSION_WRITE_DIRECTORY);
-
-// set the session cookie parameters
- if (function_exists('session_set_cookie_params')) {
- session_set_cookie_params(0, $cookie_path, $cookie_domain);
- } elseif (function_exists('ini_set')) {
- ini_set('session.cookie_lifetime', '0');
- ini_set('session.cookie_path', $cookie_path);
- ini_set('session.cookie_domain', $cookie_domain);
- }
-
- @ini_set('session.use_only_cookies', (SESSION_FORCE_COOKIE_USE == 'True') ? 1 : 0);
-
-// lets start our session
- tep_session_start();
-
-// TODO remove when no more global sessions exist
- extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS);
-
-
-// set the language
- if (!tep_session_is_registered('language') || isset($_GET['language'])) {
- if (!tep_session_is_registered('language')) {
- tep_session_register('language');
- tep_session_register('languages_id');
- }
-
- include(DIR_WS_CLASSES . 'language.php');
- $lng = new language();
-
- if (isset($_GET['language']) && tep_not_null($_GET['language'])) {
- $lng->set_language($_GET['language']);
- } else {
- $lng->get_browser_language();
- }
-
- $language = $lng->language['directory'];
- $languages_id = $lng->language['id'];
- }
-
-// redirect to login page if administrator is not yet logged in
- if (!tep_session_is_registered('admin')) {
- $redirect = false;
-
- $current_page = $PHP_SELF;
-
-// if the first page request is to the login page, set the current page to the index page
-// so the redirection on a successful login is not made to the login page again
- if ( ($current_page == FILENAME_LOGIN) && !tep_session_is_registered('redirect_origin') ) {
- $current_page = FILENAME_DEFAULT;
- $_GET = array();
- }
-
- if ($current_page != FILENAME_LOGIN) {
- if (!tep_session_is_registered('redirect_origin')) {
- tep_session_register('redirect_origin');
-
- $redirect_origin = array('page' => $current_page,
- 'get' => $_GET);
- }
-
-// try to automatically login with the HTTP Authentication values if it exists
- if (!tep_session_is_registered('auth_ignore')) {
- if (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($_SERVER['PHP_AUTH_PW'])) {
- $redirect_origin['auth_user'] = $_SERVER['PHP_AUTH_USER'];
- $redirect_origin['auth_pw'] = $_SERVER['PHP_AUTH_PW'];
- }
- }
-
- $redirect = true;
- }
-
- if (!isset($login_request) || isset($_GET['login_request']) || isset($_POST['login_request']) || isset($_COOKIE['login_request']) || isset($_SESSION['login_request']) || isset($_FILES['login_request']) || isset($_SERVER['login_request'])) {
- $redirect = true;
- }
-
- if ($redirect == true) {
- tep_redirect(tep_href_link(FILENAME_LOGIN, (isset($redirect_origin['auth_user']) ? 'action=process' : '')));
- }
-
- unset($redirect);
- }
-
-// include the language translations
- $_system_locale_numeric = setlocale(LC_NUMERIC, 0);
- require(DIR_WS_LANGUAGES . $language . '.php');
- setlocale(LC_NUMERIC, $_system_locale_numeric); // Prevent LC_ALL from setting LC_NUMERIC to a locale with 1,0 float/decimal values instead of 1.0 (see bug #634)
-
- $current_page = basename($PHP_SELF);
- if (file_exists(DIR_WS_LANGUAGES . $language . '/' . $current_page)) {
- include(DIR_WS_LANGUAGES . $language . '/' . $current_page);
- }
-
-// define our localization functions
+ require(DIR_WS_CLASSES . 'language.php');
require(DIR_WS_FUNCTIONS . 'localization.php');
-
-// Include validation functions (right now only email address)
require(DIR_WS_FUNCTIONS . 'validations.php');
-
-// setup our boxes
require(DIR_WS_CLASSES . 'table_block.php');
require(DIR_WS_CLASSES . 'box.php');
-
-// initialize the message stack for output messages
require(DIR_WS_CLASSES . 'message_stack.php');
- $messageStack = new messageStack;
-
-// split-page-results
require(DIR_WS_CLASSES . 'split_page_results.php');
-
-// entry/item info classes
require(DIR_WS_CLASSES . 'object_info.php');
-
-// email classes
require(DIR_WS_CLASSES . 'mime.php');
require(DIR_WS_CLASSES . 'email.php');
-
-// file uploading class
require(DIR_WS_CLASSES . 'upload.php');
-
-// action recorder
require(DIR_WS_CLASSES . 'action_recorder.php');
+ require(DIR_WS_CLASSES . 'cfg_modules.php');
+
+ OSCOM::initialize('Admin');
// calculate category path
if (isset($_GET['cPath'])) {
@@ -239,16 +68,10 @@
$current_category_id = 0;
}
-// initialize configuration modules
- require(DIR_WS_CLASSES . 'cfg_modules.php');
- $cfgModules = new cfg_modules();
-
// the following cache blocks are used in the Tools->Cache section
// ('language' in the filename is automatically replaced by available languages)
$cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true),
array('title' => TEXT_CACHE_MANUFACTURERS, 'code' => 'manufacturers', 'file' => 'manufacturers_box-language.cache', 'multiple' => true),
array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true)
);
-
- Registry::set('Hooks', new Hooks());
?>
View
2 catalog/admin/includes/column_left.php
@@ -86,7 +86,7 @@ function tep_sort_admin_boxes_links($a, $b) {
$menu_found = false;
foreach ($cl_box_groups as $groups) {
foreach ($groups['apps'] as $app) {
- if (($app['code'] == $PHP_SELF) || (!empty($_GET) && (strncmp($app['code'], 'App/', 4) === 0) && (substr($app['code'], 4) == array_keys($_GET)[0]))){
+ if (($app['code'] == $PHP_SELF) || ((count($_GET) > 1) && ($app['code'] == array_keys($_GET)[1]))) {
$menu_found = true;
break 2;
}
View
118 catalog/admin/index.php
@@ -1,111 +1,23 @@
<?php
-/*
- $Id$
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
+use OSC\OM\OSCOM;
- Copyright (c) 2010 osCommerce
+require('includes/application_top.php');
- Released under the GNU General Public License
-*/
+if (OSCOM::isRPC() === false) {
+ $page_file = OSCOM::getSitePageFile();
- use OSC\OM\Apps;
-
- require('includes/application_top.php');
-
- $languages = tep_get_languages();
- $languages_array = array();
- $languages_selected = DEFAULT_LANGUAGE;
- for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
- $languages_array[] = array('id' => $languages[$i]['code'],
- 'text' => $languages[$i]['name']);
- if ($languages[$i]['directory'] == $language) {
- $languages_selected = $languages[$i]['code'];
+ if (empty($page_file) || !file_exists($page_file)) {
+ $page_file = DIR_FS_CATALOG . 'includes/error_documents/404.php';
}
- }
-
- require(DIR_WS_INCLUDES . 'template_top.php');
-?>
-
- <table border="0" width="100%" cellspacing="0" cellpadding="2">
- <tr>
- <td><table border="0" width="100%" cellspacing="0" cellpadding="2" height="40">
- <tr>
- <td class="pageHeading"><?php echo STORE_NAME; ?></td>
-
-<?php
- if (sizeof($languages_array) > 1) {
-?>
-
- <td class="pageHeading" align="right"><?php echo tep_draw_form('adminlanguage', FILENAME_DEFAULT, '', 'get') . tep_draw_pull_down_menu('language', $languages_array, $languages_selected, 'onchange="this.form.submit();"') . tep_hide_session_id() . '</form>'; ?></td>
-
-<?php
- }
-?>
-
- </tr>
- </table></td>
- </tr>
- <tr>
- <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
-<?php
- if ( defined('MODULE_ADMIN_DASHBOARD_INSTALLED') && tep_not_null(MODULE_ADMIN_DASHBOARD_INSTALLED) ) {
- $adm_array = explode(';', MODULE_ADMIN_DASHBOARD_INSTALLED);
-
- $col = 0;
-
- for ( $i=0, $n=sizeof($adm_array); $i<$n; $i++ ) {
- $adm = $adm_array[$i];
- if (strpos($adm, '\\') !== false) {
- $class = Apps::getModuleClass($adm, 'AdminDashboard');
- } else {
- $class = substr($adm, 0, strrpos($adm, '.'));
+ include($page_file);
+}
- if ( !class_exists($class) ) {
- include(DIR_WS_LANGUAGES . $language . '/modules/dashboard/' . $adm);
- include(DIR_WS_MODULES . 'dashboard/' . $class . '.php');
- }
- }
-
- $ad = new $class();
-
- if ( $ad->isEnabled() ) {
- if ($col < 1) {
- echo ' <tr>' . "\n";
- }
-
- $col++;
-
- if ($col <= 2) {
- echo ' <td width="50%" valign="top">' . "\n";
- }
-
- echo $ad->getOutput();
-
- if ($col <= 2) {
- echo ' </td>' . "\n";
- }
-
- if ( !isset($adm_array[$i+1]) || ($col == 2) ) {
- if ( !isset($adm_array[$i+1]) && ($col == 1) ) {
- echo ' <td width="50%" valign="top">&nbsp;</td>' . "\n";
- }
-
- $col = 0;
-
- echo ' </tr>' . "\n";
- }
- }
- }
- }
-?>
- </table></td>
- </tr>
- </table>
-
-<?php
- require(DIR_WS_INCLUDES . 'template_bottom.php');
- require(DIR_WS_INCLUDES . 'application_bottom.php');
-?>
+require('includes/application_bottom.php');
View
7 catalog/admin/modules.php
@@ -11,7 +11,6 @@
*/
use OSC\OM\Apps;
- use OSC\OM\OSCOM;
use OSC\OM\Registry;
require('includes/application_top.php');
@@ -241,11 +240,7 @@
$module_info['keys'] = $keys_extra;
- if (strpos($module->code, '\\') !== false) {
- $module_info['code'] = addslashes($module->code);
- }
-
- $mInfo = new objectInfo($module_info);
+ $mInfo = new \ArrayObject($module_info, \ArrayObject::ARRAY_AS_PROPS);
}
if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {
View
26 catalog/admin/modules_content.php
@@ -164,6 +164,10 @@ function _sortContentModuleFiles($a, $b) {
if ( $m['code'] == $code ) {
if (strpos($code, '\\') !== false) {
$class = Apps::getModuleClass($code, 'Content');
+
+ $installed_code = $m['code'];
+ } else {
+ $installed_code = $m['group'] . '/' . $m['code'];
}
$module = new $class();
@@ -172,8 +176,8 @@ function _sortContentModuleFiles($a, $b) {
$modules_installed = explode(';', MODULE_CONTENT_INSTALLED);
- if (in_array($m['group'] . '/' . $m['code'], $modules_installed)) {
- unset($modules_installed[array_search($m['group'] . '/' . $m['code'], $modules_installed)]);
+ if (in_array($installed_code, $modules_installed)) {
+ unset($modules_installed[array_search($installed_code, $modules_installed)]);
}
Registry::get('Db')->save('configuration', ['configuration_value' => implode(';', $modules_installed), 'last_modified' => 'now()'], ['configuration_key' => 'MODULE_CONTENT_INSTALLED']);
@@ -226,6 +230,7 @@ function _sortContentModuleFiles($a, $b) {
$class = Apps::getModuleClass($m['code'], 'Content');
$module = new $class();
+ $module->code = $m['code'];
} else {
$module = new $m['code']();
}
@@ -237,11 +242,7 @@ function _sortContentModuleFiles($a, $b) {
'signature' => (isset($module->signature) ? $module->signature : null),
'api_version' => (isset($module->api_version) ? $module->api_version : null));
- if (strpos($module->code, '\\') !== false) {
- $module_info['code'] = addslashes($module->code);
- }
-
- $mInfo = new objectInfo($module_info);
+ $mInfo = new \ArrayObject($module_info, \ArrayObject::ARRAY_AS_PROPS);
}
if (isset($mInfo) && is_object($mInfo) && ($module->code == $mInfo->code) ) {
@@ -252,7 +253,7 @@ function _sortContentModuleFiles($a, $b) {
?>
<td class="dataTableContent"><?php echo $module->title; ?></td>
<td class="dataTableContent"><?php echo $module->group; ?></td>
- <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($module->code == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link('modules_content.php', 'action=list_new&module=' . addslashes($module->code)) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
+ <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($module->code == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link('modules_content.php', 'action=list_new&module=' . $module->code) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
</tr>
<?php
}
@@ -274,6 +275,7 @@ function _sortContentModuleFiles($a, $b) {
$class = Apps::getModuleClass($m['code'], 'Content');
$module = new $class();
+ $module->code = $m['code'];
} else {
$module = new $m['code']();
}
@@ -300,11 +302,7 @@ function _sortContentModuleFiles($a, $b) {
'set_function' => $key_value['set_function']);
}
- if (strpos($module->code, '\\') !== false) {
- $module_info['code'] = addslashes($module->code);
- }
-
- $mInfo = new objectInfo($module_info);
+ $mInfo = new \ArrayObject($module_info, \ArrayObject::ARRAY_AS_PROPS);
}
if (isset($mInfo) && is_object($mInfo) && ($module->code == $mInfo->code) ) {
@@ -316,7 +314,7 @@ function _sortContentModuleFiles($a, $b) {
<td class="dataTableContent"><?php echo $module->title; ?></td>
<td class="dataTableContent"><?php echo $module->group; ?></td>
<td class="dataTableContent"><?php echo $module->sort_order; ?></td>
- <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($module->code == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link('modules_content.php', 'module=' . addslashes($module->code)) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
+ <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($module->code == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link('modules_content.php', 'module=' . $module->code) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
</tr>
<?php
}
View
4 catalog/admin/modules_hooks.php
@@ -55,14 +55,14 @@
}
foreach (Apps::getModules('Hooks') as $k => $v) {
- list($app, $code) = explode('\\', $k, 2);
+ list($vendor, $app, $code) = explode('\\', $k, 3);
$h = new \ReflectionClass($v);
foreach ($h->getMethods(\ReflectionMethod::IS_STATIC | \ReflectionMethod::IS_PUBLIC) as $method) {
if ($method->name != '__construct') {
$hooks[$code][] = [
- 'app' => $app,
+ 'app' => $vendor . '\\' . $app,
'method' => $method->name
];
}
View
2 catalog/checkout_confirmation.php
@@ -19,7 +19,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => 'checkout_payment.php'));
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/checkout_payment.php
@@ -18,7 +18,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/checkout_payment_address.php
@@ -18,7 +18,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/checkout_process.php
@@ -19,7 +19,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => 'checkout_payment.php'));
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/checkout_shipping.php
@@ -19,7 +19,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/checkout_shipping_address.php
@@ -18,7 +18,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/cookie_usage.php
@@ -41,7 +41,7 @@
</div>
<div class="text-right">
- <?php echo HTML::button(IMAGE_BUTTON_CONTINUE, 'glyphicon glyphicon-chevron-right', OSCOM::link('login.php'), null, null, 'btn-success'); ?>
+ <?php echo HTML::button(IMAGE_BUTTON_CONTINUE, 'glyphicon glyphicon-chevron-right', OSCOM::link('index.php', 'Account&LogIn'), null, null, 'btn-success'); ?>
</div>
</div>
View
2 catalog/create_account.php
@@ -271,7 +271,7 @@
}
?>
-<div class="alert alert-info"><?php echo sprintf(TEXT_ORIGIN_LOGIN, OSCOM::link('login.php', tep_get_all_get_params(), 'SSL')); ?></div>
+<div class="alert alert-info"><?php echo sprintf(TEXT_ORIGIN_LOGIN, OSCOM::link('index.php', 'Account&LogIn&' . tep_get_all_get_params(['Account', 'LogIn']), 'SSL')); ?></div>
<?php echo HTML::form('create_account', OSCOM::link('create_account.php', '', 'SSL'), 'post', 'class="form-horizontal" role="form"', ['tokenize' => true, 'action' => 'process']); ?>
View
2 catalog/ext/modules/content/account/braintree/cards.php
@@ -18,7 +18,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
if ( defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED) && in_array('braintree_cc.php', explode(';', MODULE_PAYMENT_INSTALLED)) ) {
View
2 catalog/ext/modules/content/account/sage_pay/cards.php
@@ -18,7 +18,7 @@
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot();
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
if ( defined('MODULE_PAYMENT_INSTALLED') && tep_not_null(MODULE_PAYMENT_INSTALLED) && in_array('sage_pay_direct.php', explode(';', MODULE_PAYMENT_INSTALLED)) ) {
View
2 catalog/ext/modules/content/account/set_password.php
@@ -17,7 +17,7 @@
require('includes/application_top.php');
if (!isset($_SESSION['customer_id'])) {
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
if ( MODULE_CONTENT_ACCOUNT_SET_PASSWORD_ALLOW_PASSWORD != 'True' ) {
View
2 catalog/ext/modules/payment/sage_pay/checkout.php
@@ -19,7 +19,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => 'checkout_payment.php'));
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
// if there is nothing in the customers cart, redirect them to the shopping cart page
View
2 catalog/ext/modules/payment/sage_pay/direct_3dauth.php
@@ -18,7 +18,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => 'checkout_payment.php'));
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
if (!isset($_SESSION['sage_pay_direct_acsurl'])) {
View
2 catalog/ext/modules/payment/sage_pay/redirect.php
@@ -19,7 +19,7 @@
// if the customer is not logged on, redirect them to the login page
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => 'checkout_payment.php'));
- OSCOM::redirect('login.php', '', 'SSL');
+ OSCOM::redirect('index.php', 'Account&LogIn', 'SSL');
}
if ( isset($_GET['payment_error']) && tep_not_null($_GET['payment_error']) ) {
View
59 catalog/includes/OSC/OM/AppAbstract.php
@@ -8,10 +8,13 @@
namespace OSC\OM;
+use OSC\OM\OSCOM;
+
abstract class AppAbstract
{
public $code;
public $title;
+ public $vendor;
public $version;
public $modules = [];
@@ -23,11 +26,56 @@
$this->init();
}
+ final public function link()
+ {
+ $args = func_get_args();
+
+ $parameters = 'A&' . $this->vendor . '\\' . $this->code;
+
+ if (isset($args[0])) {
+ $args[0] = $parameters .= '&' . $args[0];
+ } else {
+ $args[0] = $parameters;
+ }
+
+ array_unshift($args, 'index.php');
+
+ return forward_static_call_array([
+ 'OSC\OM\OSCOM',
+ 'link'
+ ], $args);
+ }
+
+ final public function redirect()
+ {
+ $args = func_get_args();
+
+ $parameters = 'A&' . $this->vendor . '\\' . $this->code;
+
+ if (isset($args[0])) {
+ $args[0] = $parameters .= '&' . $args[0];
+ } else {
+ $args[0] = $parameters;
+ }
+
+ array_unshift($args, 'index.php');
+
+ return forward_static_call_array([
+ 'OSC\OM\OSCOM',
+ 'redirect'
+ ], $args);
+ }
+
final public function getCode()
{
return $this->code;
}
+ final public function getVendor()
+ {
+ return $this->vendor;
+ }
+
final public function getTitle()
{
return $this->title;
@@ -49,10 +97,15 @@
final private function setInfo()
{
- $this->code = (new \ReflectionClass($this))->getShortName();
+ $r = new \ReflectionClass($this);
+
+ $this->code = $r->getShortName();
+ $this->vendor = array_slice(explode('\\', $r->getNamespaceName()), -1)[0];
+
+ $metafile = OSCOM::BASE_DIR . 'OSC/Apps/' . $this->vendor . '/' . $this->code . '/oscommerce.json';
- if (!file_exists(OSCOM::BASE_DIR . 'Apps/' . $this->code . '/oscommerce.json') || (($json = @json_decode(file_get_contents(OSCOM::BASE_DIR . 'Apps/' . $this->code . '/oscommerce.json'), true)) === null)) {
- trigger_error('OSC\OM\AppAbstract::setInfo(): ' . $this->code . ' - Could not read App information in ' . OSCOM::BASE_DIR . 'Apps/' . $this->code . '/oscommerce.json.');
+ if (!file_exists($metafile) || (($json = @json_decode(file_get_contents($metafile), true)) === null)) {
+ trigger_error('OSC\OM\AppAbstract::setInfo(): ' . $this->vendor . '\\' . $this->code . ' - Could not read App information in ' . $metafile . '.');
return false;
}
View
126 catalog/includes/OSC/OM/Apps.php
@@ -13,7 +13,7 @@
class Apps
{
- public static function getModules($type, $app = null, $filter = null)
+ public static function getModules($type, $filter_vendor_app = null, $filter = null)
{
$result = [];
@@ -31,21 +31,37 @@ public static function getModules($type, $app = null, $filter = null)
$OSCOM_Type = Registry::get('ModuleType' . $type);
- $directory = OSCOM::BASE_DIR . 'Apps';
+ $filter_vendor = $filter_app = null;
- if (file_exists($directory)) {
- if ($dir = new \DirectoryIterator($directory)) {
- foreach ($dir as $file) {
- if (!$file->isDot() && $file->isDir() && (!isset($app) || ($file->getFilename() == $app)) && static::exists($file->getFilename()) && (($json = static::getInfo($file->getFilename())) !== false)) {
- if (isset($json['modules'][$type])) {
- $modules = $json['modules'][$type];
-
- if (isset($filter)) {
- $modules = $OSCOM_Type->filter($modules, $filter);
- }
+ if (isset($filter_vendor_app)) {
+ if (strpos($filter_vendor_app, '\\') !== false) {
+ list($filter_vendor, $filter_app) = explode('\\', $filter_vendor_app, 2);
+ } else {
+ $filter_vendor = $filter_vendor_app;
+ }
+ }
- foreach ($modules as $key => $data) {
- $result = array_merge($result, $OSCOM_Type->getInfo($file->getFilename(), $key, $data));
+ $vendor_directory = OSCOM::BASE_DIR . 'OSC/Apps';
+
+ if (file_exists($vendor_directory)) {
+ if ($vdir = new \DirectoryIterator($vendor_directory)) {
+ foreach ($vdir as $vendor) {
+ if (!$vendor->isDot() && $vendor->isDir() && (!isset($filter_vendor) || ($vendor->getFilename() == $filter_vendor))) {
+ if ($adir = new \DirectoryIterator($vendor->getPath() . '/' . $vendor->getFilename())) {
+ foreach ($adir as $app) {
+ if (!$app->isDot() && $app->isDir() && (!isset($filter_app) || ($app->getFilename() == $filter_app)) && static::exists($vendor->getFilename() . '\\' . $app->getFilename()) && (($json = static::getInfo($vendor->getFilename() . '\\' . $app->getFilename())) !== false)) {
+ if (isset($json['modules'][$type])) {
+ $modules = $json['modules'][$type];
+
+ if (isset($filter)) {
+ $modules = $OSCOM_Type->filter($modules, $filter);
+ }
+
+ foreach ($modules as $key => $data) {
+ $result = array_merge($result, $OSCOM_Type->getInfo($vendor->getFilename() . '\\' . $app->getFilename(), $key, $data));
+ }
+ }
+ }
}
}
}
@@ -58,16 +74,20 @@ public static function getModules($type, $app = null, $filter = null)
public static function exists($app)
{
- $app = basename($app);
-
- if (file_exists(OSCOM::BASE_DIR . 'Apps/' . $app . '/' . $app . '.php')) {
- if (is_subclass_of('OSC\OM\Apps\\' . $app . '\\' . $app, 'OSC\OM\AppAbstract')) {
- return true;
+ if (strpos($app, '\\') !== false) {
+ list($vendor, $app) = explode('\\', $app, 2);
+
+ if (class_exists('OSC\Apps\\' . $vendor . '\\' . $app . '\\' . $app)) {
+ if (is_subclass_of('OSC\Apps\\' . $vendor . '\\' . $app . '\\' . $app, 'OSC\OM\AppAbstract')) {
+ return true;
+ } else {
+ trigger_error('OSC\OM\Apps::exists(): ' . $vendor . '\\' . $app . ' - App is not a subclass of OSC\OM\AppAbstract and cannot be loaded.');
+ }
} else {
- trigger_error('OSC\OM\Apps::exists(): ' . $app . ' - App is not a subclass of OSC\OM\AppAbstract and cannot be loaded.');
+ trigger_error('OSC\OM\Apps::exists(): ' . $vendor . '\\' . $app . ' - App class does not exist.');
}
} else {
- trigger_error('OSC\OM\Apps::exists(): ' . $app . ' - App class does not exist.');
+ trigger_error('OSC\OM\Apps::exists(): ' . $app . ' - Invalid format, must be: Vendor\App.');
}
return false;
@@ -94,14 +114,68 @@ public static function getModuleClass($module, $type)
public static function getInfo($app)
{
- $app = basename($app);
+ if (strpos($app, '\\') !== false) {
+ list($vendor, $app) = explode('\\', $app, 2);
+
+ $metafile = OSCOM::BASE_DIR . 'OSC/Apps/' . basename($vendor) . '/' . basename($app) . '/oscommerce.json';
- if (!file_exists(OSCOM::BASE_DIR . 'Apps/' . $app . '/oscommerce.json') || (($json = @json_decode(file_get_contents(OSCOM::BASE_DIR . 'Apps/' . $app . '/oscommerce.json'), true)) === null)) {
- trigger_error('OSC\OM\Apps::getInfo(): ' . $app . ' - Could not read App information in ' . OSCOM::BASE_DIR . 'Apps/' . $app . '/oscommerce.json.');
+ if (file_exists($metafile) && (($json = @json_decode(file_get_contents($metafile), true)) !== null)) {
+ return $json;
+ }
+
+ trigger_error('OSC\OM\Apps::getInfo(): ' . $vendor . '\\' . $app . ' - Could not read App information in ' . $metafile . '.');
+ } else {
+ trigger_error('OSC\OM\Apps::getInfo(): ' . $app . ' - Invalid format, must be: Vendor\App.');
+ }
- return false;
+ return false;
+ }
+
+ public static function getRouteDestination($route = null, $filter_vendor_app = null)
+ {
+ if (empty($route)) {
+ $route = array_keys($_GET);
+ }
+
+ $result = $routes = [];
+
+ if (empty($route)) {
+ return $result;
+ }
+
+ $filter_vendor = $filter_app = null;
+
+ if (isset($filter_vendor_app)) {
+ if (strpos($filter_vendor_app, '\\') !== false) {
+ list($filter_vendor, $filter_app) = explode('\\', $filter_vendor_app, 2);
+ } else {
+ $filter_vendor = $filter_vendor_app;
+ }
+ }
+
+ $vendor_directory = OSCOM::BASE_DIR . 'OSC/Apps';
+
+ if (file_exists($vendor_directory)) {
+ if ($vdir = new \DirectoryIterator($vendor_directory)) {
+ foreach ($vdir as $vendor) {
+ if (!$vendor->isDot() && $vendor->isDir() && (!isset($filter_vendor) || ($vendor->getFilename() == $filter_vendor))) {
+ if ($adir = new \DirectoryIterator($vendor->getPath() . '/' . $vendor->getFilename())) {
+ foreach ($adir as $app) {
+ if (!$app->isDot() && $app->isDir() && (!isset($filter_app) || ($app->getFilename() == $filter_app)) && static::exists($vendor->getFilename() . '\\' . $app->getFilename()) && (($json = static::getInfo($vendor->getFilename() . '\\' . $app->getFilename())) !== false)) {
+ if (isset($json['routes'][OSCOM::getSite()])) {
+ $routes[$json['vendor'] . '\\' . $json['app']] = $json['routes'][OSCOM::getSite()];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
- return $json;
+ return call_user_func([
+ 'OSC\Sites\\' . OSCOM::getSite() . '\\' . OSCOM::getSite(),
+ 'resolveRoute'
+ ], $route, $routes);
}
}
View
6 catalog/includes/OSC/OM/HTTP.php
@@ -122,9 +122,11 @@ public static function getResponse(array $parameters)
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- curl_close($curl);
+ $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
+ $headers = trim(substr($result, 0, $header_size));
+ $body = substr($result, $header_size);
- list($headers, $body) = explode("\r\n\r\n", $result, 2);
+ curl_close($curl);
if (($http_code == 301) || ($http_code == 302)) {
if (!isset($parameters['redir_counter']) || ($parameters['redir_counter'] < 6)) {
View
6 catalog/includes/OSC/OM/Modules/AdminDashboard.php
@@ -27,12 +27,12 @@ public function getInfo($app, $key, $data)
public function getClass($module)
{
- list($app, $code) = explode('\\', $module, 2);
+ list($vendor, $app, $code) = explode('\\', $module, 3);
- $info = Apps::getInfo($app);
+ $info = Apps::getInfo($vendor . '\\' . $app);
if (isset($info['modules'][$this->code][$code])) {
- return $this->ns . $app . '\\' . $info['modules'][$this->code][$code];
+ return $this->ns . $vendor . '\\' . $app . '\\' . $info['modules'][$this->code][$code];
}
}
}
View
6 catalog/includes/OSC/OM/Modules/AdminMenu.php
@@ -27,12 +27,12 @@ public function getInfo($app, $key, $data)
public function getClass($module)
{
- list($app, $code) = explode('\\', $module, 2);
+ list($vendor, $app, $code) = explode('\\', $module, 3);
- $info = Apps::getInfo($app);
+ $info = Apps::getInfo($vendor . '\\' . $app);
if (isset($info['modules'][$this->code][$code])) {
- return $this->ns . $app . '\\' . $info['modules'][$this->code][$code];
+ return $this->ns . $vendor . '\\' . $app . '\\' . $info['modules'][$this->code][$code];
}
}
}
View
6 catalog/includes/OSC/OM/Modules/Content.php
@@ -30,12 +30,12 @@ public function getInfo($app, $key, $data)
public function getClass($module)
{
list($group, $code) = explode('/', $module, 2);
- list($app, $code) = explode('\\', $code, 2);
+ list($vendor, $app, $code) = explode('\\', $code, 3);
- $info = Apps::getInfo($app);
+ $info = Apps::getInfo($vendor . '\\' . $app);
if (isset($info['modules'][$this->code][$group][$code])) {
- return $this->ns . $app . '\\' . $info['modules'][$this->code][$group][$code];
+ return $this->ns . $vendor . '\\' . $app . '\\' . $info['modules'][$this->code][$group][$code];
}
}
}
View
6 catalog/includes/OSC/OM/Modules/Hooks.php
@@ -33,12 +33,12 @@ public function getClass($module)
return $module;
}
- list($app, $group, $code) = explode('\\', $module, 3);
+ list($vendor, $app, $group, $code) = explode('\\', $module, 4);
- $info = Apps::getInfo($app);
+ $info = Apps::getInfo($vendor . '\\' . $app);
if (isset($info['modules'][$this->code][$group][$code])) {
- return $this->ns . $app . '\\' . $info['modules'][$this->code][$group][$code];
+ return $this->ns . $vendor . '\\' . $app . '\\' . $info['modules'][$this->code][$group][$code];
}
}
View
6 catalog/includes/OSC/OM/Modules/Payment.php
@@ -27,12 +27,12 @@ public function getInfo($app, $key, $data)
public function getClass($module)
{
- list($app, $code) = explode('\\', $module, 2);
+ list($vendor, $app, $code) = explode('\\', $module, 3);
- $info = Apps::getInfo($app);
+ $info = Apps::getInfo($vendor . '\\' . $app);
if (isset($info['modules'][$this->code][$code])) {
- return $this->ns . $app . '\\' . $info['modules'][$this->code][$code];
+ return $this->ns . $vendor . '\\' . $app . '\\' . $info['modules'][$this->code][$code];
}
}
}
View
2 catalog/includes/OSC/OM/ModulesAbstract.php
@@ -12,7 +12,7 @@
{
public $code;
protected $interface;
- protected $ns = 'OSC\OM\Apps\\';
+ protected $ns = 'OSC\Apps\\';
abstract public function getInfo($app, $key, $data);
abstract public function getClass($module);
View
44 catalog/includes/OSC/OM/OSCOM.php
@@ -11,6 +11,7 @@
use OSC\OM\DateTime;
use OSC\OM\HTML;
use OSC\OM\HTTP;
+use OSC\OM\Registry;
class OSCOM
{
@@ -19,9 +20,11 @@ class OSCOM
protected static $version;
protected static $site = 'Shop';
- public static function initialize()
+ public static function initialize($site = null)
{
DateTime::setTimeZone();
+
+ static::setSite($site);
}
public static function getVersion()
@@ -43,14 +46,38 @@ public static function getVersion()
public static function setSite($site)
{
- static::$site = $site;
+ if (!empty($site)) {
+ static::$site = $site;
+ }
+
+ $class = 'OSC\Sites\\' . static::$site . '\\' . static::$site;
+
+ if (is_subclass_of($class, 'OSC\OM\SitesInterface')) {
+ $OSCOM_Site = new $class();
+ Registry::set('Site', $OSCOM_Site);
+
+ $OSCOM_Site->setPage();
+ } else {
+ trigger_error('OSC\OM\OSCOM::setSite() - ' . $site . ': Site does not implement OSC\OM\SitesInterface and cannot be loaded.');
+ exit;
+ }
}
public static function getSite()
{
return static::$site;
}
+ public static function getSitePageFile()
+ {
+ return Registry::get('Site')->getPage()->getFile();
+ }
+
+ public static function isRPC()
+ {
+ return Registry::get('Site')->getPage()->isRPC();
+ }
+
public static function link($page, $parameters = null, $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true)
{
global $request_type;
@@ -161,19 +188,20 @@ public static function redirect()
HTTP::redirect($url);
}
+ public static function hasRoute(array $path)
+ {
+ return array_slice(array_keys($_GET), 0, count($path)) == $path;
+ }
+
public static function autoload($class)
{
- $prefix = 'OSC\OM\\';
+ $prefix = 'OSC\\';
if (strncmp($prefix, $class, strlen($prefix)) !== 0) {
return false;
}
-
- if (strncmp($prefix . 'Apps\\', $class, strlen($prefix . 'Apps\\')) === 0) {
- $file = OSCOM_BASE_DIR . str_replace(['OSC\OM\\', '\\'], ['', '/'], $class) . '.php';
- $custom = OSCOM_BASE_DIR . str_replace(['OSC\OM\\', '\\'], ['OSC\Custom\OM\\', '/'], $class) . '.php';
- } elseif (strncmp($prefix . 'Module\\', $class, strlen($prefix . 'Module\\')) === 0) {
+ if (strncmp($prefix . 'OM\Module\\', $class, strlen($prefix . 'OM\Module\\')) === 0) { // TODO remove and fix namespace
$file = OSCOM_BASE_DIR . str_replace(['OSC\OM\\', '\\'], ['', '/'], $class) . '.php';
$custom = OSCOM_BASE_DIR . str_replace(['OSC\OM\\', '\\'], ['OSC\Custom\OM\\', '/'], $class) . '.php';
} else {
View
101 catalog/includes/OSC/OM/PagesAbstract.php
@@ -0,0 +1,101 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\OM;
+
+use OSC\OM\HTML;
+use OSC\OM\OSCOM;
+
+abstract class PagesAbstract implements \OSC\OM\PagesInterface
+{
+ protected $code;
+ protected $file = 'main.php';
+ protected $site;
+ protected $actions_run = [];
+ protected $ignored_actions = [];
+ protected $is_rpc = false;
+
+ final public function __construct(\OSC\OM\SitesInterface $site)
+ {
+ $this->code = (new \ReflectionClass($this))->getShortName();
+ $this->site = $site;
+
+ $this->init();
+ }
+
+ protected function init()
+ {
+ }
+
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ public function getFile()
+ {
+ if (isset($this->file)) {
+ return OSCOM::BASE_DIR . (new \ReflectionClass($this))->getNamespaceName() . '/templates/' . $this->file;
+ }
+ }
+
+ public function setFile($file)
+ {
+ $this->file = $file;
+ }
+
+ public function runActions()
+ {
+ $furious_pete = [];
+
+ if (count($_GET) > $this->site->actions_index) {
+ $furious_pete = array_keys(array_slice($_GET, $this->site->actions_index, null, true));
+ }
+
+ foreach ($furious_pete as $action) {
+ $action = HTML::sanitize(basename($action));
+
+ $this->actions_run[] = $action;
+
+// get namespace from class name
+ $class = (new \ReflectionClass($this))->getNamespaceName() . '\\Actions\\' . implode('\\', $this->actions_run);
+
+ if (!in_array($action, $this->ignored_actions) && $this->actionExists($class)) {
+ $action = new $class($this);
+
+ $action->execute();
+
+ if ($action->isRPC()) {
+ $this->is_rpc = true;
+ }
+ } else {
+ array_pop($this->actions_run);
+
+ break;
+ }
+ }
+ }
+
+ public function actionExists($action)
+ {
+ if (class_exists($action)) {
+ if (is_subclass_of($action, 'OSC\OM\PagesActionsInterface')) {
+ return true;
+ } else {
+ trigger_error('OSC\OM\PagesAbstract::actionExists() - ' . $action . ': Action does not implement OSC\OM\PagesActionInterface and cannot be loaded.');
+ }
+ }
+
+ return false;
+ }
+
+ public function isRPC()
+ {
+ return ($this->is_rpc === true);
+ }
+}
View
25 catalog/includes/OSC/OM/PagesActionsAbstract.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\OM;
+
+abstract class PagesActionsAbstract implements \OSC\OM\PagesActionsInterface
+{
+ protected $page;
+ protected $is_rpc = false;
+
+ public function __construct(\OSC\OM\PagesInterface $page)
+ {
+ $this->page = $page;
+ }
+
+ public function isRPC()
+ {
+ return ($this->is_rpc === true);
+ }
+}
View
15 catalog/includes/OSC/OM/PagesActionsInterface.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\OM;
+
+interface PagesActionsInterface
+{
+ public function execute();
+ public function isRPC();
+}
View
15 catalog/includes/OSC/OM/PagesInterface.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\OM;
+
+interface PagesInterface
+{
+ public function getFile();
+ public function setFile($file);
+}
View
50 catalog/includes/OSC/OM/SitesAbstract.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\OM;
+
+use OSC\OM\HTML;
+
+abstract class SitesAbstract implements \OSC\OM\SitesInterface
+{
+ protected $code;
+ protected $default_page = 'Home';
+ protected $page;
+ protected $app;
+ protected $route;
+ public $actions_index = 1;
+
+ abstract protected function init();
+ abstract public function setPage();
+
+ final public function __construct()
+ {
+ $this->code = (new \ReflectionClass($this))->getShortName();
+
+ return $this->init();
+ }
+
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ public function getPage()
+ {
+ return $this->page;
+ }
+
+ public function getRoute()
+ {
+ return $this->route;
+ }
+
+ public static function resolveRoute(array $route, array $routes)
+ {
+ }
+}
View
16 catalog/includes/OSC/OM/SitesInterface.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\OM;
+
+interface SitesInterface
+{
+ public function getPage();
+ public function setPage();
+ public static function resolveRoute(array $route, array $routes);
+}
View
214 catalog/includes/OSC/Sites/Admin/Admin.php
@@ -0,0 +1,214 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2015 osCommerce; http://www.oscommerce.com
+ * @license GPL; http://www.oscommerce.com/gpllicense.txt
+ */
+
+namespace OSC\Sites\Admin;
+
+use OSC\OM\Apps;
+use OSC\OM\Cache;
+use OSC\OM\Db;
+use OSC\OM\Hooks;
+use OSC\OM\OSCOM;
+use OSC\OM\Registry;
+
+class Admin extends \OSC\OM\SitesAbstract
+{
+ public $default_page = 'Dashboard';
+
+ protected function init()
+ {
+ global $request_type, $cookie_domain, $cookie_path, $PHP_SELF, $login_request, $messageStack, $cfgModules;
+
+ Registry::set('Cache', new Cache());
+
+ $OSCOM_Db = Db::initialize();
+ Registry::set('Db', $OSCOM_Db);
+
+// TODO legacy
+ tep_db_connect() or die('Unable to connect to database server!');
+
+// set the application parameters
+ $Qcfg = $OSCOM_Db->get('configuration', [
+ 'configuration_key as k',
+ 'configuration_value as v'
+ ]);//, null, null, null, 'configuration'); // TODO add cache when supported by admin
+
+ while ($Qcfg->fetch()) {
+ define($Qcfg->value('k'), $Qcfg->value('v'));
+ }
+
+// Used in the "Backup Manager" to compress backups
+ define('LOCAL_EXE_GZIP', 'gzip');
+ define('LOCAL_EXE_GUNZIP', 'gunzip');
+ define('LOCAL_EXE_ZIP', 'zip');
+ define('LOCAL_EXE_UNZIP', 'unzip');
+
+// Define how do we update currency exchange rates
+// Possible values are 'oanda' 'xe' or ''
+ define('CURRENCY_SERVER_PRIMARY', 'oanda');
+ define('CURRENCY_SERVER_BACKUP', 'xe');
+
+// set the type of request (secure or not)
+ if ((isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on')) || (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == 443))) {
+ $request_type = 'SSL';
+
+ $cookie_domain = HTTPS_COOKIE_DOMAIN;
+ $cookie_path = HTTPS_COOKIE_PATH;
+ } else {
+ $request_type = 'NONSSL';
+
+ $cookie_domain = HTTP_COOKIE_DOMAIN;
+ $cookie_path = HTTP_COOKIE_PATH;
+ }
+
+// set php_self in the global scope
+ $req = parse_url($_SERVER['SCRIPT_NAME']);
+ $PHP_SELF = substr($req['path'], ($request_type == 'SSL') ? strlen(DIR_WS_HTTPS_ADMIN) : strlen(DIR_WS_ADMIN));
+
+// set the session name and save path
+ tep_session_name('oscomadminid');
+ tep_session_save_path(SESSION_WRITE_DIRECTORY);
+
+// set the session cookie parameters
+// set the session cookie parameters
+ session_set_cookie_params(0, $cookie_path, $cookie_domain);
+
+ if (function_exists('ini_set')) {
+ ini_set('session.use_only_cookies', (SESSION_FORCE_COOKIE_USE == 'True') ? 1 : 0);
+ }
+
+// lets start our session
+ tep_session_start();
+
+// TODO remove when no more global sessions exist
+ foreach ($_SESSION as $k => $v) {
+ $GLOBALS[$k] =& $_SESSION[$k];
+ }
+
+// set the language
+ if (!isset($_SESSION['language']) || isset($_GET['language'])) {
+ $lng = new \language();
+
+ if (isset($_GET['language']) && !empty($_GET['language'])) {
+ $lng->set_language($_GET['language']);
+ } else {
+ $lng->get_browser_language();
+ }
+
+ $_SESSION['language'] = $lng->language['directory'];
+ $_SESSION['languages_id'] = $lng->language['id'];
+ }
+
+// redirect to login page if administrator is not yet logged in
+ if (!isset($_SESSION['admin'])) {
+ $redirect = false;
+
+ $current_page = $PHP_SELF;
+
+// if the first page request is to the login page, set the current page to the index page
+// so the redirection on a successful login is not made to the login page again
+ if (($current_page == FILENAME_LOGIN) && !isset($_SESSION['redirect_origin'])) {
+ $current_page = FILENAME_DEFAULT;
+ }
+
+ if ($current_page != FILENAME_LOGIN) {
+ if (!isset($_SESSION['redirect_origin'])) {
+ $_SESSION['redirect_origin'] = [