Jump to content
Fredi

Phoenix Datepicker jQuery. ht_modules. Date format.

Recommended Posts

Ok
What does a constant mean and where should it be placed?

const JQUERY_DATEPICKER_I18N_CODE = 'ru';

My file russian.php

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2020 osCommerce
Translate to russian from Fred (FFR)  www.oscomm.biz 10.08.2019 
Update to Phoenix  25.10.2020
  Released under the GNU General Public License
*/

// look in your $PATH_LOCALE/locale directory for available locales
// or type locale -a on the server.
// Array examples which should work on all servers:
// 'en_US.UTF-8', 'en_US.UTF8', 'enu_usa'
// 'en_GB.UTF-8', 'en_GB.UTF8', 'eng_gb'
// 'en_AU.UTF-8', 'en_AU.UTF8', 'ena_au'
@setlocale(LC_ALL, ['ru_RU.UTF-8', 'ru_ru']);

const DATE_FORMAT_SHORT = '%d/%m/%Y';  // this is used for strftime()
const DATE_FORMAT_LONG = '%A %d %B, %Y'; // this is used for strftime()
const DATE_FORMAT = 'd/m/Y'; // this is used for date()
const DATE_TIME_FORMAT = DATE_FORMAT_SHORT . ' %H:%M:%S';
const JQUERY_DATEPICKER_FORMAT = 'dd/mm/yy'; // see http://docs.jquery.com/UI/Datepicker/formatDate
//  const JQUERY_DATEPICKER_I18N_CODE = 'ru';

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used when changing language)
const LANGUAGE_CURRENCY = 'USD';

// Global entries for the <html> tag
const HTML_PARAMS = '';

// charset for web pages and emails
const CHARSET = 'utf-8';

// page title
const TITLE = STORE_NAME;

// text in includes/modules/downloads.php
define('HEADER_TITLE_MY_ACCOUNT', 'Мой Кабинет');

// checkout procedure text
define('CHECKOUT_BAR_DELIVERY', 'Адрес доставки');
define('CHECKOUT_BAR_PAYMENT', 'Способ оплаты');
define('CHECKOUT_BAR_CONFIRMATION', 'Подтверждение');

// pull down default text
define('PULL_DOWN_DEFAULT', 'Выберите');

// javascript messages
define('JS_ERROR', 'Ошибки при заполнении формы.\n\nИсправьте пожалуйста ошибки:\n\n');
define('JS_ERROR_NO_PAYMENT_MODULE_SELECTED', '* Выберите метод оплаты для Вашего заказа.\n');
define('ERROR_NO_PAYMENT_MODULE_SELECTED', 'Выберите пожалуйста метод оплаты для Вашего заказа.');

// constants for use in tep_prev_next_display function
define('TEXT_RESULT_PAGE', 'Страницы:');
define('TEXT_DISPLAY_NUMBER_OF_PRODUCTS', 'Показано  <strong>%d</strong> - <strong>%d</strong> (всего  <strong>%d</strong> позиций)');
define('TEXT_DISPLAY_NUMBER_OF_ARTICLES', 'Показано  <strong>%d</strong> - <strong>%d</strong> (Всего опубликовано  <strong>%d</strong> статей)');

define('PREVNEXT_TITLE_FIRST_PAGE', 'Первая страница');
define('PREVNEXT_TITLE_PREVIOUS_PAGE', 'Предыдущая '); 
define('PREVNEXT_TITLE_NEXT_PAGE', 'Следующая страница');
define('PREVNEXT_TITLE_LAST_PAGE', 'Последняя страница');
define('PREVNEXT_TITLE_PAGE_NO', 'Страница %d');
define('PREVNEXT_TITLE_PREV_SET_OF_NO_PAGE', 'Предыдущие %d страниц');
define('PREVNEXT_TITLE_NEXT_SET_OF_NO_PAGE', 'Следующие %d страниц');
define('PREVNEXT_BUTTON_FIRST', '&lt;&lt;ПЕРВАЯ');
define('PREVNEXT_BUTTON_PREV', '[&lt;&lt;&nbsp;Предыдущая]');
define('PREVNEXT_BUTTON_NEXT', '[Следующая&nbsp;&gt;&gt;]');
define('PREVNEXT_BUTTON_LAST', 'ПОСЛЕДНЯЯ&gt;&gt;');

