Skip to content
Browse files

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

  • Loading branch information...
2 parents e9a4889 + 1982f4e commit 87bfd461ff99233c3e09558d0a7278f1db9c05c4 @tgely committed Apr 3, 2011
View
1 osCommerce/OM/Config/settings.ini
@@ -1,6 +1,7 @@
[OSCOM]
bootstrap_file = "index.php"
default_site = "Setup"
+time_zone = "UTC"
[RPC]
enable_ssl = 'false'
View
75 osCommerce/OM/Core/DateTime.php
@@ -9,8 +9,17 @@
namespace osCommerce\OM\Core;
class DateTime {
+
+/**
+ * @since v3.0.0
+ */
+
const DEFAULT_FORMAT = 'Y-m-d H:i:s';
+/**
+ * @since v3.0.0
+ */
+
public static function getNow($format = null) {
if ( !isset($format) ) {
$format = self::DEFAULT_FORMAT;
@@ -19,6 +28,10 @@ public static function getNow($format = null) {
return date($format);
}
+/**
+ * @since v3.0.0
+ */
+
public static function getShort($date = null, $with_time = false) {
$OSCOM_Language = Registry::get('Language');
@@ -40,6 +53,10 @@ public static function getShort($date = null, $with_time = false) {
}
}
+/**
+ * @since v3.0.0
+ */
+
public static function getLong($date = null) {
$OSCOM_Language = Registry::get('Language');
@@ -61,6 +78,10 @@ public static function getLong($date = null) {
}
}
+/**
+ * @since v3.0.0
+ */
+
public static function getTimestamp($date = null, $format = null) {
if ( !isset($date) ) {
$date = self::getNow($format);
@@ -76,6 +97,10 @@ public static function getTimestamp($date = null, $format = null) {
return $timestamp;
}
+/**
+ * @since v3.0.0
+ */
+
public static function fromUnixTimestamp($timestamp, $format = null) {
if ( !isset($format) ) {
$format = self::DEFAULT_FORMAT;
@@ -84,6 +109,10 @@ public static function fromUnixTimestamp($timestamp, $format = null) {
return date($format, $timestamp);
}
+/**
+ * @since v3.0.0
+ */
+
public static function isLeapYear($year = null) {
if ( !isset($year) ) {
$year = self::getNow('Y');
@@ -102,6 +131,10 @@ public static function isLeapYear($year = null) {
return false;
}
+/**
+ * @since v3.0.0
+ */
+
public static function validate($date_to_check, $format_string, &$date_array) {
$separator_idx = -1;
@@ -204,5 +237,47 @@ public static function validate($date_to_check, $format_string, &$date_array) {
return true;
}
+
+/**
+ * Set the time zone to use for dates.
+ *
+ * @param string $time_zone An optional time zone to set to
+ * @param string $site The Site to retrieve the time zone from
+ * @return boolean
+ * @since v3.0.1
+ */
+
+ public static function setTimeZone($time_zone = null, $site = 'OSCOM') {
+ if ( !isset($time_zone) ) {
+ if ( OSCOM::configExists('time_zone', $site) ) {
+ $time_zone = OSCOM::getConfig('time_zone', $site);
+ } else {
+ $time_zone = date_default_timezone_get();
+ }
+ }
+
+ return date_default_timezone_set($time_zone);
+ }
+
+/**
+ * Return an array of available time zones.
+ *
+ * @return array
+ * @since v3.0.1
+ */
+
+ public static function getTimeZones() {
+ $result = array();
+
+ foreach ( \DateTimeZone::listIdentifiers() as $id ) {
+ $tz_string = str_replace('_', ' ', $id);
+
+ $id_array = explode('/', $tz_string, 2);
+
+ $result[$id_array[0]][$id] = isset($id_array[1]) ? $id_array[1] : $id_array[0];
+ }
+
+ return $result;
+ }
}
?>
View
44 osCommerce/OM/Core/HTML.php
@@ -8,6 +8,7 @@
namespace osCommerce\OM\Core;
+ use osCommerce\OM\Core\DateTime;
use osCommerce\OM\Core\OSCOM;
use osCommerce\OM\Core\Registry;
@@ -19,7 +20,7 @@ class HTML {
* @param string $string The string to parse and output
* @param array $translate An array containing the characters to parse
* @return string
- * @since 3.0.0
+ * @since v3.0.0
*/
public static function output($string, $translate = null) {
@@ -64,7 +65,7 @@ public static function sanitize($string) {
* @param string $element The element to link to
* @param string $parameters Additional parameters for the a href tag
* @return string
- * @since 3.0.0
+ * @since v3.0.0
*/
public static function link($url, $element, $parameters = null) {
@@ -80,7 +81,7 @@ public static function link($url, $element, $parameters = null) {
* @param int $height The height of the image
* @param string $parameters Additional parameters for the image
* @return string
- * @since 3.0.0
+ * @since v3.0.0
*/
public static function image($image, $title = null, $width = 0, $height = 0, $parameters = null) {
@@ -162,7 +163,7 @@ public static function iconRaw($image, $group = null) {
* @param string $title The title of the image button
* @param string $parameters Additional parameters for the image
* @return string
- * @since 3.0.0
+ * @since v3.0.0
*/
public static function submitImage($image, $title = null, $parameters = null) {
@@ -181,6 +182,14 @@ public static function submitImage($image, $title = null, $parameters = null) {
return $submit;
}
+/**
+ * Generate a jQuery UI button
+ *
+ * @param array $params types(submit, button, reset), href, newwindow, params, title, icon, iconpos(left, right), priority(primary, secondary)
+ * @return string
+ * @since v3.0.0
+ */
+
public static function button($params) {
static $button_counter = 1;
@@ -699,5 +708,32 @@ public static function dateSelectMenu($name, $value = null, $default_today = tru
return $days_select_string . $months_select_string . $years_select_string;
}
+
+/**
+ * Generate a time zone selection menu
+ *
+ * @param $name string The name of the selection field
+ * @param $default The default value
+ * @return string
+ * @since v3.0.1
+ */
+
+ public static function timeZoneSelectMenu($name, $default = null) {
+ if ( !isset($default) ) {
+ $default = date_default_timezone_get();
+ }
+
+ $result = array();
+
+ foreach ( DateTime::getTimeZones() as $zone => $zones_array ) {
+ foreach ( $zones_array as $key => $value ) {
+ $result[] = array('id' => $key,
+ 'text' => $value,
+ 'group' => $zone);
+ }
+ }
+
+ return HTML::selectMenu($name, $result, $default);
+ }
}
?>
View
5 osCommerce/OM/Core/OSCOM.php
@@ -8,9 +8,10 @@
namespace osCommerce\OM\Core;
+ use osCommerce\OM\Core\DateTime;
use osCommerce\OM\Core\ErrorHandler;
- use osCommerce\OM\Core\Registry;
use osCommerce\OM\Core\HTML;
+ use osCommerce\OM\Core\Registry;
define('OSCOM_BASE_DIRECTORY', realpath(__DIR__ . '/../') . '/');
@@ -27,6 +28,8 @@ class OSCOM {
public static function initialize() {
static::loadConfig();
+ DateTime::setTimeZone();
+
ErrorHandler::initialize();
static::setSite();
View
7 osCommerce/OM/Core/PDO/MySQL/Standard.php
@@ -8,8 +8,6 @@
namespace osCommerce\OM\Core\PDO\MySQL;
- use \PDO;
-
use osCommerce\OM\Core\OSCOM;
class Standard extends \osCommerce\OM\Core\PDO {
@@ -26,11 +24,10 @@ public function __construct($server, $username, $password, $database, $port, $dr
// Override ATTR_STATEMENT_CLASS to automatically handle foreign key constraints
if ( $this->_has_native_fk === false ) {
- $this->_driver_options[PDO::ATTR_STATEMENT_CLASS] = array('osCommerce\\OM\\Core\\PDO\\MySQL\\Standard\\PDOStatement', array($this));
+ $this->_driver_options[self::ATTR_STATEMENT_CLASS] = array('osCommerce\\OM\\Core\\PDO\\MySQL\\Standard\\PDOStatement', array($this));
}
-// Only one init command can be issued (see http://bugs.php.net/bug.php?id=48859)
- $this->_driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'set session sql_mode="STRICT_ALL_TABLES", names utf8';
+ $this->_driver_options[self::MYSQL_ATTR_INIT_COMMAND] = 'set names utf8';
return $this->connect();
}
View
8 osCommerce/OM/Core/PDO/MySQL/V5.php
@@ -11,5 +11,13 @@
class V5 extends \osCommerce\OM\Core\PDO\MySQL\Standard {
protected $_has_native_fk = true;
protected $_driver_parent = 'MySQL\\Standard';
+
+ public function connect() {
+// STRICT_ALL_TABLES introduced in MySQL v5.0.2
+// Only one init command can be issued (see http://bugs.php.net/bug.php?id=48859)
+ $this->_driver_options[self::MYSQL_ATTR_INIT_COMMAND] = 'set session sql_mode="STRICT_ALL_TABLES", names utf8';
+
+ parent::connect();
+ }
}
?>
View
4 osCommerce/OM/Core/Site/Setup/Application/Install/pages/step_2.php
@@ -139,6 +139,10 @@ function prepareDB() {
<td class="inputDescription"><?php echo OSCOM::getDef('param_administrator_password_description'); ?></td>
</tr>
<tr>
+ <td class="inputField"><?php echo OSCOM::getDef('param_time_zone') . '<br />' . HTML::timeZoneSelectMenu('CFG_TIME_ZONE', (ini_get('date.timezone') ?: null)); ?></td>
+ <td class="inputDescription"><?php echo OSCOM::getDef('param_time_zone_description'); ?></td>
+ </tr>
+ <tr>
<td class="inputField"><?php echo HTML::checkboxField('DB_INSERT_SAMPLE_DATA', 'true', true) . '&nbsp;' . OSCOM::getDef('param_database_import_sample_data'); ?></td>
<td class="inputDescription"><?php echo OSCOM::getDef('param_database_import_sample_data_description'); ?></td>
</tr>
View
1 osCommerce/OM/Core/Site/Setup/Application/Install/pages/step_3.php
@@ -66,6 +66,7 @@
[OSCOM]
bootstrap_file = "index.php"
default_site = "Shop"
+time_zone = "{$_POST['CFG_TIME_ZONE']}"
[Admin]
enable_ssl = "false"
View
3 osCommerce/OM/Core/Site/Setup/Languages/en_US/Install.php
@@ -43,6 +43,9 @@
param_administrator_password = Administrator Password
param_administrator_password_description = The password to use for the administrator account.
+param_time_zone = Time Zone
+param_time_zone_description = The time zone to use for dates.
+
param_database_import_sample_data = Import Sample Data
param_database_import_sample_data_description = Inserting sample data into the database is recommended for first time installations.

0 comments on commit 87bfd46

Please sign in to comment.
Something went wrong with that request. Please try again.