Exemplo n.º 1
1
 protected function menu(&$data)
 {
     if (Sobi::Cfg('general.top_menu', true)) {
         $data['menu'] = array('front' => array('_complex' => 1, '_data' => Sobi::Reg('current_section_name'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('sid' => Sobi::Section())))));
         if (Sobi::Can('section.search')) {
             $data['menu']['search'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.SEARCH'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'search', 'sid' => Sobi::Section()))));
         }
         if (Sobi::Can('entry', 'add', 'own', Sobi::Section())) {
             $data['menu']['add'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.ADD_ENTRY'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'entry.add', 'sid' => SPRequest::sid()))));
         }
     }
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function display()
 {
     $sections =& $this->get('sections');
     $_sections = array();
     if (count($sections)) {
         foreach ($sections as $section) {
             $name = $section->get('name');
             $id = $section->get('id');
             $url = Sobi::Url(array('sid' => $id));
             $_section = array();
             $_section['id'] = $id;
             $_section['nid'] = $section->get('nid');
             $_section['name'] = "<a href=\"{$url}\">{$name}</a>";
             //				$_section[ 'entries_counter' ] 		= $section->countChilds( 'entry' );
             //				$_section[ 'categories_counter' ] 	= $section->countChilds( 'category' );
             //				$_section[ 'state' ] = SPLists::state( $section );
             //				$_section[ 'checkbox' ] = SPLists::checkedOut( $section, 'sid' );
             $_section['createdTime'] = $section->get('createdTime');
             $_section['metaDesc'] = $section->get('metaDesc');
             $_section['metaKey'] = $section->get('metaKey');
             $_section['description'] = $section->get('description');
             $_section['url'] = $url;
             $_sections[] = $_section;
         }
     }
     $this->set($_sections, 'sections');
     parent::display();
 }
Exemplo n.º 3
0
 public function install()
 {
     $id = $this->xGetString('id');
     $name = $this->xGetString('name');
     if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) {
         throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile)))));
     }
     $requirements = $this->xGetChilds('requirements/*');
     if ($requirements && $requirements instanceof DOMNodeList) {
         SPFactory::Instance('services.installers.requirements')->check($requirements);
     }
     $language = $this->xGetChilds('language/file');
     $folder = @$this->xGetChilds('language/@folder')->item(0)->nodeValue;
     if ($language && $language instanceof DOMNodeList && $language->length) {
         $langFiles = array();
         foreach ($language as $file) {
             $adm = false;
             if ($file->attributes->getNamedItem('admin')) {
                 $adm = $file->attributes->getNamedItem('admin')->nodeValue == 'true' ? true : false;
             }
             $langFiles[$file->attributes->getNamedItem('lang')->nodeValue][] = array('path' => Sobi::FixPath("{$this->root}/{$folder}/" . trim($file->nodeValue)), 'name' => $file->nodeValue, 'adm' => $adm);
         }
         SPFactory::CmsHelper()->installLang($langFiles, false, true);
     }
     $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false);
     if (SPRequest::bool('force')) {
         /** @var $from SPDirectory */
         $from = SPFactory::Instance('base.fs.directory', $this->root);
         $from->moveFiles($path);
     } else {
         if (!SPFs::move($this->root, $path)) {
             throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path));
         }
     }
     if (!SPRequest::bool('force')) {
         $section = $this->xGetChilds('install');
         if ($section instanceof DOMNodeList && $section->length) {
             $this->section($id);
         }
     }
     //05 Oct 2015 Kishore
     $exec = $this->xGetString('exec');
     if ($exec && SPFs::exists($path . DS . $exec)) {
         include_once "{$path}/{$exec}";
     }
     /** @var $dir SPDirectory */
     $dir =& SPFactory::Instance('base.fs.directory', $path);
     $zip = array_keys($dir->searchFile('.zip', false));
     if (count($zip)) {
         foreach ($zip as $file) {
             SPFs::delete($file);
         }
     }
     Sobi::Trigger('After', 'InstallTemplate', array($id));
     $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
     $dir->deleteFiles();
     return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name));
 }
Exemplo n.º 4
0
 /**
  */
 private function edit()
 {
     $id = $this->get('entry.id');
     if ($id) {
         $this->addHidden($id, 'entry.id');
     }
     $sid = SPRequest::int('pid') ? SPRequest::int('pid') : SPRequest::sid();
     $this->assign(Sobi::Url(array('task' => 'category.chooser', 'sid' => $sid, 'out' => 'html', 'multiple' => 1), true), 'cat_chooser_url');
 }
