Exemple #1
0
 /**
  * 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;
     }
     $class = $this->required ? $this->cssClass . ' required' : $this->cssClass;
     $params = array('id' => $this->nid, 'class' => $class);
     if ($this->maxLength) {
         $params['maxlength'] = $this->maxLength;
     }
     //for compatibility reason still there
     if ($this->width) {
         $params['style'] = "width: {$this->width}px;";
     }
     if ($this->labelAsPlaceholder) {
         $params['placeholder'] = $this->__get('name');
     }
     $value = $this->getRaw();
     $value = strlen($value) ? $value : $this->defaultValue;
     $field = SPHtml_Input::text($this->nid, $value, $params);
     if (!$return) {
         echo $field;
     } else {
         return $field;
     }
 }
Exemple #2
0
 /**
  * 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 = SPConfig::unserialize($this->getRaw());
     }
     if ($this->ownLabel) {
         $fieldTitle = null;
         $params = array('id' => $this->nid, 'size' => $this->labelWidth, '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);
     }
     $class = $this->required ? $this->cssClass . ' required' : $this->cssClass;
     $this->nid .= '_url';
     $params = array('id' => $this->nid, 'size' => $this->width, 'class' => $class);
     if ($this->maxLength) {
         $params['maxlength'] = $this->maxLength;
     }
     if ($this->width) {
         $params['style'] = "width: {$this->width}px;";
     }
     $field .= SPHtml_Input::text($this->nid, is_array($raw) && isset($raw['url']) ? $raw['url'] : null, $params);
     if ($this->ownLabel) {
         $label = Sobi::Txt('FD.MAIL_EMAIL_ADDRESS');
         $field = "\n<div class=\"spFieldEmailLabel\">{$fieldTitle}</div>\n<div class=\"spFieldEmail\"><label for=\"{$this->nid}_url\" class=\"{$this->cssClass}Title\">{$label}</label>\n{$field}</div>";
     }
     if (!$return) {
         echo $field;
     } else {
         return $field;
     }
 }
Exemple #3
0
 /**
  * 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;
     }
     $class = $this->required ? $this->cssClass . ' required' : $this->cssClass;
     $params = array('id' => $this->nid, 'class' => $class);
     if ($this->maxLength) {
         $params['maxlength'] = $this->maxLength;
     }
     if ($this->width) {
         $params['style'] = "width: {$this->width}px;";
     }
     $field = SPHtml_Input::text($this->nid, $this->getRaw(), $params);
     if (!$return) {
         echo $field;
     } else {
         return $field;
     }
 }
Exemple #4
0
 /**
  * Creates the "position" table row with order up/order down and position inputbox
  *
  * @param $row - SPDataModel
  * @param $count - number of entries/cats
  * @param $id - id ident for the box
  * @param $type - object type
  * @param $parent - id ident of parent object
  * @param $lsid - id of the object for the link
  * @return unknown_type
  */
 public static function position($row, $count, $id = 'sid', $type = null, $parent = 'pid', $lsid = 'sid')
 {
     SPLoader::loadClass('html.tooltip');
     $position = $row->get('position');
     /** @todo check what the hell the $up should be */
     $up = null;
     if (!$type) {
         $type = $row->type();
     }
     if ($position > 1) {
         $up = Sobi::Cfg('list_icons.position_up');
         $url = Sobi::Url(array('task' => $type . '.up', $parent => SPRequest::sid(), $lsid => $row->get('id')));
         /* translate alternative text */
         $s = Sobi::Txt($type . '.order_up');
         $a = Sobi::Txt($type . '.order_up_expl');
         $img = SPTooltip::toolTip($a, $s, $up);
         $up = "<a href=\"{$url}\">{$img}</a>";
     }
     $down = Sobi::Cfg('list_icons.position_down');
     $url = Sobi::Url(array('task' => $type . '.down', $parent => SPRequest::sid(), $lsid => $row->get('id')));
     /* translate alternative text */
     $s = Sobi::Txt($type . '.order_down');
     if ($position != $count) {
         $a = Sobi::Txt($type . '.order_down_expl');
         $img = SPTooltip::toolTip($a, $s, $down);
         $down = "<a href=\"{$url}\">{$img}</a>";
     } else {
         $down = null;
     }
     $sid = $row->get('id');
     $box = SPHtml_Input::text("{$id}[{$sid}]", $position, array('style' => 'text-align:center; width: 40px;'));
     return "<div style=\"width:30%;float:left;\">{$up}&nbsp;{$down}</div>&nbsp;{$box}";
 }
