Просмотр исходного кода

#21 removing old date/time related code

Alex Trofimov 13 лет назад
Родитель
Сommit
3c7cc6c767

+ 2 - 2
inc/classes/BxDolRssFactory.php

@@ -54,7 +54,7 @@ class BxDolRssFactory extends BxDol {
         $sUnits = '';
         $sUnits = '';
         $sRSSLast = '';
         $sRSSLast = '';
         if (isset($aRssData[0]))
         if (isset($aRssData[0]))
-            $sRSSLast = getLocaleDate($aRssData[0][$aFields['DateTimeUTS']], 6);
+            $sRSSLast = bx_time_utc($aRssData[0][$aFields['DateTimeUTS']]);
 
 
         if ($iPID > 0)
         if ($iPID > 0)
             $aPIDOwnerInfo = getProfileInfo($iPID);
             $aPIDOwnerInfo = getProfileInfo($iPID);
@@ -67,7 +67,7 @@ class BxDolRssFactory extends BxDol {
                 $sUnitGuid = $aUnitInfo[$aFields['Guid']];
                 $sUnitGuid = $aUnitInfo[$aFields['Guid']];
 
 
                 $sUnitTitle = strmaxwordlen(strip_tags($aUnitInfo[$aFields['Title']]), 100);
                 $sUnitTitle = strmaxwordlen(strip_tags($aUnitInfo[$aFields['Title']]), 100);
-                $sUnitDate = getLocaleDate($aUnitInfo[$aFields['DateTimeUTS']], 6);
+                $sUnitDate = bx_time_utc($aUnitInfo[$aFields['DateTimeUTS']]);
 
 
                 $sLinkMore = '';
                 $sLinkMore = '';
                 if ( strlen( $aUnitInfo[$aFields['Desc']]) > $iUnitLimitChars ) {
                 if ( strlen( $aUnitInfo[$aFields['Desc']]) > $iUnitLimitChars ) {

+ 3 - 15
inc/design.inc.php

@@ -50,21 +50,9 @@ define('BX_DB_PADDING_DEF', 11);
 define('BX_DB_PADDING_NO_CAPTION', 13);
 define('BX_DB_PADDING_NO_CAPTION', 13);
 
 
 
 
-/**
- * Date format identifier for use in @see bx_time_js function
- */
-define('BX_FORMAT_DATE', 'sys_format_date');
-
-/**
- * Time format identifier for use in @see bx_time_js function
- */
-define('BX_FORMAT_TIME', 'sys_format_time');
-
-/**
- * Datetime format identifier for use in @see bx_time_js function
- */
-define('BX_FORMAT_DATE_TIME', 'sys_format_datetime');
-
+define('BX_FORMAT_DATE', 'sys_format_date'); ///< date format identifier for use in @see bx_time_js function
+define('BX_FORMAT_TIME', 'sys_format_time'); ///< time format identifier for use in @see bx_time_js function
+define('BX_FORMAT_DATE_TIME', 'sys_format_datetime'); ///< datetime format identifier for use in @see bx_time_js function
 
 
 
 
 /**
 /**

+ 0 - 70
inc/utils.inc.php

@@ -7,13 +7,6 @@
  * @{
  * @{
  */
  */
 
 
-define('BX_DOL_LOCALE_TIME', 2);
-define('BX_DOL_LOCALE_DATE_SHORT', 4);
-define('BX_DOL_LOCALE_DATE', 5);
-
-define('BX_DOL_LOCALE_PHP', 1);
-define('BX_DOL_LOCALE_DB', 2);
-
 define('BX_DATA_TEXT', 1); ///< regular text data type
 define('BX_DATA_TEXT', 1); ///< regular text data type
 define('BX_DATA_TEXT_MULTILINE', 2); ///< regular multiline text data type
 define('BX_DATA_TEXT_MULTILINE', 2); ///< regular multiline text data type
 define('BX_DATA_INT', 3); ///< integer data type
 define('BX_DATA_INT', 3); ///< integer data type
@@ -56,54 +49,6 @@ function uri2title($sValue) {
     );
     );
 }
 }
 
 
-/**
- * Convert date(timestamp) in accordance with requested format code.
- *
- * @param string $sTimestamp - timestamp
- * @param integer $iCode - format code
- *                  1(4) - short date format. @see sys_options -> short_date_format_php
- *                  2 - time format. @see sys_options -> time_format_php
- *                  3(5) - long date format. @see sys_options -> date_format_php
- *                  6 - RFC 2822 date format.
- */
-function getLocaleDate($sTimestamp = '', $iCode = BX_DOL_LOCALE_DATE_SHORT) {
-    $sFormat = (int)$iCode == 6 ? 'r' : getLocaleFormat($iCode);
-
-    return date($sFormat, $sTimestamp);
-}
-/**
- * Get data format in accordance with requested format code and format type.
- *
- * @param integer $iCode - format code
- *                  1(4) - short date format. @see sys_options -> short_date_format_php
- *                  2 - time format. @see sys_options -> time_format_php
- *                  3(5) - long date format. @see sys_options -> date_format_php
- *                  6 - RFC 2822 date format.
- * @param integer $iType - format type
- *                  1 - for PHP code.
- *                  2 - for database.
- */
-function getLocaleFormat($iCode = BX_DOL_LOCALE_DATE_SHORT, $iType = BX_DOL_LOCALE_PHP) {
-    $sPostfix = (int)$iType == BX_DOL_LOCALE_PHP ? '_php' : '';
-
-    $sResult = '';
-    switch ($iCode) {
-        case 2:
-            $sResult = getParam('time_format' . $sPostfix);
-            break;
-        case 1:
-        case 4:
-            $sResult = getParam('short_date_format' . $sPostfix);
-            break;
-        case 3:
-        case 5:
-            $sResult = getParam('date_format' . $sPostfix);
-            break;
-    }
-
-    return $sResult;
-}
-
 /*
 /*
  * functions for limiting maximal word length
  * functions for limiting maximal word length
  */
  */
@@ -661,21 +606,6 @@ function _format_when ($iSec) {
     return $s;
     return $s;
 }
 }
 
 