Exemplo n.º 5
0
 private function errors()
 {
     $errors = $this->get('errors');
     $levels = $this->get('levels');
     $icons = array('error' => Sobi::Cfg('list_icons.err_err'), 'warning' => Sobi::Cfg('list_icons.err_warn'), 'notice' => Sobi::Cfg('list_icons.err_notice'), 'details' => Sobi::Cfg('list_icons.err_details'));
     /* create the header */
     if (count($errors)) {
         foreach ($errors as $i => $error) {
             $error['errFile'] = str_replace(SOBI_ADM_PATH, null, $error['errFile']);
             $error['errFile'] = str_replace(SOBI_PATH, null, $error['errFile']);
             $error['errFile'] = str_replace(SOBI_ROOT, null, $error['errFile']);
             $error['errFile'] = $error['errFile'] . ': ' . $error['errLine'];
             if ($error['errReq']) {
                 $error['errReq'] = "<a href=\"{$error['errReq']}\" target=\"_blank\">{$error['errReq']}</a>";
             }
             $level = $levels[$error['errNum']];
             switch ($error['errNum']) {
                 case E_ERROR:
                 case E_CORE_ERROR:
                 case E_COMPILE_ERROR:
                 case E_USER_ERROR:
                 case E_RECOVERABLE_ERROR:
                     $error['errNum'] = "<img src=\"{$icons['error']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}";
                     break;
                 case E_WARNING:
                 case E_CORE_WARNING:
                 case E_COMPILE_WARNING:
                 case E_USER_WARNING:
                     $error['errNum'] = "<img src=\"{$icons['warning']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}";
                     break;
                 case E_NOTICE:
                 case E_USER_NOTICE:
                 case E_STRICT:
                 case E_USER_WARNING:
                 case E_DEPRECATED:
                 case E_USER_DEPRECATED:
                     $error['errNum'] = "<img src=\"{$icons['notice']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}";
                     break;
             }
             $error['errMsg'] = str_replace(SOBI_ROOT, null, $error['errMsg']);
             $error['errMsg'] = str_replace('href=\'function.', 'target="_blank" href=\'http://php.net/manual/en/function.', $error['errMsg']);
             $dh = Sobi::Url(array('task' => 'error.details', 'eid' => $error['eid']));
             $error['details'] = "<a href=\"{$dh}\"><img src=\"{$icons['details']}\"/></a>";
             $errors[$i] = $error;
         }
     }
     //		Sobi::Error( 'H', date( DATE_RFC1123 ), SPC::ERROR );
     $this->assign($errors, 'errors');
 }
Exemplo n.º 6
0
 function getObjectInfo($id, $language = null)
 {
     $info = new JCommentsObjectInfo();
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         $db = JFactory::getDBO();
         $query = "SELECT o.id, o.name, o.owner, o.parent, fd.baseData" . " FROM #__sobipro_object as o" . " LEFT JOIN #__sobipro_field_data AS fd ON o.id = fd.sid" . " JOIN #__sobipro_field AS f ON fd.fid = f.fid AND f.nid = 'field_name'" . " WHERE o.id = " . $id . " AND o.oType = 'entry'";
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $sobiCore = JPATH_SITE . '/components/com_sobipro/lib/base/fs/loader.php';
             if (is_file($sobiCore)) {
                 if (!defined('SOBIPRO')) {
                     $ver = new JVersion();
                     $ver = str_replace('.', null, $ver->RELEASE);
                     if ($ver > '15') {
                         $ver = '16';
                     }
                     define('SOBI_CMS', 'joomla' . $ver);
                     define('SOBIPRO', true);
                     define('SOBI_TASK', 'task');
                     define('SOBI_DEFLANG', JFactory::getLanguage()->getDefault());
                     define('SOBI_ACL', 'front');
                     define('SOBI_ROOT', JPATH_ROOT);
                     define('SOBI_MEDIA', implode(DS, array(JPATH_ROOT, 'media', 'sobipro')));
                     define('SOBI_MEDIA_LIVE', JURI::root() . '/media/sobipro');
                     define('SOBI_PATH', JPATH_ROOT . '/components/com_sobipro');
                     define('SOBI_LIVE_PATH', 'components/com_sobipro');
                     require_once JPATH_ROOT . '/components/com_sobipro/lib/base/fs/loader.php';
                 }
                 SPLoader::loadClass('sobi');
                 SPLoader::loadClass('base.request');
                 SPLoader::loadClass('base.object');
                 SPLoader::loadClass('base.factory');
                 SPLoader::loadClass('base.mainframe');
                 SPLoader::loadClass('base.const');
                 SPLoader::loadClass('cms.base.mainframe');
                 SPLoader::loadClass('cms.base.lang');
                 $info->title = empty($row->name) ? isset($row->baseData) ? $row->baseData : '' : $row->name;
                 $info->access = NULL;
                 $info->userid = $row->owner;
                 $info->link = Sobi::Url(array('title' => $row->name, 'pid' => $row->parent, 'sid' => $row->id));
             }
         }
     }
     return $info;
 }