Exemple #5
0
 public function proceedCell($cell, $span = null)
 {
     $span = $this->istSet($cell['attributes'], 'element') ? $cell['attributes']['element'] : $span;
     if ($cell['type'] == 'text') {
         return $this->parseElement($cell);
     }
     if ($cell['type'] == 'tooltip' || $cell['type'] == 'popover') {
         return $this->tooltip($cell);
     }
     $data = null;
     if (isset($cell['attributes']) && count($cell['attributes'])) {
         foreach ($cell['attributes'] as $att => $value) {
             if (!strstr($att, 'data-')) {
                 continue;
             }
             $data .= ' ' . $att . '="' . $value . '" ';
         }
     }
     if (isset($cell['attributes']['class'])) {
         $c = $cell['attributes']['class'];
         $this->_out[] = "\n<{$span} {$data} class=\"{$c}\">\n";
     } else {
         $this->_out[] = "\n<{$span} {$data}>\n";
     }
     $type = isset($cell['attributes']['type']) ? $cell['attributes']['type'] : 'text';
     switch ($type) {
         /** no break here - continue */
         case 'text':
         case 'link':
             if ($type == 'link') {
                 $class = null;
                 $target = null;
                 if ($this->istSet($cell['attributes'], 'link-class')) {
                     $class = "class=\"{$cell['attributes']['link-class']}\" ";
                 }
                 if ($this->istSet($cell['attributes'], 'target')) {
                     $target = "target=\"{$cell['attributes']['target']}\" ";
                 }
                 $this->_out[] = "<a href=\"{$cell['link']}\"{$class}{$target} >";
             }
             if ($this->istSet($cell['attributes'], 'icon')) {
                 $this->_out[] = '<i class="icon-' . $cell['attributes']['icon'] . '"></i>&nbsp;';
             }
             if ($this->istSet($cell['attributes'], 'label')) {
                 $this->_out[] = $cell['attributes']['label'];
             }
             if ($this->istSet($cell, 'label')) {
                 $class = null;
                 //if label in cell directly (with optional class) add a span as it could be a label/value pair
                 if ($this->istSet($cell['attributes'], 'class')) {
                     $class = "class=\"{$cell['attributes']['class']}Label\"";
                 }
                 $this->_out[] = "<span {$class}>{$cell['label']}</span>";
             }
             if ($this->istSet($cell['content'], 'element', 'button')) {
                 $this->renderButton($cell['content']);
             } else {
                 $this->_out[] = $cell['content'];
             }
             /** no break here - continue */
             if ($type == 'link') {
                 $this->_out[] = "</a>";
             }
             break;
         case 'image':
             $this->_out[] = "<img src=\"{$cell['link']}\" />";
             break;
         case 'ordering':
             if (isset($cell['attributes']['label'])) {
                 $this->_out[] = $cell['attributes']['label'];
                 $this->_out[] = '<button class="btn sp-mini-bt" name="spReorder" rel="' . $cell['attributes']['rel'] . '">';
                 $this->_out[] = '<i class="icon-reorder"></i>';
                 $this->_out[] = '</button>';
             } else {
                 $this->_out[] = SPHtml_Input::text($cell['attributes']['name'], $cell['content'], array('class' => 'input-mini sp-input-micro spSubmit'));
             }
             break;
         case 'checkbox':
             $cell = $this->checkbox($cell);
             break;
         case 'ticker':
             $cell = $this->ticker($cell);
             break;
     }
     if (isset($cell['childs']) && count($cell['childs'])) {
         foreach ($cell['childs'] as $child) {
             $this->proceedCell($child, 'div');
         }
     }
     $this->_out[] = "\n</{$span}>\n";
 }
