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 progress($percent, $message = null, $type = SPC::INFO_MSG, $interval = 1000) { $this->id = SPRequest::cmd('ProgressMsg', null, 'cookie'); $percent = ceil($percent); $this->msg = strlen($message) ? $message : $this->msg; $this->status($message, $percent, $interval, $type); }
/** * Simple initialisation method * */ public function init() { if (self::$cs) { Sobi::Error('config', SPLang::e('CRITICAL_SECTION_VIOLATED'), SPC::ERROR, 500, __LINE__, __CLASS__); } /* define critical section to avoid infinite loops */ self::$cs = true; $nameField = self::key('entry.name_field'); if ($nameField) { $fc = SPLoader::loadModel('field'); $field = new $fc(); $field->init($nameField); $this->set('name_field_nid', $field->get('nid'), 'entry'); $this->set('name_field_id', $field->get('fid'), 'entry'); } if (defined('SOBIPRO_ADM')) { if (self::key('language.adm_domain')) { SPLang::registerDomain(self::key('language.adm_domain')); } } else { if (self::key('language.domain')) { SPLang::registerDomain(self::key('language.domain')); } } /* set allowed request attributes and tags */ SPRequest::setTagsAllowed($this->key('html.allowed_tags_array')); SPRequest::setAttributesAllowed($this->key('html.allowed_attributes_array')); $this->_store['general']['root'] = SOBI_ROOT; $this->_store['general']['path'] = SOBI_PATH; $this->_store['general']['cms'] = SOBI_CMS; $this->_store['general']['live_path'] = SOBI_LIVE_PATH; /* leave critical section */ self::$cs = false; }
protected function upload() { $ident = SPRequest::cmd('ident', null, 'post'); $data = SPRequest::file($ident, 'tmp_name'); $secret = md5(Sobi::Cfg('secret')); if ($data) { $properties = SPRequest::file($ident); $fileName = md5(SPRequest::file($ident, 'name') . time() . $secret); $path = SPLoader::dirPath("tmp.files.{$secret}", 'front', false) . '/' . $fileName; /** @var $file SPFile */ $file = SPFactory::Instance('base.fs.file'); if (!$file->upload($data, $path)) { $this->message(array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE'), 'id' => '')); } $path = $file->getPathname(); $type = $this->check($path); $properties['tmp_name'] = $path; SPFs::write($path . '.var', SPConfig::serialize($properties)); $response = array('type' => 'success', 'text' => Sobi::Txt('FILE_UPLOADED', $properties['name'], $type), 'id' => 'file://' . $fileName, 'data' => array('name' => $properties['name'], 'type' => $properties['type'], 'size' => $properties['size'])); } else { $response = array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE_NO_DATA'), 'id' => ''); } // $field = SPRequest::cmd( 'field', null ); $this->message($response); }
public function install() { $id = $this->xGetString('id'); $name = $this->xGetString('name'); if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) { throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile))))); } $requirements = $this->xGetChilds('requirements/*'); if ($requirements && $requirements instanceof DOMNodeList) { SPFactory::Instance('services.installers.requirements')->check($requirements); } $language = $this->xGetChilds('language/file'); $folder = @$this->xGetChilds('language/@folder')->item(0)->nodeValue; if ($language && $language instanceof DOMNodeList && $language->length) { $langFiles = array(); foreach ($language as $file) { $adm = false; if ($file->attributes->getNamedItem('admin')) { $adm = $file->attributes->getNamedItem('admin')->nodeValue == 'true' ? true : false; } $langFiles[$file->attributes->getNamedItem('lang')->nodeValue][] = array('path' => Sobi::FixPath("{$this->root}/{$folder}/" . trim($file->nodeValue)), 'name' => $file->nodeValue, 'adm' => $adm); } SPFactory::CmsHelper()->installLang($langFiles, false, true); } $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false); if (SPRequest::bool('force')) { /** @var $from SPDirectory */ $from = SPFactory::Instance('base.fs.directory', $this->root); $from->moveFiles($path); } else { if (!SPFs::move($this->root, $path)) { throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path)); } } if (!SPRequest::bool('force')) { $section = $this->xGetChilds('install'); if ($section instanceof DOMNodeList && $section->length) { $this->section($id); } } //05 Oct 2015 Kishore $exec = $this->xGetString('exec'); if ($exec && SPFs::exists($path . DS . $exec)) { include_once "{$path}/{$exec}"; } /** @var $dir SPDirectory */ $dir =& SPFactory::Instance('base.fs.directory', $path); $zip = array_keys($dir->searchFile('.zip', false)); if (count($zip)) { foreach ($zip as $file) { SPFs::delete($file); } } Sobi::Trigger('After', 'InstallTemplate', array($id)); $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install')); $dir->deleteFiles(); return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name)); }
/** */ private function edit() { $id = $this->get('entry.id'); if ($id) { $this->addHidden($id, 'entry.id'); } $sid = SPRequest::int('pid') ? SPRequest::int('pid') : SPRequest::sid(); $this->assign(Sobi::Url(array('task' => 'category.chooser', 'sid' => $sid, 'out' => 'html', 'multiple' => 1), true), 'cat_chooser_url'); }
/** * @param string The control name * @param string The contents of the text area * @param string The width of the text area (px or %) * @param string The height of the text area (px or %) * @param boolean True and the editor buttons will be displayed * @param array Associative array of editor parameters * @return string */ public function display($name, $html, $width, $height, $buttons, $params) { if (SPRequest::cmd('format') != 'raw') { // public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array()) $editor = JEditor::getInstance(JFactory::getConfig()->get('editor')); // JFactory::getEditor()->display( $name, $html, $width, $height, '75', '20', $buttons, $params ); return $editor->display($name, $html, $width, $height, 75, 20, $buttons, null, null, null, $params); } }
/** * @param string $title * @return string|void */ public function setTitle($title) { if (strstr(SPRequest::task(), '.add')) { $title = str_replace('EDIT', 'ADD', $title); } $title = Sobi::Txt($title, array('field' => $this->get('field.name'), 'field_type' => $this->get('field.fieldType'))); Sobi::Trigger('setTitle', $this->name(), array(&$title)); SPFactory::header()->setTitle($title); $this->set($title, 'site_title'); }
protected function search() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } // $selected = SPRequest::int( 'selected', 0 ); $ssid = SPRequest::base64('ssid'); $query = SPRequest::string('q', null); $session = SPFactory::user()->getUserState('userSelector', null, array()); $setting = $session[$ssid]; /* get the site to display */ $site = SPRequest::int('site', 1); $eLim = Sobi::Cfg('user_selector.entries_limit', 18); $eLimStart = ($site - 1) * $eLim; $params = array(); if ($query) { $q = '%' . $query . '%'; $params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR'); } try { $count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult(); $data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList(); } catch (SPException $x) { echo $x->getMessage(); exit; } $response = array('sites' => ceil($count / $eLim), 'site' => $site); if (count($data)) { $replacements = array(); preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements); $placeholders = array(); if (isset($replacements[0]) && count($replacements[0])) { foreach ($replacements[0] as $placeholder) { $placeholders[] = str_replace('%', null, $placeholder); } } if (count($replacements)) { foreach ($data as $index => $user) { $txt = $setting['format']; foreach ($placeholders as $attribute) { if (isset($user[$attribute])) { $txt = str_replace('%' . $attribute, $user[$attribute], $txt); } } $data[$index]['text'] = $txt; } } $response['users'] = $data; } SPFactory::mainframe()->cleanBuffer(); echo json_encode($response); exit; }
public function execute() { $this->start = microtime(true); $sites = $this->getSites(); $responses = array(); $status = 'working'; $message = null; $this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT; // $this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL; $task = SPRequest::task(); if (in_array($task, array('crawler.init', 'crawler.restart'))) { if ($task == 'crawler.restart') { SPFactory::cache()->cleanSection(Sobi::Section()); } SPFactory::db()->truncate(self::DB_TABLE); $multiLang = Sobi::Cfg('lang.multimode', false); if ($multiLang) { $langs = SPFactory::CmsHelper()->getLanguages(); if ($multiLang && $langs) { foreach ($langs as $lang) { $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang); } } } $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section()); $sites = $this->getSites(); } if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) { $message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult()); SPFactory::db()->truncate(self::DB_TABLE); $this->response(array('status' => 'done', 'data' => array(), 'message' => $message)); } if (count($sites)) { $i = 0; $timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true); foreach ($sites as $site) { if (!strlen($site)) { continue; } $responses[] = $this->getResponse($site); $i++; if (microtime(true) - $this->start > $timeLimit) { break; } } $message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites)); } $this->response(array('status' => $status, 'data' => $responses, 'message' => $message)); }
protected function save() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } $data = SPRequest::string('bankdata', null, true); $data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section()); try { SPLang::saveValues($data); } catch (SPException $x) { $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage()); Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__); $this->response(Sobi::Back(), $message, false, 'error'); } $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success'); }
public function functions() { $functions = $this->get('functions'); $out = array(); $section = SPRequest::int('section'); $out[] = '<form action="index.php" method="post">'; $out[] = SPHtml_Input::select('function', $functions, null, false, array('id' => 'SobiProFunctions')); $out[] = '<input type="hidden" name="option" value="com_sobipro">'; $out[] = '<input type="hidden" name="task" value="menu">'; $out[] = '<input type="hidden" name="tmpl" value="component">'; $out[] = '<input type="hidden" name="format" value="html">'; $out[] = '<input type="hidden" name="mid" value="' . SPRequest::int('mid') . '">'; $out[] = '<input type="hidden" name="section" value="' . $section . '">'; $out[] = '</form>'; echo implode("\n", $out); }
protected function js() { $lang = SPLang::jsLang(true); if (count($lang)) { foreach ($lang as $term => $text) { unset($lang[$term]); $term = str_replace('SP.JS_', null, $term); $lang[$term] = $text; } } if (!SPRequest::int('deb')) { SPFactory::mainframe()->cleanBuffer(); header('Content-type: text/javascript'); } echo 'SobiPro.setLang( ' . json_encode($lang) . ' );'; exit; }
/** * 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')); }
public function install() { $id = $this->xGetString('id'); $name = $this->xGetString('name'); if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) { throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile))))); } $requirements = $this->xGetChilds('requirements/*'); if ($requirements && $requirements instanceof DOMNodeList) { SPFactory::Instance('services.installers.requirements')->check($requirements); } $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false); if (SPRequest::bool('force')) { /** @var $from SPDirectory */ $from = SPFactory::Instance('base.fs.directory', $this->root); $from->moveFiles($path); } else { if (!SPFs::move($this->root, $path)) { throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path)); } } if (!SPRequest::bool('force')) { $section = $this->xGetChilds('install'); if ($section instanceof DOMNodeList && $section->length) { $this->section($id); } } $exec = $this->xGetString('exec'); if ($exec && SPFs::exists($this->root . DS . $exec)) { include_once "{$this->root}/{$exec}"; } /** @var $dir SPDirectory */ $dir =& SPFactory::Instance('base.fs.directory', $path); $zip = array_keys($dir->searchFile('.zip', false)); if (count($zip)) { foreach ($zip as $file) { SPFs::delete($file); } } Sobi::Trigger('After', 'InstallTemplate', array($id)); $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install')); $dir->deleteFiles(); return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name)); }
protected function save() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } $this->validate('extensions.paypal', array('task' => 'paypal', 'pid' => Sobi::Section())); SPFactory::registry()->saveDBSection(array(array('key' => 'ppurl', 'value' => SPRequest::string('ppurl')), array('key' => 'ppemail', 'value' => SPRequest::string('ppemail')), array('key' => 'ppcc', 'value' => SPRequest::string('ppcc')), array('key' => 'pprurl', 'value' => SPRequest::string('pprurl'))), 'paypal_' . Sobi::Section()); $data = array('key' => 'ppexpl', 'value' => SPRequest::string('ppexpl', null, true), 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section()); try { SPLang::saveValues($data); $data['key'] = 'ppsubject'; $data['value'] = SPRequest::string('ppsubject', true); SPLang::saveValues($data); } catch (SPException $x) { $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage()); Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__); $this->response(Sobi::Back(), $message, false, 'error'); } $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success'); }
public function chooser() { $pid = $this->get('category.parent'); $path = null; if (!$pid) { $pid = SPRequest::sid(); } $this->assign($pid, 'parent'); $id = $this->get('category.id'); $id = $id ? $id : $pid; if ($id) { $path = $this->parentPath($id); } $this->assign($path, 'parent_path'); $this->assign(Sobi::Url(array('task' => 'category.parents', 'out' => 'json', 'format' => 'raw'), true), 'parent_ajax_url'); /* @TODO */ $tpl = str_replace(implode('/', array('usr', 'templates', 'category')), 'views/tpl/', $this->_template . '.php'); Sobi::Trigger('Display', $this->name(), array(&$this)); include $tpl; Sobi::Trigger('AfterDisplay', $this->name()); }
private function screen() { $view =& SPFactory::View('view', true); $view->setTemplate('config.help'); if (SPLoader::path('etc.repos.sobipro_core.repository', 'front', true, 'xml')) { $repository = SPFactory::Instance('services.installers.repository'); $repository->loadDefinition(SPLoader::path("etc.repos.sobipro_core.repository", 'front', true, 'xml')); try { $repository->connect(); } catch (SPException $x) { $view->assign(SPLang::e('REPO_ERR', $x->getMessage()), 'message'); } try { $response = $repository->help($repository->get('token'), SPRequest::cmd('mid')); $view->assign($response, 'message'); } catch (SPException $x) { $view->assign(SPLang::e('REPO_ERR', $x->getMessage()), 'message'); } } else { $view->assign(Sobi::Txt('MSG.HELP_ADD_CORE_REPO'), 'message'); } $view->display(); }
/** */ public function execute() { /* parent class executes the plugins */ SPRequest::set('task', $this->_type . '.' . $this->_task); switch ($this->_task) { case 'front': $this->getSections(); /** @var $view SPAdmPanelView */ $view = SPFactory::View('front'); /* load template config */ // $this->tplCfg( 'front' ); // $view->setConfig( $this->_tCfg, 'general' ); $view->determineTemplate('front', SPC::DEFAULT_TEMPLATE); $view->assign($this->_sections, 'sections'); $view->display(); break; default: /* case parents or plugin didn't registered this task, it was an error */ if (!parent::execute()) { Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__); } break; } }
public function execute() { SPRequest::set('task', $this->_type . '.' . $this->_task); if (strstr($this->_task, '.')) { $task = explode('.', $this->_task); $class = SPLoader::loadClass('opt.listing.' . $task[0], false, null, true); } else { $class = SPLoader::loadClass('opt.listing.' . $this->_task, false, null, true); } if ($class) { $imp = class_implements($class); if (is_array($imp) && in_array('SPListing', $imp)) { /** @noinspection PhpIncludeInspection $compatibility */ $listing = new $class(); if (!isset($class::$compatibility)) { define('SOBI_LEGACY_LISTING', true); if (strstr($this->_task, '.')) { $t = explode('.', $this->_task); $listing->setTask($t[0]); } else { $listing->setTask($this->_task); } } else { $listing->setTask($this->_task); } return $listing->execute(); } else { Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND Wrong class definition', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__); } } else { /* case parent didn't registered this task, it was an error */ if (!parent::execute() && $this->name() == __CLASS__) { Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__); } } }
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(); }
/** * Returns currently used language * @param bool $storage - force lang for storage. * If the $_POST array contain "sp_language" index and the $storage param is set, this language will be returned. * In other cases it is recommended to call this function with $storage = false. However because this happen only while recieving data from POST /// * @param bool $allowEmpty * @return string */ public static function Lang($storage = true, $allowEmpty = false) { /* when storing lang depend values and there was lang in request */ static $langPost = -1; static $langGet = -1; if ($langPost == -1 || $langGet == -1) { $langPost = SPRequest::cmd('sp-language', false, 'post'); $langGet = SPRequest::cmd('sp-language', false, 'get'); } if ($storage && $langPost) { $lang = SPRequest::cmd('sp-language', false, 'post'); } elseif ($langGet && self::Cfg('lang.multimode', false)) { $lang = SPRequest::cmd('sp-language', false, 'get'); } else { static $lang = null; if (!strlen($lang)) { if (self::Cfg('lang.multimode', false)) { $lang = SPFactory::config()->key('language'); } else { $lang = self::DefLang(); } self::Trigger('Language', 'Determine', array(&$lang)); } } $lang = strlen($lang) ? $lang : ($allowEmpty ? self::DefLang() : self::Lang(false, true)); return $lang; }
/** * @param SPEntry $entry * @param string $request * @throws SPException * @return array */ protected function verify($entry, $request) { $save = array(); $data = SPRequest::raw($this->nid . '_url', null, $request); $dexs = strlen($data); $data = SPFactory::db()->escape($data); if ($this->ownLabel) { $save['label'] = SPRequest::raw($this->nid, null, $request); /* check if there was a filter */ if ($this->filter && strlen($save['label'])) { $registry =& SPFactory::registry(); $registry->loadDBSection('fields_filter'); $filters = $registry->get('fields_filter'); $filter = isset($filters[$this->filter]) ? $filters[$this->filter] : null; if (!count($filter)) { throw new SPException(SPLang::e('FIELD_FILTER_ERR', $this->filter)); } else { if (!preg_match(base64_decode($filter['params']), $save['label'])) { throw new SPException(str_replace('$field', $this->name, SPLang::e($filter['description']))); } } } } /* check if it was required */ if ($this->required && !$dexs) { throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name)); } /* check if there was an adminField */ if ($this->adminField && $dexs) { if (!Sobi::Can('adm_fields.edit')) { throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->name)); } } /* check if it was free */ if (!$this->isFree && $this->fee && $dexs) { SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid); } /* check if it should contains unique data */ if ($this->uniqueData && $dexs) { $matches = $this->searchData($data, Sobi::Reg('current_section')); if (count($matches)) { throw new SPException(SPLang::e('FIELD_NOT_UNIQUE', $this->name)); } } /* check if it was editLimit */ if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit') && $dexs) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name)); } /* check if it was editable */ if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $dexs && $entry->get('version') > 1) { throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name)); } /* check the response code */ if ($dexs && $this->validateUrl) { if (preg_match('/[a-z0-9]@[a-z0-9].[a-z]/i', $data)) { $domain = explode('@', $data, 2); $domain = $domain[1]; if (!checkdnsrr($domain, 'MX')) { throw new SPException(SPLang::e('FIELD_MAIL_NO_MX', $data)); } } else { throw new SPException(SPLang::e('FIELD_MAIL_WRONG_FORM', $data)); } } if ($dexs) { /* if we are here, we can save these data */ $save['url'] = $data; } else { $save = null; } $this->setData($save); return $save; }
private function getLink($button) { $link = '#'; if (isset($button['type'])) { switch ($button['type']) { case 'help': $link = 'https://www.sigsiu.net/help_screen/' . Sobi::Reg('help_task', SPRequest::task()); break; case 'url': if (isset($button['sid']) && $button['sid'] == 'true') { $link = Sobi::Url(array('task' => $button['task'], 'sid' => SPRequest::sid('request', SPRequest::int('pid'), true))); } else { $link = Sobi::Url($button['task'] ? $button['task'] : $button['url']); } break; } } return $link; }
/** * @param $entry * @param $request * @param $files * @return SPdb * @throws SPException */ protected function storeData(&$entry, $request, $files) { /* @var SPdb $db */ $db =& SPFactory::db(); $this->verify($entry, $request); $time = SPRequest::now(); $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER'); $uid = Sobi::My('id'); /* if we are here, we can save these data */ /* collect the needed params */ $save = count($files) ? SPConfig::serialize($files) : null; $params = array(); $params['publishUp'] = $entry->get('publishUp'); $params['publishDown'] = $entry->get('publishDown'); $params['fid'] = $this->fid; $params['sid'] = $entry->get('id'); $params['section'] = Sobi::Reg('current_section'); $params['lang'] = Sobi::Lang(); $params['enabled'] = $entry->get('state'); $params['baseData'] = $db->escape($save); $params['approved'] = $entry->get('approved'); $params['confirmed'] = $entry->get('confirmed'); /* if it is the first version, it is new entry */ if ($entry->get('version') == 1) { $params['createdTime'] = $time; $params['createdBy'] = $uid; $params['createdIP'] = $IP; } $params['updatedTime'] = $time; $params['updatedBy'] = $uid; $params['updatedIP'] = $IP; $params['copy'] = !$entry->get('approved'); if (Sobi::My('id') == $entry->get('owner')) { --$this->editLimit; } $params['editLimit'] = $this->editLimit; /* save it */ try { $db->insertUpdate('spdb_field_data', $params); return $db; } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELDS_DATA_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); return $db; } return $db; }
public function save(&$attr) { static $lang = null; static $defLang = null; if (!$lang) { $lang = Sobi::Lang(); $defLang = Sobi::DefLang(); } $file = SPRequest::file('spfieldsopts', 'tmp_name'); if ($file) { $data = parse_ini_file($file, true); } elseif (is_string($attr['options'])) { $data = parse_ini_string($attr['options'], true); } else { $data = null; } $options = $this->parseOptsFile($data); if (!count($options) && count($attr['options'])) { $p = 0; $hold = array(); foreach ($attr['options'] as $o) { if (is_numeric($o['id'])) { $o['id'] = $this->nid . '_' . $o['id']; } if (isset($o['id'])) { $i = 0; $oid = $o['id']; while (isset($hold[$oid])) { $oid = $o['id'] . '_' . ++$i; } $options[] = array('id' => $oid, 'name' => $o['name'], 'parent' => null, 'position' => ++$p); $hold[$oid] = $oid; } } } if (count($options)) { unset($attr['options']); $optionsArr = array(); $labelsArr = array(); $defLabelsArr = array(); $optsIds = array(); foreach ($options as $i => $option) { /* check for doubles */ foreach ($options as $pos => $opt) { if ($i == $pos) { continue; } if ($option['id'] == $opt['id']) { $option['id'] = $option['id'] . '_' . substr((string) microtime(), 2, 8) . rand(1, 100); SPFactory::message()->warning('FIELD_WARN_DUPLICATE_OPT_ID'); } } $optionsArr[] = array('fid' => $this->id, 'optValue' => $option['id'], 'optPos' => $option['position'], 'optParent' => $option['parent']); $defLabelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $defLang, 'oType' => 'field_option', 'fid' => $this->id); $labelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $lang, 'oType' => 'field_option', 'fid' => $this->id); $optsIds[] = $option['id']; } /* @var SPdb $db */ $db =& SPFactory::db(); /* try to delete the existing labels */ try { $db->delete('spdb_field_option', array('fid' => $this->id)); $db->delete('spdb_language', array('oType' => 'field_option', 'fid' => $this->id, '!sKey' => $optsIds)); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_DELETE_SELECTED_OPTIONS', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } /* insert new values */ try { $db->insertArray('spdb_field_option', $optionsArr); $db->insertArray('spdb_language', $labelsArr, true); if ($defLang != $lang) { $db->insertArray('spdb_language', $defLabelsArr, false, true); } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_STORE_FIELD_OPTIONS_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } } if (!isset($attr['params'])) { $attr['params'] = array(); } $myAttr = $this->getAttr(); $properties = array(); if (count($myAttr)) { foreach ($myAttr as $property) { $properties[$property] = isset($attr[$property]) ? $attr[$property] : null; } } $attr['params'] = $properties; $this->sets['field.options'] = SPFactory::Instance('types.array')->toINIString($data); }
/** * Switching error reporting and displaying of errors compl. off * For e.g JavaScript, or XML output where the document structure is very sensible * */ public function &cleanBuffer() { error_reporting(0); ini_set('display_errors', 'off'); SPRequest::set('tmpl', 'component'); JResponse::setBody(null); while (ob_get_length()) { ob_end_clean(); } return $this; }
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(); }
/** * @todo Enter description here... * * @param array $ordering * @param string $type * @param string $id * @param string $fname * @return string */ public static function tableHeader($ordering, $type, $id = 'sid', $fname = 'order', $def = 'position.asc') { $header = array(); $current = SPFactory::user()->getUserState($type . '.order', $fname, $def); if (strstr($current, '.')) { $current = explode('.', $current); $newDirect = trim($current[1]) == 'asc' ? 'desc' : 'asc'; $current = $current[0]; } $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('pid'); if (is_array($ordering) && count($ordering)) { foreach ($ordering as $order => $active) { $class = null; $params = array(); if (is_array($active)) { $params = $active; $active = $active['type']; } switch ($active) { case SP_TBL_HEAD_RAW: $header[$order] = Sobi::Txt($type . '.header_' . $order); break; case 1: case 3: case 4: case 5: case 6: $direction = 'asc'; $ico = null; $aico = null; if (isset($params['order'])) { $sortBy = $params['order']; } else { $sortBy = $order; } $label = Sobi::Txt($type . '.header_' . $order); $title = Sobi::Txt($type . '.header_order_by_' . $order); if ($sortBy == $current) { $class = "class=\"selected\""; $ico = Sobi::Cfg('list_icons.sort_direction_' . ($newDirect == 'asc' ? 'desc' : 'asc')); $ico = " <img src=\"{$ico}\"/> "; $direction = $newDirect; } if ($active == SP_TBL_HEAD_SORTABLE_FIELD) { $label = $params['label']; $title = Sobi::Txt('LIST.ORDER_BY_FIELD', array('field' => $label)); } if ($active == SP_TBL_HEAD_STATE) { SPLoader::loadClass('html.tooltip'); $msg = Sobi::Txt('LIST.MAKE_SELECTION'); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.publish' ); }\""; $url = "#"; $ai = Sobi::Cfg('list_icons.enable'); $s = Sobi::Txt('LIST.ENABLE_S', array('type' => Sobi::Txt(strtoupper($type)))); $a = Sobi::Txt($type . '.enable_expl'); $aico = SPTooltip::toolTip($a, $s, $ai); $aico = " <span class=\"headerStateIcons\"><a href=\"{$url}\"{$onclk}>{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.disable'); $s = Sobi::Txt('LIST.DISABLE_S', array('type' => Sobi::Txt(strtoupper($type)))); $a = Sobi::Txt($type . '.disable_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.hide' ); }\""; $uico = " <span class=\"headerStateIcons\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } if ($active == SP_TBL_HEAD_APPROVAL) { SPLoader::loadClass('html.tooltip'); $msg = Sobi::Txt('LIST.MAKE_SELECTION'); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.approve' ); }\""; $url = "#"; $ai = Sobi::Cfg('list_icons.approve'); $s = Sobi::Txt($type . '.approve'); $a = Sobi::Txt($type . '.approve_expl'); $aico = SPTooltip::toolTip($a, $s, $ai); $aico = " <span class=\"headerAppIcons\"><a href=\"{$url}\"{$onclk}>{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.disable'); $s = Sobi::Txt($type . '.unapprove'); $a = Sobi::Txt($type . '.unapprove_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.unapprove' ); }\""; $uico = " <span class=\"headerAppIcons\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } if ($active == SP_TBL_HEAD_ORDER) { SPLoader::loadClass('html.tooltip'); $url = "#"; $onclk = " onclick=\"SPReorder( '{$type}', {$sid} );\" "; $aico = " <span class=\"headerStateIcons\"><a href=\"{$url}\" title=\"{$a}\">{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.order'); $s = Sobi::Txt($type . '.save_order'); $a = Sobi::Txt($type . '.save_order_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $uico = " <span class=\"headerOrderIcon\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } $header[$order] = "<a {$class} href=\"javascript:SPOrdering( '{$sortBy}','{$direction}', '{$fname}', {$sid} );\" title=\"{$title}\">{$label}</a> {$ico}{$aico}"; break; case SP_TBL_HEAD_SELECTION_BOX: $name = Sobi::Txt($type . '.header_toggle'); $header[$order] = "<input type=\"checkbox\" name=\"toggle\" id=\"toggel_{$id}\" title=\"{$name}\" value=\"1\" onclick=\"SPCheckListElements('{$id}', this );\"/>"; break; } } } return $header; }
private function __construct() { $this->client = $this->parse_user_agent(SPRequest::raw('HTTP_USER_AGENT', null, 'server')); }