-function _format_time($iSec, $aParams = array()) {
-    $sDivider = isset($aParams['divider']) ? $aParams['divider'] : ':';
-
-    $iSec = (int)$iSec;
-    $sFormat = $iSec > 3600 ? 'H' . $sDivider . 'i' . $sDivider . 's' : 'i' . $sDivider . 's';
-
-    return gmdate($sFormat, $iSec);
-}
-
-function defineTimeInterval($iTime) {
-    $iTime = time() - (int)$iTime;
-    $sCode = _format_when($iTime);
-    return $sCode;
-}
-
 function execSqlFile($sFileName) {
 function execSqlFile($sFileName) {
     if (! $f = fopen($sFileName, "r"))
     if (! $f = fopen($sFileName, "r"))
         return false;
         return false;

+ 0 - 7
install/sql/v70.sql

@@ -362,15 +362,8 @@ SET @iCategoryId = LAST_INSERT_ID();
 INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
 INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
 (@iCategoryId, 'currency_code', 'Currency code (for checkout system)', 'USD', 'select', 'USD,EURO', 'return strlen($arg0) > 0;', 'Cannot be empty.', 1),
 (@iCategoryId, 'currency_code', 'Currency code (for checkout system)', 'USD', 'select', 'USD,EURO', 'return strlen($arg0) > 0;', 'Cannot be empty.', 1),
 (@iCategoryId, 'currency_sign', 'Currency sign (for display purposes only)', '&#36;', 'digit', '', 'return strlen($arg0) > 0;', 'Cannot be empty.', 2),
 (@iCategoryId, 'currency_sign', 'Currency sign (for display purposes only)', '&#36;', 'digit', '', 'return strlen($arg0) > 0;', 'Cannot be empty.', 2),
-(@iCategoryId, 'time_format_php', 'Time Format(for code)', 'H:i', 'digit', '', '', '', 3),
-(@iCategoryId, 'short_date_format_php', 'Short Date Format(for code)', 'd.m.Y', 'digit', '', '', '', 4),
-(@iCategoryId, 'date_format_php', 'Long Date Format(for code)', 'd.m.Y H:i', 'digit', '', '', '', 5),
-(@iCategoryId, 'time_format', 'Time Format(for database)', '%H:%i', 'digit', '', '', '', 6),
-(@iCategoryId, 'short_date_format', 'Short Date Format(for database)', '%d.%m.%Y', 'digit', '', '', '', 7),
-(@iCategoryId, 'date_format', 'Long Date Format(for database)', '%d.%m.%Y %H:%i', 'digit', '', '', '', 8),
 (@iCategoryId, 'enable_gd', 'Use GD library for image processing', 'on', 'checkbox', '', '', '', 10),
 (@iCategoryId, 'enable_gd', 'Use GD library for image processing', 'on', 'checkbox', '', '', '', 10),
 (@iCategoryId, 'sys_calendar_starts_sunday', 'Does Calender start on Sunday?', '', 'checkbox', '', '', '', 11),
 (@iCategoryId, 'sys_calendar_starts_sunday', 'Does Calender start on Sunday?', '', 'checkbox', '', '', '', 11),
-(@iCategoryId, 'php_date_format', 'PHP date format', 'F j, Y', 'digit', '', '', '', 12),
 (@iCategoryId, 'license_code', 'Dolphin License Code', '', 'digit', '', '', '', 13),
 (@iCategoryId, 'license_code', 'Dolphin License Code', '', 'digit', '', '', '', 13),
 (@iCategoryId, 'boonexAffID', 'My BoonEx Affiliate ID', '', 'digit', '', '', '', 14),
 (@iCategoryId, 'boonexAffID', 'My BoonEx Affiliate ID', '', 'digit', '', '', '', 14),
 (@iCategoryId, 'useLikeOperator', 'Use operator LIKE for search (recommended for small content)', 'on', 'checkbox', '', '', '', 15);
 (@iCategoryId, 'useLikeOperator', 'Use operator LIKE for search (recommended for small content)', 'on', 'checkbox', '', '', '', 15);

+ 3 - 3
modules/boonex/sites/classes/BxSitesAccount.php

@@ -91,7 +91,7 @@ class BxSitesAccount
 					'Domain' => $this->_oModule->getDomain($aAccount['domain']),
 					'Domain' => $this->_oModule->getDomain($aAccount['domain']),
 					'Email' => $aUpdateParams['email'],
 					'Email' => $aUpdateParams['email'],
 					'Status' => _t('_bx_sites_txt_status_' . BX_SITES_ACCOUNT_STATUS_TRIAL),
 					'Status' => _t('_bx_sites_txt_status_' . BX_SITES_ACCOUNT_STATUS_TRIAL),
-					'NextPaymentDate' => getLocaleDate($aUpdateParams['paid']),
+					'NextPaymentDate' => bx_time_js($aUpdateParams['paid']),
 					'DetailsFormUrl' => BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=site-edit&sid=' . $aAccount['pd_profile_sid'])
 					'DetailsFormUrl' => BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=site-edit&sid=' . $aAccount['pd_profile_sid'])
 				));
 				));
 
 
