/** * Gets basic data from the CMS (e.g Joomla) and stores in the #SPConfig instance */ public function getBasicCfg() { parent::getBasicCfg(); if (defined('SOBIPRO_ADM')) { SPFactory::config()->change('adm_img_folder_live', Sobi::FixPath(JURI::root() . '/' . SOBI_ADM_FOLDER . '/templates/' . JFactory::getApplication()->getTemplate() . '/images/admin'), 'general'); } }
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 __construct() { $cfg = SPFactory::config(); $this->setSender(array($cfg->get('mail.mailfrom'), $cfg->get('mail.fromname'))); switch ($cfg->get('mail.mailer')) { case 'smtp': $this->useSMTP((int) ($cfg->get('mail.smtpauth') != 0), $cfg->get('mail.smtphost'), $cfg->get('mail.smtpuser'), $cfg->get('mail.smtppass'), $cfg->get('mail.smtpsecure'), $cfg->get('mail.smtpport')); break; case 'sendmail': $this->IsSendmail(); break; default: $this->IsMail(); break; } }
protected function getInput() { if (!self::$sid) { self::$sid = isset($this->params->sid) ? $this->params->sid : $this->value; $link = $this->form->getValue('link'); if (!self::$sid && strlen($link)) { parse_str($link, $request); if (isset($request['sid']) && $request['sid']) { self::$sid = $request['sid']; } } $path = SPFactory::config()->getParentPath(self::$sid); self::$section = $path[0]; $this->getFunctionsLabel(); } return $this->fieldname == 'sid' ? $this->loadSection() : $this->loadAdvanced(); }
/** * legacy function * @deprecated * @param string $tooltip * @param string $title * @param int $width * @param string $image * @param string $text * @param string $href * @param bool $link * @param string $position * @return string */ public static function toolTip($tooltip, $title = null, $image = null, $width = null, $text = null, $href = null, $target = '_blank') { $class = SPFactory::config()->key('html.tooltip_class', 'editlinktip hasTip'); while (strstr($text, "\\'")) { $text = stripcslashes($text); } while (strstr($text, "\\'")) { $text = stripcslashes($text); } while (strstr($title, "\\'")) { $title = stripcslashes($title); } if (!$text || $image) { $tip = "<img src=\"{$image}\" alt=\"{$title}\"/>"; $tip = "<span class=\"{$class}\" title=\"{$title}::{$tooltip}\">{$tip}</span>"; } else { $tip = "<span class=\"{$class}\" title=\"{$title}::{$tooltip}\">{$text}</span>"; } if ($href) { $tip = "<a href=\"{$href}\" target=\"{$target}\">{$tip}</a>"; } return $tip; }
protected function js() { $lang = SPLang::jsLang(); 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) . ' );'; echo "\n"; exit('SobiPro.setIcons( ' . json_encode(SPFactory::config()->icons()) . ' );'); }
/** * Full init */ public function loadTable($cache = false) { if ($this->id && !$cache) { $cats = $this->getCategories(true); $this->section = Sobi::Section(); if (isset($cats[0])) { $sid = SPFactory::config()->getParentPath($cats[0], false); $this->section = isset($sid[0]) && $sid[0] ? $sid[0] : Sobi::Section(); } // we need to get some information from the object table $this->valid = $this->valid && count($this->categories) > 0; $this->loadFields(Sobi::Section(), true); Sobi::Trigger($this->name(), ucfirst(__FUNCTION__), array(&$this->fields)); if (count($this->fields)) { foreach ($this->fields as $field) { /* create field aliases */ $this->fieldsIds[$field->get('id')] = $field; $this->fieldsNids[$field->get('nid')] = $field; } } $this->primary =& $this->parent; $this->url = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $this->get('nid') : $this->get('name'), 'pid' => $this->get('primary'), 'sid' => $this->id), false, true, true, true); Sobi::Trigger($this->name(), ucfirst(__FUNCTION__), array(&$this->fieldsIds, &$this->fieldsNids)); } if ($this->id) { $counter = SPFactory::db()->select('counter', 'spdb_counter', array('sid' => $this->id))->loadResult(); if ($counter !== null) { $this->counter = $counter; } } if (!strlen($this->name)) { $this->name = Sobi::Txt('ENTRY_NO_NAME'); } if ($this->owner && $this->owner == Sobi::My('id')) { $stop = true; SPFactory::registry()->set('break_cache_view', $stop); } $this->translate(); // if the visitor can't see unapproved entries we are showing the approved version anyway if (SPRequest::task() != 'entry.edit' && SPRequest::task() != 'entry.submit' && SPRequest::task() != 'entry.save' && !$this->approved && !Sobi::Can('entry', 'edit', '*', Sobi::Section())) { $this->approved = 1; } }
private function browse() { /** @var $view SPExtensionsView */ $view = SPFactory::View('extensions', true); $def = SPFactory::Instance('types.array'); $list = null; $apps = array(); if (SPFs::exists(SPLoader::path('etc.extensions', 'front', false, 'xml'))) { $list = $def->fromXML(DOMDocument::load(SPLoader::path('etc.extensions', 'front', false, 'xml')), 'extensionslist'); } if (!count($list)) { SPFactory::message()->warning('EX.MSG_UPDATE_FIRST'); $status = array('label' => Sobi::Txt('EX.LAST_UPDATED', Sobi::Txt('UNKNOWN')), 'type' => SPC::ERROR_MSG); $view->assign($status, 'last-update'); } else { try { $installed = SPFactory::db()->select('*', 'spdb_plugins')->loadAssocList(); } catch (SPException $x) { } $status = array('label' => Sobi::Txt('EX.LAST_UPDATED', SPFactory::config()->date($list['extensionslist']['created'])), 'type' => SPC::INFO_MSG); $view->assign($status, 'last-update'); $list = $list['extensionslist']['extensions']; if (count($list)) { foreach ($list as $pid => $plugin) { $plugin['installed'] = -1; $plugin['action'] = array('text' => Sobi::Txt('EX.INSTALL_APP'), 'class' => 'install'); $eid = $pid; if ($plugin['type'] == 'language') { $eid = explode('-', $pid); $eid[0] = strtolower($eid[0]); $eid[1] = strtoupper($eid[1]); $eid = implode('-', $eid); } if (count($installed)) { foreach ($installed as $ex) { if ($eid == $ex['pid'] || str_replace('_', '-', $ex['pid']) == $eid) { $plugin['installed'] = -2; $plugin['action'] = array('text' => Sobi::Txt('EX.REINSTALL_APP'), 'class' => 'reinstall'); if (version_compare($plugin['version'], $ex['version'], '>')) { $plugin['installed'] = -3; $plugin['action'] = array('text' => Sobi::Txt('EX.UPDATE_APP'), 'class' => 'update'); } } } } if ($plugin['type'] == 'update') { $compare = version_compare($plugin['version'], implode('.', SPFactory::CmsHelper()->myVersion())); if ($compare <= 0) { $plugin['installed'] = -1; $eid = $eid . '.disabled'; $plugin['action'] = array('text' => Sobi::Txt('EX.APP_UPDATE_DISABLED'), 'class' => 'disabled'); } else { $plugin['installed'] = -3; $plugin['action'] = array('text' => Sobi::Txt('EX.UPDATE_CORE'), 'class' => 'update'); } } $plugin['pid'] = $eid; $plugin['eid'] = $plugin['repository'] . '.' . $plugin['type'] . '.' . $plugin['pid']; $list[$eid] = $plugin; $index = in_array($plugin['type'], array('application', 'field', 'update', 'template', 'language')) ? $plugin['type'] . 's' : 'others'; $apps[$index][] = $plugin; } if (isset($apps['updates'])) { usort($apps['updates'], function ($from, $to) { return version_compare($to['version'], $from['version']) > 0; }); } } } $repos = array(); $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('etc.repos')); $xml = array_keys($dir->searchFile('repository.xml', false, 2)); foreach ($xml as $def) { $repository = SPFactory::Instance('services.installers.repository'); $repository->loadDefinition($def); $repos[] = $repository->getDef(); } $view->assign($this->_task, 'task')->assign($this->menu(), 'menu')->assign($apps, 'extensions')->assign($repos, 'repositories')->assign($list, 'full-list')->determineTemplate('extensions', $this->_task); Sobi::Trigger($this->_task, $this->name(), array(&$view)); $view->display(); Sobi::Trigger('After' . ucfirst($this->_task), $this->name(), array(&$view)); }
/** * @author Radek Suski * @version 1.0 * @param string $path * @param bool $adm * @param bool $checkExist * @param bool $toLive * @param string $ext * @param bool $count * @internal param string $root * @internal param bool $existCheck * @return string */ public static function CssFile($path, $adm = false, $checkExist = true, $toLive = true, $ext = 'css', $count = false) { if (strstr($path, 'root.')) { $file = self::translatePath(str_replace('root.', null, $path), 'root', $checkExist, $ext, $count); } elseif (strstr($path, 'front.')) { $file = self::translatePath(str_replace('front.', null, $path), 'front', $checkExist, $ext, $count); } elseif (strstr($path, 'absolute.')) { $file = self::translatePath(str_replace('absolute.', null, $path), 'absolute', $checkExist, $ext, $count); } else { $root = $adm ? 'adm.' : null; $file = self::translatePath($root . $path, 'css', $checkExist, $ext, $count); } if ($toLive) { $file = str_replace(SOBI_ROOT, SPFactory::config()->get('live_site'), $file); $file = str_replace('\\', '/', $file); } return Sobi::FixPath($file); }
/** * @param $url * @return bool */ protected function getItemid(&$url) { $sid = isset($url['pid']) && $url['pid'] ? $url['pid'] : $url['sid']; if (!(int) $sid) { return false; } $url['Itemid'] = 0; // Thu, Feb 27, 2014 16:28:22 - iy is probably the right solution // but NTaRS $menu = JFactory::getApplication('site')->getMenu('site'); // Thu, Mar 6, 2014 12:42:01 - let's check // $menu = JApplication::getMenu( 'site' ); if (isset($url['task'])) { $task = $url['task'] == 'search.results' ? 'search' : $url['task']; $link = 'index.php?option=com_sobipro&task=' . $task . '&sid=' . $sid; } else { $link = 'index.php?option=com_sobipro&sid=' . $sid; } $item = $menu->getItems('link', $link, true); if ($item && count($item)) { $url['Itemid'] = $item->id; } else { $path = SPFactory::config()->getParentPath($sid); if (count($path)) { foreach ($path as $sid) { $item = $menu->getItems('link', 'index.php?option=com_sobipro&sid=' . $sid, true); if ($item && count($item)) { $url['Itemid'] = $item->id; } } } } // if we still don't have an Itemid it means that there is no link to SobiPro section if (!$url['Itemid'] && !defined('SOBIPRO_ADM')) { SPFactory::message()->warning(Sobi::Txt('ITEMID_MISSING_WARN', 'https://www.sigsiu.net/help_screen/joomla.menu', $sid), false, false)->setSystemMessage('SEF-URL'); } }
private function cloneTpl() { $dir = $this->dir(SPRequest::cmd('templateName')); $newName = SPRequest::word('templateNewName', 'Duplicated Template', 'post'); $dirName = SPLang::nid($newName); $dirNameOrg = $dirName; $c = 1; while (SPFs::exists(SPLoader::dirPath('usr.templates.' . $dirName, 'front', false))) { $dirName = $dirNameOrg . '-' . $c++; } $newPath = SPLoader::dirPath('usr.templates.' . $dirName, 'front', false); if (!SPFs::copy($dir, $newPath)) { throw new SPException(SPLang::e('COULD_NOT_COPY_DIRECTORY', $dir, $newPath)); } $defFile = SPLoader::path($newPath . '.template', 'absolute', true, 'xml'); if ($defFile) { $fc = SPLoader::loadClass('base.fs.file'); $def = new DOMDocument(); $def->load($defFile); $xdef = new DOMXPath($def); $oldName = $xdef->query('/template/name')->item(0)->nodeValue; $oldDesc = $xdef->query('/template/description')->item(0)->nodeValue; $date = SPFactory::config()->date(time()); $xdef->query('/template/name')->item(0)->nodeValue = $newName; $xdef->query('/template/creationDate')->item(0)->nodeValue = $date; $xdef->query('/template/id')->item(0)->nodeValue = $dirName; $newDesc = Sobi::Txt('TP.CLONE_NOTE', array('name' => $oldName, 'date' => $date)); $xdef->query('/template/description')->item(0)->nodeValue = "{$newDesc}\n{$oldDesc}"; $file = new $fc($defFile); $file->content($def->saveXML()); $file->save(); } $this->response(Sobi::Url(array('task' => 'template.info', 'template' => str_replace(SOBI_PATH . DS . 'usr' . DS . 'templates' . DS, null, $dirName))), Sobi::Txt('TP.DUPLICATED'), false, 'success'); }
/** * @param $name - field name * @param $value - field value * @param null $class * @param string $dateFormat - date format in PHP * @param null $params - additional parameters * @internal param string $icon - field icon * @return string */ public static function dateGetter($name, $value, $class = null, $dateFormat = 'Y-m-d H:i:s', $params = null) { self::createLangFile(); $value = strtotime($value); $valueDisplay = $value ? SPFactory::config()->date($value, null, $dateFormat) : null; $params = self::checkArray($params); if (!isset($params['id'])) { $params['id'] = SPLang::nid($name); } if ($class) { $params['class'] = $class; } $params = self::params($params); $f = "\n"; $f .= '<div class="spOutput">'; $f .= "\n\t"; $f .= '<span ' . $params . '>' . $valueDisplay . '</span>'; $f .= "\n"; $f .= '</div>'; $f .= "\n"; Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$f)); return "\n<!-- Date Getter '{$name}' Output -->{$f}<!-- Date Getter '{$name}' End -->\n\n"; }
?> </td> </tr> <tr class="row<?php echo ++$row % 2; ?> "> <td class="key"> <?php $this->txt('FM.CSS_CLASS'); ?> </td> <td> <?php $params = array('id' => 'field_css', 'size' => 15, 'maxlength' => 50, 'class' => 'inputbox', 'style' => 'text-align:center;'); if ($this->get('field.id') == SPFactory::config()->nameField()->get('id')) { $params['readonly'] = 'readonly'; } $this->field('text', 'field.cssClass', 'value:field.cssClass', $params); ?> </td> </tr> <tr class="row<?php echo ++$row % 2; ?> "> <td class="key"> <?php $this->txt('FM.ADM_FIELD'); ?> </td>
/** * initialise config object * @return void */ private function createConfig() { $this->_config =& SPFactory::config(); /* load basic configuration settings */ $this->_config->addIniFile('etc.config', true); $this->_config->addIniFile('etc.adm.config', true); $this->_config->addTable('spdb_config', $this->_section); /* initialise interface config setting */ $this->_mainframe->getBasicCfg(); /* initialise config */ $this->_config->init(); }
/** * Returns ip value of requested variable * * @param string $name variable name * @param string $default default value * @param string $method request method * @return string */ public static function datetime($name, $default = null, $method = 'REQUEST') { $config =& SPFactory::config(); $config->addIniFile('etc.calendar'); self::$val = self::string($name, $default, false, $method); if (self::$val) { self::$val = SPFactory::config()->rdate(self::$val); self::$val = date('Y-m-d H:i:s', self::$val); } else { self::$val = SPFactory::db()->getNullDate(); } return self::$val; }
/** */ public function save($update = false, $init = true) { /* @var SPdb $db */ $db =& SPFactory::db(); /* check nid */ if (!$update) { $c = 1; while ($c) { /* section name id has to be unique */ try { $db->select('COUNT(nid)', 'spdb_object', array('oType' => 'section', 'nid' => $this->nid)); $c = $db->loadResult(); if ($c > 0) { $this->nid = $this->nid . '_' . rand(0, 1000); } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } } } SPFactory::registry()->set('current_section', $this->id); $db->transaction(); parent::save(); /* case adding new section, define the default title field */ if (!$update && $init) { $field = SPFactory::Model('field', true); $fid = $field->saveNew(array('name' => 'Name', 'nid' => 'field_name', 'showIn' => 'both', 'fieldType' => 'inbox', 'enabled' => 1, 'required' => 1, 'editable' => 1, 'section' => $this->id, 'inSearch' => 1, 'searchMethod' => 'general', 'isFree' => 1, 'editLimit' => -1, 'withLabel' => 1)); $field = SPFactory::Model('field', true); $field->saveNew(array('name' => 'Category', 'nid' => 'field_category', 'showIn' => 'hidden', 'fieldType' => 'category', 'enabled' => 1, 'required' => 1, 'editable' => 1, 'section' => $this->id, 'inSearch' => 1, 'searchMethod' => 'select', 'isFree' => 1, 'editLimit' => -1, 'withLabel' => 1, 'method' => 'select', 'isPrimary' => true)); SPFactory::config()->saveCfg('entry.name_field', $fid)->saveCfg('list.entries_ordering', 'field_name')->saveCfg('template.icon_fonts_arr', array('font-awesome-3-local')); SPFactory::Controller('acl', true)->addNewRule($this->get('name'), array($this->id), array('section.access.valid', 'category.access.valid', 'entry.access.valid', 'entry.add.own', 'section.search.*'), array('visitor', 'registered'), 'Default permissions for the section "' . $this->get('name') . '"'); } /* insert relation */ try { $db->insertUpdate('spdb_relations', array('id' => $this->id, 'pid' => 0, 'oType' => 'section', 'position' => 1, 'validSince' => $this->validSince, 'validUntil' => $this->validUntil)); } catch (SPException $x) { $db->rollback(); Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } /* if there was no errors, commit the database changes */ $db->commit(); // if( !$update ) { // SPFactory::mainframe()->msg( Sobi::Txt( 'SEC.CREATED' ) ); // } SPFactory::cache()->cleanSection(); /* trigger plugins */ Sobi::Trigger('afterSave', $this->name(), array(&$this)); }
public function save($attr) { /* @var SPdb $db */ $db = SPFactory::db(); $base = $attr; $this->loadType(); /* clean input */ if (isset($attr['name'])) { $base['name'] = $db->escape($attr['name']); } else { $base['name'] = 'missing name - something went wrong'; } if (isset($attr['nid'])) { $base['nid'] = $this->nid($db->escape(preg_replace('/[^[:alnum:]\\-\\_]/', null, $attr['nid'])), false); } if (isset($attr['cssClass'])) { $base['cssClass'] = $db->escape(preg_replace('/[^[:alnum:]\\-\\_ ]/', null, $attr['cssClass'])); } if (isset($attr['notice'])) { $base['notice'] = $attr['notice']; } if (isset($attr['showIn'])) { $base['showIn'] = $db->escape(preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['showIn'])); } if (isset($attr['filter'])) { $base['filter'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['filter']); } if (isset($attr['fieldType'])) { $base['fieldType'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['fieldType']); } if (isset($attr['type'])) { $base['fieldType'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['type']); } if (isset($attr['enabled'])) { $base['enabled'] = (int) $attr['enabled']; } if (isset($attr['required'])) { $base['required'] = (int) $attr['required']; } if (isset($attr['adminField'])) { $base['adminField'] = (int) $attr['adminField']; } if ($attr['adminField']) { $attr['required'] = false; } if (isset($attr['editable'])) { $base['editable'] = (int) $attr['editable']; } if (isset($attr['inSearch'])) { $base['inSearch'] = (int) $attr['inSearch']; } if (isset($attr['editLimit'])) { $base['editLimit'] = (int) $attr['editLimit']; } $base['editLimit'] = isset($base['editLimit']) && $base['editLimit'] > 0 ? $base['editLimit'] : -1; if (isset($attr['isFree'])) { $base['isFree'] = (int) $attr['isFree']; } if (isset($attr['withLabel'])) { $base['withLabel'] = (int) $attr['withLabel']; } if (isset($attr['fee'])) { $base['fee'] = (double) str_replace(',', '.', $attr['fee']); } if (isset($attr['addToMetaDesc'])) { $base['addToMetaDesc'] = (int) $attr['addToMetaDesc']; } if (isset($attr['addToMetaKeys'])) { $base['addToMetaKeys'] = (int) $attr['addToMetaKeys']; } if (isset($attr['uniqueData'])) { $base['uniqueData'] = (int) $attr['uniqueData']; } /* both strpos are removed because it does not allow to have one parameter only */ // if( isset( $attr[ 'allowedAttributes' ] ) && strpos( $attr[ 'allowedAttributes' ], '|' ) ) if (isset($attr['allowedAttributes'])) { $att = SPFactory::config()->structuralData($attr['allowedAttributes'], true); if (count($att)) { foreach ($att as $i => $k) { $att[$i] = trim($k); } } $base['allowedAttributes'] = SPConfig::serialize($att); } if (isset($attr['allowedTags'])) { $tags = SPFactory::config()->structuralData($attr['allowedTags'], true); if (count($tags)) { foreach ($tags as $i => $k) { $tags[$i] = trim($k); } } $base['allowedTags'] = SPConfig::serialize($tags); } if (isset($attr['admList'])) { $base['admList'] = (int) $attr['admList']; } if (isset($attr['description'])) { $base['description'] = $attr['description']; } else { $base['description'] = null; } if (isset($attr['suffix'])) { $base['suffix'] = $db->escape($attr['suffix']); } else { $base['suffix'] = null; } $this->version++; $base['version'] = $this->version; /* section id is needed only if it was new field */ if (!(isset($attr['section']) && $attr['section'])) { if (!SPRequest::int('fid')) { $base['section'] = SPRequest::sid(); } } /* bind attributes to this object */ foreach ($attr as $a => $v) { $a = trim($a); if ($this->has($a)) { $this->{$a} = $v; } } if ($this->_type && method_exists($this->_type, 'save')) { $this->_type->save($base); } /* get database columns and their ordering */ $cols = $db->getColumns('spdb_field'); $values = array(); /* and sort the properties in the same order */ foreach ($cols as $col) { if (array_key_exists($col, $base)) { $values[$col] = $base[$col]; } } /* save field */ try { $db->update('spdb_field', $values, array('fid' => $this->fid)); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } /* save language dependent properties */ $labels = array(); $defLabels = array(); $labels[] = array('sKey' => 'name', 'sValue' => $base['name'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid); $labels[] = array('sKey' => 'description', 'sValue' => $base['description'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid); $labels[] = array('sKey' => 'suffix', 'sValue' => $base['suffix'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid); if (Sobi::Lang() != Sobi::DefLang()) { $defLabels[] = array('sKey' => 'name', 'sValue' => $base['name'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid); $defLabels[] = array('sKey' => 'suffix', 'sValue' => $base['suffix'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid); $defLabels[] = array('sKey' => 'description', 'sValue' => $base['description'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid); } if (count($labels)) { try { if (Sobi::Lang() != Sobi::DefLang()) { $db->insertArray('spdb_language', $defLabels, false, true); } $db->insertArray('spdb_language', $labels, true); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELD_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } } SPFactory::cache()->cleanSection(); }
/** */ private function editForm() { $sid = SPRequest::int('pid'); $sid = $sid ? $sid : SPRequest::sid(); $view = SPFactory::View('entry', true); $this->checkTranslation(); /* if adding new */ if (!$this->_model) { $this->setModel(SPLoader::loadModel('entry')); } $this->_model->formatDatesToEdit(); $id = $this->_model->get('id'); if (!$id) { $this->_model->set('state', 1); $this->_model->set('approved', 1); } else { $view->assign($view->languages(), 'languages-list'); } $this->_model->loadFields(Sobi::Reg('current_section'), true); $this->_model->formatDatesToEdit(); if ($this->_model->isCheckedOut()) { SPFactory::message()->error(Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), false); } else { /* check out the model */ $this->_model->checkOut(); } /* get fields for this section */ /* @var SPEntry $this ->_model */ $fields = $this->_model->get('fields'); if (!count($fields)) { throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section'))); } $revisionChange = false; $rev = SPRequest::cmd('revision'); $revisionsDelta = array(); if ($rev) { $revision = SPFactory::message()->getRevision(SPRequest::cmd('revision')); if (isset($revision['changes']) && count($revision['changes'])) { SPFactory::message()->warning(Sobi::Txt('HISTORY_REVISION_WARNING', $revision['changedAt']), false); foreach ($fields as $i => $field) { if ($field->get('enabled') && $field->enabled('form')) { if (isset($revision['changes']['fields'][$field->get('nid')])) { $revisionData = $revision['changes']['fields'][$field->get('nid')]; } else { $revisionData = null; } $currentData = $field->getRaw(); if (is_array($revisionData) && !is_array($currentData)) { try { $currentData = SPConfig::unserialize($currentData); } catch (SPException $x) { } } if ($revisionData || $currentData) { if (md5(serialize($currentData)) != md5(serialize($revisionData))) { $field->revisionChanged()->setRawData($revisionData); } } $fields[$i] = $field; } } unset($revision['changes']['fields']); foreach ($revision['changes'] as $attr => $value) { if ($value != $this->_model->get($attr)) { $revisionsDelta[$attr] = $value; $this->_model->setRevData($attr, $value); } } $revisionChange = true; } else { SPFactory::message()->error(Sobi::Txt('HISTORY_REVISION_NOT_FOUND'), false)->setSystemMessage(); } } $f = array(); foreach ($fields as $field) { if ($field->get('enabled') && $field->enabled('form')) { $f[] = $field; } } /* create the validation script to check if required fields are filled in and the filters, if any, match */ $this->createValidationScript($fields); $view->assign($this->_model, 'entry'); /* get the categories */ $cats = $this->_model->getCategories(true); if (count($cats)) { $tCats = array(); foreach ($cats as $cid) { /* ROTFL ... damn I like arrays ;-) */ $tCats2 = SPFactory::config()->getParentPath($cid, true); if (is_array($tCats2) && count($tCats2)) { $tCats[] = implode(Sobi::Cfg('string.path_separator'), $tCats2); } } if (count($tCats)) { $view->assign(implode("\n", $tCats), 'parent_path'); } $view->assign(implode(", ", $cats), 'parents'); } elseif ($this->_model->get('valid')) { $parent = $sid == Sobi::Reg('current_section') ? 0 : $sid; if ($parent) { $view->assign(implode(Sobi::Cfg('string.path_separator', ' > '), SPFactory::config()->getParentPath($parent, true)), 'parent_path'); } $view->assign($parent, 'parents'); } else { $n = null; $view->assign($n, 'parents'); $view->assign($n, 'parent_path'); } $history = array(); $messages = SPFactory::message()->getHistory($id); if (count($messages)) { foreach ($messages as $message) { $message['change'] = Sobi::Txt('HISTORY_CHANGE_TYPE_' . str_replace('-', '_', strtoupper($message['change']))); $message['site'] = Sobi::Txt('HISTORY_CHANGE_AREA_' . strtoupper($message['site'])); if (strlen($message['reason'])) { $message['status'] = 1; } else { $message['status'] = 0; } $history[] = $message; } } $versioningAdminBehaviour = Sobi::Cfg('entry.versioningAdminBehaviour', 1); if ($versioningAdminBehaviour || !Sobi::Cfg('entry.versioning', true)) { SPFactory::header()->addJsCode(' SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( "[rel=\'entry.saveWithRevision\']" ).parent().css( "display", "none" ); } ); '); } $view->assign($this->_task, 'task')->assign($f, 'fields')->assign($id, 'id')->assign($history, 'history')->assign($revisionChange, 'revision-change')->assign($revisionsDelta, 'revision')->assign($versioningAdminBehaviour, 'history-behaviour')->assign(SPFactory::CmsHelper()->userSelect('entry.owner', $this->_model->get('owner') ? $this->_model->get('owner') : ($this->_model->get('id') ? 0 : Sobi::My('id')), true), 'owner')->assign(Sobi::Reg('current_section'), 'sid')->determineTemplate('entry', 'edit')->addHidden($rev, 'revision')->addHidden($sid, 'pid'); $view->display(); }
/** */ protected function view($allEntries, $term = null) { if ($allEntries) { SPRequest::set('task', 'section.entries'); } else { SPRequest::set('task', 'section.view'); } /* @var SPdb $db */ $db = SPFactory::db(); $c = array(); $e = array(); if (!Sobi::Section()) { Sobi::Error('Section', SPLang::e('Missing section identifier'), SPC::ERROR, 500, __LINE__, __FILE__); } $this->_model->init(Sobi::Section()); /* get the lists ordering and limits */ $eLimit = Sobi::GetUserState('entries.limit', 'elimit', Sobi::Cfg('admin.entries-limit', 25)); $cLimit = Sobi::GetUserState('categories.limit', 'climit', Sobi::Cfg('admin.categories-limit', 15)); $eLimStart = SPRequest::int('eSite', 0); $cLimStart = SPRequest::int('cSite', 0); /* get child categories and entries */ /* @todo: need better method - the query can be very large with lot of entries */ if (!$allEntries) { $e = $this->_model->getChilds(); $c = $this->_model->getChilds('category'); } elseif (!($term && $allEntries)) { $c = $this->_model->getChilds('category', true); $c[] = Sobi::Section(); if (count($c)) { try { $e1 = $db->dselect('id', 'spdb_relations', array('pid' => $c, 'oType' => 'entry'))->loadResultArray(); $e2 = $db->dselect('sid', 'spdb_field_data', array('section' => Sobi::Section(), 'fid' => Sobi::Cfg('entry.name_field')))->loadResultArray(); $e = array_merge($e1, $e2); $e = array_unique($e); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } } } else { try { $e = $db->dselect('sid', 'spdb_field_data', array('section' => Sobi::Section(), 'fid' => Sobi::Cfg('entry.name_field'), 'baseData' => "%{$term}%"))->loadResultArray(); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } } // just in case the given site is grater than all existing sites $cCount = count($c); $cPages = ceil($cCount / $cLimit); if ($cLimStart > $cPages) { $cLimStart = $cPages; SPRequest::set('cSite', $cPages); } $eCount = count($e); $ePages = ceil($eCount / $eLimit); if ($eLimStart > $ePages) { $eLimStart = $ePages; SPRequest::set('eSite', $ePages); } $entries = array(); $categories = array(); /* if there are entries in the root */ if (count($e)) { try { $Limit = $eLimit > 0 ? $eLimit : 0; $LimStart = $eLimStart ? ($eLimStart - 1) * $eLimit : $eLimStart; $eOrder = $this->parseOrdering('entries', 'eorder', 'position.asc', $Limit, $LimStart, $e); $results = $db->select('id', 'spdb_object', array('id' => $e, 'oType' => 'entry'), $eOrder, $Limit, $LimStart)->loadResultArray(); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } foreach ($results as $i => $entry) { $entries[$i] = $entry; } } /* if there are categories in the root */ if (count($c)) { try { $LimStart = $cLimStart ? ($cLimStart - 1) * $cLimit : $cLimStart; $Limit = $cLimit > 0 ? $cLimit : 0; $cOrder = $this->parseOrdering('categories', 'corder', 'order.asc', $Limit, $LimStart, $c); $results = $db->select('id', 'spdb_object', array('id' => $c, 'oType' => 'category'), $cOrder, $Limit, $LimStart)->loadResultArray(); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } foreach ($results as $i => $category) { $categories[$i] = SPFactory::Category($category); } } /* create menu */ $mClass = SPLoader::loadClass('views.adm.menu'); $menu = new $mClass('section.' . $this->_task, Sobi::Section()); /* load the menu definition */ $cfg = SPLoader::loadIniFile('etc.adm.section_menu'); Sobi::Trigger('Create', 'AdmMenu', array(&$cfg)); if (count($cfg)) { foreach ($cfg as $section => $keys) { $menu->addSection($section, $keys); } } Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu)); /* create new SigsiuTree */ $tree = SPLoader::loadClass('mlo.tree'); $tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'order.asc')); /* set link */ $tree->setHref(Sobi::Url(array('sid' => '{sid}'))); $tree->setId('menuTree'); /* set the task to expand the tree */ $tree->setTask('category.expand'); $tree->init(Sobi::Reg('current_section')); /* add the tree into the menu */ $menu->addCustom('AMN.ENT_CAT', $tree->getTree()); $entriesName = SPFactory::config()->nameField()->get('name'); $entriesField = SPFactory::config()->nameField()->get('nid'); $view = SPFactory::View('section', true); $view->assign($entriesName, 'entries_name')->assign($entriesField, 'entries_field')->assign($eLimit, 'entries-limit')->assign($cLimit, 'categories-limit')->assign(SPRequest::int('eSite', 1), 'entries-site')->assign(SPRequest::int('cSite', 1), 'categories-site')->assign($cCount, 'categories-count')->assign($eCount, 'entries-count')->assign($this->_task, 'task')->assign($term, 'filter')->assign($this->customCols(), 'fields')->assign($this->_model, 'section')->assign($categories, 'categories')->assign($entries, 'entries')->assign(SPFactory::config()->nameField()->get('name'), 'entries_name')->assign($menu, 'menu')->assign(Sobi::GetUserState('entries.eorder', 'eorder', 'order.asc'), 'ordering')->assign(Sobi::GetUserState('categories.corder', 'corder', 'order.asc'), 'corder')->assign(Sobi::Section(true), 'category')->addHidden(Sobi::Section(), 'pid')->addHidden(SPRequest::sid(), 'sid'); Sobi::Trigger('Section', 'View', array(&$view)); $view->display(); }
/** * Creates syntax to check the expiration date, state, and start publishing date off an row * @param string $until - row name where the expiration date is stored * @param string $since - row name where the start date is stored * @param string $pub - row name where the state is stored (e.g. 'published') * @param array $exception * @return string */ public function valid($until, $since = null, $pub = null, $exception = null) { $null = $this->getNullDate(); $pub = $pub ? " AND {$pub} = 1 " : null; $stamp = date(SPFactory::config()->key('date.db_format', 'Y-m-d H:i:s'), 0); if ($since) { // $since = "AND ( {$since} < '{$now}' OR {$since} IN( '{$null}', '{$stamp}' ) ) "; $since = "AND ( {$since} < NOW() OR {$since} IN( '{$null}', '{$stamp}' ) ) "; } if ($exception && is_array($exception)) { $ex = array(); foreach ($exception as $subject => $value) { $ex[] = "{$subject} = '{$value}'"; } $exception = implode('OR', $ex); $exception = 'OR ' . $exception; } // return " ( ( {$until} > '{$now}' OR {$until} IN ( '{$null}', '{$stamp}' ) ) {$since} {$pub} ) "; return "( ( {$until} > NOW() OR {$until} IN ( '{$null}', '{$stamp}' ) ) {$since} {$pub} ) {$exception} "; }
/** * @param int $id * @param bool $parents * @param bool $last * @param int $offset * @return array */ protected function parentPath($id, $parents = false, $last = false, $offset = 2) { static $pathArray = null; $path = null; if (!$pathArray) { $pathArray = SPFactory::config()->getParentPath($id, true, $parents); } if (!$last) { if (is_array($pathArray)) { // if ( strstr( $this->get( 'task' ), 'edit' ) ) { // unset( $path[ count( $path ) - 1 ] ); // } $path = implode(Sobi::Cfg('string.path_separator', ' > '), $pathArray); } } else { if (is_array($pathArray) && isset($pathArray[count($pathArray) - $offset])) { $path = $pathArray[count($pathArray) - $offset]; } } return SPLang::clean($path); }
private function _jsFiles() { if (Sobi::Cfg('cache.include_js_files', false) && !defined('SOBIPRO_ADM')) { if (count($this->_cache['js'])) { $compression = Sobi::Cfg('cache.compress_js', false); $comprLevel = Sobi::Cfg('cache.compress_level', 0); $check = array('section' => Sobi::Section(), 'compress_level' => $comprLevel, 'compress_js' => $compression); foreach ($this->_cache['js'] as $file) { $check[$file] = filemtime($file); } $check = md5(serialize($check)); if (!SPFs::exists(SOBI_PATH . "/var/js/{$check}.js")) { $noCompress = explode(',', Sobi::Cfg('cache.js_compress_exceptions')); $jsContent = "\n/* Created at: " . date(SPFactory::config()->key('date.log_format', 'D M j G:i:s T Y')) . " */\n"; foreach ($this->_cache['js'] as $file) { $fName = str_replace(SOBI_ROOT, null, $file); $jsContent .= "\n// ========\n// File: {$fName}\n// ========\n\n"; if ($compression && !in_array(basename($file), $noCompress)) { $compressor = SPFactory::Instance('env.jspacker', SPFs::read($file), $comprLevel, false, true); $jsContent .= $compressor->pack(); } else { $jsContent .= SPFs::read($file); } $jsContent .= ";\n"; } SPFs::write(SOBI_PATH . "/var/js/{$check}.js", $jsContent); } $cfile = SPLoader::JsFile('front.var.js.' . $check, false, true, true); $this->jsFiles[++$this->count] = "\n<script type=\"text/javascript\" src=\"{$cfile}\"></script>"; } } return $this->jsFiles; }
private function download() { // $file = SPLoader::path( 'tmp.info', 'front', false, 'txt' ); $cont = null; $settings = array(); $settings['SobiPro'] = array('Version' => SPFactory::CmsHelper()->myVersion(true), 'Version_Num' => implode('.', SPFactory::CmsHelper()->myVersion())); $file = SPLoader::path('tmp.info', 'front', false, 'txt'); // if ( SPFs::exists( $file ) ) { // $cont = SPFs::read( $file ); // } // $cont = explode( "\n", $cont ); // if ( count( $cont ) ) { // foreach ( $cont as $line ) { // if ( strstr( $line, '=' ) ) { // $line = explode( "=", $line ); // $line[ 1 ] = explode( ';', $line[ 1 ] ); // $settings[ $line[ 0 ] ] = array( 'key' => $line[ 0 ], 'response' => $line[ 1 ][ 0 ], 'status' => $line[ 1 ][ 1 ] ); // } // } // } $this->prepareStoredData($settings); $settings['env'] = array('PHP_OS' => PHP_OS, 'php_uname' => php_uname(), 'PHP_VERSION_ID' => PHP_VERSION_ID); $settings['ftp'] = $this->ftp(); $settings['curl'] = $this->curlFull(); $settings['exec']['response'] = $this->execResp(); $settings['SOBI_SETTINGS'] = SPFactory::config()->getSettings(); $c = SPFactory::db()->select('*', 'spdb_config')->loadObjectList(); $sections = SPFactory::db()->select(array('nid', 'id'), 'spdb_object', array('oType' => 'section'))->loadAssocList('id'); $as = array(); foreach ($c as $key) { if ($key->section == 0 || !isset($sections[$key->section])) { continue; } $key->section = $sections[$key->section]['nid']; if (!isset($as[$key->section])) { $as[$key->section] = array(); } if (!isset($as[$key->section][$key->cSection])) { $as[$key->section][$key->cSection] = array(); } $_c = explode('_', $key->sKey); if ($_c[count($_c) - 1] == 'array') { $key->sValue = SPConfig::unserialize($key->sValue); } $as[$key->section][$key->cSection][$key->sKey] = $key->sValue; } $settings['SOBI_SETTINGS']['sections'] = $as; $apps = SPFactory::db()->select('*', 'spdb_plugins')->loadObjectList(); foreach ($apps as $app) { $settings['Apps'][$app->pid] = get_object_vars($app); } $settings['SOBI_SETTINGS']['mail']['smtphost'] = $settings['SOBI_SETTINGS']['mail']['smtphost'] ? 'SET' : 0; $settings['SOBI_SETTINGS']['mail']['smtpuser'] = $settings['SOBI_SETTINGS']['mail']['smtpuser'] ? 'SET' : 0; $settings['SOBI_SETTINGS']['mail']['smtppass'] = $settings['SOBI_SETTINGS']['mail']['smtppass'] ? 'SET' : 0; $php = ini_get_all(); unset($php['extension_dir']); unset($php['include_path']); unset($php['mysql.default_user']); unset($php['mysql.default_password']); unset($php['mysqli.default_pw']); unset($php['mysqli.default_user']); unset($php['open_basedir']); unset($php['pdo_mysql.default_socket']); unset($php['sendmail_path']); unset($php['session.name']); unset($php['session.save_path']); unset($php['soap.wsdl_cache_dir']); unset($php['upload_tmp_dir']); unset($php['doc_root']); unset($php['docref_ext']); unset($php['docref_root']); unset($php['mysql.default_socket']); $settings['PHP_SETTINGS'] = $php; $php = get_loaded_extensions(); $settings['PHP_EXT'] = $php; $out = SPFactory::Instance('types.array'); $data = $out->toXML($settings, 'settings'); $data = str_replace(array(SOBI_ROOT, '></'), array('REMOVED', '>0</'), $data); $f = SPLang::nid($settings['SOBI_SETTINGS']['general']['site_name'] . '-' . date(DATE_RFC822)); SPFactory::mainframe()->cleanBuffer(); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); header("Content-type: application/xml"); header("Content-Disposition: attachment; filename=\"sobipro_system_{$f}.xml\""); header('Content-Length: ' . strlen($data)); ob_clean(); flush(); echo $data; exit; }
protected function saveDefaultOrdering() { $target = SPRequest::cmd('target'); $order = Sobi::GetUserState($target . '.order', null); $saved = false; if (strlen($order)) { SPFactory::config()->saveCfg('admin.' . $target . '-order', $order); $saved = true; } $limit = Sobi::GetUserState($target . '.limit', 10); if ($limit) { SPFactory::config()->saveCfg('admin.' . $target . '-limit', $limit); $saved = true; } if ($saved) { $this->response(Sobi::Back(), Sobi::Txt('MSG_DEFAULT_ORDERING_SAVED'), false); } }
protected function fixTimes(&$data) { $fix = array('valid_since', 'valid_until', 'updated_time', 'created_time'); static $offset = null; if ($offset === null) { $offset = SPFactory::config()->getTimeOffset(); } foreach ($fix as $index) { $timestamp = strtotime($data[$index] . 'UTC'); if (!$data[$index]) { continue; } $data[$index] = array('_complex' => 1, '_data' => gmdate(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $timestamp + $offset), '_attributes' => array('UTC' => $data[$index], 'timestamp' => $timestamp, 'offset' => $offset, 'timezone' => Sobi::Cfg('time_offset'))); } }
/** */ private function editForm() { if ($this->_task != 'add') { $sid = SPRequest::sid(); $sid = $sid ? $sid : SPRequest::int('pid'); } else { $this->authorise($this->_task, 'own'); $this->_model = null; $sid = SPRequest::int('pid'); // $section = SPFactory::Section( Sobi::Section() ); } if ($this->_model && $this->_model->isCheckedOut()) { Sobi::Redirect(Sobi::Url(array('sid' => SPRequest::sid())), Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), SPC::ERROR_MSG, true); } /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); /* load template config */ $this->template(); $this->tplCfg($tplPackage); /* check if we have stored last edit in cache */ $this->getCache(SPRequest::string('editentry', null, false, 'cookie'), 'editcache'); $section = SPFactory::Model('section'); $section->init(Sobi::Section()); SPFactory::cache()->setJoomlaCaching(false); if ($this->_model) { /* handle meta data */ SPFactory::header()->objMeta($this->_model); /* add pathway */ SPFactory::mainframe()->addObjToPathway($this->_model); } else { /* handle meta data */ SPFactory::header()->objMeta($section); if ($this->_task == 'add') { SPFactory::header()->addKeyword($section->get('efMetaKeys'))->addDescription($section->get('efMetaDesc')); } SPFactory::mainframe()->addToPathway(Sobi::Txt('EN.ADD_PATH_TITLE'), Sobi::Url('current')); SPFactory::mainframe()->setTitle(Sobi::Txt('EN.ADD_TITLE', array('section' => $section->get('name')))); /* add pathway */ SPFactory::mainframe()->addObjToPathway($section); $this->setModel(SPLoader::loadModel('entry')); } $this->_model->formatDatesToEdit(); $id = $this->_model->get('id'); if (!$id) { $this->_model->set('state', 1); } if ($this->_task != 'add' && !$this->authorise($this->_task, $this->_model->get('owner') == Sobi::My('id') ? 'own' : '*')) { throw new SPException(SPLang::e('YOU_ARE_NOT_AUTH_TO_EDIT_THIS_ENTRY')); } $this->_model->loadFields(Sobi::Reg('current_section')); /* get fields for this section */ $fields = $this->_model->get('fields'); if (!count($fields)) { throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section'))); } /* create the validation script to check if required fields are filled in and the filters, if any, match */ $this->createValidationScript($fields); /* check out the model */ $this->_model->checkOut(); $class = SPLoader::loadView('entry'); $view = new $class($this->template); $view->assign($this->_model, 'entry'); $cache = Sobi::Reg('editcache'); /* get the categories */ if (isset($cache) && isset($cache['entry_parent'])) { $cats = explode(',', $cache['entry_parent']); } else { $cats = $this->_model->getCategories(true); } if (count($cats)) { $tCats = array(); foreach ($cats as $cid) { $tCats2 = SPFactory::config()->getParentPath((int) $cid, true); if (is_array($tCats2) && count($tCats2)) { $tCats[] = implode(Sobi::Cfg('string.path_separator', ' > '), $tCats2); } } if (count($tCats)) { $view->assign(implode("\n", $tCats), 'parent_path'); } $view->assign(implode(", ", $cats), 'parents'); } else { $parent = $sid == Sobi::Reg('current_section') ? 0 : $sid; if ($parent) { $view->assign(implode(Sobi::Cfg('string.path_separator', ' > '), SPFactory::config()->getParentPath($parent, true)), 'parent_path'); } $view->assign($parent, 'parents'); } $view->assign($this->_task, 'task'); $view->assign($fields, 'fields'); $view->assign($id, 'id'); $view->assign($id, 'sid'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . ($this->template == 'add' ? 'edit' : $this->template)); $view->addHidden($sid ? $sid : SPRequest::sid(), 'pid'); $view->addHidden($id, 'sid'); $view->addHidden(SPRequest::int('pid') && SPRequest::int('pid') != $id ? SPRequest::int('pid') : Sobi::Section(), 'pid'); $view->addHidden('entry.submit', SOBI_TASK); Sobi::Trigger($this->name(), __FUNCTION__, array(&$view)); $view->display(); }
/** * @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 mixed $attr * @param int $index * @return mixed */ public function &get($attr, $index = -1) { $config = SPFactory::config(); if (!$config->key($attr, false)) { return parent::get($attr, $index); } else { $value = $config->key($attr); // WHY?! For gods' sake - write comments to your code you fraking idiot!!!! // Tue, Jun 4, 2013 15:21:19 : got that - we have some arrays that have to be displayed as a string while editing config // see also bug #894 // if ( is_array( $attr ) ) { // $attr = implode( ',', $attr ); // } // ... let's fix it ;) if (is_array($value) && strstr($attr, '_array')) { $value = implode(',', $value); } return $value; } }
public function getEntries($eLimit, $site, $ids = false) { $conditions = array(); $entries = array(); /* get the site to display */ $eLimStart = ($site - 1) * $eLimit; if (isset($this->_letter[1]) && $this->_letter[1] == '-') { $this->_letter = "[{$this->_letter[0]}-{$this->_letter[2]}]"; } $db = SPFactory::db(); /* * Don't know exactly why but on Windows servers there seems to be some problem with unicode chars * - strtolower/strtoupper is destroying these chars completely * - MySQL seems to be suddenly case sensitive with non-latin chars so we need to ask both * * Wed, Apr 4, 2012: Apparently it's not only Windows related */ if (!preg_match('/^[\\x20-\\x7f]*$/D', $this->_letter) && function_exists('mb_strtolower')) { // if we have multibyte string support - ask both cases ... $baseCondition = "REGEXP:^{$this->_letter}|^" . mb_strtoupper($this->_letter); } else { // if no unicode - great, it'll work. // if we don't have MB - shit happens $baseCondition = "REGEXP:^{$this->_letter}"; } switch ($this->_fieldType) { case 'chbxgroup': case 'select': case 'multiselect': $eOrder = 'sValue'; $table = $db->join(array(array('table' => 'spdb_field_option_selected', 'as' => 'opts'), array('table' => 'spdb_language', 'as' => 'lang', 'key' => array('opts.optValue', 'lang.sKey')), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('opts.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('opts.sid', 'sprl.id')))); $oPrefix = 'spo.'; $conditions['spo.oType'] = 'entry'; $conditions['opts.fid'] = $this->_field; $conditions['lang.sValue'] = $baseCondition; break; default: $eOrder = 'baseData'; $table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id')))); $oPrefix = 'spo.'; $conditions['spo.oType'] = 'entry'; $conditions['fdef.fid'] = $this->_field; $conditions['fdata.baseData'] = $baseCondition; break; } $this->_field = $this->_field ? $this->_field : Sobi::Cfg('alphamenu.primary_field', SPFactory::config()->nameField()->get('id')); /* check user permissions for the visibility */ if (Sobi::My('id')) { $this->userPermissionsQuery($conditions, $oPrefix); } else { $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince'))); } $conditions['sprl.copy'] = '0'; try { $db->select($oPrefix . 'id', $table, $conditions, $eOrder, $eLimit, $eLimStart, true); $results = $db->loadResultArray(); } catch (SPException $x) { Sobi::Error('AlphaListing', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } if ($ids) { Sobi::SetUserData('currently-displayed-entries', $results); return $results; } if (count($results)) { foreach ($results as $i => $sid) { // it needs too much memory moving the object creation to the view //$entries[ $i ] = SPFactory::Entry( $sid ); $entries[$i] = $sid; } } Sobi::Trigger($this->name(), 'AfterGetEntries', array(&$entries, false)); return $entries; }
/** * @param string $eOrder * @param int $eLimit * @param int $eLimStart * @param bool $count * @param array $conditions * @param bool $entriesRecursive * @param int $pid * @return array */ public function getEntries($eOrder, $eLimit = null, $eLimStart = null, $count = false, $conditions = array(), $entriesRecursive = false, $pid = 0) { /* var SPDb $db */ $db = SPFactory::db(); $entries = array(); $eDir = 'asc'; $oPrefix = null; $conditions = is_array($conditions) ? $conditions : array(); /* get the ordering and the direction */ if (strstr($eOrder, '.')) { $eOr = explode('.', $eOrder); $eOrder = array_shift($eOr); $eDir = implode('.', $eOr); } $pid = $pid ? $pid : SPRequest::sid(); /* if sort by name, then sort by the name field */ if ($eOrder == 'name') { $eOrder = SPFactory::config()->nameField()->get('fid'); } if ($entriesRecursive) { $pids = $this->_model->getChilds('category', true); if (is_array($pids)) { $pids = array_keys($pids); } $pids[] = SPRequest::sid(); $conditions['sprl.pid'] = $pids; } else { $conditions['sprl.pid'] = $pid; } if ($pid == -1) { unset($conditions['sprl.pid']); } /* sort by field */ if (strstr($eOrder, 'field_')) { static $field = null; $specificMethod = false; if (!$field) { try { $fType = $db->select('fieldType', 'spdb_field', array('nid' => $eOrder, 'section' => Sobi::Section()))->loadResult(); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } if ($fType) { $field = SPLoader::loadClass('opt.fields.' . $fType); } } if ($field && method_exists($field, 'customOrdering')) { $table = null; $oPrefix = null; $specificMethod = call_user_func_array(array($field, 'customOrdering'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir)); } elseif ($field && method_exists($field, 'sortBy')) { $table = null; $oPrefix = null; $specificMethod = call_user_func_array(array($field, 'sortBy'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir)); } if (!$specificMethod) { $table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id')))); $oPrefix = 'spo.'; $conditions['spo.oType'] = 'entry'; $conditions['fdef.nid'] = $eOrder; $eOrder = 'baseData.' . $eDir; } } elseif (strstr($eOrder, 'counter')) { $table = $db->join(array(array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id'), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('spo.id', 'sprl.id')), array('table' => 'spdb_counter', 'as' => 'spcounter', 'key' => array('spo.id', 'spcounter.sid')))); $oPrefix = 'spo.'; $conditions['spo.oType'] = 'entry'; if (strstr($eOrder, '.')) { $cOrder = explode('.', $eOrder); $eOrder = 'spcounter.counter.' . $cOrder[1]; } else { $eOrder = 'spcounter.counter.desc'; } } else { $table = $db->join(array(array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id'))); $conditions['spo.oType'] = 'entry'; $eOrder = $eOrder . '.' . $eDir; $oPrefix = 'spo.'; if (strstr($eOrder, 'valid')) { $eOrder = $oPrefix . $eOrder; } } /* check user permissions for the visibility */ if (Sobi::My('id')) { $this->userPermissionsQuery($conditions, $oPrefix); if (isset($conditions[$oPrefix . 'state']) && $conditions[$oPrefix . 'state']) { $conditions['sprl.copy'] = 0; } } else { $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince'))); $conditions['sprl.copy'] = '0'; } try { $results = $db->select($oPrefix . 'id', $table, $conditions, $eOrder, $eLimit, $eLimStart, true)->loadResultArray(); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } Sobi::Trigger($this->name(), 'AfterGetEntries', array(&$results, $count)); if (count($results) && !$count) { foreach ($results as $i => $sid) { // it needs too much memory moving the object creation to the view //$entries[ $i ] = SPFactory::Entry( $sid ); $entries[$i] = $sid; } } if ($count) { Sobi::SetUserData('currently-displayed-entries', $results); return $results; } return $entries; }