1
timgno
JQuery UI formdatepicker
  • 2012/6/28 9:58

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


I've created a special class in the folder class/xoopsform as formdatepicker.php. The result is being able to delete many files from the old calendar, and use a simple method call using the id and using the datepicker plugin of jquery datepicker.js

Read News

2
irmtfan
Re: JQuery UI formdatepicker
  • 2012/6/30 12:41

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Hi timgno,
Im really really glad to see this famous JQUERY Calendar in xoops.
Voltan requested it about one year ago here:
https://sourceforge.net/tracker/?func=detail&aid=3405407&group_id=41586&atid=430843

To encourage community please show some xoops forms in action.

In my idea this is the best calendar that provide us local date support.

Persian community can go to this link to see this calendar in action (patches , ...):
http://hasheminezhad.com/datepicker

But still we have a very big problem with "strtotime" function.
Please see my solution here:
https://sourceforge.net/tracker/?func=detail&aid=3537303&group_id=41586&atid=430843

is there any better solution for that?

3
culex
Re: JQuery UI formdatepicker
  • 2012/6/30 13:08

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


With php 5.3 using the datetime class would be a solution.

Example

$date "08/04/2011"// Datepicker format

$obj DateTime::createFromFormat('d/m/y'$date);
$timestamp $obj->getTimestamp();
Programming is like sex:
One mistake and you have to support it for the rest of your life.

4
timgno
Re: JQuery UI formdatepicker
  • 2012/6/30 14:19

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Precisely at this moment I've updated the class definitions as _CAL_FORMAT and others in calendar.php in language files, and other definitions have added, short text and mini text for the week.

Download from my site, use the link above

5
irmtfan
Re: JQuery UI formdatepicker
  • 2012/7/1 5:51

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Quote:

culex wrote:
With php 5.3 using the datetime class would be a solution.

Example

$date "08/04/2011"// Datepicker format

$obj DateTime::createFromFormat('d/m/y'$date);
$timestamp $obj->getTimestamp();


Thank you for your attention.
by using datetime class still the problem is remained.
The problem is:
1- we (persian/arabic community) use local date format (Hegira date not Gregorian date)
2- we (persian/arabic community) use local numbers (Not latin 0123456789)

And php functions can not handle local dates and local numbers.

Currently we have "formatTimestamp" function for output date/time and we fully customize it for our needs.

so we have to define a xoops function for input date/time.
we should do the same localization as has been done for formatTimestamp.

Add the function (strtotime / createFromFormat / Xo_strtotime, ANYTHING YOU LIKE) to xoopslocal class.

Then we can use the same procedure: extending the function abilities in languages/OUR_LANG/locale.php)

we just need a function in xoopslocal class. Therefore it is up to developers to define a new xoops function from scratch like formatTimestamp or add the already php functions (strtotime / createFromFormat) like number_format to xoopslocal class.

Also the next most important step is forcing all module/core developers to unify their methods for getting the date/time from user (use THAT XOOPS FUNCTION just like using the formatTimestamp)

@culex:

We can hack every modules and every core and add our above mentioned needs but i want to prevent this kind of localization (hard code and hack).

@ timgno:
I can not see any change here:

http://xoops.svn.sourceforge.net/viewvc/xoops/XoopsCore/tags/2.6%20timgno/htdocs/class/xoopsform/formdatepicker.php?revision=9738&view=markup&pathrev=9738

6
timgno
Re: JQuery UI formdatepicker
  • 2012/7/1 8:05

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


download again now is updated

7
irmtfan
Re: JQuery UI formdatepicker
  • 2012/7/1 10:48

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


@timgno
Thank you.
i investigate it a little but because of my very basic knowledge in javascript i can not fully understand it.
but from my understanding you attempted to add some localization variables.
these definitions in calendar.php is good for Gregorian calendar but for our needs it is not suitable.
I think it would be great if you move them totally to the language folder like this:

