Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
c4d671a3
Commit
c4d671a3
authored
Jan 29, 2008
by
Nigel McNie
Browse files
Upgraded to pieforms 0.3 branch. Now let's watch everything break.
parent
bbeaad37
Changes
36
Expand all
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/pieforms/pieform.php
View file @
c4d671a3
This diff is collapsed.
Click to expand it.
htdocs/lib/pieforms/pieform/elements/button.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieform
* @subpackage element
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -34,13 +34,13 @@
* @return string The HTML for the element
* @todo rename to inputbutton
*/
function
pieform_element_button
(
Pieform
$form
,
$element
)
{
function
pieform_element_button
(
Pieform
$form
,
$element
)
{
/*{{{*/
if
(
!
isset
(
$element
[
'value'
]))
{
throw
new
PieformException
(
'Button elements must have a value'
);
}
return
'<input type="button"'
.
$form
->
element_attributes
(
$element
)
.
' value="'
.
Pieform
::
hsc
(
$element
[
'value'
])
.
'">'
;
}
}
/*}}}*/
?>
htdocs/lib/pieforms/pieform/elements/bytes.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieform
* @subpackage element
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -32,7 +32,7 @@
* @param array $element The element to render
* @return string The HTML for the element
*/
function
pieform_element_bytes
(
Pieform
$form
,
$element
)
{
function
pieform_element_bytes
(
Pieform
$form
,
$element
)
{
/*{{{*/
$formname
=
$form
->
get_name
();
$result
=
''
;
$name
=
$element
[
'name'
];
...
...
@@ -78,7 +78,7 @@ function pieform_element_bytes(Pieform $form, $element) {
$uselect
.
=
"</select>
\n
"
;
return
$numberinput
.
$uselect
;
}
}
/*}}}*/
/**
* Gets the value of the expiry element and converts it to a time in seconds.
...
...
@@ -87,7 +87,7 @@ function pieform_element_bytes(Pieform $form, $element) {
* @param array $element The element to get the value for
* @return int The number of seconds until expiry
*/
function
pieform_element_bytes_get_value
(
Pieform
$form
,
$element
)
{
function
pieform_element_bytes_get_value
(
Pieform
$form
,
$element
)
{
/*{{{*/
$name
=
$element
[
'name'
];
$global
=
(
$form
->
get_property
(
'method'
)
==
'get'
)
?
$_GET
:
$_POST
;
...
...
@@ -103,9 +103,9 @@ function pieform_element_bytes_get_value(Pieform $form, $element) {
return
null
;
}
return
$number
*
pieform_element_bytes_in
(
$unit
);
}
}
/*}}}*/
function
pieform_element_bytes_in
(
$units
)
{
function
pieform_element_bytes_in
(
$units
)
{
/*{{{*/
switch
(
$units
)
{
case
'megabytes'
:
return
1048576
;
...
...
@@ -117,9 +117,9 @@ function pieform_element_bytes_in($units) {
return
1
;
break
;
};
}
}
/*}}}*/
function
pieform_element_bytes_i18n
()
{
function
pieform_element_bytes_i18n
()
{
/*{{{*/
return
array
(
'en.utf8'
=>
array
(
'bytes'
=>
'Bytes'
,
...
...
@@ -140,13 +140,13 @@ function pieform_element_bytes_i18n() {
'invalidvalue'
=>
'Valeur doit être un nombre'
,
),
);
}
}
/*}}}*/
function
pieform_element_bytes_get_bytes_units
()
{
function
pieform_element_bytes_get_bytes_units
()
{
/*{{{*/
return
array
(
'bytes'
,
'kilobytes'
,
'megabytes'
);
}
}
/*}}}*/
function
pieform_element_bytes_get_bytes_from_bytes
(
$bytes
)
{
function
pieform_element_bytes_get_bytes_from_bytes
(
$bytes
)
{
/*{{{*/
if
(
$bytes
==
null
)
{
return
array
(
'number'
=>
'0'
,
'units'
=>
'bytes'
);
}
...
...
@@ -158,6 +158,6 @@ function pieform_element_bytes_get_bytes_from_bytes($bytes) {
}
return
array
(
'number'
=>
$bytes
,
'units'
=>
'bytes'
);
}
}
/*}}}*/
?>
htdocs/lib/pieforms/pieform/elements/calendar.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieform
* @subpackage element
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -34,7 +34,7 @@
* @param array $element The element to render
* @return string The HTML for the element
*/
function
pieform_element_calendar
(
Pieform
$form
,
$element
)
{
function
pieform_element_calendar
(
Pieform
$form
,
$element
)
{
/*{{{*/
$id
=
$form
->
get_name
()
.
'_'
.
$element
[
'name'
];
$value
=
$form
->
get_value
(
$element
);
if
(
$value
)
{
...
...
@@ -66,7 +66,7 @@ function pieform_element_calendar(Pieform $form, $element) {
$result
.
=
'<script type="text/javascript">Calendar.setup('
.
$encodedoptions
.
');</script>'
;
return
$result
;
}
}
/*}}}*/
/**
* Sets default attributes of the calendar element.
...
...
@@ -74,14 +74,14 @@ function pieform_element_calendar(Pieform $form, $element) {
* @param array $element The element to configure
* @return array The configured element
*/
function
pieform_element_calendar_set_attributes
(
$element
)
{
function
pieform_element_calendar_set_attributes
(
$element
)
{
/*{{{*/
$element
[
'jsroot'
]
=
isset
(
$element
[
'jsroot'
])
?
$element
[
'jsroot'
]
:
''
;
$element
[
'language'
]
=
isset
(
$element
[
'language'
])
?
$element
[
'language'
]
:
'en'
;
$element
[
'theme'
]
=
isset
(
$element
[
'theme'
])
?
$element
[
'theme'
]
:
'calendar-win2k-2'
;
$element
[
'caloptions'
][
'ifFormat'
]
=
isset
(
$element
[
'caloptions'
][
'ifFormat'
])
?
$element
[
'caloptions'
][
'ifFormat'
]
:
'%Y/%m/%d'
;
$element
[
'caloptions'
][
'daFormat'
]
=
isset
(
$element
[
'caloptions'
][
'daFormat'
])
?
$element
[
'caloptions'
][
'daFormat'
]
:
'%Y/%m/%d'
;
return
$element
;
}
}
/*}}}*/
/**
* Returns code to go in <head> for the given calendar instance
...
...
@@ -89,7 +89,7 @@ function pieform_element_calendar_set_attributes($element) {
* @param array $element The element to get <head> code for
* @return array An array of HTML elements to go in the <head>
*/
function
pieform_element_calendar_get_headdata
(
$element
)
{
function
pieform_element_calendar_get_headdata
(
$element
)
{
/*{{{*/
if
(
isset
(
$element
[
'themefile'
]))
{
$themefile
=
$element
[
'themefile'
];
}
...
...
@@ -109,7 +109,7 @@ function pieform_element_calendar_get_headdata($element) {
'<script type="text/javascript" src="'
.
$setupfile
.
'"></script>'
);
return
$result
;
}
}
/*}}}*/
/**
* Retrieves the value of the calendar as a unix timestamp
...
...
@@ -118,7 +118,7 @@ function pieform_element_calendar_get_headdata($element) {
* @param array $element The element to get the value for
* @return int The unix timestamp represented by the calendar
*/
function
pieform_element_calendar_get_value
(
Pieform
$form
,
$element
)
{
function
pieform_element_calendar_get_value
(
Pieform
$form
,
$element
)
{
/*{{{*/
$name
=
$element
[
'name'
];
$global
=
(
$form
->
get_property
(
'method'
)
==
'get'
)
?
$_GET
:
$_POST
;
...
...
@@ -145,12 +145,12 @@ function pieform_element_calendar_get_value(Pieform $form, $element) {
}
return
null
;
}
}
/*}}}*/
/**
* i18n for calendar
*/
function
pieform_element_calendar_i18n
()
{
function
pieform_element_calendar_i18n
()
{
/*{{{*/
return
array
(
'en.utf8'
=>
array
(
'invalidvalue'
=>
'Invalid date/time specified'
...
...
@@ -162,6 +162,6 @@ function pieform_element_calendar_i18n() {
'invalidvalue'
=>
'Date/Heure indiquée invalide'
),
);
}
}
/*}}}*/
?>
htdocs/lib/pieforms/pieform/elements/cancel.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieform
* @subpackage element
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -33,7 +33,7 @@
* @param array $element The element to render
* @return string The HTML for the element
*/
function
pieform_element_cancel
(
Pieform
$form
,
$element
)
{
function
pieform_element_cancel
(
Pieform
$form
,
$element
)
{
/*{{{*/
if
(
!
isset
(
$element
[
'value'
]))
{
throw
new
PieformException
(
'Cancel elements must have a value'
);
}
...
...
@@ -48,11 +48,11 @@ function pieform_element_cancel(Pieform $form, $element) {
return
'<input type="submit"'
.
$attributes
.
' value="'
.
Pieform
::
hsc
(
$element
[
'value'
])
.
'">'
;
}
}
/*}}}*/
function
pieform_element_cancel_set_attributes
(
$element
)
{
function
pieform_element_cancel_set_attributes
(
$element
)
{
/*{{{*/
$element
[
'cancelelement'
]
=
true
;
return
$element
;
}
}
/*}}}*/
?>
htdocs/lib/pieforms/pieform/elements/checkbox.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieform
* @subpackage element
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -31,7 +31,7 @@
* @param array $element The element to render
* @return string The HTML for the element
*/
function
pieform_element_checkbox
(
Pieform
$form
,
$element
)
{
function
pieform_element_checkbox
(
Pieform
$form
,
$element
)
{
/*{{{*/
$checked
=
false
;
if
(
!
empty
(
$element
[
'value'
]))
{
$checked
=
true
;
...
...
@@ -48,9 +48,9 @@ function pieform_element_checkbox(Pieform $form, $element) {
.
$form
->
element_attributes
(
$element
)
.
(
$checked
?
' checked="checked"'
:
''
)
.
'>'
;
}
}
/*}}}*/
function
pieform_element_checkbox_get_value
(
Pieform
$form
,
$element
)
{
function
pieform_element_checkbox_get_value
(
Pieform
$form
,
$element
)
{
/*{{{*/
$name
=
$element
[
'name'
];
$global
=
(
$form
->
get_property
(
'method'
)
==
'get'
)
?
$_GET
:
$_POST
;
...
...
@@ -70,6 +70,6 @@ function pieform_element_checkbox_get_value(Pieform $form, $element) {
}
return
false
;
}
}
/*}}}*/
?>
htdocs/lib/pieforms/pieform/elements/date.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieforms
* @subpackage element
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -31,7 +31,7 @@
* @param array $element The element to render
* @return string The HTML for the element
*/
function
pieform_element_date
(
Pieform
$form
,
$element
)
{
function
pieform_element_date
(
Pieform
$form
,
$element
)
{
/*{{{*/
$result
=
''
;
$name
=
$element
[
'name'
];
$element
[
'minyear'
]
=
(
isset
(
$element
[
'minyear'
]))
?
intval
(
$element
[
'minyear'
])
:
1950
;
...
...
@@ -104,7 +104,7 @@ EOF;
}
return
$result
;
}
}
/*}}}*/
/**
* Gets the value of the date element from the request and converts it into a
...
...
@@ -113,7 +113,7 @@ EOF;
* @param Pieform $form The form the element is attached to
* @param array $element The element to get the value for
*/
function
pieform_element_date_get_value
(
Pieform
$form
,
$element
)
{
function
pieform_element_date_get_value
(
Pieform
$form
,
$element
)
{
/*{{{*/
$name
=
$element
[
'name'
];
$global
=
(
$form
->
get_property
(
'method'
)
==
'get'
)
?
$_GET
:
$_POST
;
if
(
isset
(
$global
[
$name
.
'_day'
])
&&
isset
(
$global
[
$name
.
'_month'
])
&&
isset
(
$global
[
$name
.
'_year'
])
)
{
...
...
@@ -125,9 +125,9 @@ function pieform_element_date_get_value(Pieform $form, $element) {
}
return
null
;
}
}
/*}}}*/
function
pieform_element_date_i18n
()
{
function
pieform_element_date_i18n
()
{
/*{{{*/
return
array
(
'en.utf8'
=>
array
(
'or'
=>
'or'
,
...
...
@@ -142,10 +142,10 @@ function pieform_element_date_i18n() {
'notspecified'
=>
'Non indiqué'
),
);
}
}
/*}}}*/
/** helper: used when rendering the element, to get the value for it */
function
pieform_element_date_get_timeperiod_value
(
$timeperiod
,
$min
,
$max
,
$element
,
Pieform
$form
)
{
function
pieform_element_date_get_timeperiod_value
(
$timeperiod
,
$min
,
$max
,
$element
,
Pieform
$form
)
{
/*{{{*/
static
$lookup
=
array
(
'year'
=>
0
,
'month'
=>
1
,
...
...
@@ -189,6 +189,6 @@ function pieform_element_date_get_timeperiod_value($timeperiod, $min, $max, $ele
}
return
$value
;
}
}
/*}}}*/
?>
htdocs/lib/pieforms/pieform/elements/expiry.php
View file @
c4d671a3
<?php
/**
* This program is part of Pieforms
* Pieforms: Advanced web forms made easy
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
*
This program is free software
;
you can redistribute it and/or modify
*
it under the terms of the GNU General Public License as published by
*
the Free Software Foundation
;
either version
2
of the License, or
*
(at your option) any later version.
* This program is free software
:
you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation
,
either version
3
of the License, or
* (at your option) any later version.
*
*
This program is distributed in the hope that it will be useful,
*
but WITHOUT ANY WARRANTY; without even the implied warranty of
*
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package pieform
* @subpackage element
* @author Richard Mansfield <richard.mansfield@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
* @copyright (C) 2006
-2008
Catalyst IT Ltd http://catalyst.net.nz
*
*/
...
...
@@ -32,7 +32,7 @@
* @param array $element The element to render
* @return string The HTML for the element
*/
function
pieform_element_expiry
(
Pieform
$form
,
$element
)
{
function
pieform_element_expiry
(
Pieform
$form
,
$element
)
{
/*{{{*/
$formname
=
$form
->
get_name
();
$result
=
''
;
$name
=
$element
[
'name'
];
...
...
@@ -98,7 +98,7 @@ function {$name}_change() {
EOJS;
return
$numberinput
.
$uselect
.
$script
;
}
}
/*}}}*/
/**
* Gets the value of the expiry element and converts it to a time in seconds.
...
...
@@ -107,7 +107,7 @@ EOJS;
* @param array $element The element to get the value for
* @return int The number of seconds until expiry
*/
function
pieform_element_expiry_get_value
(
Pieform
$form
,
$element
)
{
function
pieform_element_expiry_get_value
(
Pieform
$form
,
$element
)
{
/*{{{*/
$name
=
$element
[
'name'
];
$global
=
(
$form
->
get_property
(
'method'
)
==
'get'
)
?
$_GET
:
$_POST
;
$unit
=
$global
[
$name
.
'_units'
];
...
...
@@ -120,9 +120,9 @@ function pieform_element_expiry_get_value(Pieform $form, $element) {
return
null
;
}
return
$number
*
pieform_element_expiry_seconds_in
(
$unit
);
}
}
/*}}}*/
function
pieform_element_expiry_i18n
()
{
function
pieform_element_expiry_i18n
()
{
/*{{{*/
return
array
(
'en.utf8'
=>
array
(
'days'
=>
'Days'
,
...
...
@@ -146,13 +146,13 @@ function pieform_element_expiry_i18n() {
'noenddate'
=>
'Pas de date de fin'
),
);
}
}
/*}}}*/
function
pieform_element_expire_get_expiry_units
()
{
function
pieform_element_expire_get_expiry_units
()
{
/*{{{*/
return
array
(
'days'
,
'weeks'
,
'months'
,
'years'
,
'noenddate'
);
}
}
/*}}}*/
function
pieform_element_expiry_seconds_in
(
$unit
)
{
function
pieform_element_expiry_seconds_in
(
$unit
)
{
/*{{{*/
$dayseconds
=
60
*
60
*
24
;
switch
(
$unit
)
{
case
'days'
:
return
$dayseconds
;
...
...
@@ -161,9 +161,9 @@ function pieform_element_expiry_seconds_in($unit) {
case
'years'
:
return
$dayseconds
*
365
;