/e107_handlers/form_handler.php
PHP | 4384 lines | 2656 code | 795 blank | 933 comment | 486 complexity | 36b2a064186e9964bdf6e858e9dac778 MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- * e107 website system
- *
- * Copyright (C) 2008-2012 e107 Inc (e107.org)
- * Released under the terms and conditions of the
- * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
- *
- * Form Handler
- *
- * $URL$
- * $Id$
- *
- */
-
- if (!defined('e107_INIT')) { exit; }
-
- /**
- *
- * @package e107
- * @subpackage e107_handlers
- * @version $Id$
- * @todo hardcoded text
- *
- * Automate Form fields creation. Produced markup is following e107 CSS/XHTML standards
- * If options argument is omitted, default values will be used (which OK most of the time)
- * Options are intended to handle some very special cases.
- *
- * Overall field options format (array or GET string like this one: var1=val1&var2=val2...):
- *
- * - id => (mixed) custom id attribute value
- * if numeric value is passed it'll be just appended to the name e.g. {filed-name}-{value}
- * if false is passed id will be not created
- * if empty string is passed (or no 'id' option is found)
- * in all other cases the value will be used as field id
- * default: empty string
- *
- * - class => (string) field class(es)
- * Example: 'tbox select class1 class2 class3'
- * NOTE: this will override core classes, so you have to explicit include them!
- * default: empty string
- *
- * - size => (int) size attribute value (used when needed)
- * default: 40
- *
- * - title (string) title attribute
- * default: empty string (omitted)
- *
- * - readonly => (bool) readonly attribute
- * default: false
- *
- * - selected => (bool) selected attribute (used when needed)
- * default: false
- *
- * checked => (bool) checked attribute (used when needed)
- * default: false
- * - disabled => (bool) disabled attribute
- * default: false
- *
- * - tabindex => (int) tabindex attribute value
- * default: inner tabindex counter
- *
- * - other => (string) additional data
- * Example: 'attribute1="value1" attribute2="value2"'
- * default: empty string
- */
- class e_form
- {
- protected $_tabindex_counter = 0;
- protected $_tabindex_enabled = true;
- protected $_cached_attributes = array();
-
- /**
- * @var user_class
- */
- protected $_uc;
-
- protected $_required_string;
-
- function __construct($enable_tabindex = false)
- {
- $this->_tabindex_enabled = $enable_tabindex;
- $this->_uc = e107::getUserClass();
- $this->setRequiredString('<span class="required">* </span>');
- }
-
- /**
- * Open a new form
- * @param string name
- * @param $method - post|get default is post
- * @param @target - e_REQUEST_URI by default
-
- * @param $other - unused at the moment.
- */
- public function open($name, $method=null, $target=null, $options=null)
- {
- if($target == null)
- {
- $target = e_REQUEST_URI;
- }
-
- if($method == null)
- {
- $method = "post";
- }
-
- $class = "";
- $autoComplete = "";
-
- parse_str($options,$options);
-
- $target = str_replace("&", "&", $target);
-
- if(vartrue($options['class']))
- {
- $class = "class='".$options['class']."'";
- }
-
- if(isset($options['autocomplete'])) // leave as isset()
- {
- $autoComplete = " autocomplete='".($options['autocomplete'] ? 'on' : 'off')."'";
- }
-
- $text = "\n<form {$class} action='{$target}' id='".$this->name2id($name)."' method = '{$method}'{$autoComplete}>\n";
-
- if($method == 'get' && strpos($target,'='))
- {
- list($url,$qry) = explode("?",$target);
-
- parse_str($qry,$m);
- foreach($m as $k=>$v)
- {
- $text .= $this->hidden($k, $v);
- }
-
- }
-
- return $text;
- }
-
- /**
- * Close a Form
- */
- public function close()
- {
- return "</form>";
-
- }
-
-
- /**
- * Get required field markup string
- * @return string
- */
- public function getRequiredString()
- {
- return $this->_required_string;
- }
-
- /**
- * Set required field markup string
- * @param string $string
- * @return e_form
- */
- public function setRequiredString($string)
- {
- $this->_required_string = $string;
- return $this;
- }
-
- // For Comma separated keyword tags.
- function tags($name, $value, $maxlength = 200, $options = array())
- {
- if(is_string($options)) parse_str($options, $options);
- $options['class'] = 'tbox span1 e-tags';
- $options['size'] = 7;
- return $this->text($name, $value, $maxlength, $options);
- }
-
- /**
- * Text-Field Form Element
- * @param $name
- * @param $value
- * @param $maxlength
- * @param $options
- * - size: mini, small, medium, large, xlarge, xxlarge
- * - class:
- * - typeahead: 'users'
- *
- */
- function text($name, $value = '', $maxlength = 80, $options= array())
- {
- if(is_string($options))
- {
- parse_str($options,$options);
- }
-
- if(!vartrue($options['class']))
- {
- $options['class'] = "tbox";
- }
-
- if(deftrue('BOOTSTRAP') === 3)
- {
- $options['class'] .= ' form-control';
- }
-
- /*
- if(!vartrue($options['class']))
- {
- if($maxlength < 10)
- {
- $options['class'] = 'tbox input-text span3';
- }
-
- elseif($maxlength < 50)
- {
- $options['class'] = 'tbox input-text span7';
- }
-
- elseif($maxlength > 99)
- {
- $options['class'] = 'tbox input-text span7';
- }
- else
- {
- $options['class'] = 'tbox input-text';
- }
- }
- */
-
- if(vartrue($options['typeahead']))
- {
- if(vartrue($options['typeahead']) == 'users')
- {
- $options['data-source'] = e_BASE."user.php";
- $options['class'] .= " e-typeahead";
- }
- }
-
- if(vartrue($options['size']) && !is_numeric($options['size']))
- {
- $options['class'] .= " input-".$options['size'];
- unset($options['size']); // don't include in html 'size='.
- }
-
- $mlength = vartrue($maxlength) ? "maxlength=".$maxlength : "";
-
- $options = $this->format_options('text', $name, $options);
- //never allow id in format name-value for text fields
- return "<input type='text' name='{$name}' value='{$value}' {$mlength} ".$this->get_attributes($options, $name)." />";
- }
-
-
-
- function number($name, $value, $maxlength = 200, $options = array())
- {
- if(is_string($options)) parse_str($options, $options);
- if (vartrue($options['maxlength'])) $maxlength = $options['maxlength'];
- unset($options['maxlength']);
- if(!vartrue($options['size'])) $options['size'] = 15;
- if(!vartrue($options['class'])) $options['class'] = 'tbox number e-spinner input-small';
- if(!$value) $value = '0';
- return $this->text($name, $value, $maxlength, $options);
- }
-
-
-
- function email($name, $value, $maxlength = 200, $options = array())
- {
- $options = $this->format_options('text', $name, $options);
- //never allow id in format name-value for text fields
- return "<input type='email' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />
- ";
- }
-
-
-
- function iconpreview($id, $default, $width='', $height='') // FIXME
- {
- // XXX - $name ?!
- $parms = $name."|".$width."|".$height."|".$id;
- $sc_parameters .= 'mode=preview&default='.$default.'&id='.$id;
- return e107::getParser()->parseTemplate("{ICONPICKER=".$sc_parameters."}");
- }
-
- /**
- * @param $name
- * @param $default value
- * @param $label
- * @param $options - gylphs=1
- * @param $ajax
- */
- function iconpicker($name, $default, $label, $options = array(), $ajax = true)
- {
-
-
- $options['media'] = '_icon';
-
- return $this->imagepicker($name, $default, $label, $options);
-
-
- }
-
- /**
- * Internal Function used by imagepicker and filepicker
- */
- private function mediaUrl($category = '', $label = '', $tagid='', $extras=null)
- {
-
- $cat = ($category) ? '&for='.$category : "";
- if(!$label) $label = ' Upload an image or file';
- if($tagid) $cat .= '&tagid='.$tagid;
-
- if(is_string($extras))
- {
- parse_str($extras,$extras);
- }
-
- if(vartrue($extras['bbcode'])) $cat .= '&bbcode=1';
- $mode = vartrue($extras['mode'],'main');
- $action = vartrue($extras['action'],'dialog');
- // $tabs // TODO - option to choose which tabs to display.
-
- //TODO Parse selection data back to parent form.
-
- $url = e_ADMIN_ABS."image.php?mode={$mode}&action={$action}".$cat;
- $url .= "&iframe=1";
-
- if(vartrue($extras['w']))
- {
- $url .= "&w=".$extras['w'];
- }
-
- if(vartrue($extras['glyphs']))
- {
- $url .= "&glyphs=1";
- }
-
- if(vartrue($extras['video']))
- {
- $url .= "&video=1";
- }
-
- $title = "Media Manager : ".$category;
-
- // $ret = "<a title=\"{$title}\" rel='external' class='e-dialog' href='".$url."'>".$label."</a>"; // using colorXXXbox.
- $ret = "<a title=\"{$title}\" class='e-modal' data-modal-caption='Media Manager' data-cache='false' data-target='#uiModal' href='".$url."'>".$label."</a>"; // using bootstrap.
-
-
- // $footer = "<div style=\'padding:5px;text-align:center\' <a href=\'#\' >Save</a></div>";
- $footer = '';
- if(!e107::getRegistry('core/form/mediaurl'))
- {
- /*
- e107::js('core','core/admin.js','prototype');
- e107::js('core','core/dialog.js','prototype');
- e107::js('core','core/draggable.js','prototype');
- e107::css('core','core/dialog/dialog.css','prototype');
- e107::css('core','core/dialog/e107/e107.css','prototype');
- e107::js('footer-inline','
- $$("a.e-dialog").invoke("observe", "click", function(ev) {
- var element = ev.findElement("a");
- ev.stop();
- new e107Widgets.URLDialog(element.href, {
- id: element["id"] || "e-dialog",
- width: 890,
- height: 680
-
- }).center().setHeader("Media Manager : '.$category.'").setFooter('.$footer.').activate().show();
- });
-
- ','prototype');
- */
- e107::setRegistry('core/form/mediaurl', true);
- }
- return $ret;
- }
-
-
- /**
- * Avatar Picker
- * @param $name - form element name ie. value to be posted.
- * @param $curVal - current avatar value. ie. the image-file name or URL.
- */
- function avatarpicker($name,$curVal='',$options=array())
- {
-
- $tp = e107::getParser();
- $pref = e107::getPref();
-
- $attr = "aw=".$pref['im_width']."&ah=".$pref['im_height'];
- $tp->setThumbSize($pref['im_width'],$pref['im_height']);
-
- $blankImg = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg",$attr);
- $localonly = true; //TODO add a pref for allowing external or internal avatars or both.
- $idinput = $this->name2id($name);
- $previnput = $idinput."-preview";
- $optioni = $idinput."-options";
-
-
- $path = (substr($curVal,0,8) == '-upload-') ? '{e_AVATAR}upload/' : '{e_AVATAR}default/';
- $curVal = str_replace('-upload-','',$curVal);
-
- $img = (strpos($curVal,"://")!==false) ? $curVal : $tp->thumbUrl($path.$curVal);
-
- if(!$curVal)
- {
- $img = $blankImg;
- }
-
- if($localonly == true)
- {
- $text = "<input class='tbox' style='width:80%' id='{$idinput}' type='hidden' name='image' size='40' value='{$curVal}' maxlength='100' />";
- $text .= "<img src='".$img."' id='{$previnput}' class='img-rounded e-expandit e-tip avatar' style='cursor:pointer; width:".$pref['im_width']."px; height:".$pref['im_height']."px' title='Click on the avatar to change it'/>"; // TODO LAN
- }
- else
- {
- $text = "<input class='tbox' style='width:80%' id='{$idinput}' type='text' name='image' size='40' value='$curVal' maxlength='100' title=\"".LAN_SIGNUP_111."\" />";
- $text .= "<img src='".$img."' id='{$previnput}' style='display:none' />";
- $text .= "<input class='img-rounded btn btn-default button e-expandit' type ='button' style='cursor:pointer' size='30' value=\"Choose Avatar\" />"; //TODO Common LAN.
- }
-
- $avFiles = e107::getFile()->get_files(e_AVATAR_DEFAULT,".jpg|.png|.gif|.jpeg|.JPG|.GIF|.PNG");
-
- $text .= "\n<div id='{$optioni}' style='display:none;padding:10px' >\n"; //TODO unique id.
-
- if (vartrue($pref['avatar_upload']) && FILE_UPLOADS && vartrue($options['upload']))
- {
- $diz = LAN_USET_32.($pref['im_width'] || $pref['im_height'] ? "\n".str_replace(array('--WIDTH--','--HEIGHT--'), array($pref['im_width'], $pref['im_height']), LAN_USER_86) : "");
-
- $text .= "<div style='margin-bottom:10px'>".LAN_USET_26."
- <input class='tbox' name='file_userfile[avatar]' type='file' size='47' title=\"{$diz}\" />
- </div>
- <div class='divider'><span>OR</span></div>";
- }
-
-
- foreach($avFiles as $fi)
- {
- $img_path = $tp->thumbUrl(e_AVATAR_DEFAULT.$fi['fname']);
- $text .= "\n<a class='e-expandit' title='Choose this avatar' href='#{$optioni}'><img src='".$img_path."' alt='' onclick=\"insertext('".$fi['fname']."', '".$idinput."');document.getElementById('".$previnput."').src = this.src;\" /></a> ";
- //TODO javascript CSS selector
- }
-
-
-
-
- $text .= "<br />
- </div>";
-
- // Used by usersettings.php right now.
-
-
-
-
-
-
-
- return $text;
-
- //TODO discuss and FIXME
- // Intentionally disable uploadable avatar and photos at this stage
- if (false && $pref['avatar_upload'] && FILE_UPLOADS)
- {
- $text .= "<br /><span class='smalltext'>".LAN_SIGNUP_25."</span> <input class='tbox' name='file_userfile[]' type='file' size='40' />
- <br /><div class='smalltext'>".LAN_SIGNUP_34."</div>";
- }
-
- if (false && $pref['photo_upload'] && FILE_UPLOADS)
- {
- $text .= "<br /><span class='smalltext'>".LAN_SIGNUP_26."</span> <input class='tbox' name='file_userfile[]' type='file' size='40' />
- <br /><div class='smalltext'>".LAN_SIGNUP_34."</div>";
- }
- }
-
-
-
-
- /**
- * FIXME {IMAGESELECTOR} rewrite
-
- * @param string $name input name
- * @param string $default default value
- * @param string $label custom label
- * @param string $sc_parameters shortcode parameters
- * --- SC Parameter list ---
- * - media: if present - load from media category table
- * - w: preview width in pixels
- * - h: preview height in pixels
- * - help: tooltip
- * - video: when set to true, will enable the Youtube (video) tab.
- * @example $frm->imagepicker('banner_image', $_POST['banner_image'], '', 'banner'); // all images from category 'banner_image' + common images.
- * @example $frm->imagepicker('banner_image', $_POST['banner_image'], '', 'media=banner&w=600');
- * @return string html output
- */
- function imagepicker($name, $default, $label = '', $sc_parameters = '')
- {
- $tp = e107::getParser();
- $name_id = $this->name2id($name);
- $meta_id = $name_id."-meta";
-
- if(is_string($sc_parameters))
- {
- if(strpos($sc_parameters, '=') === false) $sc_parameters = 'media='.$sc_parameters;
- parse_str($sc_parameters, $sc_parameters);
- }
-
- // print_a($sc_parameters);
-
- if(empty($sc_parameters['media']))
- {
- $sc_parameters['media'] = '_common';
- }
-
- $default_thumb = $default;
- if($default)
- {
- if($video = $tp->toVideo($default, array('thumb'=>'src')))
- {
- $default_url = $video;
- }
- else
- {
- if('{' != $default[0])
- {
- // convert to sc path
- $default_thumb = $tp->createConstants($default, 'nice');
- $default = $tp->createConstants($default, 'mix');
- }
- $default_url = $tp->replaceConstants($default, 'abs');
- }
- $blank = FALSE;
-
-
- }
- else
- {
- //$default = $default_url = e_IMAGE_ABS."generic/blank.gif";
- $default_url = e_IMAGE_ABS."generic/nomedia.png";
- $blank = TRUE;
- }
-
-
-
- //$width = intval(vartrue($sc_parameters['width'], 150));
- $cat = $tp->toDB(vartrue($sc_parameters['media']));
-
- if($cat == '_icon') // ICONS
- {
- $ret = "<div class='imgselector-container' style='display:block;width:64px;min-height:64px'>";
- $thpath = isset($sc_parameters['nothumb']) || vartrue($hide) ? $default : $default_thumb;
- $label = "<div id='{$name_id}_prev' class='text-center well well-small image-selector' >";
-
- $label .= $tp->toIcon($default_url);
-
- $label .= "
- </div>";
-
- // $label = "<img id='{$name_id}_prev' src='{$default_url}' alt='{$default_url}' class='well well-small image-selector' style='{$style}' />";
-
- }
- else // Images
- {
-
- $title = (vartrue($sc_parameters['help'])) ? "title='".$sc_parameters['help']."'" : "";
- $width = vartrue($sc_parameters['w'], 120);
- $height = vartrue($sc_parameters['h'], 100);
-
- $ret = "<div class='imgselector-container e-tip' {$title} style='margin-right:25px; display:inline-block; width:".$width."px;min-height:".$height."px;'>";
- $att = 'aw='.$width."'&ah=".$height."'";
- $thpath = isset($sc_parameters['nothumb']) || vartrue($hide) ? $default : $tp->thumbUrl($default_thumb, $att, true);
-
-
- $label = "<img id='{$name_id}_prev' src='{$default_url}' alt='{$default_url}' class='well well-small image-selector' style='display:block;' />";
-
- if($cat != 'news' && $cat !='page' && $cat !='')
- {
- $cat = $cat . "_image";
- }
- }
-
-
- $ret .= $this->mediaUrl($cat, $label,$name_id,$sc_parameters);
- $ret .= "</div>\n";
- $ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' />";
- $ret .= "<input type='hidden' name='mediameta_{$name}' id='{$meta_id}' value='' />";
- // $ret .= $this->text($name,$default); // to be hidden eventually.
- return $ret;
-
-
-
-
-
- // ----------------
-
- }
-
-
-
-
-
- function filepicker($name, $default, $label = '', $sc_parameters = '')
- {
- $tp = e107::getParser();
- $name_id = $this->name2id($name);
- if(is_string($sc_parameters))
- {
- if(strpos($sc_parameters, '=') === false) $sc_parameters = 'media='.$sc_parameters;
- parse_str($sc_parameters, $sc_parameters);
- }
-
- $cat = vartrue($sc_parameters['media']) ? $tp->toDB($sc_parameters['media']) : "_common_file";
-
- $default_label = ($default) ? $default : "Choose a file";
- $label = "<span id='{$name_id}_prev' class='btn btn-default btn-small'>".basename($default_label)."</span>";
-
- $sc_parameters['mode'] = 'main';
- $sc_parameters['action'] = 'dialog';
-
-
- // $ret .= $this->mediaUrl($cat, $label,$name_id,"mode=dialog&action=list");
- $ret .= $this->mediaUrl($cat, $label,$name_id,$sc_parameters);
- $ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' style='width:400px' />";
-
- return $ret;
-
-
- }
-
-
-
-
- /**
- * Date field with popup calendar // NEW in 0.8/2.0
- *
- * @param string $name the name of the field
- * @param integer $datestamp UNIX timestamp - default value of the field
- * @param array or str
- * @example $frm->datepicker('my_field',time(),'type=date');
- * @example $frm->datepicker('my_field',time(),'type=datetime&inline=1');
- * @example $frm->datepicker('my_field',time(),'type=date&format=yyyy-mm-dd');
- * @example $frm->datepicker('my_field',time(),'type=datetime&format=MM, dd, yyyy hh:ii');
- *
- * @url http://trentrichardson.com/examples/timepicker/
- */
- function datepicker($name, $datestamp = false, $options = null)
- {
-
- if(vartrue($options) && is_string($options))
- {
- parse_str($options,$options);
- }
-
- $type = varset($options['type']) ? trim($options['type']) : "date"; // OR 'datetime'
- $dateFormat = varset($options['format']) ? trim($options['format']) :e107::getPref('inputdate', '%Y-%m-%d');
- $ampm = (preg_match("/%l|%I|%p|%P/",$dateFormat)) ? 'true' : 'false';
-
- if($type == 'datetime' && !varset($options['format']))
- {
- $dateFormat .= " ".e107::getPref('inputtime', '%H:%M:%S');
- }
-
- $dformat = e107::getDate()->toMask($dateFormat);
-
- $id = $this->name2id($name);
-
- $classes = array('date' => 'e-date', 'datetime' => 'e-datetime');
-
- if ($datestamp)
- {
- $value = is_numeric($datestamp) ? e107::getDate()->convert_date($datestamp, $dateFormat) : $datestamp; //date("d/m/Y H:i:s", $datestamp);
- }
-
- $text = "";
- // $text .= 'dformat='.$dformat.' defdisp='.$dateFormat;
-
- $class = (isset($classes[$type])) ? $classes[$type] : "tbox e-date";
- $size = vartrue($options['size']) ? intval($options['size']) : 40;
- $required = vartrue($options['required']) ? "required" : "";
- $firstDay = vartrue($options['firstDay']) ? $options['firstDay'] : 0;
-
- if(vartrue($options['inline']))
- {
- $text .= "<div class='{$class}' id='inline-{$id}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' ></div>
- <input type='hidden' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-time-format='{$tformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' />
- ";
- }
- else
- {
- $text .= "<input class='{$class} input-xlarge' type='text' size='{$size}' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-language='".e_LAN."' data-date-firstday='{$firstDay}' {$required} />";
- }
-
- // $text .= "ValueFormat: ".$dateFormat." Value: ".$value;
- // $text .= " ({$dformat}) type:".$dateFormat." ".$value;
-
- return $text;
-
-
- }
-
- /**
- * User auto-complete search
- *
- * @param string $name_fld field name for user name
- * @param string $id_fld field name for user id
- * @param string $default_name default user name value
- * @param integer $default_id default user id
- * @param array|string $options [optional] 'readonly' (make field read only), 'name' (db field name, default user_name)
- * @return string HTML text for display
- */
- function userpicker($name_fld, $id_fld, $default_name, $default_id, $options = array())
- {
- $tp = e107::getParser();
- if(!is_array($options)) parse_str($options, $options);
-
- $default_name = vartrue($default_name, '');
- $default_id = vartrue($default_id, 0);
-
- //TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ?
-
- $fldid = $this->name2id($name_fld);
- $hidden_fldid = $this->name2id($id_fld);
-
- $ret = '<div class="input-append">';
- $ret .= $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly']))
- .$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))."<span class='add-on'>".$tp->toGlyph('fa-user')." <span id='{$fldid}-id'>".$default_id.'</span></span>';
- $ret .= "<a class='btn btn-inverse' href='#' id='{$fldid}-reset'>reset</a>
- </div>";
-
- e107::js('footer-inline', "
- \$('#{$fldid}').blur(function () {
- \$('#{$fldid}-id').html(\$('#{$hidden_fldid}').val());
- });
- \$('#{$fldid}-reset').click(function () {
- \$('#{$fldid}-id').html('0');
- \$('#{$hidden_fldid}').val(0);
- \$('#{$fldid}').val('');
- return false;
- });
- ");
-
- return $ret;
- /*
- $label_fld = str_replace('_', '-', $name_fld).'-upicker-lable';
-
- //'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).'
- $ret = '
- <div class="e-autocomplete-c">
- '.$this->text($name_fld, $default_name, 150, array('id' => false, 'readonly' => vartrue($options['readonly']) ? true : false)).'
- <span id="'.$label_fld.'" class="'.($default_id ? 'success' : 'warning').'">Id #'.((int) $default_id).'</span>
- '.$this->hidden($id_fld, $default_id, array('id' => false)).'
- <span class="indicator" style="display: none;">
- <img src="'.e_IMAGE_ABS.'generic/loading_16.gif" class="icon action S16" alt="Loading..." />
- </span>
- <div class="e-autocomplete"></div>
- </div>
- ';
-
- e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2);
-
- e107::getJs()->footerInline("
- //autocomplete fields
- \$\$('input[name={$name_fld}]').each(function(el) {
-
- if(el.readOnly) {
- el.observe('click', function(ev) { ev.stop(); var el1 = ev.findElement('input'); el1.blur(); } );
- el.next('span.indicator').hide();
- el.next('div.e-autocomplete').hide();
- return;
- }
- new Ajax.Autocompleter(el, el.next('div.e-autocomplete'), '".e_JS."e_ajax.php', {
- paramName: '{$name_fld}',
- minChars: 2,
- frequency: 0.5,
- afterUpdateElement: function(txt, li) {
- if(!\$(li)) return;
- var elnext = el.next('input[name={$id_fld}]'),
- ellab = \$('{$label_fld}');
- if(\$(li).id) {
- elnext.value = parseInt(\$(li).id);
- } else {
- elnext.value = 0
- }
- if(ellab)
- {
- ellab.removeClassName('warning').removeClassName('success');
- ellab.addClassName((elnext.value ? 'success' : 'warning')).update('Id #' + elnext.value);
- }
- },
- indicator: el.next('span.indicator'),
- parameters: 'ajax_used=1&ajax_sc=usersearch=".rawurlencode('searchfld='.str_replace('user_', '', vartrue($options['name'], 'user_name')).'--srcfld='.$name_fld)."'
- });
- });
- ");
- return $ret;
- */
- }
-
-
- /**
- * A Rating element
- * @var $text
- */
- function rate($table,$id,$options=null)
- {
- $table = preg_replace('/\W/', '', $table);
- $id = intval($id);
-
- return e107::getRate()->render($table, $id, $options);
- }
-
- function like($table,$id,$options=null)
- {
- $table = preg_replace('/\W/', '', $table);
- $id = intval($id);
-
- return e107::getRate()->renderLike($table,$id,$options);
- }
-
-
-
-
-
- function file($name, $options = array())
- {
- $options = $this->format_options('file', $name, $options);
- //never allow id in format name-value for text fields
- return "<input type='file' name='{$name}'".$this->get_attributes($options, $name)." />";
- }
-
- function upload($name, $options = array())
- {
- return 'Ready to use upload form fields, optional - file list view';
- }
-
- function password($name, $value = '', $maxlength = 50, $options = array())
- {
- if(is_string($options)) parse_str($options, $options);
-
- $addon = "";
- $gen = "";
-
- if(vartrue($options['generate']))
- {
- $gen = ' <a href="#" class="btn btn-default btn-small e-tip" id="Spn_PasswordGenerator" title="Generate a password">Generate</a> <a class="btn btn-default btn-small e-tip" href="#" id="showPwd" title="Display the password">Show</a><br />';
- }
-
- if(vartrue($options['strength']))
- {
- $addon .= "<div style='margin-top:4px'><div id='pwdColor' class='progress' style='float:left;display:inline-block;width:218px'><div class='bar' id='pwdMeter' style='width:0%' ></div></div> <div id='pwdStatus' class='smalltext' style='float:left;display:inline-block;width:150px;margin-left:5px'></span></div>";
- }
-
- $options['pattern'] = vartrue($options['pattern'],'[\S]{4,}');
- $options['required'] = varset($options['required'], 1);
- $options['class'] = vartrue($options['class'],'e-password');
-
- if(deftrue('BOOTSTRAP') == 3)
- {
- $options['class'] .= ' form-control';
- }
-
- $options = $this->format_options('text', $name, $options);
-
- //never allow id in format name-value for text fields
- $text = "<input type='password' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />";
-
- return "<span class='form-inline'>".$text.$gen."</span>".vartrue($addon);
-
- }
-
-
-
- /**
- * Render a bootStrap ProgressBar.
- * @param string $name
- * @param number $value
- * @param array $options
- */
- public function progressBar($name,$value,$options=array())
- {
- if(!deftrue('BOOTSTRAP'))
- {
- return;
- }
-
- $class = vartrue($options['class'],'');
-
- return "<div class='progress ".$class."' id='".$this->name2id($name)."'>
- <div class='bar' style='width: ".number_format($value,1)."%'></div>
- </div>";
-
- }
-
-
- /**
- * Textarea Element
- * @param $name
- * @param $value
- * @param $rows
- * @param $cols
- * @param $options
- * @param $count
- */
- function textarea($name, $value, $rows = 10, $cols = 80, $options = array(), $counter = false)
- {
- if(is_string($options)) parse_str($options, $options);
- // auto-height support
-
- if(vartrue($options['size']) && !is_numeric($options['size']))
- {
- $options['class'] .= " input-".$options['size'];
- unset($options['size']); // don't include in html 'size='.
- }
- elseif(!vartrue($options['noresize']))
- {
- $options['class'] = (isset($options['class']) && $options['class']) ? $options['class'].' e-autoheight' : 'tbox span7 e-autoheight';
- }
-
- $options = $this->format_options('textarea', $name, $options);
- //never allow id in format name-value for text fields
- return "<textarea name='{$name}' rows='{$rows}' cols='{$cols}'".$this->get_attributes($options, $name).">{$value}</textarea>".(false !== $counter ? $this->hidden('__'.$name.'autoheight_opt', $counter) : '');
- }
-
- /**
- * Bbcode Area. Name, value, template, media-Cat, size, options array eg. counter
- * IMPORTANT: $$mediaCat is also used is the media-manager category identifier
- */
- function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'large', $options = array())
- {
- if(is_string($options)) parse_str($options, $options);
- //size - large|medium|small
- //width should be explicit set by current admin theme
- $size = 'input-large';
-
- switch($size)
- {
- case 'small':
- $rows = '7';
- $height = "style='height:250px'"; // inline required for wysiwyg
- break;
-
- case 'medium':
- $rows = '10';
-
- $height = "style='height:375px'"; // inline required for wysiwyg
- $size = "input-block-level";
- break;
-
- case 'large':
- default:
- $rows = '15';
- $size = 'large input-block-level';
- // $height = "style='height:500px;width:1025px'"; // inline required for wysiwyg
- break;
- }
-
- // auto-height support
- $options['class'] = 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg e-autoheight';
- $bbbar = '';
-
-
- $help_tagid = $this->name2id($name)."--preview";
- $options['other'] = "onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' {$height}";
-
- $counter = vartrue($options['counter'],false);
-
- $ret = "
- <div class='bbarea {$size}'>
- <div class='field-spacer'><!-- --></div>\n";
-
-
- $ret .= e107::getBB()->renderButtons($template,$help_tagid);
- $ret .= $this->textarea($name, $value, $rows, 70, $options, $counter); // higher thank 70 will break some layouts.
-
- $ret .= "</div>\n";
-
- $_SESSION['media_category'] = $mediaCat; // used by TinyMce.
-
- return $ret;
-
- // Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler
- /*
-
- e107::getJs()->footerInline("
- if(typeof tinyMCE === 'undefined')
- {
- \$$('a.e-wysiwyg-switch').invoke('hide');
- }
- ");
- */
-
-
- }
-
- /**
- * Render a checkbox
- * @param string $name
- * @param mixed $value
- * @param boolean $checked
- * @param mixed $options query-string or array or string for a label. eg. label=Hello&foo=bar or array('label'=>Hello') or 'Hello'
- * @return void
- */
- function checkbox($name, $value, $checked = false, $options = array())
- {
- if(!is_array($options))
- {
- if(strpos($options,"=")!==false)
- {
- parse_str($options, $options);
- }
- else // Assume it's a label.
- {
- $options = array('label'=>$options);
- }
-
- }
- $options = $this->format_options('checkbox', $name, $options);
-
- $options['checked'] = $checked; //comes as separate argument just for convenience
-
- $text = "";
-
- $pre = (vartrue($options['label'])) ? "<label class='checkbox'>" : ""; // Bootstrap compatible markup
- $post = (vartrue($options['label'])) ? $options['label']."</label>" : "";
- unset($options['label']); // not to be used as attribute;
-
- $text .= "<input type='checkbox' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
-
- return $pre.$text.$post;
- }
-
- function checkbox_label($label_title, $name, $value, $checked = false, $options = array())
- {
- return $this->checkbox($name, $value, $checked, $options).$this->label($label_title, $name, $value);
- }
-
- function checkbox_switch($name, $value, $checked = false, $label = '')
- {
- return $this->checkbox($name, $value, $checked).$this->label($label ? $label : LAN_ENABLED, $name, $value);
- }
-
- function checkbox_toggle($name, $selector = 'multitoggle', $id = false, $label='')
- {
- $selector = 'jstarget:'.$selector;
- if($id) $id = $this->name2id($id);
-
- return $this->checkbox($name, $selector, false, array('id' => $id,'class' => 'checkbox toggle-all','label'=>$label));
- }
-
- function uc_checkbox($name, $current_value, $uc_options, $field_options = array())
- {
- if(!is_array($field_options)) parse_str($field_options, $field_options);
- return '
- <div class="check-block">
- '.$this->_uc->vetted_tree($name, array($this, '_uc_checkbox_cb'), $current_value, $uc_options, $field_options).'
- </div>
- ';
- }
-
-
- /**
- * Callback function used with $this->uc_checkbox
- *
- * @see user_class->select() for parameters
- */
- function _uc_checkbox_cb($treename, $classnum, $current_value, $nest_level, $field_options)
- {
- if($classnum == e_UC_BLANK)
- return '';
-
- if (!is_array($current_value))
- {
- $tmp = explode(',', $current_value);
- }
-
- $classIndex = abs($classnum); // Handle negative class values
- $classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
-
- $class = $style = '';
- if($nest_level == 0)
- {
- $class = " strong";
- }
- else
- {
- $style = " style='text-indent:" . (1.2 * $nest_level) . "em'";
- }
- $descr = varset($field_options['description']) ? ' <span class="smalltext">('.$this->_uc->uc_get_classdescription($classnum).')</span>' : '';
-
- return "<div class='field-spacer{$class}'{$style}>".$this->checkbox($treename.'[]', $classnum, in_array($classnum, $tmp), $field_options).$this->label($this->_uc->uc_get_classname($classIndex).$descr, $treename.'[]', $classnum)."</div>\n";
- }
-
-
- function uc_label($classnum)
- {
- return $this->_uc->uc_get_classname($classnum);
- }
-
- /**
- * A Radio Button Form Element
- * @param $name
- * @param @value array pair-values|string - auto-detected.
- * @param $checked boolean
- * @param $options
- */
- function radio($name, $value, $checked = false, $options = null)
- {
-
- if(!is_array($options)) parse_str($options, $options);
-
- if(is_array($value))
- {
- return $this->radio_multi($name, $value, $checked, $options);
- }
-
- $labelFound = vartrue($options['label']);
- unset($options['label']); // label attribute not valid in html5
-
- $options = $this->format_options('radio', $name, $options);
- $options['checked'] = $checked; //comes as separate argument just for convenience
- // $options['class'] = 'inline';
- $text = "";
-
-
-
- // return print_a($options,true);
- if($labelFound) // Bootstrap compatible markup
- {
- $text .= "<label class='radio inline'>";
-
- }
-
-
-
-
- $text .= "<input type='radio' name='{$name}' value='".$value."'".$this->get_attributes($options, $name, $value)." />";
-
- if(vartrue($options['help']))
- {
- $text .= "<div class='field-help'>".$options['help']."</div>";
- }
-
- if($labelFound)
- {
- $text .= $labelFound."</label>";
- }
-
- return $text;
- }
-
- /**
- * @param name
- * @param check_enabled
- * @param label_enabled
- * @param label_disabled
- * @param options
- */
- function radio_switch($name, $checked_enabled = false, $label_enabled = '', $label_disabled = '',$options=array())
- {
- if(!is_array($options)) parse_str($options, $options);
-
- $options_on = varset($options['enabled'],array());
- $options_off = varset($options['disabled'],array());
-
- if(vartrue($options['class']) == 'e-expandit' || vartrue($options['expandit'])) // See admin->prefs 'Single Login' for an example.
- {
- $options_on = array_merge($options, array('class' => 'e-expandit-on'));
- $options_off = array_merge($options, array('class' => 'e-expandit-off'));
- }
-
- $options_on['label'] = $label_enabled ? defset($label_enabled,$label_enabled) : LAN_ENABLED;
- $options_off['label'] = $label_disabled ? defset($label_disabled,$label_disabled) : LAN_DISABLED;
-
- if(vartrue($options['reverse'])) // reverse order.
- {
- unset($options['reverse']);
-
- return $this->radio($name, 0, !$checked_enabled, $options_off)." ".
- $this->radio($name, 1, $checked_enabled, $options_on);
-
- // return $this->radio($name, 0, !$checked_enabled, $options_off)."".$this->label($label_disabled ? $label_disabled : LAN_DISABLED, $name, 0)." ".
- // $this->radio($name, 1, $checked_enabled, $options_on)."".$this->label($label_enabled ? $label_enabled : LAN_ENABLED, $name, 1);
- }
-
-
-
- // $helpLabel = (is_array($help)) ? vartrue($help[$value]) : $help;
-
- // Bootstrap Style Code - for use later.
-
-
- // ['help'] = $helpLabel;
- // $text[] = $this->radio($name, $value, (string) $checked === (string) $value, $options);
- return $this->radio($name, 1, $checked_enabled, $options_on)." ".$this->radio($name, 0, !$checked_enabled, $options_off);
-
-
- // return $this->radio($name, 1, $checked_enabled, $options_on)."".$this->label($label_enabled ? $label_enabled : LAN_ENABLED, $name, 1)."
- // ".$this->radio($name, 0, !$checked_enabled, $options_off)."".$this->label($label_disabled ? $label_disabled : LAN_DISABLED, $name, 0);
-
- }
-
-
- /**
- * XXX INTERNAL ONLY - Use radio() instead. array will automatically trigger this internal method.
- * @param string $name
- * @param array $elements = arrays value => label
- * @param string/integer $checked = current value
- * @param boolean $multi_line
- * @param mixed $help array of field help items or string of field-help (to show on all)
- */
- private function radio_multi($name, $elements, $checked, $options=array(), $help = null)
- {
-
-
-
- /* // Bootstrap Test.
- return' <label class="checkbox">
- <input type="checkbox" value="">
- Option one is this and thatâbe sure to include why its great
- </label>
-
- <label class="radio">
- <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
- Option one is this and thatâbe sure to include why its great
- </label>
- <label class="radio">
- <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
- Option two can be something else and selecting it will deselect option one
- </label>';
- */
-
-
- $text = array();
-
- if(is_string($elements)) parse_str($elements, $elements);
- if(!is_array($options)) parse_str($options, $options);
- $help = '';
- if(vartrue($options['help']))
- {
- $help = "<div class='field-help'>".$options['help']."</div>";
- unset($options['help']);
- }
-
- foreach ($elements as $value => $label)
- {
- $label = defset($label, $label);
-
- $helpLabel = (is_array($help)) ? vartrue($help[$value]) : $help;
-
- // Bootstrap Style Code - for use later.
- $options['label'] = $label;
- $options['help'] = $helpLabel;
- $text[] = $this->radio($name, $value, (string) $checked === (string) $value, $options);
-
- // $text[] = $this->radio($name, $value, (string) $checked === (string) $value)."".$this->label($label, $name, $value).(isset($helpLabel) ? "<div class='field-help'>".$helpLabel."</div>" : '');
- }
-
- if($multi_line === false)
- {
- // return implode(" ", $text);
- }
-
- // support of UI owned 'newline' parameter
- if(!varset($options['sep']) && vartrue($options['newline'])) $options['sep'] = '<br />'; // TODO div class=separator?
- $separator = varset($options['sep']," ");
- // return print_a($text,true);
- return implode($separator, $text).$help;
-
- // return implode("\n", $text);
- //XXX Limiting markup.
- // return "<div class='field-spacer' style='width:50%;float:left'>".implode("</div><div class='field-spacer' style='width:50%;float:left'>", $text)."</div>";
-
- }
-
- /**
- * Just for BC - use the $options['label'] instead.
- */
- function label($text, $name = '', $value = '')
- {
- e107::getMessage()->addDebug("Deprecated \$frm->label() used");
- $for_id = $this->_format_id('', $name, $value, 'for');
- return "<label$for_id class='e-tip legacy'>{$text}</label>";
- }
-
- function help($text)
- {
- return !empty($text) ? '<div class="field-help">'.$text.'</div>' : '';
- }
-
- function select_open($name, $options = array())
- {
- $options = $this->format_options('select', $name, $options);
-
- return "<select name='{$name}'".$this->get_attributes($options, $name).">";
- }
-
-
- /**
- * @DEPRECATED - use select() instead.
- */
- function selectbox($name, $option_array, $selected = false, $options = array(), $defaultBlank= false)
- {
- return $this->select($name, $option_array, $selected, $options, $defaultBlank);
- }
-
-
-
- /**
- *
- * @param string $name
- * @param array $option_array
- * @param boolean $selected [optional]
- * @param string|array $options [optional]
- * @param boolean|string $defaultBlank [optional] set to TRUE if the first entry should be blank, or to a string to use it for the blank description.
- * @return string HTML text for display
- */
- function select($name, $option_array, $selected = false, $options = array(), $defaultBlank= false)
- {
- if(!is_array($options)) parse_str($options, $options);
-
- if($option_array === 'yesno')
- {
- $option_array = array(1 => LAN_YES, 0 => LAN_NO);
- }
-
- if(vartrue($options['multiple']))
- {
- $name = (strpos($name, '[') === false) ? $name.'[]' : $name;
- if(!is_array($selected)) $selected = explode(",",$selected);
- }
-
- $text = $this->select_open($name, $options)."\n";
-
- if(isset($options['default']))
- {
- $text .= $this->option($options['default'], varset($options['defaultValue']));
- }
- elseif($defaultBlank)
- {
- $diz = is_string($defaultBlank) ? $defaultBlank : ' ';
- $text .= $this->option($diz, '');
- }
-
- if(varset($options['useValues'])) // use values as keys.
- {
- $new = array();
- foreach($option_array as $v)
- {
- $new[$v] = $v;
- }
- $option_array = $new;
- }
-
- $text .= $this->option_multi($option_array, $selected)."\n".$this->select_close();
- return $text;
- }
-
-
-
-
-
- //TODO
- /**
- * Universal Userclass selector - checkboxes, dropdown, everything.
- * @param $name - form element name
- * @param $curval - current userclass value(s) as array or comma separated.
- * @param $type - 'checkbox', 'dropdown',
- * @param options - query string or array. 'options=admin,mainadmin,classes&vetted=1&exclusions=0' etc.
- * @return the userclass form element
- */
- function userclass($name, $curval, $type, $options)
- {
-
-
- }
-
-
- /**
- * Renders a generic search box. If $filter has values, a filter box will be included with the options provided.
- *
- */
- function search($name, $searchVal, $submitName, $filterName='', $filterArray=false, $filterVal=false)
- {
- $tp = e107::getParser();
-
- $text = '<span class="input-append e-search">'.$tp->toGlyph('fa-search').'
- '.$this->text($name, $searchVal,20,'class=search-query').'
- <button class="btn btn-primary" name="'.$submitName.'" type="submit">'.LAN_GO.'</button>
- </span>';
-
-
-
- if(is_array($filter))
- {
- $text .= $this->selectbox($$filterName, $filterArray, $filterVal);
- }
-
- // $text .= $this->admin_button($submitName,LAN_SEARCH,'search');
-
- return $text;
-
- /*
- $text .=
-
- <select style="display: none;" data-original-title="Filter the results below" name="filter_options" id="filter-options" class="e-tip tbox select filter" title="">
- <option value="">Display All</option>
- <option value="___reset___">Clear Filter</option>
- <optgroup class="optgroup" label="Filter by Category">
- <option value="faq_parent__1">General</option>
- <option value="faq_parent__2">Misc</option>
- <option value="faq_parent__4">Test 3</option>
- </optgroup>
-
- </select><div class="btn-group bootstrap-select e-tip tbox select filter"><button id="filter-options" class="btn dropdown-toggle clearfix" data-toggle="dropdown"><span class="filter-option pull-left">Display All</span> <span class="caret"></span></button><ul style="max-height: none; overflow-y: auto;" class="dropdown-menu" role="menu"><li rel="0"><a tabindex="-1" class="">Display All</a></li><li rel="1"><a tabindex="-1" class="">Clear Filter</a></li><li rel="2"><dt class="optgroup-div">Filter by Category</dt><a tabindex="-1" class="opt ">General</a></li><li rel="3"><a tabindex="-1" class="opt ">Misc</a></li><li rel="4"><a tabindex="-1" class="opt ">Test 3</a></li></ul></div>
- <div class="e-autocomplete"></div>
-
-
- <button type="submit" name="etrigger_filter" value="etrigger_filter" id="etrigger-filter" class="btn filter e-hide-if-js btn-primary"><span>Filter</span></button>
-
- <span class="indicator" style="display: none;">
- <img src="/e107_2.0/e107_images/generic/loading_16.gif" class="icon action S16" alt="Loading...">
- </span>
-
- */
- }
-
-
-
-
-
-
-
- function uc_select($name, $current_value, $uc_options, $select_options = array(), $opt_options = array())
- {
- return $this->select_open($name, $select_options)."\n".$this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options)."\n".$this->select_close();
- }
-
- // Callback for vetted_tree - Creates the option list for a selection box
- function _uc_select_cb($treename, $classnum, $current_value, $nest_level)
- {
- $classIndex = abs($classnum); // Handle negative class values
- $classSign = (substr($classnum, 0, 1) == '-') ? '-' : '';
-
- if($classnum == e_UC_BLANK)
- return $this->option(' ', '');
-
- $tmp = explode(',', $current_value);
- if($nest_level == 0)
- {
- $prefix = '';
- $style = "font-weight:bold; font-style: italic;";
- }
- elseif($nest_level == 1)
- {
- $prefix = ' ';
- $style = "font-weight:bold";
- }
- else
- {
- $prefix = ' '.str_repeat('--', $nest_level - 1).'>';
- $style = '';
- }
- return $this->option($prefix.$this->_uc->uc_get_classname($classnum), $classSign.$classIndex, ($current_value !== '' && in_array($classnum, $tmp)), array("style"=>"{$style}"))."\n";
- }
-
-
- function optgroup_open($label, $disabled = false)
- {
- return "<optgroup class='optgroup' label='{$label}'".($disabled ? " disabled='disabled'" : '').">";
- }
-
- /**
- * <option> tag generation.
- * @param $option_title
- * @param $value
- * @param $selected
- * @param $options (eg. disabled=1)
- */
- function option($option_title, $value, $selected = false, $options = '')
- {
- if(is_string($options)) parse_str($options, $options);
-
- if(false === $value) $value = '';
- $options = $this->format_options('option', '', $options);
- $options['selected'] = $selected; //comes as separate argument just for convenience
-
- return "<option value='{$value}'".$this->get_attributes($options).">".defset($option_title, $option_title)."</option>";
- }
-
-
- /**
- * Use selectbox() instead.
- */
- function option_multi($option_array, $selected = false, $options = array())
- {
- if(is_string($option_array)) parse_str($option_array, $option_array);
-
- $text = '';
- foreach ($option_array as $value => $label)
- {
- if(is_array($label))
- {
- $text .= $this->optgroup_open($value);
- foreach($label as $val => $lab)
- {
- $text .= $this->option($lab, $val, (is_array($selected) ? in_array($val, $selected) : $selected == $val), $options)."\n";
- }
- $text .= $this->optgroup_close();
- }
- else
- {
- $text .= $this->option($label, $value, (is_array($selected) ? in_array($value, $selected) : $selected == $value), $options)."\n";
- }
- }
-
- return $text;
- }
-
- function optgroup_close()
- {
- return "</optgroup>";
- }
-
- function select_close()
- {
- return "</select>";
- }
-
- function hidden($name, $value, $options = array())
- {
- $options = $this->format_options('hidden', $name, $options);
- return "<input type='hidden' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
- }
-
- /**
- * Generate hidden security field
- * @return string
- */
- function token()
- {
- return "<input type='hidden' name='e-token' value='".defset('e_TOKEN', '')."' />";
- }
-
- function submit($name, $value, $options = array())
- {
- $options = $this->format_options('submit', $name, $options);
- return "<input type='submit' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
- }
-
- function submit_image($name, $value, $image, $title='', $options = array())
- {
- $tp = e107::getParser();
- $options = $this->format_options('submit_image', $name, $options);
- switch ($image)
- {
- case 'edit':
- $icon = "e-edit-32";
- $options['class'] = $options['class'] == 'action' ? 'btn btn-default action edit' : $options['class'];
- break;
-
- case 'delete':
- $icon = "e-delete-32";
- $options['class'] = $options['class'] == 'action' ? 'btn btn-default action delete' : $options['class'];
- $options['other'] = 'data-confirm="'.LAN_JSCONFIRM.'"';
- break;
-
- case 'execute':
- $icon = "e-execute-32";
- $options['class'] = $options['class'] == 'action' ? 'btn btn-default action execute' : $options['class'];
- break;
-
- case 'view':
- $icon = "e-view-32";
- $options['class'] = $options['class'] == 'action' ? 'btn btn-default action view' : $options['class'];
- break;
- }
- $options['title'] = $title;//shorthand
-
- return "<button type='submit' name='{$name}' data-placement='left' value='{$…
Large files files are truncated, but you can click here to view the full file