Rename first_year and last_year placeholders (#185)
This commit is contained in:
parent
71b0a8bd0e
commit
8f006a2600
3 changed files with 9 additions and 9 deletions
|
@ -52,12 +52,12 @@ class element extends \mod_customcert\element {
|
|||
/**
|
||||
* First year in a date range placeholder string.
|
||||
*/
|
||||
const FIRST_YEAR_PLACEHOLDER = '{{first_year}}';
|
||||
const FIRST_YEAR_PLACEHOLDER = '{{range_first_year}}';
|
||||
|
||||
/**
|
||||
* Last year in a date range placeholder string.
|
||||
*/
|
||||
const LAST_YEAR_PLACEHOLDER = '{{last_year}}';
|
||||
const LAST_YEAR_PLACEHOLDER = '{{range_last_year}}';
|
||||
|
||||
/**
|
||||
* A year in the user's date.
|
||||
|
@ -557,7 +557,7 @@ class element extends \mod_customcert\element {
|
|||
*
|
||||
* As recurring date ranges do not depend on the year,
|
||||
* we will use a date's year to build a new matched recurring date range with
|
||||
* start year and end year. This is required to replace placeholders like first_year and last_year.
|
||||
* start year and end year. This is required to replace placeholders like range_first_year and range_last_year.
|
||||
*
|
||||
* @param int $date Unix timestamp date to check.
|
||||
* @param \stdClass $range Range object.
|
||||
|
|
|
@ -33,7 +33,7 @@ $string['dateitem_help'] = 'This will be the date that is printed on the certifi
|
|||
$string['dateranges'] = 'Dateranges';
|
||||
$string['fallbackstring'] = 'Fallback string';
|
||||
$string['fallbackstring_help'] = 'This string will be displayed if no daterange applies to a date. If Fallback string is not set, then there will be no output at all.';
|
||||
$string['help'] = 'Configure a string representation for each daterange. Set start and end dates as well as a string you would like to transform each range to. Make sure your ranges do not overlap, otherwise the first detected daterange will be applied. If no daterange applied to a date, then Fallback string will be displayed. If Fallback string is not set, then there will be no output at all. If you mark a date range as Recurring, then the configured year will not be considered. As the year of a recurring date range is not considered, you are not allowed to configure a recurring date range with more than 12 months as it would become ambiguous otherwise. Also there are {{first_year}}, {{last_year}}, {{current_year}} and {{date_year}} placeholders that could be used in the string representation. The placeholders will be replaced by first year or last year in the matched range or the current year or a year from the users\'s date.';
|
||||
$string['help'] = 'Configure a string representation for each daterange. Set start and end dates as well as a string you would like to transform each range to. Make sure your ranges do not overlap, otherwise the first detected daterange will be applied. If no daterange applied to a date, then Fallback string will be displayed. If Fallback string is not set, then there will be no output at all. If you mark a date range as Recurring, then the configured year will not be considered. As the year of a recurring date range is not considered, you are not allowed to configure a recurring date range with more than 12 months as it would become ambiguous otherwise. Also there are {{range_first_year}}, {{range_last_year}}, {{current_year}} and {{date_year}} placeholders that could be used in the string representation. The placeholders will be replaced by first year or last year in the matched range or the current year or a year from the users\'s date.';
|
||||
$string['issueddate'] = 'Issued date';
|
||||
$string['maxranges'] = 'Maximum number ranges';
|
||||
$string['maxranges_desc'] = 'Set a maximum number of date ranges per each element';
|
||||
|
|
|
@ -125,7 +125,7 @@ class customcertelement_daterange_element_test extends advanced_testcase {
|
|||
(object)[
|
||||
'startdate' => strtotime('01.10.2017'),
|
||||
'enddate' => strtotime('31.03.2018'),
|
||||
'datestring' => 'WS {{first_year}}/{{last_year}}',
|
||||
'datestring' => 'WS {{range_first_year}}/{{range_last_year}}',
|
||||
'recurring' => true,
|
||||
'enabled' => true,
|
||||
],
|
||||
|
@ -170,17 +170,17 @@ class customcertelement_daterange_element_test extends advanced_testcase {
|
|||
(object)[
|
||||
'startdate' => strtotime('01.04.2017'),
|
||||
'enddate' => strtotime('30.09.2018'),
|
||||
'datestring' => '{{current_year}} - {{first_year}} - {{last_year}} - {{date_year}}',
|
||||
'datestring' => '{{current_year}} - {{range_first_year}} - {{range_last_year}} - {{date_year}}',
|
||||
'recurring' => false,
|
||||
'enabled' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$fallbackstring = '{{current_year}} - {{first_year}} - {{last_year}} - {{date_year}}';
|
||||
$fallbackstring = '{{current_year}} - {{range_first_year}} - {{range_last_year}} - {{date_year}}';
|
||||
$element = $this->get_datarange_element($dateranges, $fallbackstring);
|
||||
|
||||
$date = strtotime('1.01.2000');
|
||||
$expected = date('Y', time()) . ' - {{first_year}} - {{last_year}} - 2000';
|
||||
$expected = date('Y', time()) . ' - {{range_first_year}} - {{range_last_year}} - 2000';
|
||||
$this->assertEquals($expected, $element->get_daterange_string($date));
|
||||
|
||||
$date = strtotime('1.07.2017');
|
||||
|
@ -196,7 +196,7 @@ class customcertelement_daterange_element_test extends advanced_testcase {
|
|||
(object)[
|
||||
'startdate' => strtotime('01.04.2017'),
|
||||
'enddate' => strtotime('30.09.2018'),
|
||||
'datestring' => '{{current_year}} - {{first_year}} - {{last_year}} - {{date_year}}',
|
||||
'datestring' => '{{current_year}} - {{range_first_year}} - {{range_last_year}} - {{date_year}}',
|
||||
'recurring' => false,
|
||||
'enabled' => true,
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue