/** * (non-PHPdoc) * @see solidbase/lib/__FormField#render() */ function render() { $id = idfy($this->name); $vals = count($this->data); $rows = ceil($vals / $this->cols); $values = array_keys($this->data); $text = array_values($this->data); if ($this->selected == false) { $this->selected = array(); } if (is_string($this->selected)) { $this->selected = explode(',', $this->selected); } $r = '<span class="formelem"><fieldset id="' . $id . '" class="checkset' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '"><legend>' . $this->label . '</legend><table cellpadding="0" cellspacing="0" border="0">'; if ($vals) { for ($i = 0; $i < $rows; $i++) { $r .= '<tr>'; for ($j = 0; $j < $this->cols; $j++) { $r .= '<td>'; if (@(!empty($values[$i + $j * $rows]))) { $r .= '<label><input type="checkbox" class="Checkbox" name="' . $this->name . '[]" value="' . @$values[$i + $j * $rows] . '"' . ($this->selected === true || in_array($values[$i + $j * $rows], $this->selected) ? ' checked="checked"' : '') . ' />' . @$text[$i + $j * $rows] . '</label>'; } $r .= '</td>'; } $r .= '</tr>'; } } $r .= '</table></fieldset></span>'; return $r; }
/** * (non-PHPdoc) * @see solidbase/lib/__FormField#render() */ function render() { $id = idfy($this->name); $vals = count($this->data); $rows = ceil($vals / $this->cols); $values = array_keys($this->data); $text = array_values($this->data); /* Head::add(' .Radioset table {width:100%;} .Radioset label {width:100%;} .Radioset td {width:33%;vertical-align:top;padding:1em;}', 'css-raw'); */ if ($this->selected == false) { $this->selected = array(); } $r = '<span class="formelem"><fieldset id="' . $id . '" class="radioset' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '"><legend>' . $this->label . '</legend><table cellpadding="0" cellspacing="0" border="0">'; for ($i = 0; $i < $rows; $i++) { $r .= '<tr>'; for ($j = 0; $j < $this->cols; $j++) { $r .= '<td>'; if (@(!empty($values[$i + $j * $rows]))) { $r .= '<label><input type="radio" class="radio" name="' . $this->name . '" value="' . @$values[$i + $j * $rows] . '"' . ($values[$i + $j * $rows] == $this->selected ? ' checked="checked"' : '') . ' />' . @$text[$i + $j * $rows] . '</label>'; } $r .= '</td>'; } $r .= '</tr>'; } $r .= '</table></fieldset></span>'; return $r; }
function render() { $id = idfy($this->name); JS::loadjQuery(false); JS::lib('imgPicker'); JS::raw('setupPreview("' . $id . '");'); //FIXME: Flytta styling till stylesheet! return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="text' . ($this->validate ? ' ' . $this->validate : '') . '" value="' . $this->value . '" type="hidden" />' . '<div class="tools">' . icon('small/cross', __('Remove'), "javascript:removePreview('{$id}');", $id . "remicon") . icon('small/folder_picture', __('Browse picture'), "javascript:explore('{$id}', " . ($this->dir ? $this->dir : 'false') . ");") . '</div>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . ($this->preview ? '<div id="' . $id . 'prev" style="margin:10px 0 5px 150px;"><img id="' . $id . 'img" src="index.php?id=' . $this->value . '&mw=300" /></div>' : '') . '</span>'; }
function render() { $id = idfy($this->name); JS::loadjQuery(); Head::add('$(function(){$(".sortable_list").sortable({axis:"y"});});', 'js-raw'); $val = (array) $this->value; array_walk($val, array($this, 'addHiddenFormField')); return '<span class="formelem">' . ($this->label === false ? '' : '<label for"' . $id . '">' . $this->label . '</label>') . listify($val, 'sortable_list' . ($this->validate ? ' ' . $this->validate : '')) . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>'; }
function render() { $id = idfy($this->name); if (is_array($this->value)) { $value = Short::parseDateAndTime($this->value); } global $CONFIG; JS::loadjQuery(true); JS::lib('jquery/jquery.timePicker'); Head::add('timePicker', 'css-lib'); Head::add('$(function(){$("input.time").timePicker();});', 'js-raw'); return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="time' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '" value="' . (is_numeric($this->value) ? date('H:i', $this->value) : $this->value) . '" />' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>'; }
function render() { $id = idfy($this->name); if ($this->multiple) { JS::loadJQuery(true); JS::lib('jquery/plugins/localisation/jquery.localisation-min'); JS::lib('jquery/plugins/scrollTo/jquery.scrollTo-min'); JS::lib('jquery/ui.multiselect'); if (!$this->nojs) { /*FIXME: Translation JS::raw('$(function(){$.localise("ui-multiselect", {language: "en", path: "lib/js/locale/"});});'); */ JS::raw('$(function(){$("#' . $id . '").multiselect({' . $this->jsparams . '});});'); } Head::add('ui.multiselect', 'css-lib'); if ($this->class) { $this->class .= ' '; } $this->class .= 'multiselect'; } $r = ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<select id="' . $id . '" name="' . $this->name . ($this->multiple ? '[]" multiple="multiple"' : '"') . ' class="' . $this->validate . ($this->validate ? ' ' : '') . $this->class . '">'; if ($this->startEmpty) { $r .= '<option value="">' . ($this->startEmpty !== true ? $this->startEmpty : '') . '</option>'; } if (is_array($this->data)) { foreach ($this->data as $value => $text) { if (is_array($text)) { if (isset($text['id'])) { $r .= $this->inflatedGroup($text); } else { $r .= $this->optgroup($value, $text); } } else { if (is_bool($this->selected)) { $s = $this->selected; } else { $match_pos = array_search($value, $this->selected, true); if (!$match_pos) { $match_pos = array_search($value, $this->selected); } $match = $match_pos === false ? false : $this->selected[$match_pos]; $s = strcmp($match, $value) === 0; } $r .= '<option value="' . $value . '"' . ($s ? ' selected="selected"' : '') . '>' . $text . '</option>'; } } } $r .= '</select>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : ($this->multiple ? ' ' : '')); return '<span class="formelem">' . $r . '</span>'; }
function render() { $id = idfy($this->name); JS::loadjQuery(false); if ($this->available_values) { JS::lib('jquery/jquery.bgiframe.min'); JS::lib('jquery/jquery-plugin-ajaxqueue'); JS::lib('jquery/jquery.autocomplete.min'); Head::add('jquery.autocomplete', 'css-lib'); JS::raw('$(function(){$("#' . $id . '").autocomplete(["' . join('","', $this->available_values) . '"], {width: 320,max: 4,highlight: false,multiple: true,multipleSeparator: " ",scroll: true,scrollHeight: 300})});'); } $r = ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="text tags' . ($this->validate ? ' ' . $this->validate : '') . '" value="' . $this->value . '" />' . ($this->description ? '<span class="description">' . $this->description . '</span>' : ''); return '<span class="formelem">' . $r . '</span>'; }
/** * Delivers the contents of the object, wrapped in a fieldset and an ordered list * @return void */ function render() { $id = idfy($this->name); $r = '<fieldset id="' . $id . '"' . (empty($this->class) ? '' : ' class="' . $this->class . '"') . '><legend>' . $this->name . '</legend><ol class="set">'; $hidden = ''; $i = 1; foreach ($this->content as $c) { if (is_object($c) && method_exists($c, 'render')) { if (is_a($c, 'Hidden')) { $hidden .= $c->render(); } else { $r .= '<li class="' . ($i++ % 2 ? 'evenform' : 'oddform') . '">' . $c->render() . '</li>'; } } elseif (is_string($c)) { $r .= '<li class="' . ($i++ % 2 ? 'evenform' : 'oddform') . '">' . $c . '</li>'; } } return $r . '</ol>' . $hidden . '</fieldset>'; }
function popup($URL, $window_name = false, $settings = false) { if ($settings) { $settings_ = $settings; $settings = ''; foreach ($settings_ as $key => $opt) { $settings .= $key . '=' . $opt . ','; } } if (!$window_name) { $window_name = self::$currentWindowHandle; } else { self::$currentWindowHandle = $window_name; } $id = idfy($URL); JS::loadjQuery(); Head::add('$(function(){$("' . $id . '").click(function(){});});', 'js-raw'); return '<a href="' . url($URL) . '" id="' . $id . '"'; }
function render() { $id = idfy($this->name); JS::loadjQuery(); /* Head::add('3rdParty/tiny_mce/tiny_mce_gzip.js', 'js-url', true, false, false); */ /* Head::add('tinyMCEGZinit', 'js-lib', true, false, false); */ //Head::add('3rdParty/tiny_mce/tiny_mce.js', 'js-url', true, false, false); /* Head::add('tinyMCEinit', 'js-lib', true, false, false); */ //testar ny editor Head::add('3rdParty/ckeditor/ckeditor.js', 'js-url', false, false); Head::add('3rdParty/ckeditor/adapters/jquery.js', 'js-url', false, false); JS::raw('CKEDITOR.replace("' . $id . '",{customConfig : "/3rdParty/ckeditor/config.js"});'); return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<textarea id="' . $id . '" name="' . $this->name . '" class="textarea mceEditor' . ($this->validate ? ' ' . $this->validate : '') . ($this->validate ? ' ' : '') . $this->class . '" rows="8" cols="70">' . $this->value . '</textarea>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>'; }
/** * (non-PHPdoc) * @see solidbase/lib/__FormField#render() */ function render() { $id = idfy($this->name); if ($this->value === false) { $sel = $this->interval; } else { $sel = (array) $this->value; if (count($sel) == 1) { $sel[1] = $sel[0]; } } Head::add(JQUERY_THEME . '/jquery-ui-1.8.7.custom', 'css-lib'); if (!$this->nojs) { JS::loadjQuery(true); JS::raw('$(function(){$("#' . $id . ' .slider").slider({' . 'range:' . ($this->return_interval ? 'true' : 'false') . ',' . 'min:' . $this->interval[0] . ',' . 'max:' . $this->interval[1] . ',' . 'values:[' . ($this->return_interval ? $sel[0] . ',' . $sel[1] : $sel[0]) . '],' . 'slide:function(event,ui){' . '$(event.target).closest(".slidercontainer")' . ' .find(".val_low").text(ui.values[0]).end()' . ($this->return_interval ? ' .find(".val_high").text(ui.values[1]).end()' : '') . ' .find(".sliderfield").val(ui.values[0]' . ($this->return_interval ? '+":"+ui.values[1]' : '') . ' );' . '}});});'); } JS::raw('$(".sliderfield").hide();'); return '<span class="formelem"><div id="' . $id . '" class="slidercontainer">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '_value" class="sliderfield' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '" value="' . ($this->return_interval ? $sel[0] . ":" . $sel[1] : $sel[0]) . '" />' . '<div class="slidervalues">' . '<span class="slidertext val_low">' . $sel[0] . '</span>' . ($this->return_interval ? '<span class="slidertext sliderdash">-</span><span class="slidertext val_high">' . $sel[1] . '</span>' : '') . '</div>' . '<div class="slider"></div>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</div></span>'; }
function selectLanguage() { global $CONFIG; JS::loadjQuery(false); JS::raw("\$(function(){\$('#" . idfy('user_settings::language') . "').change(function(e){\$(e.target).closest('form').submit();})});"); echo Form::quick(url(null, true), false, new Select(false, 'user_settings::language', google::languages($CONFIG->Site->languages), @$_COOKIE['user_settings::language'], false, __('Choose language'))); }
/** * (non-PHPdoc) * @see solidbase/lib/__FormField#render() */ function render() { $id = idfy($this->name); return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="text' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '" value="' . $this->value . '" />' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>'; }
/** * Render the page * @return void */ function run() { global $Templates, $USER, $CONFIG, $Controller, $DB; if (!$this->may($USER, ANYTHING)) { errorPage('401'); } /** * User input types */ $_REQUEST->setType('editField', 'string'); $_REQUEST->setType('editFieldSubm', 'string'); $_REQUEST->setType('newFieldSubm', 'any'); $_REQUEST->setType('fieldlabel', 'string'); $_REQUEST->setType('fieldtype', '#^(string|image|file)$#'); $_REQUEST->setType('fieldvalidation', 'string'); $_REQUEST->setType('deleteField', 'string'); $_REQUEST->setType('moveField', '#^(up|down)$#'); $_REQUEST->setType('field', 'string'); $_REQUEST->setType('oldname', 'string'); /** * Create a new field or edit an existing one */ if ($this->may($USER, EDIT) && ($_REQUEST['newFieldSubm'] || $_REQUEST['editFieldSubm'])) { if (!is_array($a = $CONFIG->userinfo->Fields)) { $a = array(); } $busy = false; $newname = idfy($_REQUEST['fieldlabel']); if (!empty($newname)) { if ($_REQUEST['editFieldSubm'] || !in_array($_REQUEST['newname'], (array) $this->Fields)) { $a[$newname] = array('label' => $_REQUEST['fieldlabel'], 'type' => $_REQUEST['fieldtype'], 'validation' => $_REQUEST['fieldvalidation'], 'description' => $_REQUEST['fielddesc']); if ($_REQUEST['editFieldSubm'] && $_REQUEST['oldname'] != $newname) { $this->Fields = arrayRemove($this->Fields, $_REQUEST['oldname']); unset($a[$_REQUEST['oldname']]); $DB->userinfo->update(array('prop' => $newname), array('prop' => $_REQUEST['oldname']), false, false); $this->Fields[] = $newname; } if ($_REQUEST['newFieldSubm']) { $this->Fields[] = $newname; Flash::create(__('Field created'), 'confirmation'); } else { Flash::create(__('Field updated'), 'confirmation'); } $CONFIG->userinfo->Fields = $a; } else { Flash::create(__('Name is already taken. Please try again')); } } else { Flash::create('Fieldname is not valid. Please try again', 'warning'); } } elseif ($_REQUEST->valid('moveField') && $this->may($USER, EDIT)) { $dir = $_REQUEST['moveField']; $which = $_REQUEST['field']; $uinfoFields = @$CONFIG->userinfo->Fields; if (!is_array($uinfoFields)) { $uinfoFields = array(); } $last = false; $a = array(); foreach ($uinfoFields as $name => $uf) { if ($last == false) { $last = array($name, $uf); continue; } if ($dir == 'up' && $name == $which || $dir == 'down' && $last[0] == $which) { $a[$name] = $uf; } else { $a[$last[0]] = $last[1]; $last = array($name, $uf); } } if ($last) { $a[$last[0]] = $last[1]; } $CONFIG->userinfo->Fields = $a; } elseif ($_REQUEST['deleteField'] !== false && $this->may($USER, DELETE)) { if (!is_array($a = $CONFIG->userinfo->Fields)) { $a = array(); } $na = array(); foreach ($a as $name => $b) { if ($name != $_REQUEST['deleteField']) { $na[$name] = $b; } else { if (in_array($b['type'], array('image', 'file'))) { $otd = $Controller->get($DB->userinfo->asList(array('prop' => $_REQUEST['deleteField']), 'val')); foreach ($otd as $f) { if (is_a($f, 'File') && strpos($f->path, $this->rootDir() . '/UInfoFiles') === 0) { $f->delete(); } } } $DB->userinfo->delete(array('prop' => $_REQUEST['deleteField'])); Flash::create(__('Field removed')); break; } } $CONFIG->userinfo->Fields = $na; } if ($_REQUEST->valid('editField') && in_array($_REQUEST['editField'], $this->Fields)) { $this->setContent('header', __('Edit field')); $this->setContent('main', $this->fieldForm($_REQUEST['editField'])); } else { $this->setContent('header', __('User information-fields')); $this->setContent('main', $this->fieldSettings()); } $Templates->admin->render(); }
/** * (non-PHPdoc) * @see solidbase/lib/__FormField#render() */ function render() { $id = idfy($this->name); return '<span class="formelem">' . '<input name="' . $this->name . '" type="submit" id="' . $id . '" class="submit' . ($this->class ? ' ' . $this->class : '') . '" value="' . $this->label . '" />' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . '</span'; }
function render() { $id = idfy($this->name); return '<span class="formelem"><input name="' . $this->name . '" value="' . $this->value . '" id="' . $id . '" type="Checkbox" class="' . __CLASS__ . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '"' . ($this->checked ? ' checked="checked"' : '') . ' />' . ($this->label === false ? '' : '<label for="' . $id . '" class="Minicheck">' . $this->label . '</label>') . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>'; }
/** * (non-PHPdoc) * @see solidbase/lib/__FormField#render() */ function render() { $id = idfy($this->name); return '<input name="' . $this->name . '" id="' . $id . '" type="hidden" value="' . $this->value . '" />'; }