Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git://github.com/osCommerce/oscommerce

  • Loading branch information...
commit 1f55a41f730f1a4c8f62fa9ca730a5194ab79750 2 parents 407c130 + 55c1c68
@tgely authored
Showing with 528 additions and 110 deletions.
  1. +4 −0 osCommerce/OM/Config/settings.ini
  2. +1 −1  osCommerce/OM/Core/Autoloader.php
  3. +16 −10 osCommerce/OM/Core/Cache.php
  4. +22 −19 osCommerce/OM/Core/ErrorHandler.php
  5. +6 −2 osCommerce/OM/Core/MessageStack.php
  6. +2 −1  osCommerce/OM/Core/OSCOM.php
  7. +5 −8 osCommerce/OM/Core/Registry.php
  8. +15 −1 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/applyPackage.php
  9. +16 −19 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getPackageContents.php
  10. +2 −4 osCommerce/OM/Core/Site/Admin/Application/ServerInfo/Model/getAll.php
  11. +8 −0 osCommerce/OM/Core/Site/Admin/Controller.php
  12. +4 −0 osCommerce/OM/Core/Site/Admin/Module/Dashboard/ErrorLog.php
  13. +3 −1 osCommerce/OM/Core/Site/Admin/languages/en_US.php
  14. +1 −0  osCommerce/OM/Core/Site/Admin/languages/en_US/modules/Dashboard/ErrorLog.php
  15. +4 −4 osCommerce/OM/Core/Site/Admin/templates/oscom/header.php
  16. +1 −0  osCommerce/OM/Core/Site/Setup/Application/Install/pages/step_3.php
  17. +21 −1 osCommerce/OM/Core/Site/Shop/Application/Search/Action/Q.php
  18. +1 −1  osCommerce/OM/Core/Site/Shop/Application/Search/pages/results.php
  19. +1 −1  osCommerce/OM/Core/Site/Shop/Module/Content/RecentlyVisited/Controller.php
  20. +159 −37 osCommerce/OM/Core/Site/Shop/Search.php
  21. +51 −0 osCommerce/OM/Tests/Autoloader.php
  22. +16 −0 osCommerce/OM/Tests/bootstrap.php
  23. +10 −0 osCommerce/OM/Tests/configuration.xml
  24. +15 −0 osCommerce/OM/Tests/osCommerce/OM/Core/ErrorHandler.php
  25. +144 −0 osCommerce/OM/Tests/osCommerce/OM/Core/HTMLTest.php