$GLOBALS['xoTheme']->addScript(XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/date/ui.datepicker.js');

the above code is awkward.


8
timgno
Re: JQuery UI formdatepicker
  • 2012/7/1 10:53

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Download these 2 file and traslate it in your language

http://xoops.svn.sourceforge.net/viewvc/xoops/XoopsCore/tags/2.6%20timgno/htdocs/language/english/

9
irmtfan
Re: JQuery UI formdatepicker
  • 2012/7/1 11:15

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


@ timgno:
you misunderstood me.
Persian and Arabic communities need more localization than just some definitions.
|for example please see the below code i copy and paste fromhttp://hasheminezhad.com/datepicker

this file is: jquery.ui.datepicker-cc-ar.js [Arabic calendar]

// Mahdi Hasheminezhad. email: hasheminezhad at gmail dot com (http://hasheminezhad.com)
jQuery(function($){
    $.
datepicker.regional['ar'] = {
        
calendarHijriDate,
        
closeText'إغلاق',
        
prevText'السابق',
        
nextText'التالي',
        
currentText'اليوم',
        
monthNames: ['محرّم''صفر''ربيع الأول''ربيع الثاني''جمادى الأولى''جمادى الآخرة''رجب''شعبان''رمضان''شوال''ذو القعدة''ذو الحجة'],
        
monthNamesShort: ['محرّم''صفر''ربيع الأول''ربيع الثاني''جمادى الأولى''جمادى الآخرة''رجب''شعبان''رمضان''شوال''ذو القعدة''ذو الحجة'],
        
dayNames: ['الأحد''الاثنين''الثلاثاء''الأربعاء''الخميس''الجمعة''السبت'],
        
dayNamesShort: ['أحد''اثنين''ثلاثاء''أربعاء''خميس''جمعة''سبت'],
        
dayNamesMin: ['أ''ا''ث''أ''خ''ج''س'],
        
weekHeader'س',
        
dateFormat'dd/mm/yy',
        
firstDay6,
        
isRTLtrue,
        
showMonthAfterYearfalse,
        
yearSuffix'',
        
calculateWeek: function(date) {
            var 
checkDate = new HijriDate(date.getFullYear(), date.getMonth(), date.getDate() + (date.getDay() || 7) - 3);
            return 
Math.floor(Math.round((checkDate.getTime() - new HijriDate(checkDate.getFullYear(), 01).getTime()) / 86400000) / 7) + 1;
        }};
    $.
datepicker.setDefaults($.datepicker.regional['ar']);
});

function 
HijriDate(p0p1p2) {
    var 
gregorianDate;
    var 
hijriDate;

    if (!
isNaN(parseInt(p0)) && !isNaN(parseInt(p1)) && !isNaN(parseInt(p2))) {
        var 
hijri_to_gregorian([parseInt(p010), parseInt(p110), parseInt(p210)]);
        
setFullDate(new Date(g[0], g[1], g[2]));
    } else {
        
setFullDate(p0);
    }

    function 
hijri_to_gregorian(d) {
        var 
gregorian jd_to_gregorian(islamic_to_jd(d[0], d[1] + 1d[2]));
        
gregorian[1]--;
        return 
gregorian;
    }

    function 
gregorian_to_hijri(d) {
        var 
hijri jd_to_islamic(gregorian_to_jd(d[0], d[1] + 1d[2]));
        
hijri[1]--;
        return 
hijri;
    }

    function 
setFullDate(date) {
        if (
date && date.getGregorianDatedate date.getGregorianDate();
        
gregorianDate = new Date(date);
        
gregorianDate.setHours(gregorianDate.getHours() > 12 gregorianDate.getHours() + 0)
        if (!
gregorianDate || gregorianDate == 'Invalid Date' || isNaN(gregorianDate || !gregorianDate.getDate())) {
            
gregorianDate = new Date();
        }
        
hijriDate gregorian_to_hijri([
            
gregorianDate.getFullYear(),
            
gregorianDate.getMonth(),
            
gregorianDate.getDate()]);
        return 
this;
    }

    
this.getGregorianDate = function() { return gregorianDate; }

    
this.setFullDate setFullDate;

    
this.setMonth = function(e) {
        
hijriDate[1] = e;
        var 
hijri_to_gregorian(hijriDate);
        
gregorianDate = new Date(g[0], g[1], g[2]);
        
hijriDate gregorian_to_hijri([g[0], g[1], g[2]]);
    }

    
this.setDate = function(e) {
        
hijriDate[2] = e;
        var 
hijri_to_gregorian(hijriDate);
        
gregorianDate = new Date(g[0], g[1], g[2]);
        
hijriDate gregorian_to_hijri([g[0], g[1], g[2]]);
    };

    
this.getFullYear = function() { return hijriDate[0]; };
    
this.getMonth = function() { return hijriDate[1]; };
    
this.getDate = function() { return hijriDate[2]; };
    
this.toString = function() { return hijriDate.join(',').toString(); };
    
this.getDay = function() { return gregorianDate.getDay(); };
    
this.getHours = function() { return gregorianDate.getHours(); };
    
this.getMinutes = function() { return gregorianDate.getMinutes(); };
    
this.getSeconds = function() { return gregorianDate.getSeconds(); };
    
this.getTime = function() { return gregorianDate.getTime(); };
    
this.getTimeZoneOffset = function() { return gregorianDate.getTimeZoneOffset(); };
    
this.getYear = function() { return hijriDate[0] % 100; };

    
this.setHours = function(e) { gregorianDate.setHours(e) };
    
this.setMinutes = function(e) { gregorianDate.setMinutes(e) };
    
this.setSeconds = function(e) { gregorianDate.setSeconds(e) };
    
this.setMilliseconds = function(e) { gregorianDate.setMilliseconds(e) };
}


you can see there are some other new functions like HijriDate.
So IMO it is better to move the whole customizations (definitions for Garegorian Calendar and definitions + functions for other calendars) to language folder.

10
timgno
Re: JQuery UI formdatepicker
  • 2012/7/1 11:51

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


This is the result in the Italian language:

Resized Image


Send your picture like mine to show me your result

Login

Who's Online

155 user(s) are online (60 user(s) are browsing Support Forums)


Members: 0


Guests: 155


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits