public function functions() { $functions = $this->get('functions'); $out = array(); $section = SPRequest::int('section'); $out[] = '<form action="index.php" method="post">'; $out[] = SPHtml_Input::select('function', $functions, null, false, array('id' => 'SobiProFunctions')); $out[] = '<input type="hidden" name="option" value="com_sobipro">'; $out[] = '<input type="hidden" name="task" value="menu">'; $out[] = '<input type="hidden" name="tmpl" value="component">'; $out[] = '<input type="hidden" name="format" value="html">'; $out[] = '<input type="hidden" name="mid" value="' . SPRequest::int('mid') . '">'; $out[] = '<input type="hidden" name="section" value="' . $section . '">'; $out[] = '</form>'; echo implode("\n", $out); }
/** * @param $path * @param $subParams * @return string */ protected function travelDependencyPath($path, $subParams) { $subFields = null; if (count($path)) { $progress = array(); foreach ($path as $index => $step) { $progress[] = $step; $subParams['data']['order'] = $index + 1; $subParams['id'] = $this->nid . '_' . $index; $lists = $this->loadDependencyDefinition($progress); if (count($lists)) { $subFields .= SPHtml_Input::select($this->nid, $lists, $path[$index + 1], false, $subParams); } } } return $subFields; }
/** * @deprecated */ public function display($return = false) { $pn = null; $pages = $this->limit > 0 ? ceil($this->count / $this->limit) : 0; $sid = SPRequest::sid() ? SPRequest::sid() : Sobi::Section(); $pn .= '<div style="text-align:center;"><div class="pagination">'; $pn .= '<div class="limit">'; $pn .= Sobi::Txt('PN.DISPLAY'); $box = array(); foreach ($this->limits as $v) { if ($v) { $box[$v] = $v; } else { $box[-1] = Sobi::Txt('PN.ALL'); } } $pn .= SPHtml_Input::select($this->box, $box, $this->limit, false, array('onchange' => "{$this->boxFunc}( {$sid} )")); $pn .= '</div>'; if ($pages > 1) { if ($this->current == 1) { $pn .= '<div class="button2-right off"><div class="start"><span>'; $pn .= Sobi::Txt('PN.START'); $pn .= '</span></div></div>'; $pn .= '<div class="button2-right off"><div class="prev"><span>'; $pn .= Sobi::Txt('PN.PREVIOUS'); $pn .= '</span></div></div>'; } else { $link = " onclick=\"{$this->func}( 1, {$sid} )\" "; $txt = Sobi::Txt('PN.START'); $pn .= "<div class=\"button2-right\"><div class=\"start\"><a href=\"#\"{$link} title=\"{$txt}\">{$txt}</a></div></div>"; $prevpage = $this->current - 1; $txt = Sobi::Txt('PN.PREVIOUS'); $link = " onclick=\"{$this->func}( {$prevpage}, {$sid} )\" "; $pn .= "<div class=\"button2-right\"><div class=\"start\"><a href=\"#\"{$link} title=\"{$txt}\">{$txt}</a></div></div>"; } $pn .= '<div class="button2-left"><div class="page">'; for ($page = 1; $page <= $pages; $page++) { if ($pages > 1000 && $page % 1000 != 0) { continue; } elseif ($pages > 100 && $page % 100 != 0) { continue; } elseif ($pages > 20 && $page % 5 != 0) { continue; } $link = " onclick=\"{$this->func}( {$page}, {$sid} )\" "; if ($page == $this->current) { $pn .= '<span>' . $page . '</span>'; } else { $pn .= "<a href=\"#\"{$link}\" title=\"{$page}\">{$page}</a>"; } } $pn .= '</div></div>'; if ($this->current == $pages) { $pn .= '<div class="button2-left off"><div class="next"><span>'; $pn .= Sobi::Txt('PN.NEXT'); $pn .= '</span></div></div>'; $pn .= '<div class="button2-left off"><div class="end"><span>'; $pn .= Sobi::Txt('PN.END'); $pn .= '</span></div></div>'; } else { $nextpage = $this->current + 1; $link = " onclick=\"{$this->func}( {$nextpage}, {$sid} )\" "; $txt = Sobi::Txt('PN.NEXT'); $pn .= "<div class=\"button2-left\"><div class=\"next\"><a href=\"#\"{$link}title=\"{$txt}\">{$txt}</a></div></div>"; $link = " onclick=\"{$this->func}( {$pages}, {$sid} )\" "; $txt = Sobi::Txt('PN.END'); $pn .= "<div class=\"button2-left\"><div class=\"end\"><a href=\"#\"{$link}title=\"{$txt}\">{$txt}</a></div></div>"; } $pn .= "<div class=\"limit\">"; $pn .= Sobi::Txt('PN.CURRENT_SITE', array('current' => $this->current, 'pages' => $pages)); $pn .= '</div></div>'; } $pn .= '</div><br/>'; if ($return) { return $pn; } else { echo $pn; } }
public function fetchElement($name, &$label) { $sid = $this->settings()->get('sid'); $this->oType = 'section'; switch ($name) { case 'sid': $params = array('id' => 'sid', 'size' => 5, 'class' => 'text_area', 'style' => 'text-align: center;', 'readonly' => 'readonly'); return SPHtml_Input::text('jform[params][sid]', $sid, $params); break; case 'tplFile': case 'modalTemplate': return $this->tplFile($this->settings()->get('tplFile'), $name == 'modalTemplate'); break; case 'spOrder': return $this->ordering($this->settings()->get('spOrder')); break; case 'spLimit': return $this->limits($this->settings()->get('spLimit')); break; case 'cid': if (!in_array($sid, array_keys($this->sections))) { $catName = SPLang::translateObject($sid, array('name')); if (isset($catName[$sid]['value'])) { $this->oName = $catName[$sid]['value']; $this->oType = 'category'; } } return $this->getCat(); break; default: $sections = array(); if (count($this->sections)) { $sections[] = Sobi::Txt('SELECT_SECTION'); foreach ($this->sections as $section) { if (Sobi::Can('section', 'access', 'valid', $section->id)) { $s = SPFactory::Model('section'); $s->extend($section); $sections[$s->get('id')] = $s->get('name'); } } } $params = array('id' => 'spsection', 'class' => 'text_area required'); return SPHtml_Input::select('jform[params][section]', $sections, $this->settings()->get('section'), false, $params); break; } }
/** * Shows the field in the edit entry or add entry form * @param bool $return return or display directly * @return string */ public function field($return = false) { if (!$this->enabled) { return false; } $field = null; $fdata = Sobi::Reg('editcache'); if ($fdata && is_array($fdata)) { $raw = $this->fromCache($fdata); } else { $raw = $this->getRaw(); if (!is_array($raw)) { try { $raw = SPConfig::unserialize($raw); } catch (SPException $x) { $raw = null; } } } if ($this->ownLabel) { $fieldTitle = null; $params = array('id' => $this->nid, 'class' => $this->cssClass . 'Title'); if ($this->labelMaxLength) { $params['maxlength'] = $this->labelMaxLength; } if ($this->labelWidth) { $params['style'] = "width: {$this->labelWidth}px;"; } if (strlen($this->labelsLabel)) { $this->labelsLabel = SPLang::clean($this->labelsLabel); //$fieldTitle .= "<label for=\"{$this->nid}\" class=\"{$this->cssClass}Title\">{$this->labelsLabel}</label>\n"; $params['placeholder'] = $this->labelsLabel; } $fieldTitle .= SPHtml_Input::text($this->nid, is_array($raw) && isset($raw['label']) ? SPLang::clean($raw['label']) : null, $params); } $protocols = array(); if (count($this->allowedProtocols)) { foreach ($this->allowedProtocols as $protocol) { $protocols[$protocol] = $protocol . '://'; } } else { $protocols = array('http' => 'http://', 'https' => 'https://'); } $params = array('id' => $this->nid . '_protocol', 'size' => 1, 'class' => $this->cssClass . 'Protocol'); if (Sobi::Cfg('template.bootstrap3-styles')) { $protofield = '<div class="input-group"><div class="input-group-btn">'; } else { $protofield = '<div class="input-prepend"><div class="btn-group">'; } $protofield .= SPHtml_Input::select($this->nid . '_protocol', $protocols, is_array($raw) && isset($raw['protocol']) ? $raw['protocol'] : 'http', false, $params); $protofield .= '</div>'; //$field .= '<span class="spFieldUrlProtocol">://</span>'; $class = $this->required ? $this->cssClass . ' required' : $this->cssClass; $params = array('id' => $this->nid . '_url', 'class' => $class); if ($this->maxLength) { $params['maxlength'] = $this->maxLength; } //for compatibility reason still there if ($this->width) { $params['style'] = "width: {$this->width}px;"; } $label = Sobi::Txt('FD.URL_ADDRESS'); if (!$this->ownLabel && $this->labelAsPlaceholder) { // the field label will be shown only if labelAsPlaceholder is true and no own label for the URL is selected $label = $this->__get('name'); } $params['placeholder'] = $label; $value = is_array($raw) && isset($raw['url']) ? $raw['url'] : null; if ($value == null) { if ($this->defaultValue) { $value = $this->defaultValue; } } $field .= $protofield; $field .= SPHtml_Input::text($this->nid . '_url', $value, $params); $field .= '</div>'; if ($this->ownLabel) { $field = "\n<div class=\"spFieldUrlLabel\">{$fieldTitle}</div>\n<div class=\"spFieldUrl\">{$field}</div>"; } else { $field = "\n<div class=\"spFieldUrl\">{$field}</div>"; } if ($this->countClicks && $this->sid) { $counter = $this->getCounter(); if ($counter) { SPFactory::header()->addJsFile('opt.field_url_edit'); } $classes = 'btn spCountableReset'; $attr = array(); if (!$counter) { $attr['disabled'] = 'disabled'; } $field .= SPHtml_Input::button($this->nid . '_reset', Sobi::Txt('FM.URL.EDIT_CLICKS', $counter), null, $classes); } if (!$return) { echo $field; } else { return $field; } }
/** * Shows the field in the search form * @param bool $return return or display directly * @return string */ public function searchForm($return = false) { if ($this->searchMethod == 'general') { return false; } if ($this->searchMethod == 'range') { return $this->rangeSearch($this->searchRangeValues, $this->freeRange); } $fdata = array(); try { $data = SPFactory::db()->dselect(array('baseData', 'sid', 'lang'), 'spdb_field_data', array('fid' => $this->fid, 'copy' => '0', 'enabled' => 1), 'field( lang, \'' . Sobi::Lang() . '\'), baseData', 0, 0, 'baseData')->loadAssocList(); $languages = array(); $output = array(); $lang = Sobi::Lang(false); $defLang = Sobi::DefLang(); if (count($data)) { foreach ($data as $row) { $languages[$row['lang']][$row['sid']] = $row['baseData']; } } if (isset($languages[$lang])) { foreach ($languages[$lang] as $sid => $fieldData) { $output[$sid] = $fieldData; } unset($languages[$lang]); } if (isset($languages[$defLang])) { foreach ($languages[$defLang] as $sid => $fieldData) { if (!isset($output[$sid])) { $output[$sid] = $fieldData; } } unset($languages[$defLang]); } if (count($languages)) { foreach ($languages as $language => $langData) { foreach ($langData as $sid => $fieldData) { if (!isset($output[$sid])) { $output[$sid] = $fieldData; } } unset($languages[$language]); } } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_GET_FIELDS_DATA_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } $data = (array) $output; if (count($data)) { $fdata[''] = Sobi::Txt('FD.INBOX_SEARCH_SELECT', array('name' => $this->name)); foreach ($data as $i => $d) { if (strlen($d)) { $fdata[strip_tags($d)] = strip_tags($d); } } } return SPHtml_Input::select($this->nid, $fdata, $this->_selected, false, array('class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect'), 'size' => '1', 'id' => $this->nid)); }
/** * Shows the field in the search form * @param bool $return return or display directly * @return string */ public function searchForm($return = false) { $data = $this->getValues(); $field = null; switch ($this->searchMethod) { default: case 'general': $field = false; break; case 'chbx': $list = SPHtml_Input::checkBoxGroup($this->nid, $data, $this->nid, $this->_selected, array('class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_checkbox_def_css', 'SPSearchChbx')), $this->labelSite, true); if (count($list)) { $c = 0; foreach ($list as $box) { $box = '<div class="spFieldCheckbox" style="width:' . $this->optWidth . 'px;">' . $box . '</div>'; $field .= "\n" . $box; if (!(++$c % $this->optInLine)) { $field .= "\n<div class=\"clearfix\"></div>\n"; } } $field = "<div id=\"{$this->nid}\" >{$field}</div>"; $field .= "\n<div class=\"clearfix\"></div>\n"; } break; case 'radio': $field = $this->getField($this->cssClass . ' ' . Sobi::Cfg('search.form_radio_def_css', 'SPSearchRadio'), $this->_selected); $field .= "\n<div class=\"clearfix\"></div>\n"; break; case 'select': case 'mselect': $params = array('id' => $this->nid, 'size' => $this->searchMethod == 'mselect' ? $this->optInLine : 1, 'class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect')); $data = array_merge(array('' => Sobi::Txt('FD.SEARCH_SELECT_LIST', array('name' => $this->name))), $data); $field = SPHtml_Input::select($this->nid, $data, $this->_selected, $this->searchMethod == 'mselect', $params); break; } return $field; }
/** * Shows the field in the search form * @param bool $return return or display directly * @return string */ public function searchForm($return = true) { $this->loadCategories(); if (count($this->_cats)) { if ($this->searchMethod == 'select') { $values = array('' => Sobi::Txt('FMN.CC_SEARCH_SELECT_CAT')); } else { $values = array(); } $this->createValues($this->_cats, $values, Sobi::Cfg('category_chooser.margin_sign', '-'), false); $selected = $this->_selected; if ($selected) { if (is_numeric($selected)) { $selected = array($selected); } foreach ($selected as $i => $v) { $selected[$i] = (string) $v; } } } if ($this->searchMethod == 'select') { $params = array('id' => $this->nid, 'class' => $this->cssClass); if ($this->searchWidth) { $params['style'] = "width: {$this->searchWidth}px;"; } $field = SPHtml_Input::select($this->nid, $values, $selected, false, $params); } elseif ($this->searchMethod == 'mselect') { $params = array('id' => $this->nid, 'class' => $this->cssClass); if ($this->searchWidth && $this->searchHeight) { $params['style'] = "width: {$this->searchWidth}px; height: {$this->searchHeight}px"; } $field = SPHtml_Input::select($this->nid, $values, $selected, true, $params); } return $field; }
/** * Shows the field in the edit entry or add entry form * @param bool $return return or display directly * @return string */ public function field($return = false) { if (!$this->enabled) { return false; } $field = null; $fdata = Sobi::Reg('editcache'); if ($fdata && is_array($fdata)) { $raw = $this->fromCache($fdata); } else { $raw = $this->getRaw(); if (!is_array($raw)) { try { $raw = SPConfig::unserialize($raw); } catch (SPException $x) { $raw = null; } } } if ($this->ownLabel) { $fieldTitle = null; $params = array('id' => $this->nid, 'class' => $this->cssClass . 'Title'); if ($this->labelMaxLength) { $params['maxlength'] = $this->labelMaxLength; } if ($this->labelWidth) { $params['style'] = "width: {$this->labelWidth}px;"; } if (strlen($this->labelsLabel)) { $this->labelsLabel = SPLang::clean($this->labelsLabel); $fieldTitle .= "<label for=\"{$this->nid}\" class=\"{$this->cssClass}Title\">{$this->labelsLabel}</label>\n"; } $fieldTitle .= SPHtml_Input::text($this->nid, is_array($raw) && isset($raw['label']) ? SPLang::clean($raw['label']) : null, $params); } $protocols = array(); if (count($this->allowedProtocols)) { foreach ($this->allowedProtocols as $protocol) { $protocols[$protocol] = $protocol . '://'; } } else { $protocols = array('http' => 'http://', 'https' => 'https://'); } $params = array('id' => $this->nid . '_protocol', 'size' => 1, 'class' => $this->cssClass . 'Protocol'); $field .= SPHtml_Input::select($this->nid . '_protocol', $protocols, is_array($raw) && isset($raw['protocol']) ? $raw['protocol'] : 'http', false, $params); //$field .= '<span class="spFieldUrlProtocol">://</span>'; $class = $this->required ? $this->cssClass . ' required' : $this->cssClass; $params = array('id' => $this->nid . '_url', 'class' => $class); if ($this->maxLength) { $params['maxlength'] = $this->maxLength; } if ($this->width) { $params['style'] = "width: {$this->width}px;"; } $field .= SPHtml_Input::text($this->nid . '_url', is_array($raw) && isset($raw['url']) ? $raw['url'] : null, $params); if ($this->ownLabel) { $field = "\n<div class=\"spFieldUrlLabel\">{$fieldTitle}</div>\n<div class=\"spFieldUrl\">{$field}</div>"; } else { $field = "\n<div class=\"spFieldUrl\">{$field}</div>"; } if ($this->countClicks && $this->sid) { $counter = $this->getCounter(); if ($counter) { SPFactory::header()->addJsFile('opt.field_url_edit'); } $classes = 'btn spCountableReset'; $attr = array(); if (!$counter) { $attr['disabled'] = 'disabled'; } $field .= SPHtml_Input::button($this->nid . '_reset', Sobi::Txt('FM.URL.EDIT_CLICKS', $counter), null, $classes); } if (!$return) { echo $field; } else { return $field; } }
protected function getTemplates() { $selected = $this->tpl; $templates = array(); $name = $this->tpl ? 'urlparams[sptpl]' : 'urlparams[-sptpl-]'; $templates[''] = Sobi::Txt('SELECT_TEMPLATE_OVERRIDE'); $template = SPFactory::db()->select('sValue', 'spdb_config', array('section' => $this->section, 'sKey' => 'template', 'cSection' => 'section'))->loadResult(); $templateDir = $this->templatePath($template); $this->listTemplates($templates, $templateDir, $this->oType); $params = array('id' => 'sptpl'); $field = SPHtml_Input::select($name, $templates, $selected, false, $params); return "<div class=\"SobiPro\" style=\"margin-top: 2px;\">{$field}</div>"; }
protected function rangeSearch($values, $freeInput = false) { $request['from'] = isset($this->_selected['from']) ? (int) $this->_selected['from'] : ''; $request['to'] = isset($this->_selected['to']) ? (int) $this->_selected['to'] : ''; if (!$freeInput) { $values = str_replace(array("\n", "\r", "\t"), null, $values); $values = explode(',', $values); $data = array(); $data2 = array(); if (count($values)) { foreach ($values as $k => $v) { $data[''] = Sobi::Txt('SH.SEARCH_SELECT_RANGE_FROM', array('name' => $this->name)); $data2[''] = Sobi::Txt('SH.SEARCH_SELECT_RANGE_TO', array('name' => $this->name)); $data[preg_replace('/[^\\d\\.\\-]/', null, trim($v))] = $v; $data2[preg_replace('/[^\\d\\.\\-]/', null, trim($v))] = $v; } } $from = SPHtml_Input::select($this->nid . '[from]', $data, $request['from'], false, array('class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect'), 'size' => '1')); $to = SPHtml_Input::select($this->nid . '[to]', $data2, $request['to'], false, array('class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect'), 'size' => '1')); // return '<div class="SPSearchSelectRangeFrom"><span>' . Sobi::Txt( 'SH.RANGE_FROM' ) . '</span> ' . $from . ' ' . $this->suffix . '</div><div class="SPSearchSelectRangeTo"><span>' . Sobi::Txt( 'SH.RANGE_TO' ) . '</span> ' . $to . ' ' . $this->suffix . '</div>'; return '<div class="spSelectRangeFrom">' . $from . ' ' . $this->suffix . '</div><div class="spSelectRangeTo">' . $to . ' ' . $this->suffix . '</div>'; } else { $from = SPHtml_Input::text($this->nid . '[from]', $request['from'], array('size' => '1', 'placeholder' => Sobi::Txt('SH.RANGE_FROM'))); $to = SPHtml_Input::text($this->nid . '[to]', $request['to'], array('size' => '1', 'placeholder' => Sobi::Txt('SH.RANGE_TO'))); // return '<div class="SPSearchInputRangeFrom"><span>' . Sobi::Txt( 'SH.RANGE_FROM' ) . '</span> ' . $from . ' ' . $this->suffix . '</div><div class="SPSearchInputRangeTo"><span>' . Sobi::Txt( 'SH.RANGE_TO' ) . '</span> ' . $to . ' ' . $this->suffix . '</div>'; return '<div class="spInputRangeFrom">' . $from . ' ' . $this->suffix . '</div><div class="spInputRangeTo">' . $to . ' ' . $this->suffix . '</div>'; } }
protected function loadSection() { $sections = array(); $sectionsOutput = array(); try { $sections = SPFactory::db()->select('*', 'spdb_object', array('oType' => 'section'), 'id')->loadObjectList(); } catch (SPException $x) { Sobi::Error($this->name(), $x->getMessage(), SPC::ERROR, 500, __LINE__, __FILE__); } if (count($sections)) { $sectionsOutput[] = Sobi::Txt('SOBI_SELECT_SECTION'); foreach ($sections as $section) { if (Sobi::Can('section', 'access', 'valid', $section->id)) { $s = new SPSection(); $s->extend($section); $sectionsOutput[$s->get('id')] = $s->get('name'); } } } $params = array('id' => 'SobiSection', 'class' => 'required'); return SPHtml_Input::select('section', $sectionsOutput, self::$section, false, $params); }