define('IMAGE_BUTTON_ADD_ADDRESS', 'Добавить адрес');
define('IMAGE_BUTTON_BACK', 'Назад');
define('IMAGE_BUTTON_BUY_NOW', 'КУПИТЬ!'); 
define('IMAGE_BUTTON_CHANGE_ADDRESS', 'Изменить адрес');
define('IMAGE_BUTTON_CHECKOUT', 'Оформить заказ');
define('IMAGE_BUTTON_CONFIRM_ORDER', 'Подтвердить Заказ');
define('IMAGE_BUTTON_CONTINUE', 'Продолжить');
define('IMAGE_BUTTON_DELETE', 'Удалить');
define('IMAGE_BUTTON_LOGIN', 'Войти на сайт'); 
define('IMAGE_BUTTON_IN_CART', 'Добавить в корзину');
define('IMAGE_BUTTON_SEARCH', 'Искать');
define('IMAGE_BUTTON_UPDATE', 'Обновить');
define('IMAGE_BUTTON_UPDATE_PREFERENCES', 'Обновить настройки');

define('SMALL_IMAGE_BUTTON_DELETE', 'Удалить');
define('SMALL_IMAGE_BUTTON_EDIT', 'Изменить');
define('SMALL_IMAGE_BUTTON_VIEW', 'Смотреть');
define('SMALL_IMAGE_BUTTON_BUY', 'Купить');

define('ICON_ARROW_RIGHT', 'подробнее');

define('TEXT_SORT_PRODUCTS', 'Сортировка товаров ');
define('TEXT_DESCENDINGLY', 'по убыванию');
define('TEXT_ASCENDINGLY', 'по возрастанию');
define('TEXT_BY', 'Автор : '); 

define('TEXT_UNKNOWN_TAX_RATE', 'Налоговая ставка неизвестна');

define('TEXT_CCVAL_ERROR_INVALID_DATE', 'Дата истечения срока для кредитной карты недействительна. Пожалуйста проверьте дату и попробуйте снова.');
define('TEXT_CCVAL_ERROR_INVALID_NUMBER', 'Введенный номер кредитной карты недействителен. Пожалуйста, проверьте номер и попробуйте снова.');
define('TEXT_CCVAL_ERROR_UNKNOWN_CARD', 'Первые четыре цифры введенного номера: %s. Если этот номер верен, мы не принимаем кредитные карты такого типа. Если это не так попробуйте пожалуйста еще раз.');

// category views
define('TEXT_VIEW', 'Вид страницы: ');
define('TEXT_VIEW_LIST', ' Список');
define('TEXT_VIEW_GRID', ' Ячейки');

// search placeholder
define('TEXT_SEARCH_PLACEHOLDER','Поиск');

// message for required inputs
define('FORM_REQUIRED_INFORMATION', '<i class="fas fa-asterisk text-danger"></i> Обязательная информация');
define('FORM_REQUIRED_INPUT', '<span class="form-control-feedback text-danger"><i class="fas fa-asterisk"></i></span>');

// grid/list
define('TEXT_SORT_BY', 'Сортировать по ');
// moved from index
define('TABLE_HEADING_IMAGE', '');
define('TABLE_HEADING_MODEL', 'Модель');
define('TABLE_HEADING_PRODUCTS', 'Наименование');
define('TABLE_HEADING_MANUFACTURER', 'Производитель');
define('TABLE_HEADING_QUANTITY', 'Количество');
define('TABLE_HEADING_PRICE', 'Цена');
define('TABLE_HEADING_WEIGHT', 'Вес');
define('TABLE_HEADING_BUY_NOW', 'Купить!');
define('TABLE_HEADING_LATEST_ADDED', 'Поступили в продвжу');
define('TABLE_HEADING_ORDERED', 'Самые популярные');

// product notifications
define('PRODUCT_SUBSCRIBED', '%s добавлен в список уведомлений');
define('PRODUCT_UNSUBSCRIBED', '%s удален из списока уведомлений');
define('PRODUCT_ADDED', '%s добавлен в вашу корзину');
define('PRODUCT_REMOVED', '%s удален из вашей корзины');

