protected function edit() { SPLoader::loadClass('html.tooltip'); $this->_type = 'entry_form'; $id = $this->get('entry.id'); if ($id) { $this->addHidden($id, 'entry.id'); } if (Sobi::Cfg('legacy.sigsiutree', false)) { /* load the SigsiuTree class */ $tree = SPLoader::loadClass('mlo.tree'); /* create new instance */ $tree = new $tree(Sobi::Cfg('list.categories_ordering')); $link = "javascript:SP_selectCat( '{sid}' )"; $tree->setHref($link); $tree->setTask('category.chooser'); $tree->disable(Sobi::Section()); $tree->init(Sobi::Section()); $head = SPFactory::header(); $params = array(); $params['URL'] = Sobi::Url(array('task' => 'category.parents', 'out' => 'json'), true, false, true); $params['MAXCATS'] = Sobi::Cfg('legacy.maxCats', '5'); $params['SEPARATOR'] = Sobi::Cfg('string.path_separator', ' > '); $head->addJsVarFile('edit', md5(Sobi::Section() . Sobi::Section(true) . serialize($params)), $params); } $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $data = $this->entryData(false); $fields = $this->get('fields'); $f = array(); if (count($fields)) { foreach ($fields as $field) { if ($field->enabled('form')) { $pf = null; $pfm = null; if (!$field->get('isFree') && $field->get('fee') && !Sobi::Can('entry.payment.free')) { $pf = SPLang::currency($field->get('fee')); $pfm = Sobi::Txt('EN.FIELD_NOT_FREE_MSG', array('fee' => $pf, 'fieldname' => $field->get('name'))); } $f[$field->get('nid')] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => $field->get('name'), '_attributes' => array('lang' => Sobi::Lang(false), 'show' => $field->__get('showEditLabel'))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => $field->field(true)), 'description' => array('_complex' => 1, '_xml' => 1, '_data' => $field->get('description')), 'fee' => $pf, 'fee_msg' => $pfm), '_attributes' => array('id' => $field->get('id'), 'type' => $field->get('type'), 'suffix' => $field->get('suffix'), 'position' => $field->get('position'), 'required' => $field->get('required'), 'css_edit' => $field->get('cssClassEdit'), 'width' => $field->get('bsWidth'), 'css_class' => strlen($field->get('cssClass')) ? $field->get('cssClass') : 'spField')); } } } $f['save_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('save', Sobi::Txt('EN.SAVE_ENTRY_BT'))))); $f['cancel_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::button('cancel', Sobi::Txt('EN.CANCEL_BT'), array('onclick' => 'SPcancelEdit();'))))); if (Sobi::Cfg('legacy.sigsiutree', false)) { $data['entry']['_data']['category_chooser'] = array('path' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::textarea('parent_path', $this->get('parent_path'), false, 500, 60, array('id' => 'entry.path', 'class' => 'inputbox required', 'readonly' => 'readonly'))), 'selected' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::text('entry.parent', $this->get('parents'), array('id' => 'entry.parent', 'size' => 15, 'maxlength' => 50, 'class' => 'inputbox required', 'readonly' => 'readonly', 'style' => 'text-align:center;')))); } $data['entry']['_data']['fields'] = array('_complex' => 1, '_data' => $f, '_attributes' => array('lang' => Sobi::Lang(false))); if (Sobi::Cfg('legacy.sigsiutree', false)) { $data['tree'] = array('_complex' => 1, '_xml' => 1, '_data' => SPLang::entities($tree->display(true), true)); } $this->_attr = $data; Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); } }
/** * 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; } }
private function submit() { $xml = $this->payment(); $visitor = $this->get('visitor'); $id = $this->get('entry')->get('id'); SPLoader::loadClass('mlo.input'); if ($id) { $saveUrl = Sobi::Url(array('task' => 'entry.save', 'pid' => Sobi::Reg('current_section'), 'sid' => $id), false, false); $backUrl = Sobi::Url(array('task' => 'entry.edit', 'pid' => Sobi::Reg('current_section'), 'sid' => $id)); } else { $saveUrl = Sobi::Url(array('task' => 'entry.save', 'pid' => Sobi::Reg('current_section')), false, false); $backUrl = Sobi::Url(array('task' => 'entry.add', 'pid' => Sobi::Reg('current_section'))); } $xml['buttons']['save_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::button('save', Sobi::Txt('EN.PAYMENT_SAVE_ENTRY_BT'), array('href' => $saveUrl))))); $xml['buttons']['back_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::button('back', Sobi::Txt('EN.PAYMENT_BACK_BT'), array('href' => $backUrl))))); $xml['buttons']['cancel_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('save', Sobi::Txt('EN.CANCEL_BT')), '_data' => SPHtml_Input::button('cancel', Sobi::Txt('EN.CANCEL_BT'), array('href' => Sobi::Url(array('task' => 'entry.cancel', 'pid' => Sobi::Reg('current_section')))))))); $xml['save_url'] = $saveUrl; $xml['visitor'] = $this->visitorArray($visitor); $this->_attr = $xml; Sobi::Trigger('PaymentView', ucfirst(__FUNCTION__), array(&$this->_attr)); }
protected function tree() { $selector = null; $selectedCategories = array(); $tree = SPFactory::Instance('mlo.tree', Sobi::Cfg('list.categories_ordering'), array('preventParents' => !$this->catsWithChilds)); $tree->setHref('#'); $tree->setTask('category.chooser'); $tree->setId($this->nid); $tree->disable(Sobi::Section()); $tree->init(Sobi::Section()); $params = array(); $params['maxcats'] = $this->catsMaxLimit; $params['field'] = $this->nid; $params['preventParents'] = !$this->catsWithChilds; $setheight = ''; if ($this->height > 0) { $setheight = " style=\"height: {$this->height}px;\""; } $addBtParams = array('class' => 'btn'); $delBtParams = array('class' => 'btn'); $selectParams = array(); SPFactory::header()->addJsFile('opt.field_category_tree')->addJsCode('SobiPro.jQuery( document ).ready( function () { new SigsiuTreeEdit( ' . json_encode($params) . '); } );'); $selector = $selector . '<div class="tree"' . $setheight . '>' . $tree->display(true) . '</div>'; if (count($this->_selectedCats)) { $selected = SPLang::translateObject($this->_selectedCats, 'name', 'category'); if (count($selected)) { $count = 0; foreach ($selected as $category) { if ($category['id'] == $this->sid && SPRequest::task() != 'entry.add') { continue; } $selectedCategories[$category['id']] = $category['value']; $count++; if ($count == $this->catsMaxLimit) { break; } } } } if (count($selectedCategories) >= $this->catsMaxLimit) { $addBtParams['disabled'] = 'disabled'; $selectParams['readonly'] = 'readonly'; } elseif (!count($selectedCategories)) { $delBtParams['disabled'] = 'disabled'; } $selector .= '<div class="selected">'; $selector .= SPHtml_Input::select($this->nid . '_list', $selectedCategories, null, true, $selectParams); $selector .= SPHtml_Input::hidden($this->nid, 'json://' . json_encode(array_keys($selectedCategories))); $selector .= '</div>'; $selector .= '<div class="buttons">'; $selector .= SPHtml_Input::button('addCategory', Sobi::Txt('CC.ADD_BT'), $addBtParams); $selector .= SPHtml_Input::button('removeCategory', Sobi::Txt('CC.DEL_BT'), $delBtParams); $selector .= '</div>'; $selector = '<div class="SigsiuTree" id="' . $this->nid . '_canvas">' . $selector . '</div>'; if ($this->modal) { $selector = SPHtml_Input::modalWindow(Sobi::Txt('EN.SELECT_CAT_PATH'), $this->nid . '_modal', $selector, 'modaltree modal hide', 'CLOSE', null); $field = SPHtml_Input::button('select-category', Sobi::Txt('EN.SELECT_CAT_PATH'), array('class' => 'btn btn-primary', 'href' => '#' . $this->nid . '_modal', 'data-toggle' => 'modal', 'id' => $this->nid . '_modal_fire')); return $field . $selector; } else { return $selector; } }
/** * 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; } }
private function getEntry() { $params = array('id' => 'sp_entry', 'class' => $this->oType == 'entry' ? 'btn input-large btn-primary' : 'btn input-medium', 'style' => 'margin-top: 10px; width: 300px'); if ($this->task) { $params['disabled'] = 'disabled'; } return '<div class="SobiPro">' . SPHtml_Input::button('sp_entry', $this->oType == 'entry' ? $this->oName : Sobi::Txt('SOBI_SELECT_ENTRY'), $params) . '<div class="modal hide" id="spEntry" style="width:500px; overflow: visible;"> <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button> <h3>' . Sobi::Txt('SOBI_SELECT_ENTRY') . '</h3> </div> <div class="modal-body" style="overflow-y: visible;"> <label>' . Sobi::Txt('SOBI_SELECT_ENTRY_TYPE_TITLE') . '</label><input type="text" data-provide="typeahead" autocomplete="off" id="spEntryChooser" class="span6" style="width: 95%" placeholder="' . Sobi::Txt('SOBI_SELECT_ENTRY_TYPE') . '"> </div> <div class="modal-footer"> <a href="#" class="btn" data-dismiss="modal">' . Sobi::Txt('SOBI_CLOSE_WINDOW') . '</a> <a href="#" id="spEntrySelect" class="btn btn-primary" data-dismiss="modal">' . Sobi::Txt('SOBI.JMENU_SAVE') . '</a> </div> </div> <input type="hidden" name="selectedEntry" id="selectedEntry" value=""/> <input type="hidden" name="selectedEntryName" id="selectedEntryName" value=""/> </div>'; }