[Tickets #13655] add windows platform support in dynamic calendar view

noreply at bugs.horde.org noreply at bugs.horde.org
Thu Oct 30 18:19:11 UTC 2014


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: https://bugs.horde.org/ticket/13655
------------------------------------------------------------------------------
  Ticket             | 13655
  Created By         | evb at ping.be
  Summary            | add windows platform support in dynamic calendar view
  Queue              | Kronolith
  Version            | 4.2.2
  Type               | Bug
  State              | Unconfirmed
  Priority           | 1. Low
  Milestone          |
  Patch              |
  Owners             |
------------------------------------------------------------------------------


evb at ping.be (2014-10-30 18:19) wrote:

The text below is a copy of the mailing traffic:
******************************************************************************
For some time now I can't edit or add events in the dynamic view. No
  problem in editing or adding in the simple view!

  So I did some debug in FireBug and the reason is a undefined
  'date_format' in the javascript file kronolith.js, function getDate:
    getDate: function(what) {
        var dateElm, timeElm, date, time;
        if (what == 'start') {
            dateElm = 'kronolithEventStartDate';
            timeElm = 'kronolithEventStartTime';
        } else {
            dateElm = 'kronolithEventEndDate';
            timeElm = 'kronolithEventEndTime';
        }
        date = Date.parseExact($F(dateElm), Kronolith.conf.date_format)
            || Date.parse($F(dateElm));
        if (date) {
            time = Date.parseExact($F(timeElm),
  Kronolith.conf.time_format);
            if (!time) {
                time = Date.parse($F(timeElm));
            }
            if (time) {
                date.setHours(time.getHours());
                date.setMinutes(time.getMinutes());
            }
        }
        return date;
    },

  Kronolith.conf.date_format is for some reason undefined.
  When I look via FireBug into the object 'Kronolith' I see two child
  objects 'conf' and 'text'. In the child object 'conf' I see a
  defined 'time_format', but no 'date_format'.
  When I define via FireBug a 'date_format', everything is working, I
  can add and edit events in the dynamic view!

****************************************************************************************

I found two problems under windows causing the above described problems:
  1. the php function nl_langinfo is used, but this function isn't
  implemented on windows platforms
  2. the php function setlocale is used, but the locale strings used are
  not the same on windows platforms

  For the first problem a workaround exists by simulating the missing
  function. Paul Kemper did write a 'windows' nl_langinfo function. This
  function is too long to include here, but I can send it if requested.
  There was still a bug in his function for the D_FMT locale and
  strftime parameter '%e'. The latter isn't implemented on windows, so
  it must be replaced by '%#d'.
  And because of this the function translateFormat in Datejs.php
  (C:\php\pear\Horde\Core\Script\Package\Datejs.php) must be adapted for
  the '%e' translation, no leading space on windows:
       /**
        * Translates date format strings from strftime to datejs.
        *
        * @param string $format  A date format string in strftime syntax.
        *
        * @return string  The date format string in datejs format.
        */
       static public function translateFormat($format)
       {
           $from = array('%e', '%-d', '%d', '%a', '%A', '%-m', '%m',
  '%h', '%b', '%B', '%y', '%Y');
           $to = array('d', 'd', 'dd', 'ddd', 'dddd', 'M', 'MM', 'MMM',
  'MMM', 'MMMM', 'yy', 'yyyy');
           if (defined('D_FMT')) {
               $from[] = '%x';
               $to[] = str_replace($from, $to, Horde_Nls::getLangInfo(D_FMT));
           }
           return str_replace($from, $to, $format);
       }

  Add the simulated function nl_langinfo as an include in the Nls.php
  file (C:\php\pear\Horde\Nls.php):
  include( 'WindowsNl_LangInfo.php' );

  For the second problem, I first created a new nls.local.php
  configuration file (C:\Apache24\htdocs\webmail\config\nls.local.php)
  with the windows locales strings:
           'usa_usa' => '‭English (American)',
           'uk_uk' => '‭English (British)',
           'canadian_can' => '‭English (Canadian)',
           'fra_fra' => 'Français',
           'nld_nld' => 'Nederlands'
  And then modified the function setLanguage in Registry.php
  (C:\php\pear\Horde\Registry.php) to not include 'UTF-8', also not
  supported on each windows platform.
  But that didn't work, I'm missing something I think.
  If I hard code the wanted language 'nld_nld' in the function
  setLanguage, then it works. Of course the user can't change the
  language anymore. That's not a problem for me, but as generic
  solution, this can't be coded like this!

  With all these changes the agenda is now working in the wanted
  language, I can now add events, delete and change events.
  But it is not future proof, the next upgrade of horde will delete the
  changes and I'm back at the beginning.
  The key question is, will horde support an installation on windows in
  the future? For this to happen, the code must be made cross-platform...






More information about the bugs mailing list