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')); } } } }
/** */ public function execute() { $r = false; switch ($this->_task) { case 'chooser': case 'expand': SPLoader::loadClass('html.input'); $r = true; $this->chooser($this->_task == 'expand'); break; case 'parents': $r = true; $this->parents(); break; case 'icon': $r = true; $this->iconChooser(); break; default: /* 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__); } else { $r = true; } break; } return $r; }
public function save(&$attr) { if (($attr['resize'] || $attr['crop']) && !($attr['resizeWidth'] && $attr['resizeHeight'])) { throw new SPException(SPLang::e('IMG_FIELD_RESIZE_NO_SIZE')); } parent::save($attr); }
public function display() { $template = SPLoader::loadTemplate($this->_tpl, 'php'); if ($template) { include $template; } else { throw new SPException(SPLang::e('CANNOT_LOAD_TEMPLATE_FILE_AT', SPLoader::loadTemplate($this->_tpl, 'php', false))); } }
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(); }
protected function check($file) { $allowed = SPLoader::loadIniFile('etc.files'); $mType = SPFactory::Instance('services.fileinfo', $file)->mimeType(); if (strlen($mType) && !in_array($mType, $allowed)) { SPFs::delete($file); $this->message(array('type' => 'error', 'text' => SPLang::e('FILE_WRONG_TYPE', $mType), 'id' => '')); } return $mType; }
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); }
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; }
/** * @return string */ public function display() { $this->_view[] = "\n <!-- Sobi Pro - admin side menu start -->"; $this->_view[] = "\n<div id=\"SPaccordionTabs\" class=\"SPmenuTabs\">"; $this->_view[] = '<div id="SPMenuCtrl">'; $this->_view[] = ' <button class="btn btn-mini btn-sobipro" id="SPMenuCtrlBt" type="button">-</button>'; $this->_view[] = '</div>'; $media = Sobi::Cfg('img_folder_live'); $this->_view[] = "\n<div class='well well-small'><a href=\"http://www.Sigsiu.NET\" target=\"_blank\" title=\"Sigsiu.NET Software Development\"><img src=\"{$media}/sp.png\" alt=\"Sigsiu.NET Software Development\" style=\"border-style:none;\" /></a></div>\n"; $fs = null; if (count($this->_sections)) { if ($this->_task == 'section.view') { // $this->_task = 'section.entries'; $this->_open = 'AMN.ENT_CAT'; } $this->_view[] = '<div class="accordion" id="SpMenu">'; foreach ($this->_sections as $section => $list) { $sid = SPLang::nid($section); $in = false; if (!$fs) { $fs = $sid; } if (!$this->_open && array_key_exists($this->_task, $list)) { $this->_open = $sid; $in = ' in'; } if ($this->_open && $section == $this->_open) { $in = ' in'; } if (!$this->_open && array_key_exists($this->_task, $list)) { $in = ' in'; } $this->_view[] = '<div class="accordion-group">'; $this->_view[] = '<div class="accordion-heading">'; $this->_view[] = '<a class="accordion-toggle" data-toggle="collapse" data-parent="#SpMenu" href="#' . $sid . '">'; $this->_view[] = Sobi::Txt($section); $this->_view[] = '</a>'; $this->_view[] = '</div>'; $this->_view[] = '<div id="' . $sid . '" class="accordion-body collapse' . $in . '">'; $this->_view[] = '<div class="accordion-inner">'; $this->_view[] = $this->section($list, $section); $this->_view[] = '</div>'; $this->_view[] = '</div>'; $this->_view[] = '</div>'; } $this->_view[] = '</div>'; } $this->_view[] = "\n</div>\n"; $this->_view[] = '<div class="brand" style="display: inherit;">© <a href="http://www.sigsiu.net">Sigsiu.NET GmbH</a></div>'; $this->_view[] = "\n<!-- Sobi Pro - admin side menu end -->\n"; return implode("\n", $this->_view); }
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); }
protected function getFunctionsLabel() { if (isset($this->params->interpreter)) { $interpreter = explode('.', $this->params->interpreter); $function = array_pop($interpreter); $obj = SPFactory::Instance(implode('.', $interpreter)); self::$functionsLabel = $obj->{$function}(self::$sid, self::$section); } elseif (isset($this->params->text)) { if (isset($this->params->loadTextFile)) { SPLang::load($this->params->loadTextFile); } self::$functionsLabel = Sobi::Txt($this->params->text); } }
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; }
/** * @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; }
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__); } } }
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); }
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(); }
/** * @return array */ public function struct() { $baseData = $this->getRaw(); $list = array(); $struct = array(); $order = SPFactory::cache()->getVar('order_' . $this->nid); if (!$order) { $order = SPFactory::db()->select('optValue', 'spdb_field_option', array('fid' => $this->id), 'optPos')->loadResultArray(); SPFactory::cache()->addVar($order, 'order_' . $this->nid); } if (is_array($baseData) && count($baseData)) { $this->cssClass = strlen($this->cssClass) ? $this->cssClass : 'spFieldsData'; $this->cssClass = $this->cssClass . ' ' . $this->nid; $this->cleanCss(); foreach ($order as $opt) { if (isset($baseData[$opt])) { $list[] = array('_tag' => 'li', '_value' => SPLang::clean($baseData[$opt]), '_class' => $opt); } } foreach ($this->options as $opt) { $struct[] = array('_complex' => 1, '_data' => $opt['label'], '_attributes' => array('selected' => isset($baseData[$opt['id']]) ? 'true' : 'false', 'id' => $opt['id'], 'position' => $opt['position'])); } $data = array('ul' => array('_complex' => 1, '_data' => $list, '_attributes' => array('class' => $this->cssClass))); } if (count($list)) { return array('_complex' => 1, '_data' => $data, '_attributes' => array('lang' => $this->lang, 'class' => $this->cssClass), '_options' => $struct); } }
/** * */ public function displayForm() { Sobi::Trigger('Display', $this->name(), array(&$this)); $action = $this->key('action'); echo '<div class="SobiPro" id="SobiPro">' . "\n"; if ($this->get('_compatibility')) { echo SPFactory::AdmToolbar()->render(); echo $this->legacyMessages(); } echo $action ? "\n<form action=\"{$action}\" method=\"post\" name=\"adminForm\" id=\"SPAdminForm\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" >\n" : null; foreach ($this->_templates as $tpl) { $template = SPLoader::path($tpl, 'adm.template'); if (!$template) { $tpl = SPLoader::translatePath($tpl, 'adm.template', false); Sobi::Error($this->name(), SPLang::e('CANNOT_LOAD_TEMPLATE_AT', $tpl), SPC::ERROR, 500, __LINE__, __FILE__); } else { include $template; } } if (count($this->_hidden)) { $this->_hidden[SPFactory::mainframe()->token()] = 1; $prefix = null; if (!$this->get('_compatibility')) { $prefix = 'SP_'; } foreach ($this->_hidden as $name => $value) { echo "\n<input type=\"hidden\" name=\"{$name}\" id=\"{$prefix}{$name}\" value=\"{$value}\"/>"; } } echo $action ? "\n</form>\n" : null; echo '</div>'; Sobi::Trigger('AfterDisplay', $this->name()); }
/** * @deprecated since 1.1 replaced by {@link #Initialise()} * @param int $sid - section id * @param null $root - root of Joomla! * @param null $lang - language * @return null */ public static function Init($root = null, $lang = null, $sid = 0) { static $loaded = false; if (!$loaded) { if (!defined('SOBI_CMS')) { define('SOBI_CMS', version_compare(JVERSION, '3.0.0', 'ge') ? 'joomla3' : (version_compare(JVERSION, '1.6.0', 'ge') ? 'joomla16' : 'joomla15')); } defined('SOBIPRO') || define('SOBIPRO', true); defined('SOBI_TASK') || define('SOBI_TASK', 'task'); defined('SOBI_DEFLANG') || define('SOBI_DEFLANG', $lang); defined('SOBI_ACL') || define('SOBI_ACL', 'front'); defined('SOBI_ROOT') || define('SOBI_ROOT', $root); defined('SOBI_MEDIA') || define('SOBI_MEDIA', implode('/', array($root, 'media', 'sobipro'))); defined('SOBI_PATH') || define('SOBI_PATH', SOBI_ROOT . '/components/com_sobipro'); defined('SOBI_LIVE_PATH') || define('SOBI_LIVE_PATH', 'components/com_sobipro'); require_once SOBI_PATH . '/lib/base/fs/loader.php'; SPLoader::loadController('sobipro'); SPLoader::loadController('interface'); SPLoader::loadClass('base.exception'); SPLoader::loadClass('base.const'); SPLoader::loadClass('base.object'); SPLoader::loadClass('base.filter'); SPLoader::loadClass('base.request'); SPLoader::loadClass('cms.base.lang'); SPLoader::loadClass('models.dbobject'); SPLoader::loadClass('base.factory'); SPLoader::loadClass('base.config'); SPLoader::loadClass('cms.base.fs'); // in case it is a CLI call if (isset($_SERVER['REQUEST_URI'])) { SPFactory::config()->set('live_site', JURI::root()); } $loaded = true; } if ($sid) { $section = null; if ($sid) { $path = array(); $id = $sid; $path[] = (int) $id; while ($id > 0) { try { $id = SPFactory::db()->select('pid', 'spdb_relations', array('id' => $id))->loadResult(); if ($id) { $path[] = (int) $id; } } catch (SPException $x) { Sobi::Error('ExtCoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } } $path = array_reverse($path); $section = SPFactory::object($path[0]); } /* set current section in the registry */ SPFactory::registry()->set('current_section', $section->id); $_config =& SPFactory::config(); /* load basic configuration settings */ $_config->addIniFile('etc.config', true); $_config->addTable('spdb_config', $sid); /* initialise interface config setting */ SPFactory::mainframe()->getBasicCfg(); /* initialise config */ $_config->init(); } }
/** * @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 mimeFromExt() { $ext = SPFs::getExt($this->_path); if (!count(self::$_exts)) { self::$_exts = SPLoader::loadIniFile('etc.mime', false); } if (!isset(self::$_exts[$ext])) { Sobi::Error('FileInfo', SPLang::e('Cannot determine the right file type from extension'), SPC::WARNING, 0); } else { $this->_mime = self::$_exts[$ext]; } }
private function renderButton($button, $list = false) { $rel = null; $onclick = null; $title = ''; $class = isset($button['class']) ? ' ' . $button['class'] : null; if (isset($button['type']) && $button['type'] == 'url') { $rel = null; $href = $this->getLink($button); } elseif (!isset($button['task']) || !$button['task']) { $href = $this->getLink($button); } else { $rel = $button['task']; $href = '#'; } if (!isset($button['label']) || !$button['label']) { $label = $this->getLabel($button); } else { $label = $button['label']; } if (isset($button['confirm'])) { $title = ' title="' . Sobi::Txt($button['confirm']) . '" '; } if ($button['element'] == 'button-legacy') { $class .= ' legacy'; $onclick = 'onclick="Joomla.submitform(\'' . $rel . '\');"'; // damn SqueezeBox - download field license window $rel = null; } $target = isset($button['target']) && $button['target'] ? " target=\"{$button['target']}\"" : null; if (isset($button['buttons']) && count($button['buttons'])) { $this->output[] = '<div class="btn-group">'; $this->output[] = "<a href=\"{$href}\" class=\"{$this->btClass}{$class}\"{$target} rel=\"{$rel}\">"; if (!(isset($button['icon']) && $button['icon'])) { $icon = $this->getIcon($button, true); } else { $icon = $button['icon']; } $this->output[] = '<i class="icon-' . $icon . '"></i> ' . $label; $this->output[] = '</a>'; $this->output[] = '<button class="' . $this->btClass . ' dropdown-toggle" data-toggle="dropdown"><span class="icon-caret-down"></span> </button>'; $this->output[] = '<div class="dropdown-menu" id="spmenu-' . SPLang::nid($button['task']) . '">'; $this->output[] = '<ul class="nav nav-stacked SpDropDownBt">'; foreach ($button['buttons'] as $bt) { $this->renderButton($bt, true); } $this->output[] = '</ul>'; $this->output[] = '</div>'; $this->output[] = '</div>'; } elseif (!$list) { $this->output[] = "<a href=\"{$href}\" rel=\"{$rel}\" class=\"{$this->btClass}{$class}\"{$target}{$onclick}{$title}>"; if (!(isset($button['icon']) && $button['icon'])) { $icon = $this->getIcon($button); } else { $icon = $button['icon']; } $this->output[] = '<i class="icon-' . $icon . '"></i> ' . $label; $this->output[] = '</a>'; } else { if ($button['element'] == 'nav-header') { $this->output[] = '<li class="nav-header">' . $button['label'] . '</li>'; } else { $this->output[] = '<li><a href="' . $href . '"' . $target . $title . ' rel="' . $rel . '">'; if (!(isset($button['icon']) && $button['icon'])) { $icon = $this->getIcon($button); } else { $icon = $button['icon']; } if (isset($button['selected'])) { if (!$button['selected']) { $icon = $this->icons['not-selected']; } else { $icon = $this->icons['selected']; // $this->output[ ] = '<i class="icon-' . $this->icons[ 'selected' ] . '"></i> '; } } $this->output[] = '<i class="icon-' . $icon . '"></i> ' . $label; $this->output[] = '</a></li>'; } } }
/** * @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; }
/** * @param string $title * @param bool $forceAdd */ public function setTitle($title, $forceAdd = false) { $document = JFactory::getDocument(); if (!is_array($title) && (Sobi::Cfg('browser.add_title', true) || $forceAdd)) { $title = array($title); } if (is_array($title)) { //browser.add_title = true: adds the Joomla part (this is normally the menu item) in front of it (works only if full_title is also set to true) $jTitle = $document->getTitle(); //get the title Joomla has set if (Sobi::Cfg('browser.add_title', true) || $forceAdd) { if ($title[0] != $jTitle) { array_unshift($title, $jTitle); } } else { if ($title[0] == $jTitle) { array_shift($title); } } //if ( Sobi::Cfg( 'browser.full_title', true ) || true ) { //browser.full_title = true: if title is array, use only the last. That's e.g. the entry name without categories for SobiPro standard title if (count($title)) { if (is_array($title)) { if (Sobi::Cfg('browser.reverse_title', false)) { $title = array_reverse($title); } $title = implode(Sobi::Cfg('browser.title_separator', ' - '), $title); } else { $title = isset($title[count($title) - 1]) ? $title[count($title) - 1] : $title[0]; } } else { $title = null; } } if (strlen($title)) { if (!defined('SOBIPRO_ADM')) { if (JFactory::getApplication()->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', JFactory::getApplication()->getCfg('sitename'), $title); } elseif (JFactory::getApplication()->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, JFactory::getApplication()->getCfg('sitename')); } } $document->setTitle(SPLang::clean(html_entity_decode($title))); } }
public function renderButton($button, $list = false) { $rel = null; $class = isset($button['class']) ? ' ' . $button['class'] : null; if (!isset($button['task']) || !$button['task']) { $href = null; $rel = null; } else { $rel = $button['task']; $href = null; } $label = $button['label']; $target = isset($button['target']) && $button['target'] ? " target=\"{$button['target']}\"" : null; if (isset($button['buttons']) && count($button['buttons'])) { $this->_out[] = '<div class="btn-group">'; $this->_out[] = "<a href=\"{$href}\" class=\"btn{$class}\"{$target} rel=\"{$rel}\">"; if (!(isset($button['icon']) && $button['icon'])) { $icon = 'cog'; } else { $icon = $button['icon']; } if ($icon != 'none') { $this->_out[] = '<i class="icon-' . $icon . '"></i> ' . $label; } else { $this->_out[] = ' ' . $label; } $this->_out[] = '</a>'; $this->_out[] = '<button class="btn dropdown-toggle" data-toggle="dropdown"><span class="icon-caret-down"></span> </button>'; $this->_out[] = '<div class="dropdown-menu" id="' . SPLang::nid($button['task']) . '">'; $this->_out[] = '<ul class="nav nav-stacked SpDropDownBt">'; foreach ($button['buttons'] as $bt) { $this->renderButton($bt, true); } $this->_out[] = '</ul>'; $this->_out[] = '</div>'; $this->_out[] = '</div>'; } elseif (!$list) { if ($rel || $href) { $this->_out[] = "<a href=\"{$href}\" rel=\"{$rel}\" class=\"btn{$class}\"{$target}>"; } else { if (isset($button['rel'])) { $r = " rel=\"{$button['rel']}\" "; } $this->_out[] = "<div class=\"btn{$class}\"{$r}{$target}>"; } if (!(isset($button['icon']) && $button['icon'])) { $icon = 'cog'; } else { $icon = $button['icon']; } $this->_out[] = ' <i class="icon-' . $icon . '"></i> ' . $label; if ($rel || $href) { $this->_out[] = '</a>'; } else { $this->_out[] = '</div>'; } } else { if ($button['element'] == 'nav-header') { $this->_out[] = '<li class="nav-header">' . $button['label'] . '</li>'; } else { $this->_out[] = '<li><a href="' . $href . $target . '" rel="' . $rel . '">'; if (!(isset($button['icon']) && $button['icon'])) { $icon = 'cog'; } else { $icon = $button['icon']; } $this->_out[] = '<i class="icon-' . $icon . '"></i> ' . $label; $this->_out[] = '</a></li>'; } } }
public function connect() { if ($this->definition instanceof DOMDocument && $this->xGetString('url')) { $connection = SPFactory::Instance('services.remote'); $ssl = $connection->certificate($this->xGetString('url')); if (isset($ssl['err'])) { throw new SPException($ssl['msg']); } if ($ssl['serialNumber'] != $this->xGetString('certificate/serialnumber')) { throw new SPException(SPLang::e('SSL validation error: stored serial number is %s but the serial number for the repository at %s has the number %s.', $this->xGetString('certificate/serialnumber'), $this->xGetString('url'), $ssl['serialNumber'])); } // for some reason on some servers the hash is being indeed modified // although it has been correctly transferred // it seems that it is depend on the protocol used (TSL/SSL) // if ( $ssl[ 'hash' ] != $this->xGetString( 'certificate/hash' ) ) { // throw new SPException( // SPLang::e( // 'SSL validation error: stored hash does not accords the hash for the repository at %s. %s != %s', // $this->xGetString( 'url' ), $ssl[ 'hash' ], $this->xGetString( 'certificate/hash' ) // ) // ); // } if ($ssl['validTo'] < time()) { throw new SPException(SPLang::e('SSL validation error: SSL certificate for %s is expired.', $this->xGetString('url'))); } $this->_server = SPFactory::Instance('services.soap', null, array('location' => $this->xGetString('url'))); } else { throw new SPException(SPLang::e('No repository definition file at %s or the definition is invalid.', $this->xmlFile)); } }
/** * @param int $id * @param bool $parents * @return array */ protected function parentPath($id, $parents = false) { $path = SPFactory::config()->getParentPath($id, true, $parents); if (is_array($path)) { $path = implode(Sobi::Cfg('string.path_separator', ' > '), $path); } else { $path = null; } return SPLang::clean($path); }