本文整理汇总了PHP中SPLang::translateObject方法的典型用法代码示例。如果您正苦于以下问题:PHP SPLang::translateObject方法的具体用法?PHP SPLang::translateObject怎么用?PHP SPLang::translateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPLang
的用法示例。
在下文中一共展示了SPLang::translateObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategories
/**
* @param bool $arr
* @return array
*/
public function getCategories($arr = false)
{
if ($this->id) {
if (!count($this->categories)) {
/* @var SPdb $db */
$db = SPFactory::db();
/* get fields */
try {
$c = array('id' => $this->id, 'oType' => 'entry');
if (!($this->approved || (SPRequest::task() == 'entry.edit' || Sobi::Can('entry.access.unapproved_any')))) {
$c['copy'] = '0';
}
$db->select(array('pid', 'position', 'validSince', 'validUntil'), 'spdb_relations', $c, 'position');
$categories = $db->loadAssocList('pid');
/* validate categories - case some of them has been deleted */
$cats = array_keys($categories);
if (count($cats)) {
$cats = $db->select('id', 'spdb_object', array('id' => $cats))->loadResultArray();
}
if (count($categories)) {
foreach ($categories as $i => $c) {
if (!$this->parent) {
$this->parent = $i;
}
if (!in_array($i, $cats)) {
unset($categories[$i]);
}
}
}
/* push the main category to the top of this array */
if (isset($categories[$this->parent])) {
$main = $categories[$this->parent];
unset($categories[$this->parent]);
$this->categories[$this->parent] = $main;
}
foreach ($categories as $cid => $cat) {
$this->categories[$cid] = $cat;
}
if ($this->categories) {
$labels = SPLang::translateObject(array_keys($this->categories), array('name', 'alias'), 'category');
foreach ($labels as $t) {
$this->categories[$t['id']]['name'] = $t['value'];
$this->categories[$t['id']]['alias'] = $t['alias'];
}
}
Sobi::Trigger($this->name(), ucfirst(__FUNCTION__), array(&$this->categories));
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_GET_RELATIONS_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
if ($arr) {
return array_keys($this->categories);
} else {
return $this->categories;
}
} else {
return array();
}
}
示例2: __construct
/**
* @param string $task
*/
function __construct($task)
{
SPLoader::loadClass('base.exception');
set_error_handler('SPExceptionHandler');
$this->_err = ini_set('display_errors', 'on');
$this->_mem = memory_get_usage();
$this->_time = microtime();
$this->_task = $task;
/* load all needed classes */
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.object');
SPLoader::loadClass('base.const');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
SPLoader::loadClass('sobi');
SPLoader::loadClass('base.config');
/* authorise access */
$this->checkAccess();
/* initialise mainframe interface to CMS */
$this->_mainframe =& SPFactory::mainframe();
/* get sid if any */
$this->_sid = SPRequest::sid();
/* determine section */
$this->getSection();
/* initialise config */
$this->createConfig();
ini_set('display_errors', Sobi::Cfg('debug.display_errors', false));
$this->_deb = error_reporting(Sobi::Cfg('debug.level', 0));
/* trigger plugin */
Sobi::Trigger('AdminStart');
/* initialise translator and load language files */
SPLoader::loadClass('cms.base.lang');
SPLang::setLang(Sobi::Lang());
try {
SPLang::registerDomain('admin');
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
/* load admin html files */
SPFactory::header()->initBase(true);
/** @noinspection PhpParamsInspection */
if ($this->_section) {
$sectionName = SPLang::translateObject($this->_section, 'name', 'section');
SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value']));
}
if ($this->_section && !Sobi::Cfg('section.template')) {
SPFactory::config()->set('template', SPC::DEFAULT_TEMPLATE, 'section');
}
/* check if it wasn't plugin custom task */
if (!Sobi::Trigger('custom', 'task', array($this, SPRequest::task()))) {
/* if not, start to route */
try {
$this->route();
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
return true;
}
示例3: entryData
protected function entryData($getFields = true)
{
/** @var SPEntry $entry */
$entry = $this->get('entry');
$visitor = $this->get('visitor');
$data = array();
$data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
$en = array();
$en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
$en['created_time'] = $entry->get('createdTime');
$en['updated_time'] = $entry->get('updatedTime');
$en['valid_since'] = $entry->get('validSince');
$en['valid_until'] = $entry->get('validUntil');
$en['author'] = $entry->get('owner');
$en['counter'] = $entry->get('counter');
$en['approved'] = $entry->get('approved');
$this->fixTimes($en);
// $mytime = date( 'Y-m-d H:i:s', time());
if ($entry->get('state') == 0) {
$en['state'] = 'unpublished';
} else {
if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) {
$en['state'] = 'expired';
} elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) {
$en['state'] = 'pending';
} else {
$en['state'] = 'published';
}
}
$en['url'] = Sobi::Url(array('pid' => $entry->get('parent'), 'sid' => $entry->get('id'), 'title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name')), true, true, true);
if (Sobi::Can('entry', 'edit', '*') || Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own')) {
$en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'sid' => $entry->get('id')));
}
if (Sobi::Can('entry', 'manage', '*')) {
$en['approve_url'] = Sobi::Url(array('task' => $entry->get('approved') ? 'entry.unapprove' : 'entry.approve', 'sid' => $entry->get('id')));
}
if ($entry->get('owner') == Sobi::My('id') && Sobi::Can('entry', 'delete', 'own') || Sobi::Can('entry', 'delete', '*')) {
$en['delete_url'] = Sobi::Url(array('task' => 'entry.delete', 'sid' => $entry->get('id')));
}
if (Sobi::Can('entry', 'publish', '*') || Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'publish', 'own')) {
$en['publish_url'] = Sobi::Url(array('task' => $entry->get('state') ? 'entry.unpublish' : 'entry.publish', 'sid' => $entry->get('id')));
}
$cats = $entry->get('categories');
$categories = array();
if (count($cats)) {
$cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'), 'category');
}
$primaryCat = $entry->get('parent');
foreach ($cats as $cid => $cat) {
$cAttr = array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'alias' => $cat['alias'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name'])));
if ($cat['pid'] == $primaryCat) {
$cAttr['primary'] = 'true';
}
$categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => $cAttr);
}
$en['categories'] = $categories;
$en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots'));
if ($getFields) {
$fields = $entry->getFields();
if (count($fields)) {
$en['fields'] = $this->fieldStruct($fields, 'details');
}
}
$this->menu($data);
$this->alphaMenu($data);
$data['entry'] = array('_complex' => 1, '_data' => $en, '_attributes' => array('id' => $entry->get('id'), 'nid' => $entry->get('nid'), 'version' => $entry->get('version')));
$data['visitor'] = $this->visitorArray($visitor);
return $data;
}
示例4: entry
protected function entry($entry, $manager, $noId = false)
{
$en = array();
if (is_numeric($entry)) {
$en = $this->cachedEntry($entry, $manager, $noId);
}
if (!is_array($en) || !count($en)) {
if (is_numeric($entry)) {
$entry = SPFactory::Entry($entry);
}
$en['id'] = $entry->get('id');
$en['nid'] = $entry->get('nid');
$en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
$en['url_array'] = array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id'));
if (strstr(SPRequest::task(), 'search') || $noId || Sobi::Cfg('section.force_category_id', false) && SPRequest::sid() == Sobi::Section()) {
$en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id')));
} else {
$en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
}
if (Sobi::Cfg('list.entry_meta', true)) {
$en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots'));
}
if ($manager || Sobi::My('id') && Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own', Sobi::Section())) {
$en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
} else {
if (isset($en['edit_url'])) {
unset($en['edit_url']);
}
}
$en['edit_url_array'] = array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id'));
$en['created_time'] = $entry->get('createdTime');
$en['updated_time'] = $entry->get('updatedTime');
$en['valid_since'] = $entry->get('validSince');
$en['valid_until'] = $entry->get('validUntil');
$this->fixTimes($en);
if ($entry->get('state') == 0) {
$en['state'] = 'unpublished';
} else {
if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) {
$en['state'] = 'expired';
} elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) {
$en['state'] = 'pending';
} else {
$en['state'] = 'published';
}
}
$en['author'] = $entry->get('owner');
$en['counter'] = $entry->get('counter');
$en['approved'] = $entry->get('approved');
// $en[ 'confirmed' ] = $entry->get( 'confirmed' );
if (Sobi::Cfg('list.entry_cats', true)) {
$cats = $entry->get('categories');
$categories = array();
if (count($cats)) {
$cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'));
}
foreach ($cats as $cid => $cat) {
$categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name']))));
}
$en['categories'] = $categories;
}
$fields = $entry->getFields();
if (count($fields)) {
// foreach ( $fields as $field ) {
// if ( $field->enabled( 'vcard' ) && $field->get( 'id' ) != Sobi::Cfg( 'entry.name_field' ) ) {
// $struct = $field->struct();
// $options = null;
// if ( isset( $struct[ '_options' ] ) ) {
// $options = $struct[ '_options' ];
// unset( $struct[ '_options' ] );
// }
// $f[ $field->get( 'nid' ) ] = array(
// '_complex' => 1,
// '_data' => array(
// 'label' => array(
// '_complex' => 1,
// '_data' => $field->get( 'name' ),
// '_attributes' => array( 'lang' => Sobi::Lang( false ), 'show' => $field->get( 'withLabel' ) )
// ),
// 'data' => $struct,
// ),
// '_attributes' => array( 'id' => $field->get( 'id' ), 'type' => $field->get( 'type' ), 'suffix' => $field->get( 'suffix' ), 'position' => $field->get( 'position' ), 'css_class' => ( strlen( $field->get( 'cssClass' ) ) ? $field->get( 'cssClass' ) : 'spField' ) )
// );
// if ( Sobi::Cfg( 'list.field_description', false ) ) {
// $f[ $field->get( 'nid' ) ][ '_data' ][ 'description' ] = array( '_complex' => 1, '_xml' => 1, '_data' => $field->get( 'description' ) );
// }
// if ( $options ) {
// $f[ $field->get( 'nid' ) ][ '_data' ][ 'options' ] = $options;
// }
// if ( isset( $struct[ '_xml_out' ] ) && count( $struct[ '_xml_out' ] ) ) {
// foreach ( $struct[ '_xml_out' ] as $k => $v )
// $f[ $field->get( 'nid' ) ][ '_data' ][ $k ] = $v;
// }
// }
// }
$en['fields'] = $this->fieldStruct($fields, 'vcard');
}
SPFactory::cache()->addObj($entry, 'entry', $entry->get('id'))->addObj($en, 'entry_struct', $entry->get('id'));
unset($en['url_array']);
unset($en['edit_url_array']);
//.........这里部分代码省略.........
示例5: fetchElement
public function fetchElement($name, &$label)
{
$sid = $this->settings()->get('sid');
$this->oType = 'section';
switch ($name) {
case 'sid':
$params = array('id' => 'sid', 'size' => 5, 'class' => 'text_area', 'style' => 'text-align: center;', 'readonly' => 'readonly');
return SPHtml_Input::text('jform[params][sid]', $sid, $params);
break;
case 'tplFile':
case 'modalTemplate':
return $this->tplFile($this->settings()->get('tplFile'), $name == 'modalTemplate');
break;
case 'spOrder':
return $this->ordering($this->settings()->get('spOrder'));
break;
case 'spLimit':
return $this->limits($this->settings()->get('spLimit'));
break;
case 'cid':
if (!in_array($sid, array_keys($this->sections))) {
$catName = SPLang::translateObject($sid, array('name'));
if (isset($catName[$sid]['value'])) {
$this->oName = $catName[$sid]['value'];
$this->oType = 'category';
}
}
return $this->getCat();
break;
default:
$sections = array();
if (count($this->sections)) {
$sections[] = Sobi::Txt('SELECT_SECTION');
foreach ($this->sections as $section) {
if (Sobi::Can('section', 'access', 'valid', $section->id)) {
$s = SPFactory::Model('section');
$s->extend($section);
$sections[$s->get('id')] = $s->get('name');
}
}
}
$params = array('id' => 'spsection', 'class' => 'text_area required');
return SPHtml_Input::select('jform[params][section]', $sections, $this->settings()->get('section'), false, $params);
break;
}
}
示例6: sections
protected function sections()
{
$subMenu = array();
try {
$sections = SPFactory::db()->select('id', 'spdb_object', array('oType' => 'section'), 'id')->loadResultArray();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__);
}
$sectionLength = 30;
if (count($sections)) {
$sections = SPLang::translateObject($sections, 'name');
$subMenu = array();
foreach ($sections as $section) {
$subMenu[] = array('type' => 'url', 'task' => '', 'url' => array('sid' => $section['id']), 'label' => SPLang::clean(strlen($section['value']) < $sectionLength ? $section['value'] : substr($section['value'], 0, $sectionLength - 3) . ' ...'), 'icon' => 'file', 'element' => 'button');
}
}
return $subMenu;
}
示例7: getParentPath
/**
* Returns linked lists ( names or ids ) of parent elements to the given id
*
* @param int $id - the id of object
* @param bool $names - names or ids only
* @param bool $parents
* @param bool $join
* @return array
*/
public function getParentPath($id, $names = false, $parents = false, $join = false)
{
$db = SPFactory::db();
if (!is_numeric($id)) {
return false;
}
$ident = 'relations_path' . ($names ? '_names' : '') . ($parents ? '_parents' : '') . ($join ? '_join' : '');
$cached = SPFactory::cache()->getVar($ident, $id);
if ($cached) {
return $cached;
} else {
$cid = $id;
}
$path = $parents ? array() : array($id);
while ($id > 0) {
try {
// it doesn't make sense but it happened because of a bug in the SigsiuTree category selector
$id = $db->select('pid', 'spdb_relations', array('id' => $id, '!pid' => $id))->loadResult();
if ($id) {
$path[] = (int) $id;
}
} catch (SPException $x) {
Sobi::Error(__FUNCTION__, SPLang::e('CANNOT_GET_PARENT_ID', $x->getMessage()), SPC::WARNING, 500, __LINE__, __CLASS__);
}
}
if ($names && count($path)) {
$names = SPLang::translateObject($path, array('name', 'alias'), array('section', 'category', 'entry'));
if (is_array($names) && !empty($names)) {
foreach ($path as $i => $id) {
if ($join) {
$path[$i] = array('id' => $id, 'name' => $names[$id]['value'], 'alias' => $names[$id]['alias']);
} else {
$path[$i] = $names[$id]['value'];
}
}
}
}
$path = array_reverse($path);
SPFactory::cache()->addVar($path, $ident, $cid);
return $path;
}
示例8: tree
protected function tree()
{
$selector = null;
$selectedCategories = array();
$tree = SPFactory::Instance('mlo.tree', Sobi::Cfg('list.categories_ordering'), array('preventParents' => !$this->catsWithChilds));
$tree->setHref('#');
$tree->setTask('category.chooser');
$tree->setId($this->nid);
$tree->disable(Sobi::Section());
$tree->init(Sobi::Section());
$params = array();
$params['maxcats'] = $this->catsMaxLimit;
$params['field'] = $this->nid;
$params['preventParents'] = !$this->catsWithChilds;
$setheight = '';
if ($this->height > 0) {
$setheight = " style=\"height: {$this->height}px;\"";
}
$addBtParams = array('class' => 'btn');
$delBtParams = array('class' => 'btn');
$selectParams = array();
SPFactory::header()->addJsFile('opt.field_category_tree')->addJsCode('SobiPro.jQuery( document ).ready( function () { new SigsiuTreeEdit( ' . json_encode($params) . '); } );');
$selector = $selector . '<div class="tree"' . $setheight . '>' . $tree->display(true) . '</div>';
if (count($this->_selectedCats)) {
$selected = SPLang::translateObject($this->_selectedCats, 'name', 'category');
if (count($selected)) {
$count = 0;
foreach ($selected as $category) {
if ($category['id'] == $this->sid && SPRequest::task() != 'entry.add') {
continue;
}
$selectedCategories[$category['id']] = $category['value'];
$count++;
if ($count == $this->catsMaxLimit) {
break;
}
}
}
}
if (count($selectedCategories) >= $this->catsMaxLimit) {
$addBtParams['disabled'] = 'disabled';
$selectParams['readonly'] = 'readonly';
} elseif (!count($selectedCategories)) {
$delBtParams['disabled'] = 'disabled';
}
$selector .= '<div class="selected">';
$selector .= SPHtml_Input::select($this->nid . '_list', $selectedCategories, null, true, $selectParams);
$selector .= SPHtml_Input::hidden($this->nid, 'json://' . json_encode(array_keys($selectedCategories)));
$selector .= '</div>';
$selector .= '<div class="buttons">';
$selector .= SPHtml_Input::button('addCategory', Sobi::Txt('CC.ADD_BT'), $addBtParams);
$selector .= SPHtml_Input::button('removeCategory', Sobi::Txt('CC.DEL_BT'), $delBtParams);
$selector .= '</div>';
$selector = '<div class="SigsiuTree" id="' . $this->nid . '_canvas">' . $selector . '</div>';
if ($this->modal) {
$selector = SPHtml_Input::modalWindow(Sobi::Txt('EN.SELECT_CAT_PATH'), $this->nid . '_modal', $selector, 'modaltree modal hide', 'CLOSE', null);
$field = SPHtml_Input::button('select-category', Sobi::Txt('EN.SELECT_CAT_PATH'), array('class' => 'btn btn-primary', 'href' => '#' . $this->nid . '_modal', 'data-toggle' => 'modal', 'id' => $this->nid . '_modal_fire'));
return $field . $selector;
} else {
return $selector;
}
}
示例9: getChilds
/**
* @param string $type
* @param bool $recursive
* @param int $state
* @param bool $name
* @return array
*/
public function getChilds($type = 'entry', $recursive = false, $state = 0, $name = false)
{
static $lang = null;
if (!$lang) {
$lang = Sobi::Lang(false);
}
$childs = SPFactory::cache()->getVar('childs_' . $lang . $type . ($recursive ? '_recursive' : '') . ($name ? '_full' : '') . $state, $this->id);
if ($childs) {
return $childs == SPC::NO_VALUE ? array() : $childs;
}
$db = SPFactory::db();
$childs = array();
try {
$cond = array('pid' => $this->id);
if ($state) {
$cond['so.state'] = $state;
$cond['so.approved'] = $state;
$tables = $db->join(array(array('table' => 'spdb_object', 'as' => 'so', 'key' => 'id'), array('table' => 'spdb_relations', 'as' => 'sr', 'key' => 'id')));
$db->select(array('sr.id', 'sr.oType'), $tables, $cond);
} else {
$db->select(array('id', 'oType'), 'spdb_relations', $cond);
}
$results = $db->loadAssocList('id');
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_GET_CHILDS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if ($recursive && count($results)) {
foreach ($results as $cid) {
$this->rGetChilds($results, $cid, $type);
}
}
if (count($results)) {
if ($type == 'all') {
foreach ($results as $id => $r) {
$childs[$id] = $r['id'];
}
} else {
foreach ($results as $id => $r) {
if ($r['oType'] == $type) {
$childs[$id] = $id;
}
}
}
}
if ($name && count($childs)) {
$names = SPLang::translateObject($childs, array('name', 'alias'), $type);
if (is_array($names) && !empty($names)) {
foreach ($childs as $i => $id) {
$childs[$i] = array('name' => $names[$id]['value'], 'alias' => $names[$id]['alias']);
}
}
}
if (!$state) {
SPFactory::cache()->addVar($childs, 'childs_' . $lang . $type . ($recursive ? '_recursive' : '') . ($name ? '_full' : '') . $state, $this->id);
}
return $childs;
}
示例10: __construct
/**
* @param string $task
* @return \SobiProCtrl
*/
function __construct($task)
{
$this->_mem = memory_get_usage();
$this->_time = microtime(true);
SPLoader::loadClass('base.exception');
set_error_handler('SPExceptionHandler');
$this->_err = ini_set('display_errors', 'on');
$this->_task = $task;
/* load all needed classes */
SPLoader::loadClass('base.const');
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.object');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
SPLoader::loadClass('sobi');
SPLoader::loadClass('base.config');
SPLoader::loadClass('cms.base.lang');
/* get sid if any */
$this->_sid = SPRequest::sid();
/* determine section */
$access = $this->getSection();
/* initialise mainframe interface to CMS */
$this->_mainframe = SPFactory::mainframe();
/* initialise config */
$this->createConfig();
ini_set('display_errors', Sobi::Cfg('debug.display_errors', false));
$this->_deb = error_reporting(Sobi::Cfg('debug.level', 0));
/* trigger plugin */
Sobi::Trigger('Start');
/* initialise translator and load language files */
SPLang::setLang(Sobi::Lang(false));
try {
SPLang::registerDomain('site');
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if (!$access) {
if (Sobi::Cfg('redirects.section_enabled', false)) {
$redirect = Sobi::Cfg('redirects.section_url', null);
$msg = Sobi::Cfg('redirects.section_msg', SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task()));
$msgtype = Sobi::Cfg('redirects.section_msgtype', 'message');
Sobi::Redirect(Sobi::Url($redirect), Sobi::Txt($msg), $msgtype, true);
} else {
SPFactory::mainframe()->runAway('You have no permission to access this site', 403, null, true);
}
}
/* load css and js files */
SPFactory::header()->initBase();
$sectionName = SPLang::translateObject($this->_section, 'name', 'section');
if ($this->_section) {
SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value']));
}
$start = array($this->_mem, $this->_time);
SPFactory::registry()->set('start', $start);
/* check if it wasn't plugin custom task */
if (!Sobi::Trigger('custom', 'task', array(&$this, SPRequest::task()))) {
/* if not, start to route */
try {
$this->route();
} catch (SPException $x) {
if (defined('SOBI_TESTS')) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
} else {
SPFactory::mainframe()->setRedirect(Sobi::Reg('live_site'), SPLang::e('PAGE_NOT_FOUND'), SPC::ERROR_MSG, true);
}
}
}
return true;
}