Exemplo n.º 7
0
 public function install()
 {
     $id = $this->xGetString('id');
     $name = $this->xGetString('name');
     if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) {
         throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile)))));
     }
     $requirements = $this->xGetChilds('requirements/*');
     if ($requirements && $requirements instanceof DOMNodeList) {
         SPFactory::Instance('services.installers.requirements')->check($requirements);
     }
     $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false);
     if (SPRequest::bool('force')) {
         /** @var $from SPDirectory */
         $from = SPFactory::Instance('base.fs.directory', $this->root);
         $from->moveFiles($path);
     } else {
         if (!SPFs::move($this->root, $path)) {
             throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path));
         }
     }
     if (!SPRequest::bool('force')) {
         $section = $this->xGetChilds('install');
         if ($section instanceof DOMNodeList && $section->length) {
             $this->section($id);
         }
     }
     $exec = $this->xGetString('exec');
     if ($exec && SPFs::exists($this->root . DS . $exec)) {
         include_once "{$this->root}/{$exec}";
     }
     /** @var $dir SPDirectory */
     $dir =& SPFactory::Instance('base.fs.directory', $path);
     $zip = array_keys($dir->searchFile('.zip', false));
     if (count($zip)) {
         foreach ($zip as $file) {
             SPFs::delete($file);
         }
     }
     Sobi::Trigger('After', 'InstallTemplate', array($id));
     $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
     $dir->deleteFiles();
     return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name));
 }