// bootstrap helper
define('MODULE_CONTENT_BOOTSTRAP_ROW_DESCRIPTION', '');

// noscript helper
const TEXT_NOSCRIPT = <<<'EOT'
<p><b>Скорее всего в вашем браузере отключён JavaScript.</b></p>
<p>Вы должны включить JavaScript в вашем браузере, чтобы использовать функциональные возможности этого сайта.<br>
<a class="alert-link" href="https://www.enable-javascript.com/" target="_blank" rel="nofollow">Нажмите здесь для получения инструкций по включению JavaScript в вашем браузере</a>.</p>
EOT;

// sitewide is-product
define('IS_PRODUCT_SHOW_PRICE', '%s');
define('IS_PRODUCT_SHOW_PRICE_SPECIAL', '<del>%s</del> <span class="text-danger">сейчас %s</span>');
define('IS_PRODUCT_BUTTON_BUY', '<i class="fas fa-shopping-cart"></i>');
define('IS_PRODUCT_BUTTON_VIEW', '<i class="fas fa-eye"></i> Смотреть');

// sitewide product listing
define('LISTING_SORT_DOWN', '<i class="fas fa-level-down-alt text-primary"></i>');
define('LISTING_SORT_UP', '<i class="fas fa-level-up-alt text-primary"></i>');
define('LISTING_SORT_UNSELECTED', '<i class="fas fa-level-up-alt text-black-50"></i>');
// for new style internal pages
define('LINK_TEXT_EDIT', '<small><a class="%s" href="%s">Редактировать</a></small>');
define('SHIPPING_FA_ICON', '<i class="fas fa-shipping-fast fa-fw fa-3x float-right text-black-50"></i>');
define('PAYMENT_FA_ICON', '<i class="fas fa-file-invoice-dollar fa-fw fa-3x float-right text-black-50"></i>');

define('ENTRY_COMMENTS', 'Вы хотите сообщить свое мнение?');
define('ENTRY_COMMENTS_PLACEHOLDER', 'Напишите комментарий здесь...');
define('TABLE_HEADING_OR', '-или-');

define('IS_ARTICLE_BUTTON_VIEW', '<i class="fas fa-eye"></i> Читать статью');

 It is similar to English.


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites
6 minutes ago, Fredi said:

What does a constant mean

I ask google 🙂 click

 

8 minutes ago, Fredi said:

 It is similar to English.

Nothing to do with the datepicker but that is not true..

Share this post


Link to post
Share on other sites
/ look in your $PATH_LOCALE/locale directory for available locales
// or type locale -a on the server.
// Array examples which should work on all servers:
// 'en_US.UTF-8', 'en_US.UTF8', 'enu_usa'
// 'en_GB.UTF-8', 'en_GB.UTF8', 'eng_gb'
// 'en_AU.UTF-8', 'en_AU.UTF8', 'ena_au'
@setlocale(LC_ALL, ['ru_RU.UTF-8', 'ru_ru']);

const DATE_FORMAT_SHORT = '%d/%m/%Y';  // this is used for strftime()
const DATE_FORMAT_LONG = '%A %d %B, %Y'; // this is used for strftime()
const DATE_FORMAT = 'd/m/Y'; // this is used for date()
const DATE_TIME_FORMAT = DATE_FORMAT_SHORT . ' %H:%M:%S';
const JQUERY_DATEPICKER_FORMAT = 'dd/mm/yy'; // see http://docs.jquery.com/UI/Datepicker/formatDate
const JQUERY_DATEPICKER_I18N_CODE = 'ru';

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used when changing language)
const LANGUAGE_CURRENCY = 'USD';

// Global entries for the <html> tag
const HTML_PARAMS = '';

// charset for web pages and emails
const CHARSET = 'utf-8';

Now it's right?


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites
11 minutes ago, Fredi said:

Now it's right?

That part seems oke in youre orginal russian.php is setlocale different and the HTML_PARAMS

Share this post


Link to post
Share on other sites

