/** * Render event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * * @return string The rendered output */ public function render(Zikula_Form_View $view) { if (!empty($this->defaultText) && ($this->text == null || empty($this->text))) { $this->text = $this->defaultText; } return parent::render($view); }
/** * Render event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * * @return string The rendered output */ public function render(Zikula_Form_View $view) { static $firstTime = true; if ($firstTime) { PageUtil::addVar('stylesheet', 'javascript/picky_color/picky_color.css'); PageUtil::addVar('javascript', 'javascript/picky_color/picky_color.js'); } $firstTime = false; $dom = ZLanguage::getModuleDomain('Reviews'); $result = parent::render($view); if ($this->readOnly) { return $result; } $result .= "<script type=\"text/javascript\">\n /* <![CDATA[ */\n var namePicky = new PickyColor({\n field: '" . $this->getId() . "',\n color: '" . DataUtil::formatForDisplay($this->text) . "',\n colorWell: '" . $this->getId() . "',\n closeText: '" . __('Close', $dom) . "'\n })\n /* ]]> */\n </script>"; return $result; }
/** * Render event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * * @return string The rendered output */ public function render(Zikula_Form_View $view) { static $firstTime = true; $i18n = ZI18n::getInstance(); if (!empty($this->defaultValue) && !$view->isPostBack()) { $d = strtolower($this->defaultValue); $now = getdate(); $date = null; if ($d == 'now') { $date = time(); } elseif ($d == 'today') { $date = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']); } elseif ($d == 'monthstart') { $date = mktime(0, 0, 0, $now['mon'], 1, $now['year']); } elseif ($d == 'monthend') { $daysInMonth = date('t'); $date = mktime(0, 0, 0, $now['mon'], $daysInMonth, $now['year']); } elseif ($d == 'yearstart') { $date = mktime(0, 0, 0, 1, 1, $now['year']); } elseif ($d == 'yearend') { $date = mktime(0, 0, 0, 12, 31, $now['year']); } elseif ($d == 'custom') { $date = strtotime($this->initDate); } if ($date != null) { $this->text = DateUtil::getDatetime($date, $this->ifFormat, false); } else { $this->text = __('Unknown date'); } } if ($view->isPostBack() && !empty($this->text)) { $date = strtotime($this->text); $this->text = DateUtil::getDatetime($date, $this->ifFormat, false); } if ($firstTime) { $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode()); // map of the jscalendar supported languages $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR'); if (isset($map[$lang])) { $lang = $map[$lang]; } $headers[] = 'javascript/jscalendar/calendar.js'; if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) { $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js"; } $headers[] = 'javascript/jscalendar/calendar-setup.js'; PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css'); PageUtil::addVar('javascript', $headers); } $firstTime = false; $result = ''; if ($this->useSelectionMode) { $hiddenInputField = str_replace(array('type="text"', ' *'), array('type="hidden"', ''), parent::render($view)); $result .= '<div>' . $hiddenInputField . '<span id="' . $this->id . 'cal" style="background-color: #ff8; cursor: default" onmouseover="this.style.backgroundColor=\'#ff0\';" onmouseout="this.style.backgroundColor=\'#ff8\';">'; if ($this->text) { $result .= DataUtil::formatForDisplay(DateUtil::getDatetime(DateUtil::parseUIDate($this->text, $this->ifFormat), $this->daFormat)); } else { $result .= __('Select date'); } $result .= '</span></div>'; if ($this->mandatory && $this->mandatorysym) { $result .= '<span class="z-form-mandatory-flag">*</span>'; } } else { $result .= '<span class="z-form-date" style="white-space: nowrap">'; $result .= parent::render($view); $txt = __('Select date'); $result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\"{$txt}\" /></span>"; } // build jsCalendar script options $result .= "<script type=\"text/javascript\">\n // <![CDATA[\n Calendar.setup(\n {\n inputField : \"{$this->id}\","; if ($this->includeTime) { $this->initDate = str_replace('-', ',', $this->initDate); $result .= "\n ifFormat : \"" . $this->ifFormat . "\",\n showsTime : true,\n timeFormat : \"" . $i18n->locale->getTimeformat() . "\",\n singleClick : false,"; } else { $result .= "\n ifFormat : \"" . $this->ifFormat . "\","; } if ($this->useSelectionMode) { $result .= "\n displayArea : \"{$this->id}cal\",\n daFormat : \"{$this->daFormat}\",\n align : \"Bl\",\n singleClick : true,"; } else { $result .= "\n button : \"{$this->id}_img\","; } $result .= "\n firstDay: " . $i18n->locale->getFirstweekday() . "\n }\n );\n // ]]>\n </script>"; return $result; }
/** * Render event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * * @return string The rendered output */ public function render(Zikula_Form_View $view) { $this->text = DataUtil::formatNumber($this->text, $this->precision); return Zikula_Form_Plugin_TextInput::render($view); }