Exemplo n.º 8
0
 /**
  */
 public function delete()
 {
     $childs = $this->getChilds('all', true);
     Sobi::Trigger('Section', ucfirst(__FUNCTION__), array(&$this->id));
     if (count($childs)) {
         Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), Sobi::Txt('SEC.DEL_WARN'), SPC::ERROR_MSG, true);
     } else {
         Sobi::Trigger('delete', $this->name(), array(&$this));
         $db = SPFactory::db();
         try {
             $db->delete('spdb_relations', "id = {$this->id} OR pid = {$this->id}");
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         try {
             $db->delete('spdb_config', array('section' => $this->id));
             $db->delete('spdb_plugin_section', array('section' => $this->id));
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         try {
             $fids = $db->select('fid', 'spdb_field', array('section' => $this->id))->loadResultArray();
             if (count($fids)) {
                 foreach ($fids as $fid) {
                     try {
                         $db->select('*', $db->join(array(array('table' => 'spdb_field', 'as' => 'sField', 'key' => 'fieldType'), array('table' => 'spdb_field_types', 'as' => 'sType', 'key' => 'tid'))), array('fid' => $fid));
                         $f = $db->loadObject();
                     } catch (SPException $x) {
                         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                     }
                     $field =& SPFactory::Model('field', true);
                     $field->extend($f);
                     $field->delete();
                 }
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         parent::delete();
         Sobi::Trigger('afterDelete', $this->name(), array(&$this));
     }
 }
Exemplo n.º 9
0
 public function chooser()
 {
     $pid = $this->get('category.parent');
     $path = null;
     if (!$pid) {
         $pid = SPRequest::sid();
     }
     $this->assign($pid, 'parent');
     $id = $this->get('category.id');
     $id = $id ? $id : $pid;
     if ($id) {
         $path = $this->parentPath($id);
     }
     $this->assign($path, 'parent_path');
     $this->assign(Sobi::Url(array('task' => 'category.parents', 'out' => 'json', 'format' => 'raw'), true), 'parent_ajax_url');
     /* @TODO  */
     $tpl = str_replace(implode('/', array('usr', 'templates', 'category')), 'views/tpl/', $this->_template . '.php');
     Sobi::Trigger('Display', $this->name(), array(&$this));
     include $tpl;
     Sobi::Trigger('AfterDisplay', $this->name());
 }
Exemplo n.º 10
0
 /**
  *
  */
 public function display()
 {
     $this->_type = 'frontpage';
     $type = $this->key('template_type', 'xslt');
     if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
         $type = 'php';
     }
     if ($type == 'xslt') {
         $sections = $this->get('sections');
         $data = array();
         if (count($sections)) {
             foreach ($sections as $section) {
                 $s = array('name' => array('_complex' => 1, '_data' => $section->get('name'), '_attributes' => array('lang' => Sobi::Lang(false))), 'description' => array('_complex' => 1, '_cdata' => 1, '_data' => $section->get('description'), '_attributes' => array('lang' => Sobi::Lang(false))), 'createdTime' => $section->get('createdTime'), 'meta' => array('description' => $section->get('metaDesc'), 'keys' => $this->metaKeys($section), 'author' => $section->get('metaAuthor'), 'robots' => $section->get('metaRobots')), 'owner' => $section->get('owner'), 'version' => $section->get('version'), 'validSince' => $section->get('validSince'), 'validUntil' => $section->get('validUntil'), 'url' => Sobi::Url(array('sid' => $section->get('id'))));
                 $data[] = array('_complex' => 1, '_data' => $s, '_attributes' => array('id' => $section->get('id'), 'nid' => $section->get('nid')));
             }
         }
         $this->assign($data, 'sections');
         Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
     }
     parent::display();
 }
Exemplo n.º 11
0
 private function getLink($button)
 {
     $link = '#';
     if (isset($button['type'])) {
         switch ($button['type']) {
             case 'help':
                 $link = 'https://www.sigsiu.net/help_screen/' . Sobi::Reg('help_task', SPRequest::task());
                 break;
             case 'url':
                 if (isset($button['sid']) && $button['sid'] == 'true') {
                     $link = Sobi::Url(array('task' => $button['task'], 'sid' => SPRequest::sid('request', SPRequest::int('pid'), true)));
                 } else {
                     $link = Sobi::Url($button['task'] ? $button['task'] : $button['url']);
                 }
                 break;
         }
     }
     return $link;
 }
Exemplo n.º 12
0
 public function getContentPermalink()
 {
     // $sid = SPRequest::sid();
     $sid = $this->getContentId();
     // $pid = SPRequest::int( 'pid' ) ? SPRequest::int( 'pid' ) : Sobi::Section();
     $pid = JRequest::getInt('pid') ? JRequest::getInt('pid') : Sobi::Section();
     $link = Sobi::Url(array('pid' => $pid, 'sid' => $sid, 'title' => $this->_item->title));
     $link = $this->prepareLink($link);
     // end untested codes
     return $link;
 }
Exemplo n.º 13
0
 /**
  * @return string
  */
 public function getBack()
 {
     $r = Sobi::GetUserState('back_url', Sobi::Url());
     if (!$r) {
         $r = SPRequest::string('HTTP_REFERER', self::url(), false, 'SERVER');
     }
     return $r;
 }
Exemplo n.º 14
0
 /**
  * Route by task
  * @return bool
  */
 private function routeTask()
 {
     $r = true;
     if (strstr($this->_task, '.')) {
         /* task consist of the real task and the object type */
         $task = explode('.', $this->_task);
         $obj = trim(array_shift($task));
         $task = trim(implode('.', $task));
         /* load the controller class definition and get the class name */
         $ctrl = SPLoader::loadController($obj, true);
         /* route task for multiple objects - e.g removing or publishing elements from a list */
         $sids = SPRequest::arr('sid');
         $csids = SPRequest::arr('c_sid');
         $esids = SPRequest::arr('e_sid');
         if (count($sids) || count($csids) || count($esids)) {
             $sid = array_key_exists('sid', $_REQUEST) && is_array($_REQUEST['sid']) ? 'sid' : (array_key_exists('c_sid', $_REQUEST) ? 'c_sid' : 'e_sid');
             if (count(SPRequest::arr($sid))) {
                 /* @var SPdb $db */
                 $db =& SPFactory::db();
                 $objects = null;
                 try {
                     $db->select('*', 'spdb_object', array('id' => SPRequest::arr($sid)));
                     $objects = $db->loadObjectList();
                 } catch (SPException $x) {
                     Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
                     $r = false;
                 }
                 /** @noinspection PhpUndefinedVariableInspection */
                 if (count($objects)) {
                     $this->_ctrl = array();
                     foreach ($objects as $object) {
                         $o = $this->extendObj($object, $obj, $ctrl, $task);
                         if ($o) {
                             $this->_ctrl[] = $o;
                         }
                     }
                     if (!count($this->_ctrl)) {
                         Sobi::Error('CoreCtrl', SPLang::e('IDENTIFIER_EXPECTED'), SPC::WARNING, 0, __LINE__, __FILE__);
                         Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), SPLang::e('IDENTIFIER_EXPECTED'), SPC::ERROR_MSG);
                     }
                 } else {
                     Sobi::Error('CoreCtrl', SPLang::e('IDENTIFIER_EXPECTED'), SPC::WARNING, 0, __LINE__, __FILE__);
                     Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), SPLang::e('IDENTIFIER_EXPECTED'), SPC::ERROR_MSG);
                     $r = false;
                     //break;
                 }
             } else {
                 Sobi::Error('CoreCtrl', SPLang::e('IDENTIFIER_EXPECTED'), SPC::WARNING, 0, __LINE__, __FILE__);
                 Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), SPLang::e('IDENTIFIER_EXPECTED'), SPC::ERROR_MSG);
                 $r = false;
                 //break;
             }
         } else {
             /* set controller and model */
             try {
                 $ctrl = new $ctrl();
                 $this->setController($ctrl);
                 if ($ctrl instanceof SPController) {
                     $model = SPLoader::loadModel($obj, false, false);
                     if ($model) {
                         $this->_ctrl->setModel($model);
                     }
                 }
             } catch (SPException $x) {
                 Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
             }
             if ($this->_sid) {
                 $this->_model =& SPFactory::object($this->_sid);
             }
             /* if the basic object we got from the #getSection method is the same one ... */
             if ($this->_model instanceof stdClass && $this->_model->oType == $obj) {
                 /*... extend the empty model of these data we've already got */
                 /** @noinspection PhpParamsInspection */
                 $this->_ctrl->extend($this->_model);
             }
             /* ... and so on... */
             $this->_ctrl->setTask($task);
         }
     } else {
         /** Special controllers not inherited from object and without model */
         $task = $this->_task;
         $ctrl = SPLoader::loadController($task, true);
         try {
             $this->setController(new $ctrl());
         } catch (SPException $x) {
             Sobi::Error('CoreCtrl', SPLang::e('Cannot set controller. %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     }
     return $r;
 }
Exemplo n.º 15
0
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3
 * as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
 * See http://www.gnu.org/licenses/gpl.html and http://sobipro.sigsiu.net/licenses.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 * $Date$
 * $Revision$
 * $Author$
 * $HeadURL$
 */
defined('SOBIPRO') || exit('Restricted access');
?>
<div style="padding: 10px;">
<?php 
$c = $this->count('sections');
for ($i = 0; $i < $c; $i++) {
    ?>
	<div>
		<a href="<?php 
    echo Sobi::Url(array('sid' => $this->get('sections.id', $i)));
    ?>
"><?php 
    $this->show('sections.name', $i);
    ?>
 </a>
	</div>
	<?php 
}
?>
</div>
Exemplo n.º 16
0
 protected function save($new = false)
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $content = SPRequest::raw('file_content', null, 'post');
     $file = $this->file(SPRequest::cmd('fileName'), !$new);
     Sobi::Trigger('Save', $this->name(), array(&$content, &$file));
     if (!$file) {
         throw new SPException(SPLang::e('Missing  file to save %s', SPRequest::cmd('fileName')));
     }
     $File = SPFactory::Instance('base.fs.file', $file);
     $File->content(stripslashes($content));
     try {
         $File->save();
         $u = array('task' => 'template.edit', 'file' => SPRequest::cmd('fileName'));
         if (Sobi::Section()) {
             $u['sid'] = Sobi::Section();
         }
         $this->response(Sobi::Url($u), Sobi::Txt('TP.FILE_SAVED'), $new, 'success');
     } catch (SPException $x) {
         $this->response(Sobi::Back(), $x->getMessage(), false, 'error');
     }
 }
Exemplo n.º 17
0
 /**
  */
 protected static function parseVal($label, $obj, $html = false)
 {
     if (strstr($label, '.')) {
         $properties = explode('.', $label);
     } else {
         $properties[0] = $label;
     }
     $var =& $obj;
     foreach ($properties as $property) {
         if ($var instanceof SPDBObject || method_exists($var, 'get')) {
             if (strstr($property, 'field_') && $var instanceof SPEntry) {
                 //                if ( strstr( $property, 'field_' && $var instanceof SPEntry ) ) {
                 $var = $var->getField($property)->data();
             } elseif ($property == 'name' && $var instanceof SPEntry && !strlen($var->get($property))) {
                 $var = $var->getField((int) Sobi::Cfg('entry.name_field'))->data($html);
             } elseif ($property == 'url' && $var instanceof SPEntry) {
                 $var = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $var->get('nid') : $var->get('name'), 'pid' => $var->get('primary'), 'sid' => $var->get('id')), false, true, true);
             } else {
                 $var = $var->get($property);
             }
         } elseif (is_array($var) && isset($var[$property])) {
             $var = $var[$property];
         } elseif ($var instanceof stdClass) {
             $var = $var->{$property};
         }
     }
     return $var;
 }
