How to change some default settings with Xoops 2.4.3 and Formulize 3.12
I need to change some of the date formating stuff. Apparently formulize does not make use of the settings already in Xoops so I need to find where they are located so I can change the default yyyy-mm-dd format to mm-dd-yyyy as well as where the week is defined as the week where I am starts on sunday and goes through Saturday on the normal Calendar.
I also would like to change the "Proxy" entries to list the user name instead of the real name.
The date stuff should be using the xoops formats out of the box and the Proxy user listing should be a preference in the preference menu in my opinion. As well as not having the proxy available as an option when the form really doesn't care who enters the information.
Thanks!
Rodney
our supporters
Freeform Solutions is proudly supported by a grant from the Ontario Trillium Foundation, which builds healthy and vibrant communities in this great province.
Upcoming Events
-
Thu, 10/28/2010 - 9:00am

Default settings
Search the files/folders for "Y-m-d" and you'll find where the dates are formatted.
The function that builds the proxy list is in include/formdisplay.php - you can customize the results there (function addProxyList())
Proxy selection is only available for groups you enable that feature for - set the permissions for the form and remove 'add_proxy_entries' for all appropriate groups.
For 1st day of the week - not sure where you're seeing that.
Steve K
Christian Web Resources
Thanks for the help so far.
Thanks for the help so far. I will try this and see what I find out.
Rodney
Found the addProxyList and
Found the addProxyList and was able to just modify one line to make it work.. Thanks!
The date stuff I was able to find using Notepad ++.
I also saw some entries that were YYYY-mm-dd and changed those.
Still think it should be done to take advantage of the Xoops format so the date format is the same as whatever is setup in Xoops... Or maybe in one place so it is easy to change instead of the 20+ locations I was able to find.
Thanks again!
If I have any further issues I will be sure to come here and ask.
Rodney
Definitely want to make this better
I'm glad to hear the latest XOOPS has better handling for dates and formats. This was a weak point in XOOPS 2.0.x. If you could provide a quick run down of what the new date features are, or a link to some docs of the new API, etc, that would be super. Is there a new form class? And how do you access the config settings that the user has specified as their preferred date formats?
If you would like to help implement anything along these lines, I am happy to provide commit access. :-)
I agree that it would be good to make the proxy list (and perhaps other things) respond to a config option so that the user name is shown instead of the full name. There are a few places that could be fairly easily refactored in.
Thanks for the interest in Formulize, I hope that other than these issues, using it has been smooth sailing for you.
--Julian
Yes, I think the Proxy list
Yes, I think the Proxy list should be a setting. Was easy to change.. Just modified the line to only show the user name.
In Xoops 2.4.x the format for dates is in the Language files so it should be easy to pick them up from there. Not sure about the rest of it but the Date formats are saved as a token in files in the language folders.
Would be nice if Formulize would use these date format tokens as it would allow formulize and xoops to stay in line that way.
I tried what was suggested above and found the instances of Y-m-d and YYYY-mm-dd and changed them all over to my prefered m-d-Y and mm-dd-YYYY but now the date selector doesn't work at all for me. It is all screwed up now. I may have to revert back to the stock Formulize and use a text box to deal with the date as I have had no luck with formating the date differently. This should have been done in one place to allow easy editing. The users of my site are not very computer savy and they are used to the date in the format m-d-Y and the current system will confuse the heck out of them.
I will look for the links to the API when I get home.
Would be nice to see some "simple" changes for the 3.x series of Formulize and then for 4.x I am assuming there will be a bit of a rewrite going on so it would be nice if the Xoops version is setup to use the 2.4.x and newer API as this is what they are trying to get all the new modules to be compatible with. This will allow easy use of functions and such from your module in other modules and you can use functions from other modules as well. The older version of Formulize will still work with 2.3.3 and older but if you write for 2.4.x it should work for the forseable future.
Rodney
Internationalization of date/time values
Julian - if you look in languages/english/global.php in XOOPS and ImpressCMS, you'll find language constants for the date/time formatting, so instead of using
date( 'Y-m-d', strtotime( $ele_value ) )you can use
date( _SHORTDATESTRING, strtotime( $ele_value ) )I have found you have to be careful about where you use the language constants, though - MySQL will only recognize a few of them as valid date/time representations. Both CMS's have a function for formatting date/time - formatTimestamp( $value, $format, $offset ) and there is a case for mysql formatting. You could do something like
formatTimestamp( strtotime( $ele_value ), 'mysql' )Whenever you were going to insert/update/query dates in the db.
@Rodney - I should have been more specific in my recommendation. 'YYYY-mm-dd' is used by Formulize for a special case in setting/handling default dates, similar to now() or date(), it sets the current date as the value.
For the popup date selector, that is a java applet that is part of the core cms - I've never attempted to make any changes there, which is where the first day of the week would be affected.
Steve K
Christian Web Resources
I have put the code back to
I have put the code back to original for now until I have time to play with it. I am guessing I missed something when I edited the formats blindly.
If anyone else has "successfully" changed formulize to have the standard US date formats I would appreciate getting a copy of them. My users are not very computer savy and seeing "non USA standard" dates will be very confusing for them.
I haven't looked yet but are the dates atleast saved in a neutral format so if I change the display settings they will atleast display correctly?
Thanks again! Getting there slowly...
Rodney
Thanks for the pointers
Hi guys, thanks for the info about dates in the newer versions of XOOPS and ImpressCMS. Looks like using the constant is totally the way to go.
@Rodney, the dates are stored in "Date" fields in MySQL, so they should respond properly when you try to do date-ish things with them. If you are working on finding the places here that need to change, I am more than happy to give you commit access so this can be a permanent improvement in the code. Making date formatting abstracted is certainly an excellent bit of refactoring. If you are actively working on this, I am happy to support that and put in some time to identify where the key places are to make the changes.
In the meantime, I will flag this thread so this issue isn't forgotten and add it to the roadmap for 4.0.
Our release intention is that 3.13, if there is one, would just contain simple, simple changes that have extremely low likelihood of breaking anything. Stability in the 3.x branch is paramount since that's the official release. More advanced changes like this that require refactoring in the code would go into 4.0 and would be available right away through SVN.
--Julian
Ok thanks for the
Ok thanks for the information. I will also email this to you as I got your email but I will likely work on this this week and see what I come up with. I will "try" to get it working with the Xoops code so changes made with the date format with Xoops will directly apply to the date format with formulize.
Once I have it working I can let you know and if you want to include it then great. Or I can just show the lines I changed here and if anyone else needs this they can use it.
I would strongly suggest when you go to the 4.0 version to write it to work with Xoops 2.5 and newer and leave 3.0 for the older versions. The newer versions include Jquery and a few other things. Jquery MAY be included in 2.4.4 but I am not sure so don't quote me on that.
If I had more time I would likely look into helping with this and would likely leapfrog your 4.0 roadmap and jump right to your 5.0 but I have very limited time at this point and still getting up to speed with PHP and such. I am a "BASIC" programmer from 20 years ago when I hacked main frames and such when hacking was a much different term. I will be getting more involved with core xoops modules and trying to bring them up to speed for my own use. I work 65 hours a week on two jobs and am a single parent so you can see why my time is limited.
Anyhow the API documentation for the new Xoops is here...
http://dev.xoofoo.org/
Awesome, thanks
Thanks! I hear you about the time. Any help is very greatly appreciated. I expect the scope of changes is large enough that they should just be committed. The really key thing is in the include/functions.php file, in the prepDataForWrite function, that there's a way to detect non-date default values and send back the flag that means "don't write anything in the database".
Thanks for the link to the new XOOPS api docs.
Way back when, I was a self-taught BASIC programmer too, a bit more than 20 years though. ;-)
--Julian
Looks like XOOPS uses blank string as the non-date default
Thanks for the doc link, I checked that out and I think an empty string is now the non-date default.
In this file: class/calendar/JSCal2/JSCal2.php
There's some lines like this which draw the actual input box on the screen:
// MusS: Fix for permit blank value in in fieldif ( is_int($ele_value) ) {
$input = "<input type='text' name='xoops_date[{$ele_name}]' id='xoops_date[{$ele_name}]' size='{$ele_size}' maxlength='{$ele_size}' value='" . date(_SHORTDATESTRING, $ele_value) . "'" . $formHandler->getExtra() . " onChange='date2english(this.value, \"{$ele_name}\");' />\n";
} else {
$input = "<input type='text' name='xoops_date[{$ele_name}]' id='xoops_date[{$ele_name}]' size='{$ele_size}' maxlength='{$ele_size}' value=''" . $formHandler->getExtra() . " onChange='date2english(this.value, \"{$ele_name}\");' />\n";
}
If no number is passed in (presumably the number would be a timestamp), then an empty string is used as the value for the textbox. That's good because it's a non-date default. I think that should work.
I think Formulize already checks for "" values for the date and sends back the flag to cause nothing to be written to the DB.
So it would be worth trying an install of Formulize in XOOPS 2.4 without the datebox patch, and see if it works. It might work just fine.
This doesn't change the date-formatting thing. But it does mean the non-date default issue is potentially addressed, which is what the datebox patch was all about. In 2.0 versions of XOOPS, there was no if condition around how the textbox input element was rendered.
--Julian
Actually...empty might not be good enough
An empty string can present problems, because it's not passed back when the form submits (at least not in most browsers). Formulize does track which elements were rendered on the page, there's a hidden value that gets passed back saying that there should be a value for element such-and-such. But the logic right now is built around assuming that a non-date value will be passed back...some experimenting is definitely required here.
I think it should work, or could be made to work pretty easily, with a blank string as the default. The key thing is that no date be saved in the DB when the user has not actually selected a date themselves. That's why initializing with a date as the default value is really bad.
--Julian