/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function __construct($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false) { $limit = 200; $select_element = new Xmf_Form_Element_Select("", $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS["xoopsConfig"]['anonymous']); } $member_handler =& xoops_gethandler('member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new CriteriaCompo(new Criteria("uid", "(" . implode(",", $value) . ")", "IN")); } else { $criteria = new CriteriaCompo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { parent::__construct($caption, "", $name); $this->addElement($select_element); return; } xoops_loadLanguage("findusers"); $js_addusers = "<script type=\"text/javascript\">\r\n function addusers(opts){\r\n var num = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");\r\n var arr = new Array(num);\r\n for (var n=0; n < num; n++) {\r\n var nm = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var val = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var txt = opts.substring(0, nm - val.length);\r\n opts = opts.substring(nm - val.length, opts.length);\r\n var added = false;\r\n for (var k = 0; k < sel.options.length; k++) {\r\n if(sel.options[k].value == val){\r\n added = true;\r\n break;\r\n }\r\n }\r\n if (added == false) {\r\n sel.options[k] = new Option(txt, val);\r\n sel.options[k].selected = true;\r\n }\r\n }\r\n return true;\r\n }\r\n </script>"; $token = $GLOBALS['xoopsSecurity']->createToken(); $action_tray = new Xmf_Form_Element_Tray("", " | "); $action_tray->addElement(new Xmf_Form_Element_Label('', "<a href='#' onclick='var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;'>" . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new Xmf_Form_Element_Label('', "<a href='#' onclick='openWithSelfMain(\"" . XOOPS_URL . "/include/findusers.php?target={$name}&multiple={$multiple}&token={$token}\", \"userselect\", 800, 600, null); return false;' >" . _MA_USER_MORE . "</a>" . $js_addusers)); parent::__construct($caption, "<br /><br />", $name); $this->addElement($select_element); $this->addElement($action_tray); }
function render() { $editor_handler = Xmf_Form_Element_Editor_Handler::getInstance(); $editor_handler->allowed_editors = $this->allowed_editors; $option_select = new Xmf_Form_Element_Select("", $this->name, $this->value); $extra = 'onchange="if(this.options[this.selectedIndex].value.length > 0 ){ window.document.forms.' . $this->form->getName() . '.submit(); }"'; $option_select->setExtra($extra); $option_select->addOptionArray($editor_handler->getList($this->nohtml)); $this->addElement($option_select); return parent::render(); }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * Legal values are {@link XOOPS_MATCH_START}, {@link XOOPS_MATCH_END}, * {@link XOOPS_MATCH_EQUAL}, and {@link XOOPS_MATCH_CONTAIN} * @param int $size Number of rows. "1" makes a drop-down-list */ function __construct($caption, $name, $value = null, $size = 1) { parent::__construct($caption, $name, $value, $size, false); $this->addOption(XOOPS_MATCH_START, _STARTSWITH); $this->addOption(XOOPS_MATCH_END, _ENDSWITH); $this->addOption(XOOPS_MATCH_EQUAL, _MATCHES); $this->addOption(XOOPS_MATCH_CONTAIN, _CONTAINS); }
/** * Constructor * * @param string $caption * @param string $name * @param bool $include_anon Include group "anonymous"? * @param mixed $value Pre-selected value (or array of them). * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function __construct($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false) { parent::__construct($caption, $name, $value, $size, $multiple); $member_handler =& xoops_gethandler('member'); if (!$include_anon) { $this->addOptionArray($member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!='))); } else { $this->addOptionArray($member_handler->getGroupList()); } }
function __construct($caption, $name, $size = 15, $value = 0) { parent::__construct($caption, ' '); $value = intval($value); $value = $value > 0 ? $value : time(); $datetime = getDate($value); $this->addElement(new Xmf_Form_Element_Text_DateSelect('', $name . '[date]', $size, $value)); $timearray = array(); for ($i = 0; $i < 24; $i++) { for ($j = 0; $j < 60; $j = $j + 10) { $key = $i * 3600 + $j * 60; $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j; } } ksort($timearray); $timeselect = new Xmf_Form_Element_Select('', $name . '[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10)); $timeselect->addOptionArray($timearray); $this->addElement($timeselect); }
/** * Constructor * @param object $object reference to targetobject (@link IcmsPersistableObject) * @param string $key the form name */ function __construct($object, $key) { $var = $object->vars[$key]; $timearray = array(); for ($i = 0; $i < 24; $i++) { for ($j = 0; $j < 60; $j = $j + 10) { $key_t = $i * 3600 + $j * 60; $timearray[$key_t] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j; } } ksort($timearray); parent::__construct($var['title'], $key, $object->getVar($key, 'e')); $this->addOptionArray($timearray); }
/** * Constructor * @param object $object reference to targetobject (@link IcmsPersistableObject) * @param string $key the form name */ function __construct($object, $var) { $category_title_field = $object->handler->identifierName; $control = $object->getVarControl($var); $addNoParent = isset($control['addNoParent']) ? $control['addNoParent'] : true; $criteria = new Xmf_Criteria_Compo(); $criteria->setSort("weight, " . $category_title_field); $category_handler = xoops_getmodulehandler('category', $object->handler->_moduleName); $categories = $category_handler->getObjects($criteria); $mytree = new Xmf_Object_Tree($categories, "category_id", "category_pid"); parent::__construct($object->getVarKey($var, 'title'), $var, $object->getVar($var, 'e')); $ret = array(); $options = $this->getOptionArray($mytree, $category_title_field, 0, "", $ret); if ($addNoParent) { $newOptions = array('0' => '----'); foreach ($options as $k => $v) { $newOptions[$k] = $v; } $options = $newOptions; } $this->addOptionArray($options); }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * @param int $size Number or rows. "1" makes a drop-down-list */ function __construct($caption, $name, $value = null, $size = 1) { parent::__construct($caption, $name, $value, $size); $this->addOptionArray(Xmf_Lists::getThemesList()); }
/** * Get information for the theme select box * * @param string $key key of the variables in the targetobject * @param string $var key of the variables in the targetobject * @param bool $multiple will you need a form element which shows multiple items */ function getThemeSelect($key, $var, $multiple = false) { $size = $multiple ? 5 : 1; $theme_select = new Xmf_Form_Element_Select($var['title'], $key, $this->targetObject->getVar($key), $size, $multiple); $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') { $dirlist[$file] = $file; } } closedir($handle); if (!empty($dirlist)) { asort($dirlist); $theme_select->addOptionArray($dirlist); } return $theme_select; }