efl
1217 строк · 28.9 Кб
1/*
2Concerning the EPC reference:
3
4The formatting for blocks and properties has been implemented as a table
5which is filled using ALIASES.
6For maximum flexibility I implemented them in the \@code/\@encode style,
7this means that missing one or changing the order most certainly cause
8formatting errors.
9
10\@block
11block name
12\@context
13code sample of the block
14\@description
15the block's description
16\@endblock
17
18\@property
19property name
20\@parameters
21property's parameter list
22\@effect
23the property description (lol)
24\@endproperty
25*/
26
27#ifdef HAVE_CONFIG_H28# include "elementary_config.h"29#endif30
31#include <string.h>32#include <errno.h>33#include <sys/stat.h>34#include <fcntl.h>35#include <unistd.h>36
37#include "elm_prefs_cc.h"38
39void check_min_arg_count(int min_required_args);40int params_min_check(int n);41
42/**
43* @page epcref Elementary Prefs Data Collection Reference
44* An Elementary Prefs Collection is a plain text file (normally
45* identified with the .epc extension), consisting of instructions for the
46* Elm Prefs Compiler.
47*
48* The syntax for the elementary prefs data files follows a simple structure of
49* "blocks { .. }" that can contain "properties: ..", more blocks, or both.
50*
51* @anchor sec_quickaccess Quick access to block descriptions:
52* <ul>
53* <li>@ref sec_page "Page"</li>
54* <li>@ref sec_items "Items"</li>
55* <ul>
56* <li>@ref sec_items_bool "Bool"</li>
57* <li>@ref sec_items_int "Int"</li>
58* <li>@ref sec_items_float "Float"</li>
59* <li>@ref sec_items_date "Date"</li>
60* <li>@ref sec_items_text "Text"</li>
61* <li>@ref sec_items_textarea "Text Area"</li>
62* </ul>
63* </ul>
64*
65* @author Ricardo de Almeida Gonzaga (ricardotk) ricardo@profusion.mobi
66*
67* <table class="edcref" border="0">
68*/
69
70static Elm_Prefs_Page_Node *current_page = NULL;71static Elm_Prefs_Item_Node *current_item = NULL;72
73/* objects and statments */
74
75/* Collection */
76static void ob_collection(void);77
78/**
79@epcsection{page,Page}
80*/
81
82/**
83@page epcref
84@block
85page
86@context
87collection {
88..
89page {
90name: "main";
91version: 1;
92title: "Preference Widgets";
93subtitle: "Subtitle";
94widget: "elm/vertical_frame";
95
96items { }
97}
98..
99}
100@description
101A "page" block is a grouping of prefs items together. A prefs widget
102must always be bound to a page, that can address other pages in the
103collection too as @b sub-pages.
104@endblock
105
106@property
107name
108@parameters
109[page name]
110@effect
111The name of the page (to be referred by the application). It must be
112unique within the collection.
113@endproperty
114
115@property
116version
117@parameters
118[page version]
119@effect
120The page's version.
121@endproperty
122
123@property
124title
125@parameters
126[page title]
127@effect
128Set page's title.
129@endproperty
130
131@property
132subtitle
133@parameters
134[page subtitle]
135@effect
136Set page's subtitle.
137@endproperty
138
139@property
140widget
141@parameters
142[page widget]
143@effect
144Set the widget from among the available page widgets. Valid, built-in
145page widgets are:
146@li elm/horizontal_box
147@li elm/vertical_box
148@li elm/horizontal_frame
149@li elm/vertical_frame
150@endproperty
151
152@property
153style
154@parameters
155[page style]
156@effect
157Set page's style.
158@endproperty
159
160@property
161icon
162@parameters
163[page icon]
164@effect
165Set page's icon.
166@endproperty
167
168@property
169autosave
170@parameters
171[1 or 0]
172@effect
173Takes a boolean value specifying whether page is autosaved (1)
174or not (0). The default value is 1.
175@endproperty
176*/
177
178/* Page */
179static void ob_collection_page(void);180static void st_collection_page_name(void);181static void st_collection_page_version(void);182static void st_collection_page_title(void);183static void st_collection_page_subtitle(void);184static void st_collection_page_widget(void);185static void st_collection_page_style(void);186static void st_collection_page_icon(void);187static void st_collection_page_autosave(void);188
189/**
190@epcsection{items,Items}
191*/
192
193/**
194@page epcref
195@block
196items
197@context
198page {
199..
200items {
201name: "item";
202type: INT;
203label: "Just a item label...";
204
205type { }
206}
207..
208}
209
210@description
211An "item" block declares a new Prefs item, along with its properties.
212@endblock
213
214@property
215name
216@parameters
217[item name]
218@effect
219The item's name, to be referred by the application. It must be unique
220within the page.
221@endproperty
222
223@property
224type
225@parameters
226[TYPE]
227@effect
228Set the type (all types must be entered in capitals) from among the
229available types, that are:
230@li BOOL - Checkbox.
231@li INT - Slider.
232@li FLOAT - Slider.
233@li DATE - Date/time display and input widget.
234@li TEXT - Single-line text entry.
235@li TEXTAREA - Text entry.
236@li LABEL - Read-only label.
237@li PAGE - Prefs subpage object.
238@li SEPARATOR - Line that serves only to divide and organize prefs
239item.
240@li SWALLOW - Swallows an Evas_Object.
241@li SAVE - Button that will get all the values bounded to items and
242save it on CFG file.
243@li ACTION - Button that will emit a signal to .C file and call a
244smart callback.
245@li RESET - Button that will return all the values bounded to items
246as default declared on .EPC file.
247@endproperty
248
249@property
250label
251@parameters
252[a string to label]
253@effect
254Set a string to item's label.
255@endproperty
256
257@property
258icon
259@parameters
260[item icon]
261@effect
262This is the item icon.
263@endproperty
264
265@property
266persistent
267@parameters
268[1 or 0]
269@effect
270Takes a boolean value specifying whether item is persistent (1) or
271not (0). The default value is 1. A non persistent item doesn't save
272its values when saved.
273@endproperty
274
275@property
276editable
277@parameters
278[1 or 0]
279@effect
280Takes a boolean value specifying whether item is editable (1)
281or not (0). The default value is 1.
282@endproperty
283
284@property
285visible
286@parameters
287[1 or 0]
288@effect
289Takes a boolean value specifying whether item is visible (1) or not (0).
290The default value is 1.
291@endproperty
292
293@property
294style
295@parameters
296[item style]
297@effect
298This is the item's style.
299@endproperty
300
301@property
302widget
303@parameters
304[item widget]
305@effect
306This is the item's widget, for cases where a widget differs than the
307default assigned to the type is desired.
308@endproperty
309*/
310/* Items */
311
312static void ob_collection_page_items(void);313
314static void ob_collection_page_items_item(void);315static void st_collection_page_items_item_name(void);316static void st_collection_page_items_item_type(void);317static void st_collection_page_items_item_label(void);318static void st_collection_page_items_item_icon(void);319static void st_collection_page_items_item_persistent(void);320static void st_collection_page_items_item_editable(void);321static void st_collection_page_items_item_visible(void);322static void st_collection_page_items_item_source(void);323static void st_collection_page_items_item_style(void);324static void st_collection_page_items_item_widget(void);325
326/**
327@epcsection{items_bool,Bool item sub blocks}
328*/
329
330/**
331@page epcref
332
333@block
334bool
335@context
336item {
337..
338bool {
339default: true;
340}
341..
342}
343@description
344@endblock
345
346@property
347default
348@parameters
349[true or false]
350@effect
351Takes a boolean value specifying whether item is checked (true)
352or not (false).
353@endproperty
354*/
355
356/* Item: Bool */
357static void ob_collection_page_items_item_bool(void);358static void st_collection_page_items_item_bool_default(void);359
360/**
361@epcsection{items_int,Int item sub blocks}
362*/
363
364/**
365@page epcref
366
367@block
368int
369@context
370item {
371..
372int {
373default: 150;
374min: 0;
375max: 300;
376}
377..
378}
379@description
380@endblock
381
382@property
383default
384@parameters
385[value]
386@effect
387Set a default (initial) value to the item.
388@endproperty
389
390@property
391min
392@parameters
393[value]
394@effect
395Set a minimum value to the item. Note that, without a minimum
396value, the widget implementing the item visually will get an
397available range of values bound to the minimum of the least
398integer number representable, and it might not be what you
399want.
400
401@endproperty
402
403@property
404max
405@parameters
406[value]
407@effect
408Set a maximum value to the item. Note that, without a maximum
409value, the widget implementing the item visually will get an
410available range of values bound to the maximum of the least
411integer number representable, and it might not be what you
412want.
413@endproperty
414*/
415
416/* Item: Integer */
417static void ob_collection_page_items_item_int(void);418static void st_collection_page_items_item_int_default(void);419static void st_collection_page_items_item_int_max(void);420static void st_collection_page_items_item_int_min(void);421
422/**
423@epcsection{items_float,Float item sub blocks}
424*/
425
426/**
427@page epcref
428
429@block
430float
431@context
432item {
433..
434float {
435default: 0.5;
436min: 0;
437max: 1;
438}
439..
440}
441@description
442@endblock
443
444@property
445default
446@parameters
447[value]
448@effect
449Set a default (initial) value to the item.
450@endproperty
451
452@property
453min
454@parameters
455[value]
456@effect
457Set a minimum value to the item. Note that, without a minimum
458value, the widget implementing the item visually will get an
459available range of values bound to the minimum of the least
460floating point number representable, and it might not be what you
461want.
462@endproperty
463
464@property
465max
466@parameters
467[value]
468@effect
469Set a maximum value to the item. Note that, without a maximum
470value, the widget implementing the item visually will get an
471available range of values bound to the maximum of the least
472floating point number representable, and it might not be what you
473want.
474@endproperty
475*/
476
477/* Item: Float */
478static void ob_collection_page_items_item_float(void);479static void st_collection_page_items_item_float_default(void);480static void st_collection_page_items_item_float_max(void);481static void st_collection_page_items_item_float_min(void);482
483/**
484@epcsection{items_date,Date item sub blocks}
485*/
486
487/**
488@page epcref
489
490@block
491date
492@context
493item {
494..
495date {
496default: 2012 11 05;
497min: 1900 1 1;
498max: 2200 12 31;
499}
500..
501}
502@description
503@endblock
504
505@property
506default
507@parameters
508[year month date] or "today"
509@effect
510Set a default (initial) date to the item. "today" will translate
511to current date.
512@endproperty
513
514@property
515min
516@parameters
517[year month date] or "today"
518@effect
519Set a minimum date to the item. "today" will translate
520to current date.
521@endproperty
522
523@property
524max
525@parameters
526[year month date] or "today"
527@effect
528Set a maximum date to the item. "today" will translate
529to current date.
530@endproperty
531*/
532
533/* Item: Date */
534static void ob_collection_page_items_item_date(void);535static void st_collection_page_items_item_date_default(void);536static void st_collection_page_items_item_date_max(void);537static void st_collection_page_items_item_date_min(void);538
539/**
540@epcsection{items_text,Text item sub blocks}
541*/
542
543/**
544@page epcref
545
546@block
547text
548@context
549item {
550..
551text {
552default: "Default text";
553placeholder: "Text:";
554accept: "^[a-zA-Z ]$";
555deny: "";
556}
557..
558}
559@description
560@endblock
561
562@property
563default
564@parameters
565[a string of text]
566@effect
567Set a default text.
568@endproperty
569
570@property
571placeholder
572@parameters
573[a string of text]
574@effect
575Set a placeholder.
576@endproperty
577
578@property
579accept
580@parameters
581[regular expression]
582@effect
583Set an acceptance regular expression. It must be a valid one.
584@endproperty
585
586@property
587deny
588@parameters
589[regular expression]
590@effect
591Set a denial regular expression. It must be a valid one.
592@endproperty
593*/
594
595/**
596@epcsection{items_textarea,Text Area item sub blocks}
597*/
598
599/**
600@page epcref
601
602@block
603textarea
604@context
605item {
606..
607textarea {
608default: "Default text";
609placeholder: "No Numbers!";
610accept: "";
611deny: "^[0-9]*$";
612}
613..
614}
615@description
616@endblock
617
618@property
619default
620@parameters
621[a string of text]
622@effect
623Set a default text.
624@endproperty
625
626@property
627placeholder
628@parameters
629[a string of text]
630@effect
631Set a placeholder.
632@endproperty
633
634@property
635accept
636@parameters
637[regular expression]
638@effect
639Set an acceptance regular expression. It must be a valid one.
640@endproperty
641
642@property
643deny
644@parameters
645[regular expression]
646@effect
647Set a denial regular expression. It must be a valid one.
648@endproperty
649*/
650
651/* Item: Text and Text Area */
652static void ob_collection_page_items_item_text(void);653static void ob_collection_page_items_item_textarea(void);654
655/* String shared statements */
656static void st_collection_page_items_item_string_default(void);657static void st_collection_page_items_item_string_placeholder(void);658static void st_collection_page_items_item_string_accept(void);659static void st_collection_page_items_item_string_deny(void);660static void st_collection_page_items_item_string_max(void);661static void st_collection_page_items_item_string_min(void);662
663/* Statement Array */
664New_Statement_Handler statement_handlers[] =665{
666{"collection.page.name", st_collection_page_name},667{"collection.page.name", st_collection_page_name},668{"collection.page.version", st_collection_page_version},669{"collection.page.title", st_collection_page_title},670{"collection.page.subtitle", st_collection_page_subtitle},671{"collection.page.widget", st_collection_page_widget},672{"collection.page.style", st_collection_page_style},673{"collection.page.icon", st_collection_page_icon},674{"collection.page.autosave", st_collection_page_autosave},675
676{"collection.page.items.item.name", st_collection_page_items_item_name},677{"collection.page.items.item.type", st_collection_page_items_item_type},678{"collection.page.items.item.label", st_collection_page_items_item_label},679{"collection.page.items.item.icon", st_collection_page_items_item_icon},680{"collection.page.items.item.persistent", st_collection_page_items_item_persistent},681{"collection.page.items.item.editable", st_collection_page_items_item_editable},682{"collection.page.items.item.visible", st_collection_page_items_item_visible},683{"collection.page.items.item.source", st_collection_page_items_item_source},684{"collection.page.items.item.style", st_collection_page_items_item_style},685{"collection.page.items.item.widget", st_collection_page_items_item_widget},686
687{"collection.page.items.item.bool.default", st_collection_page_items_item_bool_default},688
689{"collection.page.items.item.int.default", st_collection_page_items_item_int_default},690{"collection.page.items.item.int.max", st_collection_page_items_item_int_max},691{"collection.page.items.item.int.min", st_collection_page_items_item_int_min},692
693{"collection.page.items.item.float.default", st_collection_page_items_item_float_default},694{"collection.page.items.item.float.max", st_collection_page_items_item_float_max},695{"collection.page.items.item.float.min", st_collection_page_items_item_float_min},696
697{"collection.page.items.item.date.default", st_collection_page_items_item_date_default},698{"collection.page.items.item.date.max", st_collection_page_items_item_date_max},699{"collection.page.items.item.date.min", st_collection_page_items_item_date_min},700
701{"collection.page.items.item.text.placeholder", st_collection_page_items_item_string_placeholder},702{"collection.page.items.item.text.default", st_collection_page_items_item_string_default},703{"collection.page.items.item.text.accept", st_collection_page_items_item_string_accept},704{"collection.page.items.item.text.deny", st_collection_page_items_item_string_deny},705{"collection.page.items.item.text.max", st_collection_page_items_item_string_max},706{"collection.page.items.item.text.min", st_collection_page_items_item_string_min},707
708{"collection.page.items.item.textarea.placeholder", st_collection_page_items_item_string_placeholder},709{"collection.page.items.item.textarea.default", st_collection_page_items_item_string_default},710{"collection.page.items.item.textarea.accept", st_collection_page_items_item_string_accept},711{"collection.page.items.item.textarea.deny", st_collection_page_items_item_string_deny},712{"collection.page.items.item.textarea.max", st_collection_page_items_item_string_max},713{"collection.page.items.item.textarea.min", st_collection_page_items_item_string_min}714};715
716/* Object Array */
717New_Object_Handler object_handlers[] =718{
719{"collection", ob_collection},720{"collection.page", ob_collection_page},721
722{"collection.page.items", ob_collection_page_items},723{"collection.page.items.item", ob_collection_page_items_item},724{"collection.page.items.item.bool", ob_collection_page_items_item_bool},725{"collection.page.items.item.int", ob_collection_page_items_item_int},726{"collection.page.items.item.float", ob_collection_page_items_item_float},727{"collection.page.items.item.date", ob_collection_page_items_item_date},728{"collection.page.items.item.text", ob_collection_page_items_item_text},729{"collection.page.items.item.textarea", ob_collection_page_items_item_textarea}730};731
732int
733object_handler_num(void)734{
735return (sizeof(object_handlers) / sizeof (New_Object_Handler));736}
737
738int
739statement_handler_num(void)740{
741return (sizeof(statement_handlers) / sizeof (New_Statement_Handler));742}
743
744static void745ob_collection(void)746{
747// NULL748}
749
750static void751ob_collection_page(void)752{
753current_page = mem_alloc(SZ(Elm_Prefs_Page_Node));754if (current_page)755elm_prefs_file->pages =756eina_list_append(elm_prefs_file->pages, current_page);757}
758
759static void760st_collection_page_name(void)761{
762check_arg_count(1);763
764current_page->name = parse_str(0);765
766//TODO: check for duplicated name entries.767}
768
769static void770st_collection_page_version(void)771{
772check_arg_count(1);773
774current_page->version = parse_int(0);775}
776
777static void778st_collection_page_title(void)779{
780check_arg_count(1);781
782current_page->title = parse_str(0);783}
784
785static void786st_collection_page_subtitle(void)787{
788check_arg_count(1);789
790current_page->sub_title = parse_str(0);791}
792
793static void794st_collection_page_widget(void)795{
796check_arg_count(1);797
798current_page->widget = parse_str(0);799}
800
801static void802st_collection_page_style(void)803{
804check_arg_count(1);805
806current_page->style = parse_str(0);807}
808
809static void810st_collection_page_icon(void)811{
812check_arg_count(1);813
814current_page->icon = parse_str(0);815}
816
817static void818st_collection_page_autosave(void)819{
820check_arg_count(1);821
822current_page->autosave = parse_bool(0);823}
824
825static void826ob_collection_page_items(void)827{
828// NULL829}
830
831static void832ob_collection_page_items_item(void)833{
834current_item = mem_alloc(SZ(Elm_Prefs_Item_Node));835if (current_item)836{837current_item->visible = EINA_TRUE;838current_item->persistent = EINA_TRUE;839current_item->editable = EINA_TRUE;840current_page->items =841eina_list_append(current_page->items, current_item);842}843}
844
845static void846st_collection_page_items_item_name(void)847{
848check_arg_count(1);849
850current_item->name = parse_str(0);851}
852
853static void854st_collection_page_items_item_type(void)855{
856check_arg_count(1);857
858current_item->type = parse_enum(0,859"ACTION", ELM_PREFS_TYPE_ACTION,860"BOOL", ELM_PREFS_TYPE_BOOL,861"INT", ELM_PREFS_TYPE_INT,862"FLOAT", ELM_PREFS_TYPE_FLOAT,863"DATE", ELM_PREFS_TYPE_DATE,864"LABEL", ELM_PREFS_TYPE_LABEL,865"PAGE", ELM_PREFS_TYPE_PAGE,866"TEXT", ELM_PREFS_TYPE_TEXT,867"TEXTAREA", ELM_PREFS_TYPE_TEXTAREA,868"RESET", ELM_PREFS_TYPE_RESET,869"SAVE", ELM_PREFS_TYPE_SAVE,870"SEPARATOR", ELM_PREFS_TYPE_SEPARATOR,871"SWALLOW", ELM_PREFS_TYPE_SWALLOW,872NULL);873
874switch (current_item->type)875{876case ELM_PREFS_TYPE_ACTION:877case ELM_PREFS_TYPE_LABEL:878case ELM_PREFS_TYPE_RESET:879case ELM_PREFS_TYPE_SEPARATOR:880case ELM_PREFS_TYPE_SWALLOW:881current_item->editable = EINA_FALSE;882current_item->persistent = EINA_FALSE;883break;884
885case ELM_PREFS_TYPE_INT:886current_item->spec.i.max = INT_MAX;887current_item->spec.i.min = INT_MIN;888break;889
890case ELM_PREFS_TYPE_FLOAT:891current_item->spec.f.max = FLT_MAX;892current_item->spec.f.min = -FLT_MAX;893break;894
895case ELM_PREFS_TYPE_DATE:896{897time_t t = time(NULL);898struct tm *lt = localtime(&t);899
900current_item->spec.d.def.y = lt->tm_year + 1900;901current_item->spec.d.def.m = lt->tm_mon + 1;902current_item->spec.d.def.d = lt->tm_mday;903
904current_item->spec.d.min.y = 1900;905current_item->spec.d.min.m = 1;906current_item->spec.d.min.d = 1;907
908current_item->spec.d.max.y = 10000 - 1900;909current_item->spec.d.max.m = 1;910current_item->spec.d.max.d = 1;911}912break;913
914case ELM_PREFS_TYPE_TEXT:915case ELM_PREFS_TYPE_TEXTAREA:916current_item->spec.s.length.max = INT_MAX;917break;918
919default:920break;921}922}
923
924static void925st_collection_page_items_item_label(void)926{
927check_arg_count(1);928
929current_item->label = parse_str(0);930}
931
932static void933st_collection_page_items_item_icon(void)934{
935check_arg_count(1);936
937current_item->icon = parse_str(0);938}
939
940static void941st_collection_page_items_item_persistent(void)942{
943check_arg_count(1);944
945current_item->persistent = parse_bool(0);946}
947
948static void949st_collection_page_items_item_editable(void)950{
951check_arg_count(1);952
953current_item->editable = parse_bool(0);954}
955
956static void957st_collection_page_items_item_visible(void)958{
959check_arg_count(1);960
961current_item->visible = parse_bool(0);962}
963
964static void965st_collection_page_items_item_source(void)966{
967check_arg_count(1);968
969current_item->spec.p.source = parse_str(0);970}
971
972static void973st_collection_page_items_item_style(void)974{
975check_arg_count(1);976
977current_item->style = parse_str(0);978}
979
980static void981st_collection_page_items_item_widget(void)982{
983check_arg_count(1);984
985current_item->widget = parse_str(0);986}
987
988static void989ob_collection_page_items_item_bool(void)990{
991//TODO: check if current item type match992}
993
994static void995st_collection_page_items_item_bool_default(void)996{
997check_arg_count(1);998
999current_item->spec.b.def = parse_bool(0);1000}
1001
1002static void1003ob_collection_page_items_item_int(void)1004{
1005//TODO: check if current item type match1006}
1007
1008static void1009st_collection_page_items_item_int_default(void)1010{
1011check_arg_count(1);1012
1013current_item->spec.i.def = parse_int(0);1014}
1015
1016static void1017st_collection_page_items_item_int_max(void)1018{
1019check_arg_count(1);1020
1021current_item->spec.i.max = parse_int(0);1022}
1023
1024static void1025st_collection_page_items_item_int_min(void)1026{
1027check_arg_count(1);1028
1029current_item->spec.i.min = parse_int(0);1030}
1031
1032static void1033ob_collection_page_items_item_float(void)1034{
1035//TODO: check if current item type match1036}
1037
1038static void1039st_collection_page_items_item_float_default(void)1040{
1041check_arg_count(1);1042
1043current_item->spec.f.def = parse_float(0);1044}
1045
1046static void1047st_collection_page_items_item_float_max(void)1048{
1049check_arg_count(1);1050
1051current_item->spec.f.max = parse_float(0);1052}
1053
1054static void1055st_collection_page_items_item_float_min(void)1056{
1057check_arg_count(1);1058
1059current_item->spec.f.min = parse_float(0);1060}
1061
1062static void1063ob_collection_page_items_item_date(void)1064{
1065//TODO: check if current item type match1066}
1067
1068static void1069st_collection_page_items_item_date_default(void)1070{
1071check_min_arg_count(1);1072
1073if (params_min_check(1))1074{1075check_arg_count(3);1076
1077current_item->spec.d.def.y = parse_int_range(0, 1900, 10000);1078current_item->spec.d.def.m = parse_int_range(1, 1, 12);1079current_item->spec.d.def.d = parse_int_range(2, 1, 31);1080}1081else1082{1083const char *date = parse_str(0);1084if (!strcasecmp(date, "today"))1085{1086time_t t = time(NULL);1087struct tm *lt = localtime(&t);1088
1089current_item->spec.d.def.y = lt->tm_year + 1900;1090current_item->spec.d.def.m = lt->tm_mon + 1;1091current_item->spec.d.def.d = lt->tm_mday;1092}1093free((void *)date);1094}1095}
1096
1097static void1098st_collection_page_items_item_date_max(void)1099{
1100check_min_arg_count(1);1101
1102if (params_min_check(1))1103{1104check_arg_count(3);1105
1106current_item->spec.d.max.y = parse_int_range(0, 1900, 10000);1107current_item->spec.d.max.m = parse_int_range(1, 1, 12);1108current_item->spec.d.max.d = parse_int_range(2, 1, 31);1109}1110else1111{1112const char *date = parse_str(0);1113if (!strcasecmp(date, "today"))1114{1115time_t t = time(NULL);1116struct tm *lt = localtime(&t);1117
1118current_item->spec.d.max.y = lt->tm_year + 1900;1119current_item->spec.d.max.m = lt->tm_mon + 1;1120current_item->spec.d.max.d = lt->tm_mday;1121}1122free((void *)date);1123}1124}
1125
1126static void1127st_collection_page_items_item_date_min(void)1128{
1129check_min_arg_count(1);1130
1131if (params_min_check(1))1132{1133check_arg_count(3);1134
1135current_item->spec.d.min.y = parse_int_range(0, 1900, 10000);1136current_item->spec.d.min.m = parse_int_range(1, 1, 12);1137current_item->spec.d.min.d = parse_int_range(2, 1, 31);1138}1139else1140{1141const char *date = parse_str(0);1142if (!strcasecmp(date, "today"))1143{1144time_t t = time(NULL);1145struct tm *lt = localtime(&t);1146
1147current_item->spec.d.min.y = lt->tm_year + 1900;1148current_item->spec.d.min.m = lt->tm_mon + 1;1149current_item->spec.d.min.d = lt->tm_mday;1150}1151free((void *)date);1152}1153}
1154
1155static void1156ob_collection_page_items_item_text(void)1157{
1158//TODO: check if current item type match1159}
1160
1161static void1162ob_collection_page_items_item_textarea(void)1163{
1164//todo: check if current item type match1165}
1166
1167static void1168st_collection_page_items_item_string_placeholder(void)1169{
1170check_arg_count(1);1171
1172current_item->spec.s.placeholder = parse_str(0);1173}
1174
1175static void1176st_collection_page_items_item_string_default(void)1177{
1178check_arg_count(1);1179
1180current_item->spec.s.def = parse_str(0);1181}
1182
1183static void1184st_collection_page_items_item_string_accept(void)1185{
1186check_arg_count(1);1187
1188current_item->spec.s.accept = parse_str(0);1189
1190check_regex(current_item->spec.s.accept);1191}
1192
1193static void1194st_collection_page_items_item_string_deny(void)1195{
1196check_arg_count(1);1197
1198current_item->spec.s.deny = parse_str(0);1199
1200check_regex(current_item->spec.s.deny);1201}
1202
1203static void1204st_collection_page_items_item_string_max(void)1205{
1206check_arg_count(1);1207
1208current_item->spec.s.length.max = parse_int(0);1209}
1210
1211static void1212st_collection_page_items_item_string_min(void)1213{
1214check_arg_count(1);1215
1216current_item->spec.s.length.min = parse_int(0);1217}
1218