Thanks for the hint about the difference between

const  and define

This was another lesson for me to learn about PHP.


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites

What should be done with this hook?
Or does it all stay in work?

\templates\default\includes\hooks\shop\siteWide\jQuery.php


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites
2 hours ago, Fredi said:

What should be done with this hook?
\templates\default\includes\hooks\shop\siteWide\jQuery.php

Nothing 

Share this post


Link to post
Share on other sites

Fredi, you need to change the

includes/english/english.php

in both the admin and store sections. (files are slightly different) I have not fully checked everything works yet. but its a start for you.

mine looks like, Im in Australia.

...

// 'en_AU.UTF-8', 'en_AU.UTF8', 'ena_au'
@setlocale(LC_ALL, ['en_AU.UTF-8', 'en_AU.UTF8', 'ena_au']);

const DATE_FORMAT_SHORT = '%-d/%-m/%Y';  // this is used for strftime()
const DATE_FORMAT_LONG = '%A %w %B, %Y'; // this is used for strftime()
const DATE_FORMAT = 'd/m/Y'; // this is used for date()
const DATE_TIME_FORMAT = DATE_FORMAT_SHORT . ' %H:%M:%S';
const JQUERY_DATEPICKER_FORMAT = 'dd/mm/yy'; // see http://docs.jquery.com/UI/Datepicker/formatDate

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the application's default currency (used when changing language)
const LANGUAGE_CURRENCY = 'AUD';

...

refer to this:-

https://www.programiz.com/python-programming/datetime/strftime

Edited by MyBookShop

Share this post


Link to post
Share on other sites

@Fredi

The datepicker is a jsscript like the one below which I found in categories.php,


  <script>
  updateGross();
  $('#products_date_available').datepicker({ dateFormat: 'yy-mm-dd' });
  </script>

 

I change "yy-mm-dd" to "dd-mm-yy" and I get exactly the output I want. Is this what you should do with your code?

Share this post


Link to post
Share on other sites

My problem is that the site supports multiple languages and the date format in English is standard "mm-dd-yy", but not in Russian "dd-mm-yy"

The datapicker for different languages must be displayed in the correct format for them.

If I change the options in the shared files then the date format for English is not displayed correctly ...


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites

According to the API documentation, we can make the datepicker script correspond to the region:

$( selector ).datepicker( $.datepicker.regional[ "<?php echo JQUERY_DATEPICKER_I18N_CODE ?>" ] );

 

Share this post


Link to post
Share on other sites

I think this is a good idea.
There are many stores, including in Europe, that support several languages with different time formats.
It would be very nice if this problem was solved at the level of the CORE code.

Multilingual support is an important advantage of the OsCommerce. Unfortunately, during the upgrade of the kernel to Phoenix, this feature was unfortunately lost.
The problem of incorrect display in different languages affects not only Datapicker. There is also a problem with encodings in the Article Manager, when the text output is associated with the use of XML libraries in the UTF-8 format.


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites
6 hours ago, Fredi said:

It would be very nice if this problem was solved at the level of the CORE code.

Remember that this "CORE code" is a community effort so when you have it ready, share it with the community.
And if it's really great, it might even get added to the "CORE" 👍

I am eager to see what you or whoever codes it for you...comes up with.


Help shape the future of Phoenix; join the Phoenix Club

Share this post


Link to post
Share on other sites

My dear generous teacher!
For starters, read what I wrote to Matt when he changed the language support in the kernel.
After these changes, problems with encodings and other troubles began.
It's very simple: restore the structure of OsCommerce language support and everything will work.
The topic was in the Club, so I can't point a finger at the topic ... Sorry, coding teacher.


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites

It was about a year ago.


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites

If all you want to do is keep on passing the buck and blaming others, then you will struggle to be a part of the community.

 


Help shape the future of Phoenix; join the Phoenix Club

Share this post


Link to post
Share on other sites

I am part of the community since 2002, my beloved teacher of life!
But the mistakes that you make, you will have to correct.


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites

I was able to partially fix the problem.
The date format for my language now works correctly.