Exemplo n.º 18
0
 /**
  * Creates the "position" table row with order up/order down and position inputbox
  *
  * @param $row - SPDataModel
  * @param $count - number of entries/cats
  * @param $id - id ident for the box
  * @param $type - object type
  * @param $parent - id ident of parent object
  * @param $lsid - id of the object for the link
  * @return unknown_type
  */
 public static function position($row, $count, $id = 'sid', $type = null, $parent = 'pid', $lsid = 'sid')
 {
     SPLoader::loadClass('html.tooltip');
     $position = $row->get('position');
     /** @todo check what the hell the $up should be */
     $up = null;
     if (!$type) {
         $type = $row->type();
     }
     if ($position > 1) {
         $up = Sobi::Cfg('list_icons.position_up');
         $url = Sobi::Url(array('task' => $type . '.up', $parent => SPRequest::sid(), $lsid => $row->get('id')));
         /* translate alternative text */
         $s = Sobi::Txt($type . '.order_up');
         $a = Sobi::Txt($type . '.order_up_expl');
         $img = SPTooltip::toolTip($a, $s, $up);
         $up = "<a href=\"{$url}\">{$img}</a>";
     }
     $down = Sobi::Cfg('list_icons.position_down');
     $url = Sobi::Url(array('task' => $type . '.down', $parent => SPRequest::sid(), $lsid => $row->get('id')));
     /* translate alternative text */
     $s = Sobi::Txt($type . '.order_down');
     if ($position != $count) {
         $a = Sobi::Txt($type . '.order_down_expl');
         $img = SPTooltip::toolTip($a, $s, $down);
         $down = "<a href=\"{$url}\">{$img}</a>";
     } else {
         $down = null;
     }
     $sid = $row->get('id');
     $box = SPHtml_Input::text("{$id}[{$sid}]", $position, array('style' => 'text-align:center; width: 40px;'));
     return "<div style=\"width:30%;float:left;\">{$up}&nbsp;{$down}</div>&nbsp;{$box}";
 }
Exemplo n.º 19
0
 /**
  * Saves return URL - the back point to redirect to after several actions like add new object etc
  *
  */
 public static function ReturnPoint()
 {
     if (!isset($_POST['option']) || $_POST['option'] != 'com_sobipro' || isset($_GET['hidemainmenu']) && isset($_POST['hidemainmenu'])) {
         Sobi::SetUserState('back_url', Sobi::Url('current'));
     } else {
         $current = 'index.php?';
         foreach ($_POST as $k => $v) {
             $current .= $k . '=' . (string) $v . '&amp;';
         }
         Sobi::SetUserState('back_url', $current);
     }
 }
Exemplo n.º 20
0
 protected function getState()
 {
     $state = SPFactory::cache()->getVar('system_state');
     if (!$state) {
         SPLang::load('com_sobipro.messages');
         $state = array();
         $state['accelerator'] = array('type' => Sobi::Cfg('cache.l3_enabled', true) ? 'success' : 'error', 'label' => Sobi::Cfg('cache.l3_enabled', true) ? Sobi::Txt('ACCELERATOR_ENABLED') : Sobi::Txt('ACCELERATOR_DISABLED'));
         $state['xml-optimiser'] = array('type' => Sobi::Cfg('cache.xml_enabled', true) ? 'success' : 'error', 'label' => Sobi::Cfg('cache.xml_enabled', true) ? Sobi::Txt('XML_CACHE_ENABLED') : Sobi::Txt('XML_CACHE_DISABLED'));
         $state['javascript-cache'] = array('type' => Sobi::Cfg('cache.include_js_files', false) ? 'success' : 'warning', 'label' => Sobi::Cfg('cache.include_js_files', false) ? Sobi::Txt('JS_CACHE_ENABLED') : Sobi::Txt('JS_CACHE_DISABLED'));
         $state['css-cache'] = array('type' => Sobi::Cfg('cache.include_css_files', false) ? 'success' : 'warning', 'label' => Sobi::Cfg('cache.include_css_files', false) ? Sobi::Txt('CSS_CACHE_ENABLED') : Sobi::Txt('CSS_CACHE_DISABLED'));
         $state['display-errors'] = array('type' => Sobi::Cfg('debug.display_errors', false) ? 'error' : 'success', 'label' => Sobi::Cfg('debug.display_errors', false) ? Sobi::Txt('DISPLAY_ERRORS_ENABLED') : Sobi::Txt('DISPLAY_ERRORS_DISABLED'));
         $state['debug-level'] = array('type' => Sobi::Cfg('debug.level', 0) > 2 ? 'warning' : 'success', 'label' => Sobi::Cfg('debug.level', 0) > 2 ? Sobi::Txt('DEBUG_LEVEL_TOO_HIGH') : Sobi::Txt('DEBUG_LEVEL_OK'));
         $state['debug-xml'] = array('type' => Sobi::Cfg('debug.xml_raw', false) ? 'error' : 'success', 'label' => Sobi::Cfg('debug.xml_raw', false) ? Sobi::Txt('DEBUG_XML_ENABLED') : Sobi::Txt('DEBUG_XML_DISABLED'));
         //			uasort( $state, array( $this, 'sortMessages' ) );
         $messages = SPFactory::message()->getSystemMessages();
         $content = null;
         if (count($messages)) {
             foreach ($messages as $message) {
                 $url = Sobi::Url(array('sid' => $message['section']['id']));
                 $url = "<a href=\"{$url}\">{$message['section']['name']}</a> ";
                 $message['section']['link'] = $url;
                 $message['type-text'] = ucfirst(Sobi::Txt($message['type']));
                 $state['messages'][] = $message;
             }
         }
         SPFactory::cache()->addVar($state, 'system_state');
     }
     return $state;
 }