View
4 osCommerce/OM/Config/settings.ini
@@ -7,8 +7,12 @@ time_zone = "UTC"
enable_ssl = "false"
http_server = ""
dir_ws_http_server = ""
+http_cookie_domain = ""
+http_cookie_path = ""
[Setup]
enable_ssl = "false"
http_server = ""
dir_ws_http_server = ""
+http_cookie_domain = ""
+http_cookie_path = ""
View
2  osCommerce/OM/Core/Autoloader.php
@@ -8,7 +8,7 @@
namespace {
if ( !class_exists('SplClassLoader') ) {
- include('osCommerce/OM/External/SplClassLoader.php');
+ include(__DIR__ . '/../External/SplClassLoader.php');
}
}
View
26 osCommerce/OM/Core/Cache.php
@@ -41,11 +41,15 @@ class Cache {
*/
public function write($data, $key = null) {
- if ( empty($key) ) {
- $key = $this->_key;
+ if ( is_writable(OSCOM::BASE_DIRECTORY . 'Work/Cache/') ) {
+ if ( empty($key) ) {
+ $key = $this->_key;
+ }
+
+ return ( file_put_contents(OSCOM::BASE_DIRECTORY . 'Work/Cache/' . $key . '.cache', serialize($data), LOCK_EX) !== false );
}
- return ( file_put_contents(OSCOM::BASE_DIRECTORY . 'Work/Cache/' . $key . '.cache', serialize($data), LOCK_EX) !== false );
+ return false;
}
/**
@@ -118,17 +122,19 @@ public function stopBuffer() {
*/
public static function clear($key) {
- $key_length = strlen($key);
+ if ( is_writable(OSCOM::BASE_DIRECTORY . 'Work/Cache/') ) {
+ $key_length = strlen($key);
- $d = dir(OSCOM::BASE_DIRECTORY . 'Work/Cache/');
+ $d = dir(OSCOM::BASE_DIRECTORY . 'Work/Cache/');
- while ( ($entry = $d->read()) !== false ) {
- if ( (strlen($entry) >= $key_length) && (substr($entry, 0, $key_length) == $key) ) {
- @unlink(OSCOM::BASE_DIRECTORY . 'Work/Cache/' . $entry);
+ while ( ($entry = $d->read()) !== false ) {
+ if ( (strlen($entry) >= $key_length) && (substr($entry, 0, $key_length) == $key) ) {
+ @unlink(OSCOM::BASE_DIRECTORY . 'Work/Cache/' . $entry);
+ }
}
- }
- $d->close();
+ $d->close();
+ }
}
}
?>
View
41 osCommerce/OM/Core/ErrorHandler.php
@@ -15,11 +15,14 @@ class ErrorHandler {
static protected $_dbh;
public static function initialize() {
- if ( in_array('sqlite', PDO::getAvailableDrivers()) && is_writable(OSCOM::BASE_DIRECTORY . 'Work/Logs') ) {
- ini_set('display_errors', false);
+ ini_set('display_errors', false);
+
+ if ( is_writable(OSCOM::BASE_DIRECTORY . 'Work/Logs') ) {
ini_set('log_errors', true);
ini_set('error_log', OSCOM::BASE_DIRECTORY . 'Work/Logs/errors.txt');
+ }
+ if ( in_array('sqlite', PDO::getAvailableDrivers()) && is_writable(OSCOM::BASE_DIRECTORY . 'Work/Database/') ) {
set_error_handler(array('osCommerce\\OM\\Core\\ErrorHandler', 'execute'));
if ( file_exists(OSCOM::BASE_DIRECTORY . 'Work/Logs/errors.txt') ) {
@@ -29,8 +32,8 @@ public static function initialize() {
}
public static function execute($errno, $errstr, $errfile, $errline) {
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return false;
}
switch ($errno) {
@@ -65,12 +68,12 @@ public static function execute($errno, $errstr, $errfile, $errline) {
public static function connect() {
self::$_dbh = PDO::initialize(OSCOM::BASE_DIRECTORY . 'Work/Database/errors.sqlite3', null, null, null, null, 'SQLite3');
- self::$_dbh->exec('create table if not exists error_log ( timestamp int, message text );');
+ return self::$_dbh->exec('create table if not exists error_log ( timestamp int, message text );');
}
public static function getAll($limit = null, $pageset = null) {
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return array();
}
$query = 'select timestamp, message from error_log order by rowid desc';
@@ -89,8 +92,8 @@ public static function getAll($limit = null, $pageset = null) {
}
public static function getTotalEntries() {
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return 0;
}
$result = self::$_dbh->query('select count(*) as total from error_log')->fetch();
@@ -99,8 +102,8 @@ public static function getTotalEntries() {
}
public static function find($search, $limit = null, $pageset = null) {
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return array();
}
$query = 'select timestamp, message from error_log where message like :message order by rowid desc';
@@ -123,8 +126,8 @@ public static function find($search, $limit = null, $pageset = null) {
}
public static function getTotalFindEntries($search) {
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return 0;
}
$Qlogs = self::$_dbh->prepare('select count(*) as total from error_log where message like :message');
@@ -137,13 +140,13 @@ public static function getTotalFindEntries($search) {
}
public static function import($filename) {
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return false;
+ }
+
$error_log = file($filename);
unlink($filename);
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
- }
-
foreach ( $error_log as $error ) {
if ( preg_match('/^\[([0-9]{2})-([A-Za-z]{3})-([0-9]{4}) ([0-9]{2}):([0-5][0-9]):([0-5][0-9])\] (.*)$/', $error) ) {
$timestamp = DateTime::getTimestamp(substr($error, 1, 20), 'd-M-Y H:i:s');
@@ -158,8 +161,8 @@ public static function import($filename) {
}
public static function clear() {
- if ( !is_resource(self::$_dbh) ) {
- self::connect();
+ if ( !is_resource(self::$_dbh) && !self::connect() ) {
+ return false;
}
self::$_dbh->exec('drop table if exists error_log');
View
8 osCommerce/OM/Core/MessageStack.php
@@ -82,8 +82,12 @@ public function add($group = null, $message, $type = 'error') {
$group = OSCOM::getSiteApplication();
}
- $this->_data[$group][] = array('text' => $message,
- 'type' => $type);
+ $stack = array('text' => $message,
+ 'type' => $type);
+
+ if ( !in_array($stack, $this->_data[$group]) ) {
+ $this->_data[$group][] = $stack;
+ }
}
/**
View
3  osCommerce/OM/Core/OSCOM.php
@@ -402,6 +402,7 @@ public static function callDB($procedure, $data = null, $type = 'Application') {
* @param string $domain The The domain that the cookie is available on
* @param boolean $secure Indicates whether the cookie should only be sent over a secure HTTPS connection
* @param boolean $httpOnly Indicates whether the cookie should only accessible over the HTTP protocol
+ * @return boolean
* @since v3.0.0
*/
@@ -414,7 +415,7 @@ public static function setCookie($name, $value = null, $expires = 0, $path = nul
$domain = (static::getRequestType() == 'NONSSL') ? static::getConfig('http_cookie_domain') : static::getConfig('https_cookie_domain');
}
- header('Set-Cookie: ' . $name . '=' . urlencode($value) . '; expires=' . date('D, d-M-Y H:i:s T', $expires) . '; path=' . $path . '; domain=' . $domain . (($secure === true) ? ' secure;' : '') . (($httpOnly === true) ? ' httponly;' : ''));
+ return setcookie($name, $value, $expires, $path, $domain, $secure, $httpOnly);
}
/**
View
13 osCommerce/OM/Core/Registry.php
@@ -12,23 +12,21 @@ class Registry {
static private $_data = array();
static public function get($key) {
- if ( substr($key, 0, 4) == 'osC_' ) { // HPDL to delete
- } elseif ( substr($key, 0, 6) != 'OSCOM_' ) {
+ if ( substr($key, 0, 6) != 'OSCOM_' ) {
$key = 'OSCOM_' . $key;
}
if ( !self::exists($key) ) {
trigger_error('OSCOM_Registry::get - ' . $key . ' is not registered');
- return $GLOBALS[$key]; // HPDL to delete; return false
+ return false;
}
return self::$_data[$key];
}
static public function set($key, $value, $force = false) {
- if ( substr($key, 0, 4) == 'osC_' ) { // HPDL to delete
- } elseif ( substr($key, 0, 6) != 'OSCOM_' ) {
+ if ( substr($key, 0, 6) != 'OSCOM_' ) {
$key = 'OSCOM_' . $key;
}
@@ -38,12 +36,11 @@ static public function set($key, $value, $force = false) {
return false;
}
- $GLOBALS[$key] = self::$_data[$key] = $value; // HPDL remove GLOBALS alias?
+ $GLOBALS[$key] = self::$_data[$key] = $value; // GLOBALS used in template files
}
static public function exists($key) {
- if ( substr($key, 0, 4) == 'osC_' ) { // HPDL to delete
- } elseif ( substr($key, 0, 6) != 'OSCOM_' ) {
+ if ( substr($key, 0, 6) != 'OSCOM_' ) {
$key = 'OSCOM_' . $key;
}
View
16 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/applyPackage.php
@@ -9,6 +9,7 @@
namespace osCommerce\OM\Core\Site\Admin\Application\CoreUpdate\Model;
use \Phar;
+ use \RecursiveIteratorIterator;
use osCommerce\OM\Core\OSCOM;
class applyPackage {
@@ -17,7 +18,20 @@ public static function execute() {
try {
$phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar');
- $phar->extractTo(realpath(OSCOM::BASE_DIRECTORY . '../../'), null, true);
+
+// loop through each file individually as extractTo() does not work with
+// directories (see http://bugs.php.net/bug.php?id=54289)
+ foreach ( new RecursiveIteratorIterator($phar) as $iteration ) {
+ if ( ($pos = strpos($iteration->getPathName(), 'update.phar')) !== false ) {
+ $file = substr($iteration->getPathName(), $pos+12);
+
+ if ( substr($file, 0, 14) == 'osCommerce/OM/' ) {
+ $phar->extractTo(realpath(OSCOM::BASE_DIRECTORY . '../../'), $file, true);
+ } elseif ( substr($file, 0, 7) == 'public/' ) {
+ $phar->extractTo(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../'), $file, true);
+ }
+ }
+ }
} catch ( \Exception $e ) {
// ignore when file permissions from the phar archive cannot be set to the
// extracted files
View
35 osCommerce/OM/Core/Site/Admin/Application/CoreUpdate/Model/getPackageContents.php
@@ -11,7 +11,6 @@
use \Phar;
use \RecursiveIteratorIterator;
use osCommerce\OM\Core\OSCOM;
- use osCommerce\OM\Core\DirectoryListing;
class getPackageContents {
public static function execute() {
@@ -29,7 +28,6 @@ public static function execute() {
if ( $phar_can_open === true ) {
$update_pkg = array();
- $core_fs = array();
foreach ( new RecursiveIteratorIterator($phar) as $iteration ) {
if ( ($pos = strpos($iteration->getPathName(), 'update.phar')) !== false ) {
@@ -39,25 +37,24 @@ public static function execute() {
natcasesort($update_pkg);
- $DL = new DirectoryListing(OSCOM::BASE_DIRECTORY);
- $DL->setRecursive(true);
- $DL->setIncludeDirectories(false);
- $DL->setAddDirectoryToFilename(true);
- $DL->setStats(false);
-
- foreach ( $DL->getFiles() as $file ) {
- $core_fs[] = 'osCommerce/OM/' . $file['name'];
- }
-
$counter = 0;
- foreach ( $update_pkg as $update_file ) {
- $result['entries'][] = array('key' => $counter,
- 'name' => $update_file,
- 'exists' => in_array($update_file, $core_fs),
- 'writable' => self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '/../../') . '/' . $update_file));
-
- $counter++;
+ foreach ( $update_pkg as $file ) {
+ if ( substr($file, 0, 14) == 'osCommerce/OM/' ) {
+ $result['entries'][] = array('key' => $counter,
+ 'name' => $file,
+ 'exists' => file_exists(realpath(OSCOM::BASE_DIRECTORY . '/../../') . '/' . $file),
+ 'writable' => self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '/../../') . '/' . $file));
+
+ $counter++;
+ } elseif ( substr($file, 0, 7) == 'public/' ) {
+ $result['entries'][] = array('key' => $counter,
+ 'name' => $file,
+ 'exists' => file_exists(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file),
+ 'writable' => self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file));
+
+ $counter++;
+ }
}
}
View
6 osCommerce/OM/Core/Site/Admin/Application/ServerInfo/Model/getAll.php
@@ -20,17 +20,15 @@ public static function execute() {
$db_uptime = OSCOM::callDB('Admin\ServerInfo\GetUptime');
$db_version = OSCOM::callDB('Admin\ServerInfo\GetVersion');
- @list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);
-
$data = array(array('key' => 'date',
'title' => OSCOM::getDef('field_server_date'),
'value' => DateTime::getShort(null, true)),
array('key' => 'system',
'title' => OSCOM::getDef('field_server_operating_system'),
- 'value' => $system . ' ' . $kernel),
+ 'value' => php_uname('s') . ' ' . php_uname('r')),
array('key' => 'host',
'title' => OSCOM::getDef('field_server_host'),
- 'value' => $host . ' (' . gethostbyname($host) . ')'),
+ 'value' => php_uname('n') . ' (' . gethostbyname(php_uname('n')) . ')'),
array('key' => 'uptime',
'title' => OSCOM::getDef('field_server_up_time'),
'value' => @exec('uptime')),
View
8 osCommerce/OM/Core/Site/Admin/Controller.php
@@ -61,6 +61,14 @@ public static function initialize() {
if (function_exists('ini_get') && ((bool)ini_get('file_uploads') == false) ) {
Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_uploads_disabled'), 'warning');
}
+
+ if ( !OSCOM::configExists('time_zone', 'OSCOM') ) {
+ Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_time_zone_not_defined'), 'warning');
+ }
+
+ if ( !OSCOM::configExists('dir_fs_public', 'OSCOM') || !file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM')) ) {
+ Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_dir_fs_public_not_defined'), 'warning');
+ }
}
public static function getDefaultApplication() {
View
4 osCommerce/OM/Core/Site/Admin/Module/Dashboard/ErrorLog.php
@@ -46,6 +46,10 @@ public function __construct() {
$counter++;
}
+ } elseif ( !is_writable(OSCOM::BASE_DIRECTORY . 'Work/Database/') ) {
+ $this->_data .= ' <tr onmouseover="$(this).addClass(\'mouseOver\');" onmouseout="$(this).removeClass(\'mouseOver\');">' .
+ ' <td colspan="2">' . HTML::icon('cross.png') . '&nbsp;' . sprintf(OSCOM::getDef('admin_dashboard_module_errorlog_not_writable'), OSCOM::BASE_DIRECTORY . 'Work/Database/') . '</td>' .
+ ' </tr>';
} else {
$this->_data .= ' <tr onmouseover="$(this).addClass(\'mouseOver\');" onmouseout="$(this).removeClass(\'mouseOver\');">' .
' <td colspan="2">' . HTML::icon('tick.png') . '&nbsp;' . OSCOM::getDef('admin_dashboard_module_errorlog_no_errors_found') . '</td>' .
View
4 osCommerce/OM/Core/Site/Admin/languages/en_US.php
@@ -7,7 +7,7 @@
header_title_help = Help
header_title_oscommerce_support_site = osCommerce Support Site
-header_title_online_catalog = Online Catalog
+header_title_online_catalog = Online Shop
header_title_languages = Languages
header_title_logoff = Logoff
@@ -106,6 +106,8 @@
ms_warning_upload_no_file = Warning: No file uploaded.
ms_warning_uploads_disabled = Warning: File uploads are disabled in the php.ini configuration file.
+ms_warning_time_zone_not_defined = Warning: Missing time_zone configuration parameter. Please read http://www.oscommerce.info/confluence/x/C4BH
+ms_warning_dir_fs_public_not_defined = Warning: Missing dir_fs_public configuration parameter. Please read http://www.oscommerce.info/confluence/x/C4BH
ms_error_action_not_performed = Error: There was a problem performing the action.
ms_error_no_default_currency = Error: There is currently no default currency defined.
View
1  osCommerce/OM/Core/Site/Admin/languages/en_US/modules/Dashboard/ErrorLog.php
@@ -7,3 +7,4 @@
admin_dashboard_module_errorlog_table_heading_date = Date
admin_dashboard_module_errorlog_table_heading_message = Message
admin_dashboard_module_errorlog_no_errors_found = No errors found.
+admin_dashboard_module_errorlog_not_writable = Cannot write to %s
View
8 osCommerce/OM/Core/Site/Admin/templates/oscom/header.php
@@ -17,13 +17,13 @@
<?php
if ( isset($_SESSION[OSCOM::getSite()]['id']) ) {
- echo ' <li><a href="#"><span class="ui-icon ui-icon-triangle-1-s" style="float: right;"></span>Applications</a>' .
+ echo ' <li><a href="#">Applications &#9662;</a>' .
' <ul>';
foreach ( Access::getLevels() as $group => $links ) {
$application = current($links);
- echo ' <li><a href="' . OSCOM::getLink(null, $application['module']) . '"><span class="ui-icon ui-icon-triangle-1-e" style="float: right;"></span>' . Access::getGroupTitle($group) . '</a>' .
+ echo ' <li><a href="' . OSCOM::getLink(null, $application['module']) . '"><span style="float: right;">&#9656;</span>' . Access::getGroupTitle($group) . '</a>' .
' <ul>';
foreach ( $links as $link ) {
@@ -39,7 +39,7 @@
}
echo ' <li><a href="' . OSCOM::getLink('Shop', 'Index', null, 'NONSSL', false) . '" target="_blank">' . OSCOM::getDef('header_title_online_catalog') . '</a></li>' .
- ' <li><a href="http://www.oscommerce.com" target="_blank"><span class="ui-icon ui-icon-triangle-1-s" style="float: right;"></span>' . OSCOM::getDef('header_title_help') . '</a>' .
+ ' <li><a href="http://www.oscommerce.com" target="_blank">' . OSCOM::getDef('header_title_help') . ' &#9662;</a>' .
' <ul>' .
' <li><a href="http://www.oscommerce.com" target="_blank">osCommerce Support Site</a></li>' .
' <li><a href="http://www.oscommerce.info" target="_blank">Online Documentation</a></li>' .
@@ -74,7 +74,7 @@
echo ' </li>';
}
- echo ' <li><a href="#"><span class="ui-icon ui-icon-triangle-1-s" style="float: right;"></span>' . HTML::outputProtected($_SESSION[OSCOM::getSite()]['username']) . '</a>' .
+ echo ' <li><a href="#">' . HTML::outputProtected($_SESSION[OSCOM::getSite()]['username']) . ' &#9662;</a>' .
' <ul>' .
' <li><a href="' . OSCOM::getLink(null, 'Login', 'Logoff') . '">' . OSCOM::getDef('header_title_logoff') . '</a></li>' .
' </ul>' .
View
1  osCommerce/OM/Core/Site/Setup/Application/Install/pages/step_3.php
@@ -67,6 +67,7 @@
bootstrap_file = "index.php"
default_site = "Shop"
time_zone = "{$_POST['CFG_TIME_ZONE']}"
+dir_fs_public = "{$dir_fs_document_root}public/"
[Admin]
enable_ssl = "false"
View
22 osCommerce/OM/Core/Site/Shop/Application/Search/Action/Q.php
@@ -26,10 +26,14 @@ public static function execute(ApplicationAbstract $application) {
$OSCOM_Breadcrumb->add(OSCOM::getDef('breadcrumb_search_results'), OSCOM::getLink(null, null, OSCOM::getAllGET()));
}
+ $error = false;
+
if ( isset($_GET['datefrom_days']) && is_numeric($_GET['datefrom_days']) && isset($_GET['datefrom_months']) && is_numeric($_GET['datefrom_months']) && isset($_GET['datefrom_years']) && is_numeric($_GET['datefrom_years']) ) {
if ( checkdate($_GET['datefrom_months'], $_GET['datefrom_days'], $_GET['datefrom_years']) ) {
$OSCOM_Search->setDateFrom(mktime(0, 0, 0, $_GET['datefrom_months'], $_GET['datefrom_days'], $_GET['datefrom_years']));
} else {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_invalid_from_date'));
}
}
@@ -38,12 +42,16 @@ public static function execute(ApplicationAbstract $application) {
if ( checkdate($_GET['dateto_months'], $_GET['dateto_days'], $_GET['dateto_years']) ) {
$OSCOM_Search->setDateTo(mktime(23, 59, 59, $_GET['dateto_months'], $_GET['dateto_days'], $_GET['dateto_years']));
} else {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_invalid_to_date'));
}
}
if ( $OSCOM_Search->hasDateSet() ) {
if ( $OSCOM_Search->getDateFrom() > $OSCOM_Search->getDateTo() ) {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_to_date_less_than_from_date'));
}
}
@@ -52,6 +60,8 @@ public static function execute(ApplicationAbstract $application) {
if ( settype($_GET['pfrom'], 'double') ) {
$OSCOM_Search->setPriceFrom($_GET['pfrom']);
} else {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_price_from_not_numeric'));
}
}
@@ -60,11 +70,15 @@ public static function execute(ApplicationAbstract $application) {
if ( settype($_GET['pto'], 'double') ) {
$OSCOM_Search->setPriceTo($_GET['pto']);
} else {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_price_to_not_numeric'));
}
}
if ( $OSCOM_Search->hasPriceSet('from') && $OSCOM_Search->hasPriceSet('to') && ($OSCOM_Search->getPriceFrom() >= $OSCOM_Search->getPriceTo()) ) {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_price_to_less_than_price_from'));
}
@@ -72,11 +86,15 @@ public static function execute(ApplicationAbstract $application) {
$OSCOM_Search->setKeywords(urldecode($_GET['Q']));
if ( $OSCOM_Search->hasKeywords() === false ) {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_invalid_keywords'));
}
}
if ( !$OSCOM_Search->hasKeywords() && !$OSCOM_Search->hasPriceSet('from') && !$OSCOM_Search->hasPriceSet('to') && !$OSCOM_Search->hasDateSet('from') && !$OSCOM_Search->hasDateSet('to') ) {
+ $error = true;
+
$OSCOM_MessageStack->add('Search', OSCOM::getDef('error_search_at_least_one_input'));
}
@@ -96,7 +114,9 @@ public static function execute(ApplicationAbstract $application) {
}
}
- if ( $OSCOM_MessageStack->size('Search') > 0 ) {
+ if ( $error === false ) {
+ $OSCOM_Search->execute();
+ } else {
$application->setPageContent('main.php');
}
}
View
2  osCommerce/OM/Core/Site/Shop/Application/Search/pages/results.php
@@ -9,7 +9,7 @@
use osCommerce\OM\Core\HTML;
use osCommerce\OM\Core\OSCOM;
- $products_listing = $OSCOM_Search->execute();
+ $products_listing = $OSCOM_Search->getResult();
?>
<h1><?php echo $OSCOM_Template->getPageTitle(); ?></h1>
View
2  osCommerce/OM/Core/Site/Shop/Module/Content/RecentlyVisited/Controller.php
@@ -84,7 +84,7 @@ function initialize() {
' <ol style="list-style: none; margin: 0; padding: 0;">';
foreach ( $OSCOM_RecentlyVisited->getSearches() as $searchphrase ) {
- $this->_content .= '<li>' . HTML::link(OSCOM::getLink(null, 'Search', 'keywords=' . $searchphrase['keywords']), HTML::outputProtected($searchphrase['keywords'])) . ' <i>(' . number_format($searchphrase['results']) . ' results)</i></li>';
+ $this->_content .= '<li>' . HTML::link(OSCOM::getLink(null, 'Search', 'Q=' . $searchphrase['keywords']), HTML::outputProtected($searchphrase['keywords'])) . ' <i>(' . number_format($searchphrase['results']) . ' results)</i></li>';
}
$this->_content .= ' </ol>' .
View
196 osCommerce/OM/Core/Site/Shop/Search.php
@@ -11,14 +11,58 @@
use osCommerce\OM\Core\Registry;
class Search extends Products {
- var $_period_min_year,
- $_period_max_year,
- $_date_from,
- $_date_to,
- $_price_from,
- $_price_to,
- $_keywords,
- $_number_of_results;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_period_min_year;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_period_max_year;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_date_from;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_date_to;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_price_from;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_price_to;
+
+/**
+ * @since v3.0.0
+ */
+
+ protected $_keywords;
+
+/**
+ * @since v3.0.1
+ */
+
+ protected $_result;
+
+/**
+ * @since v3.0.0
+ */
public function __construct() {
$OSCOM_PDO = Registry::get('PDO');
@@ -30,39 +74,75 @@ public function __construct() {
$this->_period_max_year = $Qproducts->valueInt('max_year');
}
- function getMinYear() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getMinYear() {
return $this->_period_min_year;
}
- function getMaxYear() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getMaxYear() {
return $this->_period_max_year;
}
- function getDateFrom() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getDateFrom() {
return $this->_date_from;
}
- function getDateTo() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getDateTo() {
return $this->_date_to;
}
- function getPriceFrom() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getPriceFrom() {
return $this->_price_from;
}
- function getPriceTo() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getPriceTo() {
return $this->_price_to;
}
- function getKeywords() {
+/**
+ * @since v3.0.0
+ */
+
+ public function getKeywords() {
return $this->_keywords;
}
- function getNumberOfResults() {
- return $this->_number_of_results;
+/**
+ * @since v3.0.0
+ */
+
+ public function getNumberOfResults() {
+ return $this->_result['total'];
}
- function hasDateSet($flag = null) {
+/**
+ * @since v3.0.0
+ */
+
+ public function hasDateSet($flag = null) {
if ($flag == 'from') {
return isset($this->_date_from);
} elseif ($flag == 'to') {
@@ -72,7 +152,11 @@ function hasDateSet($flag = null) {
return isset($this->_date_from) && isset($this->_date_to);
}
- function hasPriceSet($flag = null) {
+/**
+ * @since v3.0.0
+ */
+
+ public function hasPriceSet($flag = null) {
if ($flag == 'from') {
return isset($this->_price_from);
} elseif ($flag == 'to') {
@@ -82,27 +166,51 @@ function hasPriceSet($flag = null) {
return isset($this->_price_from) && isset($this->_price_to);
}
- function hasKeywords() {
+/**
+ * @since v3.0.0
+ */
+
+ public function hasKeywords() {
return isset($this->_keywords) && !empty($this->_keywords);
}
- function setDateFrom($timestamp) {
+/**
+ * @since v3.0.0
+ */
+
+ public function setDateFrom($timestamp) {
$this->_date_from = $timestamp;
}
- function setDateTo($timestamp) {
+/**
+ * @since v3.0.0
+ */
+
+ public function setDateTo($timestamp) {
$this->_date_to = $timestamp;
}
- function setPriceFrom($price) {
+/**
+ * @since v3.0.0
+ */
+
+ public function setPriceFrom($price) {
$this->_price_from = $price;
}
- function setPriceTo($price) {
+/**
+ * @since v3.0.0
+ */
+
+ public function setPriceTo($price) {
$this->_price_to = $price;
}
- function setKeywords($keywords) {
+/**
+ * @since v3.0.0
+ */
+
+ public function setKeywords($keywords) {
$terms = explode(' ', trim($keywords));
$terms_array = array();
@@ -124,7 +232,11 @@ function setKeywords($keywords) {
$this->_keywords = implode(' ', $terms_array);
}
- function execute() {
+/**
+ * @since v3.0.0
+ */
+
+ public function execute() {
$OSCOM_PDO = Registry::get('PDO');
$OSCOM_Customer = Registry::get('Customer');
$OSCOM_Language = Registry::get('Language');
@@ -165,7 +277,7 @@ function execute() {
$sql_query .= ' and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and p2c.categories_id in (' . implode(',', $OSCOM_CategoryTree->getChildren($this->_category, $subcategories_array)) . ')';
} else {
- $sql_query .= ' and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id';
+ $sql_query .= ' and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = :language_id_c and p2c.categories_id = :categories_id';
}
}
@@ -175,16 +287,16 @@ function execute() {
if ( $this->hasKeywords() ) {
foreach ( explode(' ', $this->_keywords) as $keyword ) {
- $sql_query .= ' and (pd.products_name like :keyword or pd.products_description like :keyword)';
+ $sql_query .= ' and (pd.products_name like :keyword_name or pd.products_description like :keyword_description)';
}
}
if ( $this->hasDateSet('from') ) {
- $sql_query .= ' and p.products_date_added >= :products_date_added';
+ $sql_query .= ' and p.products_date_added >= :products_date_added_from';
}
if ( $this->hasDateSet('to') ) {
- $sql_query .= ' and p.products_date_added <= :products_date_added';
+ $sql_query .= ' and p.products_date_added <= :products_date_added_to';
}
if ( DISPLAY_PRICE_WITH_TAX == '1' ) {
@@ -239,7 +351,7 @@ function execute() {
if ( $this->hasCategory() ) {
if ( !$this->isRecursive() ) {
- $Qlisting->bindInt(':language_id', $OSCOM_Language->getID());
+ $Qlisting->bindInt(':language_id_c', $OSCOM_Language->getID());
$Qlisting->bindInt(':categories_id', $this->_category);
}
}
@@ -250,17 +362,17 @@ function execute() {
if ( $this->hasKeywords() ) {
foreach ( explode(' ', $this->_keywords) as $keyword ) {
- $Qlisting->bindValue(':keyword', '%' . $keyword . '%');
- $Qlisting->bindValue(':keyword', '%' . $keyword . '%');
+ $Qlisting->bindValue(':keyword_name', '%' . $keyword . '%');
+ $Qlisting->bindValue(':keyword_description', '%' . $keyword . '%');
}
}
if ( $this->hasDateSet('from') ) {
- $Qlisting->bindValue(':products_date_added', date('Y-m-d H:i:s', $this->_date_from));
+ $Qlisting->bindValue(':products_date_added_from', date('Y-m-d H:i:s', $this->_date_from));
}
if ( $this->hasDateSet('to') ) {
- $Qlisting->bindValue(':products_date_added', date('Y-m-d H:i:s', $this->_date_to));
+ $Qlisting->bindValue(':products_date_added_to', date('Y-m-d H:i:s', $this->_date_to));
}
@@ -292,9 +404,19 @@ function execute() {
$result['total'] = $Qlisting->fetchColumn();
- $this->_number_of_results = $result['total'];
+ $this->_result = $result;
+ }
+
+/**
+ * @since v3.0.1
+ */
+
+ public function getResult() {
+ if ( !isset($this->_result) ) {
+ $this->execute();
+ }
- return $result;
+ return $this->_result;
}
}
?>
View
51 osCommerce/OM/Tests/Autoloader.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
+ * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
+ */
+
+ if ( !class_exists('SplClassLoader') ) {
+ include(__DIR__ . '/../External/SplClassLoader.php');
+ }
+
+ class Autoloader extends SplClassLoader {
+ public function loadClass($className) {
+ if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
+ $fileName = '';
+ $namespace = '';
+
+ if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
+ $namespace = substr($className, 0, $lastNsPos);
+ $className = substr($className, $lastNsPos + 1);
+ $fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
+ }
+
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
+
+ $includeFile = ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
+
+// HPDL; require() returns a "file does not exist" error when \class_exists() is
+// used. Instead, use file_exists() and include()
+
+// HPDL: Check for and include custom version
+ if ( strpos($includeFile, 'osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR) !== false ) {
+ $includeFile = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $includeFile;
+
+ $custom_includeFile = str_replace('osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR, 'osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR . 'osCommerce' . DIRECTORY_SEPARATOR . 'OM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR, $includeFile);
+
+ if (file_exists($custom_includeFile)) {
+ include ($custom_includeFile);
+ return true;
+ }
+ }
+
+ if (file_exists($includeFile)) {
+ include ($includeFile);
+ return true;
+ }
+ }
+ }
+ }
+?>
View
16 osCommerce/OM/Tests/bootstrap.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
+ * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
+ */
+
+ define('OSCOM_TIMESTAMP_START', microtime());
+
+ require('Autoloader.php');
+ $OSCOM_Autoloader = new Autoloader('osCommerce\OM');
+ $OSCOM_Autoloader->register();
+
+ osCommerce\OM\Core\OSCOM::initialize();
+?>
View
10 osCommerce/OM/Tests/configuration.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<phpunit
+ bootstrap="bootstrap.php"
+ backupGlobals="false"
+ colors="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnFailure="true"
+/>
View
15 osCommerce/OM/Tests/osCommerce/OM/Core/ErrorHandler.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
+ * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
+ */
+
+ namespace osCommerce\OM\Core;
+
+ class ErrorHandler {
+ public static function initialize() {
+ }
+ }
+?>
View
144 osCommerce/OM/Tests/osCommerce/OM/Core/HTMLTest.php
@@ -0,0 +1,144 @@
+<?php
+/**
+ * osCommerce Online Merchant
+ *
+ * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
+ * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
+ */
+
+ use osCommerce\OM\Core\DateTime;
+ use osCommerce\OM\Core\HTML;
+ use osCommerce\OM\Core\Registry;
+
+ class HTMLTest extends \PHPUnit_Framework_TestCase {
+ protected function setUp() {
+ }
+
+ protected function tearDown() {
+ }
+
+ public function testOutput() {
+ $this->assertEquals('test&quot;string', HTML::output(' test"string '));
+ }
+
+ public function testOutputWithAmpersand() {
+ $this->assertEquals('test&quot;string &amp;', HTML::output(' test"string & ', array('&' => '&amp;', '"' => '&quot;')));
+ }
+
+ public function testOutputProtected() {
+ $this->assertEquals('&lt;a href=&quot;test&quot;&gt;test&amp;string&lt;/a&gt;', HTML::outputProtected(' <a href="test">test&string</a> '));
+ }
+
+ public function testSanitize() {
+ $this->assertEquals('test _test_', HTML::sanitize(' test <test> '));
+ }
+
+ public function testLink() {
+ $this->assertEquals('<a href="http://www.oscommerce.com" target="_blank">osCommerce</a>', HTML::link('http://www.oscommerce.com', 'osCommerce', 'target="_blank"'));
+ }
+
+ public function testImageWithWidthAndHeight() {
+ $this->assertEquals('<img src="http://www.oscommerce.com/images/oscommerce.gif" border="0" alt="osCommerce" title="osCommerce" width="211" height="60" id="logo" />', HTML::image('http://www.oscommerce.com/images/oscommerce.gif', 'osCommerce', 211, 60, 'id="logo"'));
+ }
+
+ public function testImageWithoutWidthAndHeight() {
+ $this->assertEquals('<img src="http://www.oscommerce.com/images/oscommerce.gif" border="0" alt="osCommerce" title="osCommerce" id="logo" />', HTML::image('http://www.oscommerce.com/images/oscommerce.gif', 'osCommerce', '', '', 'id="logo"'));
+ }
+
+ public function testIcon() {
+ $this->assertEquals('<img src="public/sites/Shop/templates/oscom/images/icons/16x16/info.png" border="0" alt="Info" title="Info" id="iconInfo" />', HTML::icon('info.png', 'Info', '16x16', 'id="iconInfo"'));
+ }
+
+ public function testIconRaw() {
+ $this->assertEquals('public/sites/Shop/templates/oscom/images/icons/16x16/info.png', HTML::iconRaw('info.png', '16x16'));
+ }
+
+ public function testSubmitImage() {
+ $this->assertEquals('<input type="image" src="public/sites/Shop/templates/oscom/images/icons/16x16/edit.png" title="Edit" id="editSubmitImage" />', HTML::submitImage(HTML::iconRaw('edit.png'), 'Edit', 'id="editSubmitImage"'));
+ }
+
+ public function testButtonSubmit() {
+ $this->assertEquals('<button id="button1" type="submit">Submit</button><script type="text/javascript">$("#button1").button({icons:{primary:"ui-icon-tick"}});</script>', HTML::button(array('title' => 'Submit', 'icon' => 'tick')));
+ }
+
+ public function testButtonReset() {
+ $this->assertEquals('<button id="button2" type="submit">Reset</button><script type="text/javascript">$("#button2").button();</script>', HTML::button(array('title' => 'Reset')));
+ }
+
+ public function testButtonButton() {
+ $this->assertEquals('<button id="button3" type="button" onclick="window.open(\'http://www.oscommerce.com\');">osCommerce</button><script type="text/javascript">$("#button3").button({icons:{secondary:"ui-icon-tick"}}).addClass("ui-priority-secondary");</script>', HTML::button(array('href' => 'http://www.oscommerce.com', 'newwindow' => true, 'title' => 'osCommerce', 'icon' => 'tick', 'iconpos' => 'right', 'priority' => 'secondary')));
+ }
+
+ public function testInputField() {
+ $this->assertEquals('<input type="text" name="site" value="osCommerce" id="ifName" />', HTML::inputField('site', 'osCommerce', 'id="ifName"'));
+ }
+
+ public function testPasswordField() {
+ $this->assertEquals('<input type="password" name="password" id="pfPassword" />', HTML::passwordField('password', 'id="pfPassword"'));
+ }
+
+ public function testTextareaField() {
+ $this->assertEquals('<textarea name="description" cols="6" rows="65" id="taDescription">Description</textarea>', HTML::textareaField('description', 'Description', 6, 65, 'id="taDescription"'));
+ }
+
+ public function testSelectMenu() {
+ $list_array = array(array('id' => 'one', 'text' => 'First'),
+ array('id' => 'two', 'text' => 'Second'),
+ array('id' => 'three', 'text' => 'Third'));
+
+ $this->assertEquals('<select name="list" id="sList"><option value="one">First</option><option value="two" selected="selected">Second</option><option value="three">Third</option></select>', HTML::selectMenu('list', $list_array, 'two', 'id="sList"'));
+ }
+
+ public function testCheckboxField() {
+ $list_array = array(array('id' => 'one', 'text' => 'First'),
+ array('id' => 'two', 'text' => 'Second'),
+ array('id' => 'three', 'text' => 'Third'));
+
+ $this->assertEquals('<input type="checkbox" name="selection" id="selection_1" value="one" /><label for="selection1" class="fieldLabel">&nbsp;First</label>&nbsp;&nbsp;<input type="checkbox" name="selection" id="selection_2" value="two" checked="checked" /><label for="selection2" class="fieldLabel">&nbsp;Second</label>&nbsp;&nbsp;<input type="checkbox" name="selection" id="selection_3" value="three" /><label for="selection3" class="fieldLabel">&nbsp;Third</label>', HTML::checkboxField('selection', $list_array, 'two'));
+ }
+
+ public function testRadioField() {
+ $list_array = array(array('id' => 'one', 'text' => 'First'),
+ array('id' => 'two', 'text' => 'Second'),
+ array('id' => 'three', 'text' => 'Third'));
+
+ $this->assertEquals('<input type="radio" name="selection" id="selection_1" value="one" checked="checked" /><label for="selection1" class="fieldLabel">&nbsp;First</label>&nbsp;&nbsp;<input type="radio" name="selection" id="selection_2" value="two" /><label for="selection2" class="fieldLabel">&nbsp;Second</label>&nbsp;&nbsp;<input type="radio" name="selection" id="selection_3" value="three" /><label for="selection3" class="fieldLabel">&nbsp;Third</label>', HTML::radioField('selection', $list_array, 'one'));
+ }
+
+ public function testHiddenField() {
+ $this->assertEquals('<input type="hidden" name="action" value="confirm" id="hfAction" />', HTML::hiddenField('action', 'confirm', 'id="hfAction"'));
+ }
+
+ public function testHiddenSessionIDField() {
+ $OSCOM_Session = Registry::get('Session');
+
+ if ( $OSCOM_Session->hasStarted() && (strlen(SID) > 0) ) {
+ $this->assertEquals('<input type="hidden" name="' . $OSCOM_Session->getName() . '" value="' . $OSCOM_Session->getID() . '" />', HTML::hiddenSessionIDField());
+ } else {
+ $this->assertEquals('', HTML::hiddenSessionIDField());
+ }
+ }
+
+ public function testLabel() {
+ $this->assertEquals('<label for="firstname">First Name</label>', HTML::label('First Name', 'firstname'));
+ }
+
+ public function testDateSelectMenu() {
+ $this->assertEquals('<select name="date_days" id="date_days"><option value="1" selected="selected">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option></select><select name="date_months" id="date_months" onchange="updateDatePullDownMenu(this.form, \'date\');"><option value="1" selected="selected">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select><select name="date_years" id="date_years" onchange="updateDatePullDownMenu(this.form, \'date\');"><option value="2011" selected="selected">2011</option><option value="2012">2012</option></select>', HTML::dateSelectMenu('date', array('year' => '2011', 'month' => '1', 'date' => '1')));
+ }
+
+ public function testTimeZoneSelectMenu() {
+ $result = array();
+
+ foreach ( DateTime::getTimeZones() as $zone => $zones_array ) {
+ foreach ( $zones_array as $key => $value ) {
+ $result[] = array('id' => $key,
+ 'text' => $value,
+ 'group' => $zone);
+ }
+ }
+
+ $this->assertEquals(HTML::selectMenu('timezone', $result, 'Europe/Berlin'), HTML::timeZoneSelectMenu('timezone', 'Europe/Berlin'));
+ }
+ }
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.