Modified file: modules/header_tags/ht_datepicker_jquery.php

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2020 osCommerce Modifed Fredi
Released under the GNU General Public License
*/

  class ht_datepicker_jquery {
    var $code = 'ht_datepicker_jquery';
    var $group = 'footer_scripts';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;
    function __construct() {
      $this->title = MODULE_HEADER_TAGS_DATEPICKER_JQUERY_TITLE;
      $this->description = MODULE_HEADER_TAGS_DATEPICKER_JQUERY_DESCRIPTION;
      if ( defined('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_STATUS') ) {
        $this->sort_order = MODULE_HEADER_TAGS_DATEPICKER_JQUERY_SORT_ORDER;
        $this->enabled = (MODULE_HEADER_TAGS_DATEPICKER_JQUERY_STATUS == 'True');
      }
    }
    function execute() {
      global $PHP_SELF, $oscTemplate;
      if (tep_not_null(MODULE_HEADER_TAGS_DATEPICKER_JQUERY_PAGES)) {
        $pages_array = page_selection::_get_pages(MODULE_HEADER_TAGS_DATEPICKER_JQUERY_PAGES);
        if (in_array(basename($PHP_SELF), $pages_array)) {
          $oscTemplate->addBlock('<script src="ext/datepicker/js/bootstrap-datepicker.min.js"></script>', $this->group);
          $oscTemplate->addBlock( JQUERY_DATEPICKER , $this->group);
          $oscTemplate->addBlock('<link rel="stylesheet" href="ext/datepicker/css/bootstrap-datepicker.min.css" />', 'header_tags');
          // create_account
          // account edit
          $oscTemplate->addBlock( JQUERY_DATEPICKER_JS , $this->group);
       }
      }
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_STATUS');
    }

    function install() {
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Datepicker jQuery Module', 'MODULE_HEADER_TAGS_DATEPICKER_JQUERY_STATUS', 'True', 'Do you want to enable the Datepicker module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Pages', 'MODULE_HEADER_TAGS_DATEPICKER_JQUERY_PAGES', 'advanced_search.php;account_edit.php;create_account.php', 'The pages to add the Datepicker jQuery Scripts to.', '6', '2', 'page_selection::_show_pages', 'page_selection::_edit_pages(', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_DATEPICKER_JQUERY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '3', now())");
    }

    function remove() {
      tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_STATUS', 'MODULE_HEADER_TAGS_DATEPICKER_JQUERY_PAGES', 'MODULE_HEADER_TAGS_DATEPICKER_JQUERY_SORT_ORDER');
    }
  }

The function works through a language file. For different languages, you only need to change the date format in the language file.

Modified file: languages/russian/modules/header_tags/ht_datepicker_jquery.php

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2014 osCommerce
Translation to RU from Fredi. Updated 7/01/2020 modifed Fredi 30/10/2020
Released under the GNU General Public License
*/

define('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_TITLE', 'Выбор даты jQuery');
define('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_DESCRIPTION', 'Добавить Выбор даты jQuery на специфические страницы');
const JQUERY_DATEPICKER = '<script src="ext/datepicker/js/bootstrap-datepicker.min.js"></script><script src="ext/datepicker/locales/bootstrap-datepicker.ru.js"></script>';
const JQUERY_DATEPICKER_JS = '<script>$(\'#dob\').datepicker({setLocale: "ru", format: "dd/mm/yyyy", endDate: "+0d", startView: 2});</script>';
?>


Modified file: languages/english/modules/header_tags/ht_datepicker_jquery.php

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2014 osCommerce
Released under the GNU General Public License
*/

define('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_TITLE', 'Datepicker jQuery');
define('MODULE_HEADER_TAGS_DATEPICKER_JQUERY_DESCRIPTION', 'Add Datepicker jQuery to specified pages');
const JQUERY_DATEPICKER = '<script src="ext/datepicker/js/bootstrap-datepicker.min.js"></script>';
const JQUERY_DATEPICKER_JS = '<script>$(\'#dob\').datepicker({format: "mm/dd/yyyy", endDate: "+0d", startView: 2});</script>';
?>

 


Support forum for osCommerce in russian language - from Ashkelon. Support since 2002.

Best regards,

Fredi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×