Exemplo n.º 21
0
 /**
  * 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;
     }
 }
Exemplo n.º 22
0
 private function section($section, $tab)
 {
     $v = null;
     if (isset($this->_custom[$tab]['before']) && is_array($this->_custom[$tab]['before'])) {
         foreach ($this->_custom[$tab]['before'] as $html) {
             $v .= "\n\t\t\t{$html}";
         }
     }
     if (count($section)) {
         $v .= "\n\t\t\t<ul>";
         foreach ($section as $pos => $label) {
             if (!SPFactory::user()->can($pos)) {
                 continue;
             }
             if (strlen($label) < 3) {
                 $label = str_replace('.', '_', $pos);
             }
             $label = Sobi::Txt($label);
             if ($this->_sid) {
                 $url = Sobi::Url(array('task' => $pos, 'pid' => $this->_sid));
             } else {
                 $url = Sobi::Url(array('task' => $pos));
             }
             if (SPRequest::task() == $pos || $this->_task == $pos) {
                 $v .= "\n\t\t\t\t<li><a href=\"{$url}\" class=\"SPMenuActive\">{$label}</a></li>";
             } else {
                 $v .= "\n\t\t\t\t<li><a href=\"{$url}\">{$label}</a></li>";
             }
         }
         $v .= "\n\t\t\t</ul>";
     }
     if (isset($this->_custom[$tab]['after']) && is_array($this->_custom[$tab]['after'])) {
         foreach ($this->_custom[$tab]['after'] as $html) {
             $v .= "\n\t\t\t{$html}";
         }
     }
     return $v;
 }
Exemplo n.º 23
0
 protected function view()
 {
     /* determine template package */
     $tplPckg = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     Sobi::ReturnPoint();
     $this->_task = 'alpha';
     if (!$this->_model) {
         $this->setModel('section');
         $this->_model->init(Sobi::Section());
     }
     $this->visible();
     /* load template config */
     $this->template();
     $this->tplCfg($tplPckg);
     /* get limits - if defined in template config - otherwise from the section config */
     $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2));
     $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2));
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLimStart = ($site - 1) * $eLimit;
     $eCount = count($this->getEntries(0, 0, true));
     $entries = $this->getEntries($eLimit, $site);
     $compare = $this->_field ? $this->_field : $this->_nid;
     if (strlen($compare) && $compare != Sobi::Cfg('alphamenu.primary_field')) {
         $t = 'list.alpha.' . strtolower($this->_letter) . '.' . $this->_nid;
     } else {
         $t = 'list.alpha.' . strtolower($this->_letter);
     }
     $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'task' => $t));
     $cUrl = array('sid' => SPRequest::sid(), 'task' => $t);
     if (SPRequest::int('site', 0)) {
         $cUrl['site'] = SPRequest::int('site', 0);
     }
     SPFactory::header()->addCanonical(Sobi::Url($cUrl, true, true, true));
     /* handle meta data */
     SPFactory::header()->objMeta($this->_model);
     $letter = urldecode(SPRequest::cmd('letter'));
     /* add pathway */
     if (!$this->_fieldType) {
         SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE', array('letter' => $letter)), Sobi::Url('current'));
         SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE', array('letter' => $letter, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site));
     } else {
         $field = SPFactory::Model('field');
         $field->init($this->_field);
         SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE_FIELD', array('letter' => $letter, 'field' => $field->get('name'))), Sobi::Url('current'));
         SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE_FIELD', array('letter' => $letter, 'section' => $this->_model->get('name'), 'field' => $field->get('name'))), array(ceil($eCount / $eLimit), $site));
     }
     /* get view class */
     $view = SPFactory::View('listing');
     $view->assign($eLimit, '$eLimit');
     $view->assign($eLimStart, '$eLimStart');
     $view->assign($eCount, '$eCount');
     $view->assign($eInLine, '$eInLine');
     $view->assign($this->_task, 'task');
     $view->assign($this->_model, 'section');
     $view->assign(Sobi::Txt('AL.PATH_TITLE', array('letter' => $this->_letter)), 'listing_name');
     $view->setConfig($this->_tCfg, $this->template);
     $view->setTemplate($tplPckg . '.' . $this->templateType . '.' . $this->template);
     $view->assign($pn->get(), 'navigation');
     $view->assign(SPFactory::user()->getCurrent(), 'visitor');
     $view->assign($entries, 'entries');
     Sobi::Trigger('AlphaListing', 'View', array(&$view));
     $view->display();
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 25
0
 protected function save($apply, $clone = false)
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $sets = array();
     if (!$clone) {
         $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('entry_id');
     } else {
         $sid = 0;
     }
     $apply = (int) $apply;
     if (!$this->_model) {
         $this->setModel(SPLoader::loadModel($this->_type));
     }
     $this->_model->init($sid);
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     $this->tplCfg($tplPackage);
     $customClass = null;
     if (isset($this->_tCfg['general']['functions']) && $this->_tCfg['general']['functions']) {
         $customClass = SPLoader::loadClass('/' . str_replace('.php', null, $this->_tCfg['general']['functions']), false, 'templates');
         if (method_exists($customClass, 'BeforeStoreEntry')) {
             $customClass::BeforeStoreEntry($this->_model, $_POST);
         }
     }
     $preState = array('approved' => $this->_model->get('approved'), 'state' => $this->_model->get('state'), 'new' => !$this->_model->get('id'));
     SPFactory::registry()->set('object_previous_state', $preState);
     $this->_model->getRequest($this->_type);
     $this->authorise($this->_model->get('id') ? 'edit' : 'add');
     try {
         $this->_model->validate('post');
     } catch (SPException $x) {
         $back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
         $data = $x->getData();
         $this->response($back, $x->getMessage(), false, 'error', array('required' => $data['field']));
     }
     try {
         $this->_model->save();
     } catch (SPException $x) {
         $back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
         $this->response($back, $x->getMessage(), false, 'error');
     }
     $sid = $this->_model->get('id');
     $sets['sid'] = $sid;
     $sets['entry.nid'] = $this->_model->get('nid');
     $sets['entry.id'] = $sid;
     if ($customClass && method_exists($customClass, 'AfterStoreEntry')) {
         $customClass::AfterStoreEntry($this->_model);
     }
     if (SPRequest::string('history-note') || $this->_task == 'saveWithRevision' || Sobi::Cfg('entry.versioningAdminBehaviour', 1)) {
         $this->logChanges('save', SPRequest::string('history-note'));
     }
     if ($apply || $clone) {
         if ($clone) {
             $msg = Sobi::Txt('MSG.OBJ_CLONED', array('type' => Sobi::Txt($this->_model->get('oType'))));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg);
         } else {
             $msg = Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType'))));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg, false, 'success', array('sets' => $sets));
         }
     } elseif ($this->_task == 'saveAndNew') {
         $msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
         $sid = $this->_model->get('parent');
         if (!$sid) {
             $sid = Sobi::Section();
         }
         $this->response(Sobi::Url(array('task' => $this->_type . '.add', 'sid' => $sid)), $msg, true, 'success', array('sets' => $sets));
     } else {
         $this->response(Sobi::Back(), Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType')))));
     }
 }