Exemple #6
0
 public function display()
 {
     $this->_type = 'search';
     $type = $this->key('template_type', 'xslt');
     if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
         $type = 'php';
     }
     if ($type == 'xslt') {
         $searchData = array();
         $fields = $this->get('fields');
         $visitor = $this->get('visitor');
         $p = $this->get('priorities');
         $priorities = array();
         if (is_array($p) && count($p)) {
             foreach ($p as $priority => $eids) {
                 if (is_array($eids) && count($eids)) {
                     foreach ($eids as $sid) {
                         $priorities[$sid] = $priority;
                     }
                 }
             }
         }
         $entries = $this->get('entries');
         $searchData['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
         $searchPhrase = $this->get('search_for');
         $phrase = $this->get('search_phrase');
         $searchPhrase = strlen($searchPhrase) ? $searchPhrase : Sobi::Txt('SH.SEARCH_FOR_BOX');
         SPFactory::header()->addJsCode('var spSearchDefStr = "' . Sobi::Txt('SH.SEARCH_FOR_BOX') . '"');
         if ($this->get('$eInLine')) {
             $searchData['entries_in_line'] = $this->get('$eInLine');
         }
         if ($this->get('$eCount') >= 0) {
             $searchData['message'] = Sobi::Txt('SH.SEARCH_FOUND_RESULTS', array('count' => $this->get('$eCount')));
         }
         $this->menu($searchData);
         $this->alphaMenu($searchData);
         $fData = array();
         if (Sobi::Cfg('search.show_searchbox', true)) {
             $fData['searchbox'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_FOR'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::text('sp_search_for', $searchPhrase, array('class' => Sobi::Cfg('search.form_box_def_css', 'SPSearchBox'), 'id' => 'SPSearchBox')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchBox'));
         }
         if (Sobi::Cfg('search.top_button', true)) {
             $fData['top_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START'), array('id' => 'top_button')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton'));
         }
         if (Sobi::Cfg('search.show_phrase', true)) {
             $fData['phrase'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::radioList('spsearchphrase', array('all' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ALL_WORDS'), 'any' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ANY_WORDS'), 'exact' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_EXACT_PHRASE')), 'spsearchphrase', strlen($phrase) ? $phrase : Sobi::Cfg('search.form_searchphrase_def', 'all'), null, 'right'))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchPhrase'));
         }
         if (count($fields)) {
             foreach ($fields as $field) {
                 $data = $field->searchForm();
                 $suffix = $field->get('searchMethod') != 'range' ? $field->get('suffix') : null;
                 if (strlen($data)) {
                     $fData[$field->get('nid')] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => $field->get('name'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => $data)), '_attributes' => array('id' => $field->get('id'), 'type' => $field->get('type'), 'suffix' => $suffix, 'position' => $field->get('position'), 'css_class' => strlen($field->get('cssClass')) ? $field->get('cssClass') : 'spField'));
                 }
             }
         }
         if (Sobi::Cfg('search.bottom_button', false)) {
             $fData['bottom_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton'));
         }
         $searchData['fields'] = $fData;
         if (count($entries)) {
             $this->loadNonStaticData($entries);
             $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false;
             foreach ($entries as $entry) {
                 $en = $this->entry($entry, $manager);
                 $searchData['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id'], 'search-priority' => isset($priorities[$en['id']]) ? $priorities[$en['id']] : 'undefined'), '_data' => $en);
             }
             $this->navigation($searchData);
         }
         $searchData['visitor'] = $this->visitorArray($visitor);
         $this->_attr = $searchData;
     }
     Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
     parent::display($this->_type);
 }
Exemple #7
0
 /**
  * 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 = SPConfig::unserialize($this->getRaw());
     }
     if ($this->ownLabel) {
         $fieldTitle = null;
         $params = array('id' => $this->nid, 'size' => $this->labelWidth, '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);
     }
     $class = $this->required ? $this->cssClass . ' required' : $this->cssClass;
     $this->nid .= '_url';
     $params = array('id' => $this->nid, 'size' => $this->width, 'class' => $class);
     if ($this->maxLength) {
         $params['maxlength'] = $this->maxLength;
     }
     if ($this->width) {
         $params['style'] = "width: {$this->width}px;";
     }
     $label = Sobi::Txt('FD.MAIL_EMAIL_ADDRESS');
     if (!$this->ownLabel && $this->labelAsPlaceholder) {
         // the field label will be shown only if labelAsPlaceholder is true and no own label for the email is selected
         $label = $this->__get('name');
         //get the field's label from the model
     }
     $params['placeholder'] = $label;
     $value = is_array($raw) && isset($raw['url']) ? $raw['url'] : null;
     if ($value == null) {
         if ($this->defaultValue) {
             $value = $this->defaultValue;
         }
     }
     $field .= SPHtml_Input::text($this->nid, $value, $params);
     if ($this->ownLabel) {
         $field = "\n<div class=\"spFieldEmailLabel\">{$fieldTitle}</div><div class=\"spFieldEmail\">{$field}</div>";
     }
     if (!$return) {
         echo $field;
     } else {
         return $field;
     }
 }
Exemple #8
0
 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));
     }
 }
Exemple #9
0
 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;
     }
 }
Exemple #10
0
 /**
  * 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;
     }
 }
Exemple #11
0
 /**
  * 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;
     }
 }
 public function fetchElement($name)
 {
     static $sid = 0;
     $selected = 0;
     $db = SPFactory::db();
     if (!$sid) {
         $sid = 0;
         if ($this->cid) {
             $link = $this->getLink();
             if (strstr($link, 'sid')) {
                 $query = array();
                 parse_str($link, $query);
                 $sid = $query['sid'];
                 if (isset($query['sptpl'])) {
                     $this->tpl = $query['sptpl'];
                 }
             }
             if ($sid) {
                 $section = SPFactory::object($sid);
                 if ($section->oType == 'section') {
                     $selected = $section->id;
                     $this->section = $selected;
                 } else {
                     $path = array();
                     $id = $sid;
                     while ($id > 0) {
                         try {
                             $db->select('pid', 'spdb_relations', array('id' => $id));
                             $id = $db->loadResult();
                             if ($id) {
                                 $path[] = (int) $id;
                             }
                         } catch (SPException $x) {
                         }
                     }
                     $path = array_reverse($path);
                     $selected = $path[0];
                     $this->section = $selected;
                 }
             } else {
                 // just to not repeating
                 $sid = -1;
             }
         }
     }
     $this->sid = $sid;
     $this->determineObjectType($sid);
     switch ($name) {
         case 'sid':
             $params = array('id' => 'sid', 'class' => 'input-mini', 'style' => 'text-align: center; margin-top: 10px; margin-left: 10px;', 'readonly' => 'readonly');
             return '<div class="SobiPro" id="jform_request_sid">' . SPHtml_Input::text('type', $this->oTypeName, array('id' => 'otype', 'class' => 'input-medium', 'style' => 'text-align: center; margin-top: 10px;', 'readonly' => 'readonly')) . SPHtml_Input::text('urlparams[sid]', $sid, $params) . '</div>';
             break;
         case 'cid':
             return $this->getCat();
             break;
         case 'eid':
             return $this->getEntry();
             break;
         case 'did':
         case 'date':
             return $this->getCalendar();
             break;
         case 'tpl':
         case 'sptpl':
             return $this->getTemplates();
             break;
     }
     $sections = array();
     $sout = array();
     try {
         $sections = $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)) {
         SPLoader::loadClass('models.datamodel');
         SPLoader::loadClass('models.dbobject');
         SPLoader::loadModel('section');
         $sout[] = Sobi::Txt('SOBI_SELECT_SECTION');
         foreach ($sections as $section) {
             if (Sobi::Can('section', 'access', 'valid', $section->id)) {
                 $s = new SPSection();
                 $s->extend($section);
                 $sout[$s->get('id')] = $s->get('name');
             }
         }
     }
     $params = array('id' => 'spsection', 'class' => 'required');
     $field = SPHtml_Input::select('sid', $sout, $selected, false, $params);
     return "<div class=\"SobiPro\" style=\"margin-top: 2px;\">{$field}</div>";
 }
Exemple #13
0
 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>';
     }
 }