function salat_block_show($options) { $block = array(); $infos = salat_getInfos(); $sform = new XoopsThemeForm(_MA_SALAT_GETPRAYERS, "form", XOOPS_URL . '/modules/salat/index.php'); foreach ($infos as $info) { $options[$info['city']] = $info['city'] . ' - ' . $info['country']; if (isset($info['default'])) { $default = $info['city']; } } $city = isset($default) ? $default : ''; $date = time(); $timezone = 0; // City $element = new XoopsFormSelect(_MA_SALAT_SELECT_CITY, 'city', $city); $element->addOptionArray($options); $element->setExtra('width="100" style="width:100px;"'); $sform->addElement($element); unset($element); $element = new XoopsFormTextDateSelect(_MA_SALAT_SELECT_DATE, 'date', 12, $date); //$element->setExtra('width="100" style="width:100px;"'); $sform->addElement($element); unset($element); // Timezone $element = new XoopsFormSelectTimezone(_MA_SALAT_SELECT_TIMEZONE, 'timezone', $timezone); $element->setExtra('width="100" style="width:100px;"'); $sform->addElement($element); unset($element); $sform->addElement(new XoopsFormButton('', 'get_prayers', _SUBMIT, 'submit')); $block['content'] = $sform->render(); return $block; }
/** * Returns a {@link XoopsFormElement} for editing the value of this field * * @param XoopsUser $user {@link XoopsUser} object to edit the value of * @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of * * @return XoopsFormElement **/ function getEditElement($user, $profile) { $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e'); $caption = $this->getVar('field_title'); $caption = defined($caption) ? constant($caption) : $caption; $name = $this->getVar('field_name', 'e'); $options = $this->getVar('field_options'); if (is_array($options)) { //asort($options); foreach (array_keys($options) as $key) { $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key]; $optkey = defined($key) ? constant($key) : $key; unset($options[$key]); $options[$optkey] = $optval; } } include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); switch ($this->getVar('field_type')) { default: case "autotext": //autotext is not for editing $element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile)); break; case "textbox": $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; case "textarea": $element = new XoopsFormTextArea($caption, $name, $value, 4, 30); break; case "dhtml": $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30); break; case "select": $element = new XoopsFormSelect($caption, $name, $value); // If options do not include an empty element, then add a blank option to prevent any default selection if (!in_array('', array_keys($options))) { $element->addOption('', _NONE); $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++ ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }"; } $element->addOptionArray($options); break; case "select_multi": $element = new XoopsFormSelect($caption, $name, $value, 5, true); $element->addOptionArray($options); break; case "radio": $element = new XoopsFormRadio($caption, $name, $value); $element->addOptionArray($options); break; case "checkbox": $element = new XoopsFormCheckBox($caption, $name, $value); $element->addOptionArray($options); break; case "yesno": $element = new XoopsFormRadioYN($caption, $name, $value); break; case "group": $element = new XoopsFormSelectGroup($caption, $name, true, $value); break; case "group_multi": $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true); break; case "language": $element = new XoopsFormSelectLang($caption, $name, $value); break; case "date": $element = new XoopsFormTextDateSelect($caption, $name, 15, $value); break; case "longdate": $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value)); break; case "datetime": $element = new XoopsFormDatetime($caption, $name, 15, $value); break; case "list": $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]); break; case "timezone": $element = new XoopsFormSelectTimezone($caption, $name, $value); $element->setExtra("style='width: 280px;'"); break; case "rank": $element = new XoopsFormSelect($caption, $name, $value); include_once $GLOBALS['xoops']->path('class/xoopslists.php'); $ranks = XoopsLists::getUserRankList(); $element->addOption(0, "--------------"); $element->addOptionArray($ranks); break; case 'theme': $element = new XoopsFormSelect($caption, $name, $value); $element->addOption("0", _PROFILE_MA_SITEDEFAULT); $handle = opendir(XOOPS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}\$/", $file) && strtolower($file) != 'cvs') { if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) { $dirlist[$file] = $file; } } } closedir($handle); if (!empty($dirlist)) { asort($dirlist); $element->addOptionArray($dirlist); } break; } if ($this->getVar('field_description') != "") { $element->setDescription($this->getVar('field_description')); } return $element; }
/** * Returns a {@link XoopsFormElement} for editing the value of this field * * @param XoopsUser $user {@link XoopsUser} object to edit the value of * @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of * * @return XoopsFormElement **/ public function getEditElement($user, $profile) { $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e'); $caption = $this->getVar('field_title'); $caption = defined($caption) ? constant($caption) : $caption; $name = $this->getVar('field_name', 'e'); $options = $this->getVar('field_options'); if (is_array($options)) { //asort($options); foreach (array_keys($options) as $key) { $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key]; $optkey = defined($key) ? constant($key) : $key; unset($options[$key]); $options[$optkey] = $optval; } } include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); switch ($this->getVar('field_type')) { default: case 'autotext': //autotext is not for editing $element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile)); break; case 'textbox': $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; case 'textarea': $element = new XoopsFormTextArea($caption, $name, $value, 4, 30); break; case 'dhtml': $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30); break; case 'select': $element = new XoopsFormSelect($caption, $name, $value); // If options do not include an empty element, then add a blank option to prevent any default selection // if (!in_array('', array_keys($options))) { if (!array_key_exists('', $options)) { $element->addOption('', _NONE); $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++) { if (selectBox.options[i].selected == true && selectBox.options[i].value != '') { hasSelected = true; break; } }" . "if (!hasSelected) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }"; } $element->addOptionArray($options); break; case 'select_multi': $element = new XoopsFormSelect($caption, $name, $value, 5, true); $element->addOptionArray($options); break; case 'radio': $element = new XoopsFormRadio($caption, $name, $value); $element->addOptionArray($options); break; case 'checkbox': $element = new XoopsFormCheckBox($caption, $name, $value); $element->addOptionArray($options); break; case 'yesno': $element = new XoopsFormRadioYN($caption, $name, $value); break; case 'group': $element = new XoopsFormSelectGroup($caption, $name, true, $value); break; case 'group_multi': $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true); break; case 'language': $element = new XoopsFormSelectLang($caption, $name, $value); break; case 'date': $element = new XoopsFormTextDateSelect($caption, $name, 15, $value); break; case 'longdate': $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace('-', '/', $value)); break; case 'datetime': $element = new XoopsFormDatetime($caption, $name, 15, $value); break; case 'list': $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]); break; case 'timezone': $element = new XoopsFormSelectTimezone($caption, $name, $value); $element->setExtra("style='width: 280px;'"); break; case 'rank': $element = new XoopsFormSelect($caption, $name, $value); include_once $GLOBALS['xoops']->path('class/xoopslists.php'); $ranks = XoopsLists::getUserRankList(); $element->addOption(0, '--------------'); $element->addOptionArray($ranks); break; case 'theme': $element = new XoopsFormSelectTheme($caption, $name, $value, 1, true); break; } if ($this->getVar('field_description') != '') { $element->setDescription($this->getVar('field_description')); } return $element; }