Example #1
0
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;
}
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
    //$xoopsTpl->assign("inemail",$xoopsUser->email());
} else {
    $uname = isset($_POST['uname']) ? $myts->stripSlashesGPC($_POST['uname']) : '';
    $url = isset($_POST['url']) ? trim($myts->stripSlashesGPC($_POST['url'])) : '';
    $timezone_offset = isset($_POST['timezone_offset']) ? intval($_POST['timezone_offset']) : $xoopsConfig['default_TZ'];
    $user_viewemail = isset($_POST['user_viewemail']) && intval($_POST['user_viewemail']) ? 1 : 0;
    $user_mailok = isset($_POST['user_mailok']) && intval($_POST['user_mailok']) ? 1 : 0;
    $agree_disc = isset($_POST['agree_disc']) && intval($_POST['agree_disc']) ? 1 : 0;
    $xoopsTpl->assign("noxoopsuser", 1);
    $xoopsTpl->assign("email_address", tep_draw_input_field('email_address'));
    $uname = new XoopsFormText(_PROFILE_MA_NICKNAME, "uname", 25, 75, $myts->htmlSpecialChars($uname));
    $xoopsTpl->assign("xoops_nick", $uname->render());
    $url = new XoopsFormText(_PROFILE_MI_URL_TITLE, "url", 25, 255, $myts->htmlSpecialChars($url));
    $xoopsTpl->assign("xoops_homepage", $url->render());
    $tzselected = $timezone_offset != "" ? $timezone_offset : $xoopsConfig['default_TZ'];
    $timezone = new XoopsFormSelectTimezone(_PROFILE_MA_TIMEZONE, "timezone_offset", $tzselected);
    $xoopsTpl->assign("xoops_timezone", $timezone->render());
    $mail = new XoopsFormRadioYN(_PROFILE_MA_MAILOK, 'user_mailok', $user_mailok);
    $xoopsTpl->assign("xoops_mailok", $mail->render());
    $email_option = new XoopsFormCheckBox("", "user_viewemail", $user_viewemail);
    $email_option->addOption(1, _PROFILE_MA_ALLOWVIEWEMAIL);
    $xoopsTpl->assign("xoops_viewemail", $email_option->render());
    if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') {
        $xoopsTpl->assign("show_disc", 1);
        $disc_tray = new XoopsFormElementTray(_PROFILE_MA_DISCLAIMER, '<br />');
        $disc_text = new XoopsFormTextarea('', 'disclaimer', $xoopsConfigUser['reg_disclaimer'], 8);
        $disc_text->setExtra('readonly="readonly"');
        $disc_tray->addElement($disc_text);
        $agree_chk = new XoopsFormCheckBox('', 'agree_disc', $agree_disc);
        $agree_chk->addOption(1, _PROFILE_MA_IAGREE);
        $disc_tray->addElement($agree_chk);