I want to change the date system of ojs 3.0.2 to my local date system (jalali).
i successfully change the public face of site date system with help of blow topic by change in smarty date_format function.
but i can not change the date system in admin panel. can any body help me.
i suppose it should be some sort of core function in the ojs for managing date, but i cant find any thing.
so finally I solved my problem by hard coding.
I manually changed the code which responsible for returning time string(date and strftime). the only drawback is that, in case of update they should be editing again.
If you think this is something that might be useful to others, please consider sharing your changes (ideally through a Github pull request). I might be able to help in grooming the changes into a general feature.
Regards,
Alec Smecher
Public Knowledge Project Team
Sure. it’s the benefits of open source project and support forum.
Unforgettably i am not so familiar with github , so I only explain what i done.
At first sorry for poor English
at first I define a new class in core class folder => “/lib/pkp/classes/core” (which obsoletelly it can be any where else) to define the date function (date and strftime) which produce different output respect to local:
now i should change ojs code to perform my date and strftime function.
As I found the class which has the word “CellProveder” inside their name (like QueriesGridCellProvider.inc.php) are responsible to admin panel data (may be a crude guess but it work in this case) so i change every date and strftime function inside them to run my functions (from date and strftime to DateManagment::date and DateManagment::strftime). and also change the strftime function inside “/lib/pkp/lib/vendor/smarty/smarty/libs/plugins/modifier.date_format.php” file which is responsible to date strings of public face of site.
the only thing now i should change is the datepicker which used in “create a new announcement” section, which i worked on it. in the case of success I would be happy to explain it (with this awful English )
finally successfully update datepicker to my local calendar (jalali), lets see what i done.
fortunately the jquery-ui datepicker (which used in ojs) support locale so easily by adding the flowing lines to the registerJSLibrary function of the “/lib/pkp/classes/template/PKPTemplateManager.inc.php” file I said ojs to load the locale file of datepicker.
and i update that javascript file in order to work based on my calendar.
but there is a very important point which should be considered. when i change the calendar, becouse the ojs store the date string, it will store the date base on my calendar system, and if i change the language to English, the ojs will confused with these date string. so i should convert date to gregorian before store.
thanks again from the ojs:
If ojs find a .datepicker in tpl the code adds (form/textInput.tpl) a new hidden field with the id = [original-element-id]-altField, and its value has been posted as the date string.
so in the datepicker javascript i update the “_updateAlternate” function to store Gregorian date in the altfield. and finally change the datepicker initialization function (_attachDatepicker) to also call the _updateAlternate function at the beginning of datepicker initialization.