protected function menu(&$data) { if (Sobi::Cfg('general.top_menu', true)) { $data['menu'] = array('front' => array('_complex' => 1, '_data' => Sobi::Reg('current_section_name'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('sid' => Sobi::Section()))))); if (Sobi::Can('section.search')) { $data['menu']['search'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.SEARCH'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'search', 'sid' => Sobi::Section())))); } if (Sobi::Can('entry', 'add', 'own', Sobi::Section())) { $data['menu']['add'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.ADD_ENTRY'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'entry.add', 'sid' => SPRequest::sid())))); } } }
public function save(&$attr) { parent::save($attr); if ($attr['method'] == 'fixed') { if (!$attr['fixedCid']) { throw new SPException(SPLang::e('FIELD_FIXED_CID_MISSING')); } else { $cids = explode(',', $attr['fixedCid']); if (count($cids)) { foreach ($cids as $cid) { $catId = (int) $cid; if (!$catId) { throw new SPException(SPLang::e('FIELD_FIXED_CID_INVALID', $cid)); } if ($catId == Sobi::Section()) { throw new SPException(SPLang::e('FIELD_FIXED_CID_INVALID', $cid)); } else { $parents = SPFactory::config()->getParentPath($catId); if (!isset($parents[0]) || $parents[0] != Sobi::Section()) { throw new SPException(SPLang::e('FIELD_FIXED_CID_INVALID_SECTION', $catId)); } } } } else { throw new SPException(SPLang::e('FIELD_FIXED_CID_MISSING')); } } } }
private function load($task) { $db =& SPFactory::db(); $adm = defined('SOBIPRO_ADM') ? 'adm.' : null; $cond = array($adm . '*', $adm . $task); if (strstr($task, '.')) { $t = explode('.', $task); $cond[] = $adm . $t[0] . '.*'; $task = $t[0] . '.' . $t[1]; } $this->_actions[$task] = null; try { $pids = $db->select('pid', 'spdb_plugin_task', array('onAction' => $cond))->loadResultArray(); } catch (SPException $x) { Sobi::Error('Plugins', $x->getMessage(), SPC::WARNING, 0, __LINE__, __FILE__); } if (!count($pids)) { $this->_actions[$task] = array(); } // get section depend apps if (Sobi::Section() && count($pids)) { try { $this->_actions[$task] = $db->select('pid', 'spdb_plugin_section', array('section' => Sobi::Section(), 'enabled' => 1, 'pid' => $pids))->loadResultArray(); } catch (SPException $x) { Sobi::Error('Plugins', $x->getMessage(), SPC::WARNING, 0, __LINE__, __FILE__); } } elseif (!(SPRequest::sid() || SPRequest::int('pid'))) { $this->_actions[$task] = $pids; } // here is a special exception for the custom listings // it can be l.alpha or list.alpha or listing.alpha if (preg_match('/^list\\..*/', $task) || preg_match('/^l\\..*/', $task)) { $this->_actions['listing' . '.' . $t[1]] = $pids; } }
private function screen() { $bankData = SPLang::getValue('bankdata', 'application', Sobi::Section()); if (!strlen($bankData)) { SPLang::getValue('bankdata', 'application'); } $tile = Sobi::Txt('APP.BANK_TRANSFER_NAME'); $this->getView('bank_transfer')->assign($tile, 'title')->assign($bankData, 'bankdata')->determineTemplate('extensions', 'bank-transfer')->display(); }
private function nameField() { /* get the field id of the field contains the entry name */ if ($this->section == Sobi::Section() || !$this->section) { $nameField = Sobi::Cfg('entry.name_field'); } else { $nameField = SPFactory::db()->select('sValue', 'spdb_config', array('section' => $this->section, 'sKey' => 'name_field', 'cSection' => 'entry'))->loadResult(); } return $nameField ? $nameField : Sobi::Cfg('entry.name_field'); }
public function save(&$attr) { $data = array('key' => $this->nid . '-viewInfo', 'value' => $attr['viewInfo'], 'type' => 'field_information', 'fid' => $this->fid, 'id' => Sobi::Section(), 'section' => Sobi::Section()); SPLang::saveValues($data); $data = array('key' => $this->nid . '-entryInfo', 'value' => $attr['entryInfo'], 'type' => 'field_information', 'fid' => $this->fid, 'id' => Sobi::Section(), 'section' => Sobi::Section()); SPLang::saveValues($data); $attr['required'] = 0; $attr['fee'] = 0; $attr['isFree'] = 1; parent::save($attr); }
public function execute() { $method = explode('.', $this->_task); $this->nid = 'field_' . $method[0]; $method = 'Proxy' . ucfirst($method[1]); $this->fid = SPFactory::db()->select('fid', 'spdb_field', array('nid' => $this->nid, 'section' => Sobi::Section()))->loadResult(); $this->field = SPFactory::Model('field'); $this->field->init($this->fid); $this->field->{$method}(); return true; }
private function view() { $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $visitor = $this->get('visitor'); $current = $this->get('section'); $categories = $this->get('categories'); $entries = $this->get('entries'); $data = array(); $data['id'] = $current->get('id'); $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false))); $data['name'] = array('_complex' => 1, '_data' => $this->get('listing_name'), '_attributes' => array('lang' => Sobi::Lang(false))); if (Sobi::Cfg('category.show_desc')) { $desc = $current->get('description'); if (Sobi::Cfg('category.parse_desc')) { Sobi::Trigger('prepare', 'Content', array(&$desc, $current)); } $data['description'] = array('_complex' => 1, '_cdata' => 1, '_data' => $desc, '_attributes' => array('lang' => Sobi::Lang(false))); } $data['meta'] = array('description' => $current->get('metaDesc'), 'keys' => $this->metaKeys($current), 'author' => $current->get('metaAuthor'), 'robots' => $current->get('metaRobots')); $data['entries_in_line'] = $this->get('$eInLine'); $data['categories_in_line'] = $this->get('$cInLine'); $this->menu($data); $this->alphaMenu($data); $data['visitor'] = $this->visitorArray($visitor); if (count($categories)) { foreach ($categories as $category) { if (is_numeric($category)) { $category = SPFactory::Category($category); } $data['categories'][] = array('_complex' => 1, '_attributes' => array('id' => $category->get('id'), 'nid' => $category->get('nid')), '_data' => $this->category($category)); unset($category); } } if (count($entries)) { $this->loadNonStaticData($entries); $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false; foreach ($entries as $eid) { $en = $this->entry($eid, $manager); $data['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id']), '_data' => $en); } $this->navigation($data); } $this->_attr = $data; } // general listing trigger Sobi::Trigger('Listing', ucfirst(__FUNCTION__), array(&$this->_attr)); // specific lisitng trigger Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); }
private function screen() { $data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section()); if (!count($data)) { $data = SPFactory::registry()->loadDBSection('paypal')->get('paypal'); } $ppexpl = SPLang::getValue('ppexpl', 'application', Sobi::Section()); $ppsubj = SPLang::getValue('ppsubject', 'application', Sobi::Section()); if (!strlen($ppsubj)) { $ppsubj = SPLang::getValue('ppsubject', 'application'); } $this->getView('paypal')->assign($tile, 'title')->assign($data['ppurl']['value'], 'ppurl')->assign($data['ppemail']['value'], 'ppemail')->assign($data['pprurl']['value'], 'pprurl')->assign($data['ppcc']['value'], 'ppcc')->assign($ppexpl, 'ppexpl')->assign($ppsubj, 'ppsubject')->determineTemplate('extensions', 'paypal')->display(); }
/** * @return array * Ausgabe des Feldes in DV and vCard */ public function struct() { $data = SPLang::getValue($this->nid . '-viewInfo', 'field_information', Sobi::Section()); $attributes = array(); if (strlen($data)) { $this->cssClass = strlen($this->cssClass) ? $this->cssClass : 'spFieldsData'; $this->cssClass = $this->cssClass . ' ' . $this->nid; $this->cleanCss(); $attributes = array('lang' => Sobi::Lang(), 'class' => $this->cssClass); } else { $this->cssClass = strlen($this->cssClass) ? $this->cssClass : 'spField'; } return array('_complex' => 1, '_data' => $data, '_attributes' => $attributes); }
private function browse() { /* create the header */ $list =& $this->get('applications'); $plugins = array(); if (count($list)) { $c = 0; foreach ($list as $plugin) { $plugin['id'] = $plugin['type'] . '.' . $plugin['pid']; $plugins[$c++] = $plugin; } } $this->assign($plugins, 'applications'); $this->assign(Sobi::Section(true), 'section'); }
public function addSection($name, $section) { Sobi::Trigger('addSection', 'SPAdmSiteMenu', array($name, $section)); if ($name == 'AMN.APPS_HEAD' || $name == 'AMN.APPS_SECTION_HEAD') { $p = SPFactory::Controller('extensions', true); $links = $p->appsMenu(); if (is_array($links)) { $section = array_merge($section, $links); } } elseif ($name == 'AMN.APPS_SECTION_TPL' && Sobi::Section() && Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE)) { $p = SPFactory::Controller('template', true); $this->_custom[$name]['after'][] = $p->getTemplateTree(Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE)); } $this->_sections[$name] =& $section; }
/** * @param $attr * @return mixed * @throws SPException */ protected function saveAttr(&$attr) { if ($this->nid) { $this->nid = $attr['nid']; } if (!isset($attr['viewInfo'])) { $attr['viewInfo'] = $this->viewInfo; $attr['entryInfo'] = $this->entryInfo; } $data = array('key' => $this->nid . '-viewInfo', 'value' => $attr['viewInfo'], 'type' => 'field_information', 'fid' => $this->fid, 'id' => Sobi::Section(), 'section' => Sobi::Section()); SPLang::saveValues($data); $data = array('key' => $this->nid . '-entryInfo', 'value' => $attr['entryInfo'], 'type' => 'field_information', 'fid' => $this->fid, 'id' => Sobi::Section(), 'section' => Sobi::Section()); SPLang::saveValues($data); $attr['required'] = 0; $attr['fee'] = 0; $attr['isFree'] = 1; return $attr; }
/** * This function have to add own string into the given array * Basically: $methods[ $this->id ] = "Some String To Output"; * Optionally the value can be also SobiPro Arr2XML array. * Check the documentation for more information * @param array $methods * @param SPEntry $entry * @param array $payment * @param bool $message * @return void */ public function PaymentMethodView(&$methods, $entry, &$payment, $message = false) { $data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section()); if (!count($data)) { $data = SPFactory::registry()->loadDBSection('paypal')->get('paypal'); } $cfg = SPLoader::loadIniFile('etc.paypal'); $rp = $cfg['general']['replace']; $to = $cfg['general']['replace'] == ',' ? '.' : ','; $amount = str_replace($rp, $to, $payment['summary']['sum_brutto']); $values = array('entry' => $entry, 'amount' => preg_replace('/[^0-9\\.,]/', null, $amount), 'ppurl' => SPLang::replacePlaceHolders($data['ppurl']['value'], $entry), 'ppemail' => SPLang::replacePlaceHolders($data['ppemail']['value'], $entry), 'pprurl' => SPLang::replacePlaceHolders($data['pprurl']['value'], $entry), 'ppcc' => SPLang::replacePlaceHolders($data['ppcc']['value'], $entry)); $expl = SPLang::replacePlaceHolders(SPLang::getValue('ppexpl', 'plugin', Sobi::Section()), $values); $subject = SPLang::replacePlaceHolders(SPLang::getValue('ppsubject', 'plugin', Sobi::Section()), $values); $values['expl'] = $expl; $values['subject'] = $subject; $values['ip'] = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER'); $methods[$this->id] = array('content' => $message ? $this->raw($cfg, $values) : $this->content($cfg, $values), 'title' => Sobi::Txt('APP.PPP.PAY_TITLE')); }
private function editFile() { if (Sobi::Section() && Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE) { SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage(); } $file = SPRequest::cmd('file'); $file = $this->file($file); $ext = SPFs::getExt($file); $fileContent = SPFs::read($file); $path = str_replace('\\', '/', SOBI_PATH); if (strstr($file, $path)) { $filename = str_replace($path . '/usr/templates/', null, $file); } else { $filename = str_replace(SOBI_ROOT, null, $file); } $menu = $this->createMenu(); if (Sobi::Section()) { $menu->setOpen('AMN.APPS_SECTION_TPL'); } else { $menu->setOpen('GB.CFG.GLOBAL_TEMPLATES'); } /** @var $view SPAdmTemplateView */ $view = SPFactory::View('template', true)->assign($fileContent, 'file_content')->assign($filename, 'file_name')->assign($ext, 'file_ext')->assign($menu, 'menu')->assign($this->_task, 'task')->assign(Sobi::Section(), 'sid')->addHidden(SPRequest::cmd('file'), 'fileName')->addHidden($filename, 'filePath')->determineTemplate('template', 'edit'); Sobi::Trigger('Edit', $this->name(), array(&$file, &$view)); $view->display(); }
/** * @param $message * @param $type - * @param $section string * @return SPMessage */ public function &setSilentSystemMessage($message, $type = SPC::NOTICE_MSG, $section = 'configuration') { $this->current = array('message' => $message, 'type' => $type, 'section' => array('id' => Sobi::Section(), 'name' => Sobi::Section(true))); $this->current['issue-type'] = $section; $this->store[md5(serialize($this->current))] = $this->current; if (count($this->store)) { $messages = SPConfig::serialize($this->store); $store = array('params' => $messages, 'key' => 'queue', 'value' => date(DATE_RFC822), 'description' => null, 'options' => null); SPFactory::registry()->saveDBSection(array('messages' => $store), 'messages'); SPFactory::cache()->cleanSection(-1, false); } return $this; }
/** * Creates ajax file field * * @param string $name - name of the html field * @param string $accept - accepted file types * @param string $value - possible value for the inbox * @param string $class - class name * @param string $task - task override * @param array $scripts - custom JavaScript files * @param array $request - custom request * @return string */ public static function fileUpload($name, $accept = '*', $value = null, $class = 'spFileUpload', $task = 'file.upload', $scripts = array('jquery', 'jquery-form', 'fileupload'), $request = null) { if (is_string($scripts)) { $scripts = SPFactory::config()->structuralData($scripts); } SPFactory::header()->addJsFile($scripts); if (!$request) { $request = array('option' => 'com_sobipro', 'task' => $task, 'sid' => Sobi::Section(), 'ident' => $name . '-file', SPFactory::mainframe()->token() => 1, 'format' => 'raw'); } $classes = array('class' => 'hide spFileUploadHidden'); SPLoader::loadClass('env.browser'); $browser = SPBrowser::getInstance()->get('browser'); $stupidInternetExplorer = false; if (strstr(strtolower($browser), 'internet explorer')) { $classes = array('class' => ''); $stupidInternetExplorer = true; } $f = null; $f .= "<div class=\"{$class}\" data-section=" . Sobi::Section() . ">"; $f .= '<div class="file">'; $f .= self::file($name . '-file', 0, $classes, $accept); $f .= '</div>'; if (!$stupidInternetExplorer) { $f .= "<input type=\"text\" readonly=\"readonly\" class=\"input-large selected pull-left\" value=\"{$value}\"/>"; } $f .= '<div class="btn-group">'; if (!$stupidInternetExplorer) { $f .= '<button class="btn select" type="button"><i class="icon-eye-open"></i> ' . Sobi::Txt('UPLOAD_SELECT') . '</button>'; } $f .= '<button class="btn upload hide" disabled="disabled" type="button" rel=\'' . json_encode($request) . '\'>' . Sobi::Txt('START_UPLOAD') . ' <i class="icon-upload-alt"></i></button>'; $f .= '<button class="btn remove" disabled="disabled" type="button">' . ' <i class="icon-remove"></i></button>'; $f .= '</div>'; $f .= '<div class="hide progress-container row">'; $f .= '<div class="span1">'; $f .= '<span class="progress-message badge badge-success">0%</span>'; $f .= '</div>'; $f .= '<div class="progress progress-success span6"><div class="bar"></div></div>'; $f .= '</div>'; $f .= '<div class="alert hide"><button type="button" class="close" data-dismiss="alert">×</button><div> </div></div>'; $f .= "<input type=\"hidden\" name=\"{$name}\" value=\"\" class='idStore'/>"; $f .= '</div>'; return $f; }
/** * @param array $head * @return bool */ public function addHead($head) { if (strlen(SPRequest::cmd('format')) && SPRequest::cmd('format') != 'html') { return true; } /** @var JDocument $document */ $document = JFactory::getDocument(); $c = 0; if (count($head)) { $document->addCustomTag("\n\t<!-- SobiPro Head Tags Output -->\n"); $document->addCustomTag("\n\t<script type=\"text/javascript\">/*\n<![CDATA[*/ \n\tvar SobiProUrl = '" . Sobi::FixPath(self::Url(array('task' => '%task%'), true, false, true)) . "'; \n\tvar SobiProSection = " . (Sobi::Section() ? Sobi::Section() : 0) . "; \n\tvar SPLiveSite = '" . Sobi::Cfg('live_site') . "'; \n/*]]>*/\n</script>\n"); if (defined('SOBI_ADM_PATH')) { $document->addCustomTag("\n\t<script type=\"text/javascript\">/* <![CDATA[ */ \n\tvar SobiProAdmUrl = '" . Sobi::FixPath(Sobi::Cfg('live_site') . SOBI_ADM_FOLDER . '/' . self::Url(array('task' => '%task%'), true, false)) . "'; \n/* ]]> */</script>\n"); } foreach ($head as $type => $code) { switch ($type) { default: if (count($code)) { foreach ($code as $html) { ++$c; $document->addCustomTag($html); } } break; case 'robots': case 'author': $document->setMetaData($type, implode(', ', $code)); // $document->setHeadData( array( $type => implode( ', ', $code ) ) ); break; case 'keywords': $metaKeys = trim(implode(', ', $code)); if (Sobi::Cfg('meta.keys_append', true)) { $metaKeys .= Sobi::Cfg('string.meta_keys_separator', ',') . $document->getMetaData('keywords'); } $metaKeys = explode(Sobi::Cfg('string.meta_keys_separator', ','), $metaKeys); if (count($metaKeys)) { $metaKeys = array_unique($metaKeys); foreach ($metaKeys as $i => $p) { if (strlen(trim($p))) { $metaKeys[$i] = trim($p); } else { unset($metaKeys[$i]); } } $metaKeys = implode(', ', $metaKeys); } else { $metaKeys = null; } $document->setMetadata('keywords', $metaKeys); break; case 'description': $metaDesc = implode(Sobi::Cfg('string.meta_desc_separator', ' '), $code); if (strlen($metaDesc)) { if (Sobi::Cfg('meta.desc_append', true)) { $metaDesc .= $this->getMetaDescription($document); } $metaDesc = explode(' ', $metaDesc); if (count($metaDesc)) { foreach ($metaDesc as $i => $p) { if (strlen(trim($p))) { $metaDesc[$i] = trim($p); } else { unset($metaDesc[$i]); } } $metaDesc = implode(' ', $metaDesc); } else { $metaDesc = null; } $document->setDescription($metaDesc); } break; } } $jsUrl = Sobi::FixPath(self::Url(array('task' => 'txt.js', 'format' => 'json'), true, false, false)); $document->addCustomTag("\n\t<script type=\"text/javascript\" src=\"" . str_replace('&', '&', $jsUrl) . "\"></script>\n"); $c++; $document->addCustomTag("\n\t<!-- SobiPro ({$c}) Head Tags Output -->\n"); // we would like to set our own canonical please :P // https://groups.google.com/forum/?fromgroups=#!topic/joomla-dev-cms/sF3-JBQspQU if (count($document->_links)) { foreach ($document->_links as $index => $link) { if ($link['relation'] == 'canonical') { unset($document->_links[$index]); } } } } }
/** * 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; } $hidden = null; $d = $this->getValues(false); $data = array('' => Sobi::Txt('FD.SEARCH_SELECT_LIST', array('name' => $this->name))); foreach ($d as $k => $v) { $data[$k] = $v; } $params = array('id' => $this->nid, 'size' => $this->ssize, 'class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect')); //still there for compatibility reason if ($this->swidth) { $params['style'] = "width: {$this->swidth}px;"; } if ($this->dependency) { SPFactory::header()->addJsFile('opt.field_select'); $request = json_decode(SPLang::clean(SPRequest::raw($this->nid . '_path', null, 'requestcache')), true); $params['class'] .= ' ctrl-dependency-field'; $hidden = $this->travelDependencyPath($request, $params); $this->_selected = isset($request[1]) ? $request[1] : null; $hiddenValue = str_replace('"', "'", json_encode((object) $request)); $hidden .= SPHtml_Input::hidden($this->nid . '_path', $hiddenValue, null, array('data' => array('selected' => '', 'section' => Sobi::Section()))); $params['data'] = array('order' => '1'); } return SPHtml_Input::select($this->nid, $data, $this->_selected, $this->searchMethod == 'mselect', $params) . $hidden; }
/** * (non-PHPdoc) * @see Site/lib/models/SPDBObject#save() */ public function save($request = 'post') { $this->loadFields(Sobi::Section(), true); // Thu, Feb 19, 2015 12:12:47 - it should be actually "beforeSave" Sobi::Trigger($this->name(), 'Before' . ucfirst(__FUNCTION__), array($this->id)); /* save the base object data */ /* @var SPdb $db */ $db = SPFactory::db(); $db->transaction(); if (!$this->nid || SPRequest::task() == 'entry.clone') { $this->nid = SPRequest::string($this->nameField, null, false, $request); $this->nid = $this->createAlias(); $this->name = $this->nid; } if (Sobi::Cfg('entry.publish_limit', 0) && !defined('SOBI_ADM_PATH')) { SPRequest::set('entry_createdTime', 0, $request); SPRequest::set('entry_validSince', 0, $request); SPRequest::set('entry_validUntil', 0, $request); $this->validUntil = gmdate('Y-m-d H:i:s', time() + Sobi::Cfg('entry.publish_limit', 0) * 24 * 3600); } $preState = Sobi::Reg('object_previous_state'); parent::save($request); $nameField = $this->nameField(); /* get the fields for this section */ foreach ($this->fields as $field) { /* @var $field SPField */ try { if ($field->enabled('form', $preState['new'])) { $field->saveData($this, $request); } else { $field->finaliseSave($this, $request); } if ($field->get('id') == $nameField) { /* get the entry name */ $this->name = $field->getRaw(); /* save the nid (name id) of the field where the entry name is saved */ $this->nameField = $field->get('nid'); } } catch (SPException $x) { if (SPRequest::task() != 'entry.clone') { $db->rollback(); throw new SPException(SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage())); } else { Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } } } $values = array(); /* get categories */ $cats = Sobi::Reg('request_categories'); if (!count($cats)) { $cats = SPRequest::arr('entry_parent', SPFactory::registry()->get('request_categories', array()), $request); } /* by default it should be comma separated string */ if (!count($cats)) { $cats = SPRequest::string('entry_parent', null, $request); if (strlen($cats) && strpos($cats, ',')) { $cats = explode(',', $cats); foreach ($cats as $i => $cat) { $c = (int) trim($cat); if ($c) { $cats[$i] = $c; } else { unset($cats[$i]); } } } elseif (strlen($cats)) { $cats = array((int) $cats); } } if (is_array($cats) && count($cats)) { foreach ($cats as $i => $v) { if (!$v) { unset($cats[$i]); } } } if (is_array($cats) && count($cats)) { /* get the ordering in these categories */ try { $db->select('pid, MAX(position)', 'spdb_relations', array('pid' => $cats, 'oType' => 'entry'), null, 0, 0, false, 'pid'); $cPos = $db->loadAssocList('pid'); $currPos = $db->select(array('pid', 'position'), 'spdb_relations', array('id' => $this->id, 'oType' => 'entry'))->loadAssocList('pid'); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } /* set the right position */ foreach ($cats as $i => $cat) { $copy = 0; if (!$this->approved) { $copy = isset($this->categories[$cats[$i]]) ? 0 : 1; } else { $db->delete('spdb_relations', array('id' => $this->id, 'oType' => 'entry')); } if (isset($currPos[$cat])) { $pos = $currPos[$cat]['position']; } else { $pos = isset($cPos[$cat]) ? $cPos[$cat]['MAX(position)'] : 0; $pos++; } $values[] = array('id' => $this->id, 'pid' => $cats[$i], 'oType' => 'entry', 'position' => $pos, 'validSince' => $this->validSince, 'validUntil' => $this->validUntil, 'copy' => $copy); } try { $db->insertArray('spdb_relations', $values, true); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } } elseif (!count($this->categories)) { throw new SPException(SPLang::e('MISSING_CAT')); } /* trigger possible state changes */ if ($preState['approved'] != $this->approved) { if ($this->approved) { $this->approveFields(true); // it's being done by the method above - removing //Sobi::Trigger( $this->name(), 'AfterApprove', array( $this->id, $this->approved ) ); } } if ($preState['state'] != $this->state) { Sobi::Trigger($this->name(), 'AfterChangeState', array($this->id, $this->state)); } SPFactory::cache()->purgeSectionVars(); SPFactory::cache()->deleteObj('entry', $this->id); if (count($cats)) { foreach ($cats as $cat) { SPFactory::cache()->deleteObj('category', $cat); } } Sobi::Trigger($this->name(), 'After' . ucfirst($preState['new'] ? __FUNCTION__ : 'Update'), array(&$this)); }
protected function view() { /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); Sobi::ReturnPoint(); $this->_task = 'user'; if (!$this->_model) { $this->setModel('section'); $this->_model->init(Sobi::Section()); } $this->visible(); /* load template config */ $this->template(); $this->tplCfg($tplPackage); /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2)); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2)); $url = array('sid' => SPRequest::sid(), 'task' => 'list.user'); if (SPRequest::int('uid')) { $url['uid'] = SPRequest::int('uid'); $this->uid = (int) SPRequest::int('uid'); } else { $this->uid = (int) Sobi::My('id'); } $this->user = SPJoomlaUser::getBaseData((int) $this->uid); if (!$this->user) { throw new SPException(SPLang::e('UNAUTHORIZED_ACCESS')); } /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; $eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc'))); $eCount = count($this->getEntries($eOrder, 0, 0, true, array('spo.owner' => $this->uid), true, Sobi::Section())); $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, array('spo.owner' => $this->uid), true, Sobi::Section()); // $eCount = count( $this->_getEntries( 0, 0, true ) ); // $entries = $this->_getEntries( $eLimit, $site ); $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, $url); if (SPRequest::int('site', 0)) { $url['site'] = SPRequest::int('site', 0); } SPFactory::header()->addCanonical(Sobi::Url($url, true, true, true)); /* handle meta data */ SPFactory::header()->objMeta($this->_model); SPFactory::mainframe()->addToPathway(Sobi::Txt('UL.PATH_TITLE', array('username' => $this->user->username, 'user' => $this->user->name)), Sobi::Url('current')); SPFactory::header()->addTitle(Sobi::Txt('UL.TITLE', array('username' => $this->user->username, 'user' => $this->user->name, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site)); /* add pathway */ /* get view class */ $view = SPFactory::View('listing'); $view->assign($eLimit, '$eLimit'); $view->assign($eLimStart, '$eLimStart'); $view->assign($eCount, '$eCount'); $view->assign($eInLine, '$eInLine'); $view->assign($this->_task, 'task'); $view->assign($this->_model, 'section'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template); $view->assign($pn->get(), 'navigation'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($entries, 'entries'); Sobi::Trigger('UserListing', 'View', array(&$view)); $view->display(); }
/** * @param array $head * @return bool */ public function addHead($head) { if (strlen(SPRequest::cmd('format')) && SPRequest::cmd('format') != 'html') { return true; } $document = JFactory::getDocument(); $c = 0; if (count($head)) { $document->addCustomTag("\n\t<!-- SobiPro Head Tags Output -->\n"); $document->addCustomTag("\n\t<script type=\"text/javascript\">/*\n<![CDATA[*/ \n\tvar SobiProUrl = '" . Sobi::FixPath(self::Url(array('task' => '%task%'), true, false, true)) . "'; \n\tvar SobiProSection = " . (Sobi::Section() ? Sobi::Section() : 0) . "; \n\tvar SPLiveSite = '" . Sobi::Cfg('live_site') . "'; \n/*]]>*/\n</script>\n"); if (defined('SOBI_ADM_PATH')) { $document->addCustomTag("\n\t<script type=\"text/javascript\">/* <![CDATA[ */ \n\tvar SobiProAdmUrl = '" . Sobi::FixPath(Sobi::Cfg('live_site') . SOBI_ADM_FOLDER . '/' . self::Url(array('task' => '%task%'), true, false)) . "'; \n/* ]]> */</script>\n"); } foreach ($head as $type => $code) { switch ($type) { default: if (count($code)) { foreach ($code as $html) { ++$c; $document->addCustomTag($html); } } break; case 'robots': case 'author': if (!defined('SOBI_ADM_PATH')) { $document->setMetadata($type, implode(', ', $code)); } break; case 'keywords': if (!defined('SOBI_ADM_PATH')) { $metaKeys = trim(implode(', ', $code)); if (Sobi::Cfg('meta.keys_append', true)) { $metaKeys .= Sobi::Cfg('string.meta_keys_separator', ',') . $document->getMetaData('keywords'); } $metaKeys = explode(Sobi::Cfg('string.meta_keys_separator', ','), $metaKeys); if (count($metaKeys)) { foreach ($metaKeys as $i => $p) { if (strlen(trim($p))) { $metaKeys[$i] = trim($p); } else { unset($metaKeys[$i]); } } $metaKeys = implode(', ', $metaKeys); } else { $metaKeys = null; } $document->setMetadata('keywords', $metaKeys); } break; case 'description': $metaDesc = implode(Sobi::Cfg('string.meta_desc_separator', ' '), $code); if (strlen($metaDesc) && !defined('SOBI_ADM_PATH')) { if (Sobi::Cfg('meta.desc_append', true)) { $metaDesc .= ' ' . $document->get('description'); } $metaDesc = explode(' ', $metaDesc); if (count($metaDesc)) { foreach ($metaDesc as $i => $p) { if (strlen(trim($p))) { $metaDesc[$i] = trim($p); } else { unset($metaDesc[$i]); } } $metaDesc = implode(' ', $metaDesc); } else { $metaDesc = null; } $document->setDescription($metaDesc); } break; } } $jsUrl = Sobi::FixPath(Sobi::Cfg('live_site') . (defined('SOBI_ADM_FOLDER') ? SOBI_ADM_FOLDER . '/' : '') . self::Url(array('task' => 'txt.js', 'format' => 'json'), true, false)); $document->addCustomTag("\n\t<script type=\"text/javascript\" src=\"" . str_replace('&', '&', $jsUrl) . "\"></script>\n"); $c++; $document->addCustomTag("\n\t<!-- SobiPro ({$c}) Head Tags Output -->\n"); } }
/** * Factory method for entries models * @param id of the entry $sid * @return SPEntry */ public static function &Entry($sid) { $cached = SPFactory::cache(Sobi::Section())->getObj('entry', $sid); if ($cached && is_object($cached)) { $cached->validateCache(); return $cached; } else { $entry = self::Model('entry'); $entry->init($sid); return $entry; } }
/** * Save the config */ protected function save($apply, $clone = false) { $sid = Sobi::Section(); $this->authorise($sid); if ($sid) { $this->validate('config.general', array('task' => 'config.general', 'sid' => $sid)); } else { $this->validate('config.global', array('task' => 'config.global')); } $fields = array(); $section = false; $data = SPRequest::arr('spcfg', array()); // strange thing =8-O if (!isset($data['alphamenu.extra_fields_array'])) { $data['alphamenu.extra_fields_array'] = array(); } if (!isset($data['template.icon_fonts_arr'])) { $data['template.icon_fonts_arr'] = array(); } foreach ($data as $k => $v) { if (is_string($v)) { $v = htmlspecialchars_decode($v); } // $k = str_replace( array( 'spcfg_', '.' ), array( null, '_' ), $k ); $k = str_replace('spcfg_', null, $k); $s = explode('.', $k); $s = $s[0]; if (!isset($fields[$s])) { $fields[$s] = array(); } $k = str_replace("{$s}.", null, $k); $c = explode('_', $k); if ($c[count($c) - 1] == 'array' && !is_array($v)) { if (!strstr($v, '|')) { $v = explode(',', $v); } else { $v = explode('|', $v); } } $fields[$s][$k] = $v; if (preg_match('/^section.*/', $k)) { $section = true; } } $values = array(); if (count($fields)) { foreach ($fields as $sec => $keys) { if (count($keys)) { foreach ($keys as $k => $v) { $values[] = array('sKey' => $k, 'sValue' => $v, 'section' => Sobi::Section(), 'critical' => 0, 'cSection' => $sec); } } } } if ($section) { /* @var $sec SPSection */ $sec = SPFactory::Model('section'); $sec->init(SPRequest::sid()); $sec->getRequest('section'); $sec->save(true); } Sobi::Trigger('SaveConfig', $this->name(), array(&$values)); try { SPFactory::db()->insertArray('spdb_config', $values, true); } catch (SPException $x) { $this->response(Sobi::Back(), $x->getMessage(), false, SPC::ERROR_MSG); } if (!($section && !Sobi::Section())) { SPFactory::cache()->cleanAll(); } else { SPFactory::cache()->cleanSection(); } Sobi::Trigger('After', 'SaveConfig', array(&$values)); $this->response(Sobi::Back(), Sobi::Txt('MSG.CONFIG_SAVED'), false, 'success'); }
/** * Parse text and replaces placeholders * @param string $text * @param SPDBObject $obj * @param bool $html * @param bool $dropEmpty * @return string */ public static function replacePlaceHolders($text, $obj = null, $html = false, $dropEmpty = false) { preg_match_all('/{([a-zA-Z0-9\\-_\\:\\.\\%\\s]+)}/', $text, $placeHolders); if (count($placeHolders[1])) { foreach ($placeHolders[1] as $placeHolder) { $replacement = null; switch ($placeHolder) { case 'section': case 'section.id': case 'section.name': $replacement = Sobi::Section($placeHolder == 'section' || $placeHolder == 'section.name'); break; /* * eat own dog food is so true. Isn't it?! */ /* * eat own dog food is so true. Isn't it?! */ case 'token': $replacement = SPFactory::mainframe()->token(); break; default: if (strstr($placeHolder, 'date%')) { $date = explode('%', $placeHolder); $replacement = date($date[1]); break; } if (strstr($placeHolder, 'cfg:')) { $replacement = Sobi::Cfg(str_replace('cfg:', null, $placeHolder)); break; } else { if (strstr($placeHolder, 'messages')) { $obj = SPFactory::registry()->get('messages'); } $replacement = self::parseVal($placeHolder, $obj, $html); } } if ($replacement && (is_string($replacement) || is_numeric($replacement))) { $text = str_replace('{' . $placeHolder . '}', (string) $replacement, $text); } elseif ($dropEmpty) { $text = str_replace('{' . $placeHolder . '}', null, $text); } } } return $text; }
protected function view() { /* determine template package */ $tplPckg = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); Sobi::ReturnPoint(); $this->_task = 'alpha'; if (!$this->_model) { $this->setModel('section'); $this->_model->init(Sobi::Section()); } $this->visible(); /* load template config */ $this->template(); $this->tplCfg($tplPckg); /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2)); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2)); /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; $eCount = count($this->getEntries(0, 0, true)); $entries = $this->getEntries($eLimit, $site); $compare = $this->_field ? $this->_field : $this->_nid; if (strlen($compare) && $compare != Sobi::Cfg('alphamenu.primary_field')) { $t = 'list.alpha.' . strtolower($this->_letter) . '.' . $this->_nid; } else { $t = 'list.alpha.' . strtolower($this->_letter); } $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'task' => $t)); $cUrl = array('sid' => SPRequest::sid(), 'task' => $t); if (SPRequest::int('site', 0)) { $cUrl['site'] = SPRequest::int('site', 0); } SPFactory::header()->addCanonical(Sobi::Url($cUrl, true, true, true)); /* handle meta data */ SPFactory::header()->objMeta($this->_model); $letter = urldecode(SPRequest::cmd('letter')); /* add pathway */ if (!$this->_fieldType) { SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE', array('letter' => $letter)), Sobi::Url('current')); SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE', array('letter' => $letter, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site)); } else { $field = SPFactory::Model('field'); $field->init($this->_field); SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE_FIELD', array('letter' => $letter, 'field' => $field->get('name'))), Sobi::Url('current')); SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE_FIELD', array('letter' => $letter, 'section' => $this->_model->get('name'), 'field' => $field->get('name'))), array(ceil($eCount / $eLimit), $site)); } /* get view class */ $view = SPFactory::View('listing'); $view->assign($eLimit, '$eLimit'); $view->assign($eLimStart, '$eLimStart'); $view->assign($eCount, '$eCount'); $view->assign($eInLine, '$eInLine'); $view->assign($this->_task, 'task'); $view->assign($this->_model, 'section'); $view->assign(Sobi::Txt('AL.PATH_TITLE', array('letter' => $this->_letter)), 'listing_name'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPckg . '.' . $this->templateType . '.' . $this->template); $view->assign($pn->get(), 'navigation'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($entries, 'entries'); Sobi::Trigger('AlphaListing', 'View', array(&$view)); $view->display(); }
public function getContentPermalink() { // $sid = SPRequest::sid(); $sid = $this->getContentId(); // $pid = SPRequest::int( 'pid' ) ? SPRequest::int( 'pid' ) : Sobi::Section(); $pid = JRequest::getInt('pid') ? JRequest::getInt('pid') : Sobi::Section(); $link = Sobi::Url(array('pid' => $pid, 'sid' => $sid, 'title' => $this->_item->title)); $link = $this->prepareLink($link); // end untested codes return $link; }
protected function entryData($getFields = true) { /** @var SPEntry $entry */ $entry = $this->get('entry'); $visitor = $this->get('visitor'); $data = array(); $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false))); $en = array(); $en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false))); $en['created_time'] = $entry->get('createdTime'); $en['updated_time'] = $entry->get('updatedTime'); $en['valid_since'] = $entry->get('validSince'); $en['valid_until'] = $entry->get('validUntil'); $en['author'] = $entry->get('owner'); $en['counter'] = $entry->get('counter'); $en['approved'] = $entry->get('approved'); $this->fixTimes($en); // $mytime = date( 'Y-m-d H:i:s', time()); if ($entry->get('state') == 0) { $en['state'] = 'unpublished'; } else { if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) { $en['state'] = 'expired'; } elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) { $en['state'] = 'pending'; } else { $en['state'] = 'published'; } } $en['url'] = Sobi::Url(array('pid' => $entry->get('parent'), 'sid' => $entry->get('id'), 'title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name')), true, true, true); if (Sobi::Can('entry', 'edit', '*') || Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own')) { $en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'sid' => $entry->get('id'))); } if (Sobi::Can('entry', 'manage', '*')) { $en['approve_url'] = Sobi::Url(array('task' => $entry->get('approved') ? 'entry.unapprove' : 'entry.approve', 'sid' => $entry->get('id'))); } if ($entry->get('owner') == Sobi::My('id') && Sobi::Can('entry', 'delete', 'own') || Sobi::Can('entry', 'delete', '*')) { $en['delete_url'] = Sobi::Url(array('task' => 'entry.delete', 'sid' => $entry->get('id'))); } if (Sobi::Can('entry', 'publish', '*') || Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'publish', 'own')) { $en['publish_url'] = Sobi::Url(array('task' => $entry->get('state') ? 'entry.unpublish' : 'entry.publish', 'sid' => $entry->get('id'))); } $cats = $entry->get('categories'); $categories = array(); if (count($cats)) { $cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'), 'category'); } $primaryCat = $entry->get('parent'); foreach ($cats as $cid => $cat) { $cAttr = array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'alias' => $cat['alias'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name']))); if ($cat['pid'] == $primaryCat) { $cAttr['primary'] = 'true'; } $categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => $cAttr); } $en['categories'] = $categories; $en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots')); if ($getFields) { $fields = $entry->getFields(); if (count($fields)) { $en['fields'] = $this->fieldStruct($fields, 'details'); } } $this->menu($data); $this->alphaMenu($data); $data['entry'] = array('_complex' => 1, '_data' => $en, '_attributes' => array('id' => $entry->get('id'), 'nid' => $entry->get('nid'), 'version' => $entry->get('version'))); $data['visitor'] = $this->visitorArray($visitor); return $data; }
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); }
/** * @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; } }