/** * Build the frontend HTML for the form field * * Method will build and return the frontend HTML of the loaded form field. The form field must be * loaded before hand * * @access public * @return string The frontend form field HTML if the form field was loaded beforehand, FALSE if not */ public function loadForFrontend() { if (!$this->isLoaded()) { return false; } $GLOBALS['FormFieldDayFieldArgs'] = ''; $GLOBALS['FormFieldMonthFieldArgs'] = ''; $GLOBALS['FormFieldYearFieldArgs'] = ''; $GLOBALS['FormFieldDefaultArgs'] = 'id="' . isc_html_escape($this->getFieldId()) . '" class="FormField"'; if ($this->extraInfo['limitfrom'] !== '') { $this->addExtraHiddenArgs('LimitFrom', $this->extraInfo['limitfrom']); } if ($this->extraInfo['limitto'] !== '') { $this->addExtraHiddenArgs('LimitTo', $this->extraInfo['limitto']); } if ($this->extraInfo['class'] !== '') { $GLOBALS['FormFieldDayFieldArgs'] .= 'class="' . isc_html_escape($this->extraInfo['class']) . ' FormFieldDay" '; $GLOBALS['FormFieldMonthFieldArgs'] .= 'class="' . isc_html_escape($this->extraInfo['class']) . ' FormFieldMonth" '; $GLOBALS['FormFieldYearFieldArgs'] .= 'class="' . isc_html_escape($this->extraInfo['class']) . ' FormFieldYear" '; } else { $GLOBALS['FormFieldDayFieldArgs'] .= 'class="FormFieldDay"'; $GLOBALS['FormFieldMonthFieldArgs'] .= 'class="FormFieldMonth"'; $GLOBALS['FormFieldYearFieldArgs'] .= 'class="FormFieldYear"'; } if ($this->extraInfo['style'] !== '') { $GLOBALS['FormFieldDayFieldArgs'] .= 'style="' . isc_html_escape($this->extraInfo['style']) . '" '; $GLOBALS['FormFieldMonthFieldArgs'] .= 'style="' . isc_html_escape($this->extraInfo['style']) . '" '; $GLOBALS['FormFieldYearFieldArgs'] .= 'style="' . isc_html_escape($this->extraInfo['style']) . '" '; } $GLOBALS['FormFieldDayFieldName'] = $this->getFieldName('Day'); $GLOBALS['FormFieldMonthFieldName'] = $this->getFieldName('Month'); $GLOBALS['FormFieldYearFieldName'] = $this->getFieldName('Year'); /** * Set the value */ if ($this->value == '' && $this->extraInfo['defaultvalue'] !== '') { $defaultValue = $this->extraInfo['defaultvalue']; } else if ($this->value == '') { if ($this->extraInfo['limitfrom'] !== '') { $defaultValue = $this->extraInfo['limitfrom']; } else { $defaultValue = ''; } } else { $defaultValue = $this->value; } /** * Now the day, month and year options */ $defaultDate = array(); if ($defaultValue !== '') { $defaultDate = explode('-', $defaultValue); } $defaultDate = array_filter($defaultDate, 'is_numeric'); if (count($defaultDate) !== 3) { $defaultDate = array(); } /** * Find the available date ranges */ $ranges = $this->findAvailableDateRange(); /** * Day */ if (empty($defaultDate)) { $GLOBALS['FormFieldDayOptions'] = '<option value="" selected>--</option>'; } else { $GLOBALS['FormFieldDayOptions'] = '<option value="">--</option>'; } $range = $ranges['day']; for ($i=$range['from']; $i<=$range['to']; $i++) { $GLOBALS['FormFieldDayOptions'] .= '<option value="' . (int)$i . '"'; if (isset($defaultDate[2]) && (int)$defaultDate[2] == $i) { $GLOBALS['FormFieldDayOptions'] .= ' selected="selected"'; } $GLOBALS['FormFieldDayOptions'] .= '>' . isc_html_escape(Store_Number::addOrdinalSuffix($i)) . '</option>'; } /** * Month */ if (empty($defaultDate)) { $GLOBALS['FormFieldMonthOptions'] = '<option value="" selected>---</option>'; } else { $GLOBALS['FormFieldMonthOptions'] = '<option value="">---</option>'; } $range = $ranges['month']; for ($i=$range['from']; $i<=$range['to']; $i++) { $month = date('F', mktime(1, 1, 1, $i, 1, date('Y'))); $month = ucfirst(isc_strtolower($month)) . 'Short'; $GLOBALS['FormFieldMonthOptions'] .= '<option value="' . (int)$i . '"'; if (isset($defaultDate[1]) && (int)$defaultDate[1] == $i) { $GLOBALS['FormFieldMonthOptions'] .= ' selected="selected"'; } $GLOBALS['FormFieldMonthOptions'] .= '>' . isc_html_escape(GetLang($month)) . '</option>'; } /** * Year */ if (empty($defaultDate)) { $GLOBALS['FormFieldYearOptions'] = '<option value="" selected>----</option>'; } else { $GLOBALS['FormFieldYearOptions'] = '<option value="">----</option>'; } $range = $ranges['year']; for ($i=$range['from']; $i<=$range['to']; $i++) { $GLOBALS['FormFieldYearOptions'] .= '<option value="' . (int)$i . '"'; if (isset($defaultDate[0]) && (int)$defaultDate[0] == $i) { $GLOBALS['FormFieldYearOptions'] .= ' selected="selected"'; } $GLOBALS['FormFieldYearOptions'] .= '>' . (int)$i . '</option>'; } return $this->buildForFrontend(); }