@@ -203,7 +203,7 @@ class BxSitesAccount
 					'Email' => $aAccount['email'],
 					'Email' => $aAccount['email'],
 					'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(),
 					'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(),
 					'Status' => _t('_bx_sites_txt_status_' . $sActStatus),
 					'Status' => _t('_bx_sites_txt_status_' . $sActStatus),
-					'NextPaymentDate' => getLocaleDate($iPaidUntil),
+					'NextPaymentDate' => bx_time_js($iPaidUntil),
 					'DetailsFormUrl' => BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=site-edit&sid=' . $aAccount['pd_profile_sid'])
 					'DetailsFormUrl' => BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=site-edit&sid=' . $aAccount['pd_profile_sid'])
 				));
 				));
 			}
 			}
@@ -213,7 +213,7 @@ class BxSitesAccount
 				$aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_sites_payment_received',  array(
 				$aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_sites_payment_received',  array(
 					'RealName' => $sFirstName . (!empty($sFirstName) && !empty($sLastName) ? ' ' . $sLastName : ''),
 					'RealName' => $sFirstName . (!empty($sFirstName) && !empty($sLastName) ? ' ' . $sLastName : ''),
 					'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(),
 					'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(),
-					'NextPaymentDate' => getLocaleDate($iPaidUntil)
+					'NextPaymentDate' => bx_time_js($iPaidUntil)
 				));
 				));
 			}
 			}
 
 

+ 2 - 2
modules/boonex/sites/classes/BxSitesGridBrowse.php

@@ -125,7 +125,7 @@ class BxSitesGridBrowse extends BxTemplGrid {
     }
     }
 
 
 	protected function _getCellCreated ($mixedValue, $sKey, $aField, $aRow) {
 	protected function _getCellCreated ($mixedValue, $sKey, $aField, $aRow) {
-        $mixedValue = _format_when(mktime() - (int)$mixedValue);
+        $mixedValue = bx_time_js((int)$mixedValue);
         return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
         return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
     }
     }
 
 
@@ -148,4 +148,4 @@ class BxSitesGridBrowse extends BxTemplGrid {
         return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
         return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
     }
     }
 }
 }
-/** @} */
+/** @} */

+ 3 - 3
modules/boonex/sites/classes/BxSitesGridOverview.php

@@ -292,7 +292,7 @@ class BxSitesGridOverview extends BxTemplGrid {
     			'title' => '_bx_sites_grid_overview_txt_payment_last',
     			'title' => '_bx_sites_grid_overview_txt_payment_last',
     			'type' => '_bx_sites_txt_payment_type_' . $aPayment['type'],
     			'type' => '_bx_sites_txt_payment_type_' . $aPayment['type'],
     			'transaction' => $aPayment['transaction'], 
     			'transaction' => $aPayment['transaction'], 
-    			'when' => getLocaleDate($aPayment['when']),
+    			'when' => bx_time_js($aPayment['when']),
     			'amount' => number_format($aPayment['amount'], 2) . ' ' .$sCurrency
     			'amount' => number_format($aPayment['amount'], 2) . ' ' .$sCurrency
     		);
     		);
 
 
@@ -317,7 +317,7 @@ class BxSitesGridOverview extends BxTemplGrid {
 	    		'title' => '_bx_sites_grid_overview_txt_payment_next',
 	    		'title' => '_bx_sites_grid_overview_txt_payment_next',
 	    		'type' => '',
 	    		'type' => '',
 	    		'transaction' => '', 
 	    		'transaction' => '', 
-	    		'when' => getLocaleDate($iNextPayment),
+	    		'when' => bx_time_js($iNextPayment),
 	    		'amount' => number_format($aAmount, 2) . ' ' .$sCurrency
 	    		'amount' => number_format($aAmount, 2) . ' ' .$sCurrency
 	    	);
 	    	);
     	}
     	}
@@ -373,4 +373,4 @@ class BxSitesGridOverview extends BxTemplGrid {
 		return '';
 		return '';
     }
     }
 }
 }
-/** @} */
+/** @} */

+ 2 - 2
template/scripts/BxBaseFormView.php

@@ -325,12 +325,12 @@ EOS;
 
 
             case 'datepicker':
             case 'datepicker':
                 $iTime = bx_process_input ($aInput['value'], BX_DATA_DATE_TS, false, false);
                 $iTime = bx_process_input ($aInput['value'], BX_DATA_DATE_TS, false, false);
-                $sValue = getLocaleDate($iTime);
+                $sValue = bx_time_js ($iTime, BX_FORMAT_DATE);
             break;
             break;
             case 'date_time':
             case 'date_time':
             case 'datetime':
             case 'datetime':
                 $iTime = bx_process_input ($aInput['value'], BX_DATA_DATETIME_TS, false, false);
                 $iTime = bx_process_input ($aInput['value'], BX_DATA_DATETIME_TS, false, false);
-                $sValue = defineTimeInterval ($iTime);
+                $sValue = bx_time_js ($iTime, BX_FORMAT_DATE_TIME);
             break;
             break;
 
 
             case 'checkbox_set':
             case 'checkbox_set':