Exemplo n.º 26
0
 protected function &createMenu($task = null)
 {
     if (!$task) {
         $task = 'config.' . $this->_task;
     }
     /* load the menu definition */
     if (Sobi::Section()) {
         /* create menu */
         $menu =& SPFactory::Instance('views.adm.menu', $task, Sobi::Section());
         $cfg = SPLoader::loadIniFile('etc.adm.section_menu');
         /* create new SigsiuTree */
         $tree = SPFactory::Instance('mlo.tree');
         /* 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::Section());
         /* add the tree into the menu */
         $menu->addCustom('AMN.ENT_CAT', $tree->getTree());
         $seClass = SPLoader::loadModel('section');
         $cSec = new $seClass();
         $cSec->init(Sobi::Section());
     } else {
         $cfg = SPLoader::loadIniFile('etc.adm.config_menu');
         /* create menu */
         $menu =& SPFactory::Instance('views.adm.menu', $task);
     }
     Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
     if (count($cfg)) {
         foreach ($cfg as $section => $keys) {
             $menu->addSection($section, $keys);
         }
     }
     if (!Sobi::Section()) {
         $menu->addCustom('GB.CFG.GLOBAL_TEMPLATES', $this->listTemplates());
     }
     Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
     return $menu;
 }
Exemplo n.º 27
0
 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();
 }
Exemplo n.º 28
0
 protected function view()
 {
     $msg = null;
     $store = array();
     Sobi::SetUserData('requirements', $store);
     $home = SPRequest::int('init') ? Sobi::Url(null, true) : Sobi::Url('config', true);
     /** @var $view SPAdmView */
     //		header( 'Cache-Control: no-cache, must-revalidate' );
     //		header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
     SPFactory::View('view', true)->assign(SPRequest::int('init'), 'init')->addHidden($home, 'redirect')->determineTemplate('config', 'requirements')->display();
 }
Exemplo n.º 29
0
 private function screen()
 {
     $filters = $this->getFilters();
     $Filters = array();
     if (count($filters)) {
         foreach ($filters as $name => $filter) {
             $Filters[] = array('id' => $name, 'regex' => str_replace('\\"' . "\\'", '[:apostrophes:]', base64_decode($filter['params'])), 'name' => $filter['value'], 'message' => $filter['description'], 'editable' => strlen($filter['options']));
         }
     }
     $menu = $this->createMenu('filter');
     /** @var $view  SPAdmView */
     $view = SPFactory::View('view', true);
     $view->assign($this->_task, 'task')->assign($this->createMenu(), 'menu')->assign(Sobi::Url(array('task' => 'filter.edit', 'out' => 'html'), true), 'edit_url')->assign($Filters, 'filters')->assign($menu, 'menu')->determineTemplate('field', 'filters');
     $view->display();
 }
Exemplo n.º 30
0
 /**
  * @return void
  * @internal param int $rid
  */
 private function delete()
 {
     $rids = SPRequest::arr('rid', array());
     /* @var SPdb $db */
     $db = SPFactory::db();
     if (!count($rids)) {
         if (SPRequest::int('rid')) {
             $rids = array(SPRequest::int('rid'));
         } else {
             $this->response(Sobi::Back(), Sobi::Txt('ACL_SELECT_RULE_FIRST'), true, SPC::ERROR_MSG);
         }
     }
     try {
         $db->delete('spdb_permissions_groups', array('rid' => $rids));
         $db->delete('spdb_permissions_map', array('rid' => $rids));
         $db->delete('spdb_permissions_rules', array('rid' => $rids));
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_REMOVE_RULES_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     $this->response(Sobi::Url('acl'), Sobi::Txt('ACL_RULE_DELETED'), true, SPC::SUCCESS_MSG);
 }