Ejemplo n.º 1
0
 /**
  */
 public function execute()
 {
     $r = false;
     switch ($this->_task) {
         case 'edit':
         case 'add':
             $r = true;
             $this->editForm();
             break;
         case 'approve':
         case 'unapprove':
             $r = true;
             $this->approval($this->_task == 'approve');
             break;
         case 'up':
         case 'down':
             $r = true;
             $this->singleReorder($this->_task == 'up');
             break;
         case 'clone':
             $r = true;
             $this->_model = null;
             SPRequest::set('entry_id', 0, 'post');
             SPRequest::set('entry_state', 0, 'post');
             $this->save(false, true);
             break;
         case 'saveWithRevision':
             $this->save(true);
             break;
         case 'reorder':
             $r = true;
             $this->reorder();
             break;
         case 'reject':
             $r = true;
             $this->reject();
             break;
         case 'revisions':
             $r = true;
             $this->revisions();
             break;
         case 'search':
             $this->search();
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             } else {
                 $r = true;
             }
             break;
     }
     return $r;
 }
Ejemplo n.º 2
0
 /**
  */
 public function execute()
 {
     $r = false;
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     switch ($this->_task) {
         case 'edit':
         case 'add':
             Sobi::ReturnPoint();
             SPLoader::loadClass('html.input');
             $this->editForm();
             break;
         case 'approve':
         case 'unapprove':
             $r = true;
             $this->approve($this->_task == 'approve');
             break;
         case 'publish':
         case 'unpublish':
         case 'hide':
             $r = true;
             $this->state($this->_task == 'publish');
             break;
         case 'submit':
             $this->submit();
             break;
         case 'details':
             $this->visible();
             $this->details();
             Sobi::ReturnPoint();
             break;
         case 'payment':
             $this->payment();
             break;
         default:
             if (!parent::execute()) {
                 Sobi::Error('entry_ctrl', SPLang::e('TASK_NOT_FOUND'), SPC::NOTICE, 404, __LINE__, $this->name());
             } else {
                 $r = true;
             }
             break;
     }
     return $r;
 }
Ejemplo n.º 3
0
 /**
  */
 public function execute()
 {
     if (!Sobi::Can('section.search')) {
         if ($this->_task != 'suggest') {
             if (Sobi::Cfg('redirects.section_search_enabled') && strlen(Sobi::Cfg('redirects.section_search_url', null))) {
                 $this->escape(Sobi::Cfg('redirects.section_search_url', null), SPLang::e(Sobi::Cfg('redirects.section_search_msg', 'UNAUTHORIZED_ACCESS')), Sobi::Cfg('redirects.section_search_msgtype', SPC::ERROR_MSG));
             } else {
                 Sobi::Error($this->name(), SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
             }
         } else {
             exit;
         }
     }
     $r = false;
     SPLoader::loadClass('env.cookie');
     SPLoader::loadClass('env.browser');
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     switch ($this->_task) {
         case 'results':
         case 'view':
             $this->form();
             $r = true;
             break;
         case 'search':
             $this->search();
             $r = true;
             break;
         case 'suggest':
             $this->suggest();
             $r = true;
             break;
         default:
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
     return $r;
 }
Ejemplo n.º 4
0
 public function execute()
 {
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     if (strstr($this->_task, '.')) {
         $task = explode('.', $this->_task);
         $class = SPLoader::loadClass('opt.listing.' . $task[0], false, null, true);
     } else {
         $class = SPLoader::loadClass('opt.listing.' . $this->_task, false, null, true);
     }
     if ($class) {
         $imp = class_implements($class);
         if (is_array($imp) && in_array('SPListing', $imp)) {
             /** @noinspection PhpIncludeInspection $compatibility */
             $listing = new $class();
             if (!isset($class::$compatibility)) {
                 define('SOBI_LEGACY_LISTING', true);
                 if (strstr($this->_task, '.')) {
                     $t = explode('.', $this->_task);
                     $listing->setTask($t[0]);
                 } else {
                     $listing->setTask($this->_task);
                 }
             } else {
                 $listing->setTask($this->_task);
             }
             return $listing->execute();
         } else {
             Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND Wrong class definition', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
         }
     } else {
         /* case parent didn't registered this task, it was an error */
         if (!parent::execute() && $this->name() == __CLASS__) {
             Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  */
 public function execute()
 {
     /* parent class executes the plugins */
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     switch ($this->_task) {
         case 'front':
             $this->getSections();
             /** @var $view SPAdmPanelView */
             $view = SPFactory::View('front');
             /* load template config */
             //				$this->tplCfg( 'front' );
             //				$view->setConfig( $this->_tCfg, 'general' );
             $view->determineTemplate('front', SPC::DEFAULT_TEMPLATE);
             $view->assign($this->_sections, 'sections');
             $view->display();
             break;
         default:
             /* case parents or plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Ejemplo n.º 6
0
 /**
  * (non-PHPdoc)
  * @see Site/lib/models/SPDBObject#save()
  */
 public function save($request = 'post')
 {
     $this->loadFields(Sobi::Section(), true);
     // Thu, Feb 19, 2015 12:12:47 - it should be actually "beforeSave"
     Sobi::Trigger($this->name(), 'Before' . ucfirst(__FUNCTION__), array($this->id));
     /* save the base object data */
     /* @var SPdb $db */
     $db = SPFactory::db();
     $db->transaction();
     if (!$this->nid || SPRequest::task() == 'entry.clone') {
         $this->nid = SPRequest::string($this->nameField, null, false, $request);
         $this->nid = $this->createAlias();
         $this->name = $this->nid;
     }
     if (Sobi::Cfg('entry.publish_limit', 0) && !defined('SOBI_ADM_PATH')) {
         SPRequest::set('entry_createdTime', 0, $request);
         SPRequest::set('entry_validSince', 0, $request);
         SPRequest::set('entry_validUntil', 0, $request);
         $this->validUntil = gmdate('Y-m-d H:i:s', time() + Sobi::Cfg('entry.publish_limit', 0) * 24 * 3600);
     }
     $preState = Sobi::Reg('object_previous_state');
     parent::save($request);
     $nameField = $this->nameField();
     /* get the fields for this section */
     foreach ($this->fields as $field) {
         /* @var $field SPField */
         try {
             if ($field->enabled('form', $preState['new'])) {
                 $field->saveData($this, $request);
             } else {
                 $field->finaliseSave($this, $request);
             }
             if ($field->get('id') == $nameField) {
                 /* get the entry name */
                 $this->name = $field->getRaw();
                 /* save the nid (name id) of the field where the entry name is saved */
                 $this->nameField = $field->get('nid');
             }
         } catch (SPException $x) {
             if (SPRequest::task() != 'entry.clone') {
                 $db->rollback();
                 throw new SPException(SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()));
             } else {
                 Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             }
         }
     }
     $values = array();
     /* get categories */
     $cats = Sobi::Reg('request_categories');
     if (!count($cats)) {
         $cats = SPRequest::arr('entry_parent', SPFactory::registry()->get('request_categories', array()), $request);
     }
     /* by default it should be comma separated string */
     if (!count($cats)) {
         $cats = SPRequest::string('entry_parent', null, $request);
         if (strlen($cats) && strpos($cats, ',')) {
             $cats = explode(',', $cats);
             foreach ($cats as $i => $cat) {
                 $c = (int) trim($cat);
                 if ($c) {
                     $cats[$i] = $c;
                 } else {
                     unset($cats[$i]);
                 }
             }
         } elseif (strlen($cats)) {
             $cats = array((int) $cats);
         }
     }
     if (is_array($cats) && count($cats)) {
         foreach ($cats as $i => $v) {
             if (!$v) {
                 unset($cats[$i]);
             }
         }
     }
     if (is_array($cats) && count($cats)) {
         /* get the ordering in these categories */
         try {
             $db->select('pid, MAX(position)', 'spdb_relations', array('pid' => $cats, 'oType' => 'entry'), null, 0, 0, false, 'pid');
             $cPos = $db->loadAssocList('pid');
             $currPos = $db->select(array('pid', 'position'), 'spdb_relations', array('id' => $this->id, 'oType' => 'entry'))->loadAssocList('pid');
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
         /* set the right position */
         foreach ($cats as $i => $cat) {
             $copy = 0;
             if (!$this->approved) {
                 $copy = isset($this->categories[$cats[$i]]) ? 0 : 1;
             } else {
                 $db->delete('spdb_relations', array('id' => $this->id, 'oType' => 'entry'));
             }
             if (isset($currPos[$cat])) {
                 $pos = $currPos[$cat]['position'];
             } else {
                 $pos = isset($cPos[$cat]) ? $cPos[$cat]['MAX(position)'] : 0;
                 $pos++;
             }
             $values[] = array('id' => $this->id, 'pid' => $cats[$i], 'oType' => 'entry', 'position' => $pos, 'validSince' => $this->validSince, 'validUntil' => $this->validUntil, 'copy' => $copy);
         }
         try {
             $db->insertArray('spdb_relations', $values, true);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     } elseif (!count($this->categories)) {
         throw new SPException(SPLang::e('MISSING_CAT'));
     }
     /* trigger possible state changes */
     if ($preState['approved'] != $this->approved) {
         if ($this->approved) {
             $this->approveFields(true);
             // it's being done by the method above - removing
             //Sobi::Trigger( $this->name(), 'AfterApprove', array( $this->id, $this->approved ) );
         }
     }
     if ($preState['state'] != $this->state) {
         Sobi::Trigger($this->name(), 'AfterChangeState', array($this->id, $this->state));
     }
     SPFactory::cache()->purgeSectionVars();
     SPFactory::cache()->deleteObj('entry', $this->id);
     if (count($cats)) {
         foreach ($cats as $cat) {
             SPFactory::cache()->deleteObj('category', $cat);
         }
     }
     Sobi::Trigger($this->name(), 'After' . ucfirst($preState['new'] ? __FUNCTION__ : 'Update'), array(&$this));
 }
Ejemplo n.º 7
0
 protected function determineFid($nid)
 {
     if (is_numeric($nid)) {
         $field = SPFactory::db()->select(array('fid', 'fieldType', 'nid'), 'spdb_field', array('section' => Sobi::Section(), 'fid' => $nid))->loadObject();
     } else {
         $field = SPFactory::db()->select(array('fid', 'fieldType', 'nid'), 'spdb_field', array('section' => Sobi::Section(), 'nid' => $nid))->loadObject();
     }
     $this->_field = $field->fid;
     $this->_nid = $field->nid;
     $this->_fieldType = $field->fieldType;
     SPRequest::set('alpha_field', strtolower($this->_nid));
 }
Ejemplo n.º 8
0
 * @author
 * Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
 * Email: sobi[at]sigsiu.net
 * Url: http://www.Sigsiu.NET
 * @copyright Copyright (C) 2006 - 2015 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
 * @license GNU/GPL Version 3
 * 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: 2015-02-19 13:24:35 +0100 (Thu, 19 Feb 2015) $
 * $Revision: 4387 $
 * $Author: Radek Suski $
 * $HeadURL: file:///opt/svn/SobiPro/Component/branches/SobiPro-1.1/Admin/field/edit.php $
 */
defined('SOBIPRO') || exit('Restricted access');
SPRequest::set('hidemainmenu', 1);
SPFactory::header()->addCSSCode('body { min-width: 1200px; }')->addJsCode("\n\t\t\tvar SPErrMsg = SobiPro.Txt( 'Please fill in all required fields!' );\n\t        function submitbutton( task )\n\t        {\n\t            var form = document.adminForm;\n\t            if ( task == 'field.cancel' || SPValidateForm() ) {\n\t                if ( SP_id( 'field.nid' ).value == '' ) {\n\t                    SP_id( 'field.nid' ).value = SP_id( 'field.name' ).value;\n\t                }\n\t                var nid = SP_id( 'field.nid' ).value;\n\t                nid = nid.replace( /(\\s+)/g, '_' );\n\t                nid = nid.replace( /[^\\w_]/g, '' );\n\t                SP_id( 'field.nid' ).value = nid.toLowerCase();\n\t                if ( SP_id( 'field.nid' ).value.indexOf( 'field_' ) != 0 ) {\n\t                    SP_id( 'field.nid' ).value = 'field_' + SP_id( 'field.nid' ).value;\n\t                }\n\t                submitform( task );\n\t            }\n\t        }\n\t        SobiPro.jQuery( document ).ready( function ()\n\t        {\n\t        \tJoomla.submitform = function ( task )\n\t            {\n\t                submitbutton( task );\n\t            }\n\t         } );\n        ");
$row = 0;
$this->trigger('OnStart');
?>

<div>
    <fieldset class="adminform">
        <table class="admintable">
            <tr class="row<?php 
echo ++$row % 2;
?>
">
                <td class="key">
					<?php 
$this->txt('FM.FIELD_LABEL');
Ejemplo n.º 9
0
 /**
  */
 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();
 }
Ejemplo n.º 10
0
 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @throws SPException
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     $del = SPRequest::bool($this->nid . '_delete', false, $request);
     $fileSize = SPRequest::file($this->nid, 'size');
     $cropped = null;
     static $store = null;
     $cache = false;
     if ($store == null) {
         $store = SPFactory::registry()->get('requestcache_stored');
     }
     if (is_array($store) && isset($store[$this->nid])) {
         if (!strstr($store[$this->nid], 'file://') && !strstr($store[$this->nid], 'directory://')) {
             $data = $store[$this->nid];
             $cache = true;
             $orgName = SPRequest::file($this->nid, 'name', $request);
         } else {
             SPRequest::set($this->nid, $store[$this->nid]);
             $orgName = SPRequest::file($this->nid, 'name');
             $data = SPRequest::file($this->nid, 'tmp_name');
         }
     } else {
         $data = SPRequest::file($this->nid, 'tmp_name');
         $orgName = SPRequest::file($this->nid, 'name');
     }
     $sPath = $this->parseName($entry, $orgName, $this->savePath);
     $path = SPLoader::dirPath($sPath, 'root', false);
     /** Wed, Oct 15, 2014 13:51:03
      * Implemented a cropper with Ajax checker.
      * This is the actual method to get those files
      * Other methods left for BC
      * */
     if (!$data) {
         $directory = SPRequest::string($this->nid, $store[$this->nid], false, $request);
         if (strlen($directory)) {
             list($data, $dirName, $files, $coordinates) = $this->getAjaxFiles($directory);
             if (count($files)) {
                 foreach ($files as $file) {
                     if ($file == '.') {
                         continue;
                     }
                     if ($file == '..') {
                         continue;
                     }
                     if (strpos($file, 'icon_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'resized_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'cropped_') !== false) {
                         $cropped = $dirName . $file;
                         SPFs::upload($cropped, $path . basename($cropped));
                         continue;
                     }
                     if (strpos($file, '.var') !== false) {
                         continue;
                     }
                     $fileSize = filesize($dirName . $file);
                     $orgName = $file;
                 }
             }
             if (strlen($coordinates)) {
                 $coordinates = json_decode(SPLang::clean($coordinates), true);
                 /** @var SPImage $croppedImage */
                 $croppedImage = SPFactory::Instance('base.fs.image', $dirName . $orgName);
                 $croppedImage->crop($coordinates['width'], $coordinates['height'], $coordinates['x'], $coordinates['y']);
                 $cropped = 'cropped_' . $orgName;
                 $croppedImage->saveAs($path . $cropped);
             }
             $data = strlen($cropped) ? $cropped : $dirName . $file;
         }
     }
     $files = array();
     /* if we have an image */
     if ($data && $orgName) {
         if ($fileSize > $this->maxSize) {
             throw new SPException(SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $fileSize, $this->maxSize));
         }
         if ($cropped) {
             SPFs::upload($dirName . $orgName, $path . $orgName);
         }
         /**
          * @var SPImage $orgImage
          */
         if ($cache) {
             $orgImage = SPFactory::Instance('base.fs.image', $data);
             $orgImage->move($path . $orgName);
         } else {
             $orgImage = SPFactory::Instance('base.fs.image');
             $nameArray = explode('.', $orgName);
             $ext = strtolower(array_pop($nameArray));
             $nameArray[] = $ext;
             $orgName = implode('.', $nameArray);
             if ($cropped) {
                 $orgImage->upload($dirName . $data, $path . basename($data));
             } else {
                 $orgImage->upload($dirName . $orgName, $path . $orgName);
             }
         }
         $files['data']['exif'] = $orgImage->exif();
         $this->cleanExif($files['data']['exif']);
         if (Sobi::Cfg('image_field.fix_rotation', true)) {
             if ($orgImage->fixRotation()) {
                 $orgImage->save();
             }
         }
         if ($this->resize) {
             $image = clone $orgImage;
             try {
                 $image->resample($this->resizeWidth, $this->resizeHeight, false);
                 $files['image'] = $this->parseName($entry, $orgName, $this->imageName, true);
                 $image->saveAs($path . $files['image']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $image->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         if ($this->generateThumb) {
             $thumb = clone $orgImage;
             try {
                 $thumb->resample($this->thumbWidth, $this->thumbHeight, false);
                 $files['thumb'] = $this->parseName($entry, $orgName, $this->thumbName, true);
                 $thumb->saveAs($path . $files['thumb']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $thumb->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         $ico = clone $orgImage;
         try {
             $icoSize = explode(':', Sobi::Cfg('image.ico_size', '80:80'));
             $ico->resample($icoSize[0], $icoSize[1], false);
             $files['ico'] = $this->parseName($entry, strtolower($orgName), 'ico_{orgname}', true);
             $ico->saveAs($path . $files['ico']);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             $ico->delete();
             throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
         }
         if (!$this->keepOrg) {
             $orgImage->delete();
         } else {
             $files['original'] = $this->parseName($entry, $orgName, '{orgname}', true);
         }
         foreach ($files as $i => $file) {
             if ($i == 'data') {
                 continue;
             }
             $files[$i] = $sPath . $file;
         }
     } elseif ($del) {
         $this->delImgs();
         $files = array();
     } else {
         return true;
     }
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $this->verify($entry, $request);
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* if we are here, we can save these data */
     /* collect the needed params */
     $save = count($files) ? SPConfig::serialize($files) : null;
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['baseData'] = $db->escape($save);
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELDS_DATA_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
 }
Ejemplo n.º 11
0
 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @param bool $clone
  * @throws SPException
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST', $clone = false)
 {
     if (!$this->enabled) {
         return false;
     }
     $del = SPRequest::bool($this->nid . '_delete', false, $request);
     if ($clone) {
         $orgSid = SPRequest::sid();
         $this->loadData($orgSid);
         $files = $this->getExistingFiles();
         $cloneFiles = array();
         if (isset($files['original']) && file_exists(SOBI_ROOT . '/' . $files['original'])) {
             return $this->cloneFiles($entry, $request, $files, $cloneFiles);
         }
     }
     $fileSize = SPRequest::file($this->nid, 'size');
     $cropped = null;
     static $store = null;
     $cache = false;
     if ($store == null) {
         $store = SPFactory::registry()->get('requestcache_stored');
     }
     if (is_array($store) && isset($store[$this->nid])) {
         if (!strstr($store[$this->nid], 'file://') && !strstr($store[$this->nid], 'directory://')) {
             $data = $store[$this->nid];
             $cache = true;
             $orgName = SPRequest::file($this->nid, 'name', $request);
         } else {
             SPRequest::set($this->nid, $store[$this->nid]);
             $orgName = SPRequest::file($this->nid, 'name');
             $data = SPRequest::file($this->nid, 'tmp_name');
         }
     } else {
         $data = SPRequest::file($this->nid, 'tmp_name');
         $orgName = SPRequest::file($this->nid, 'name');
     }
     $sPath = $this->parseName($entry, $orgName, $this->savePath);
     $path = SPLoader::dirPath($sPath, 'root', false);
     /** Wed, Oct 15, 2014 13:51:03
      * Implemented a cropper with Ajax checker.
      * This is the actual method to get those files
      * Other methods left for BC
      * */
     if (!$data) {
         $directory = SPRequest::string($this->nid, $store[$this->nid], false, $request);
         if (strlen($directory)) {
             list($data, $dirName, $files, $coordinates) = $this->getAjaxFiles($directory);
             if (count($files)) {
                 foreach ($files as $file) {
                     if ($file == '.') {
                         continue;
                     }
                     if ($file == '..') {
                         continue;
                     }
                     if (strpos($file, 'icon_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'resized_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'cropped_') !== false) {
                         $cropped = $dirName . $file;
                         SPFs::upload($cropped, $path . basename($cropped));
                         continue;
                     }
                     if (strpos($file, '.var') !== false) {
                         continue;
                     }
                     $fileSize = filesize($dirName . $file);
                     $orgName = $file;
                 }
             }
             if (strlen($coordinates)) {
                 $coordinates = json_decode(SPLang::clean($coordinates), true);
                 /** @var SPImage $croppedImage */
                 $croppedImage = SPFactory::Instance('base.fs.image', $dirName . $orgName);
                 $croppedImage->crop($coordinates['width'], $coordinates['height'], $coordinates['x'], $coordinates['y']);
                 $cropped = 'cropped_' . $orgName;
                 $croppedImage->saveAs($path . $cropped);
             }
             $data = strlen($cropped) ? $cropped : $dirName . $file;
         }
     }
     $files = array();
     /* if we have an image */
     if ($data && $orgName) {
         if ($fileSize > $this->maxSize) {
             throw new SPException(SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $fileSize, $this->maxSize));
         }
         if ($cropped) {
             SPFs::upload($dirName . $orgName, $path . $orgName);
         }
         /**
          * @var SPImage $orgImage
          */
         if ($cache) {
             $orgImage = SPFactory::Instance('base.fs.image', $data);
             $orgImage->move($path . $orgName);
         } else {
             $orgImage = SPFactory::Instance('base.fs.image');
             $nameArray = explode('.', $orgName);
             $ext = strtolower(array_pop($nameArray));
             $nameArray[] = $ext;
             $orgName = implode('.', $nameArray);
             if ($cropped) {
                 // Fri, Jul 3, 2015 17:15:05
                 // it has been actually uploaded at ~425
                 // not sure why we are trying to upload it again
                 if (SPFs::exists($dirName . $data)) {
                     $orgImage->upload($dirName . $data, $path . basename($data));
                 } else {
                     $orgImage->setFile($path . basename($data));
                 }
             } else {
                 $orgImage->upload($dirName . $orgName, $path . $orgName);
             }
         }
         $files['data']['exif'] = $orgImage->exif();
         $this->cleanExif($files['data']['exif']);
         if (Sobi::Cfg('image_field.fix_rotation', true)) {
             if ($orgImage->fixRotation()) {
                 $orgImage->save();
             }
         }
         if ($this->resize) {
             $image = clone $orgImage;
             try {
                 $image->resample($this->resizeWidth, $this->resizeHeight, false);
                 $files['image'] = $this->parseName($entry, $orgName, $this->imageName, true);
                 $image->saveAs($path . $files['image']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $image->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         if ($this->generateThumb) {
             $thumb = clone $orgImage;
             try {
                 $thumb->resample($this->thumbWidth, $this->thumbHeight, false);
                 $files['thumb'] = $this->parseName($entry, $orgName, $this->thumbName, true);
                 $thumb->saveAs($path . $files['thumb']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $thumb->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         $ico = clone $orgImage;
         try {
             $icoSize = explode(':', Sobi::Cfg('image.ico_size', '80:80'));
             $ico->resample($icoSize[0], $icoSize[1], false);
             $files['ico'] = $this->parseName($entry, strtolower($orgName), 'ico_{orgname}_' . $this->nid, true);
             $ico->saveAs($path . $files['ico']);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             $ico->delete();
             throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
         }
         if (!$this->keepOrg) {
             $orgImage->delete();
         } else {
             $files['original'] = $this->parseName($entry, $orgName, '{orgname}', true);
         }
         foreach ($files as $i => $file) {
             if ($i == 'data') {
                 continue;
             }
             $files[$i] = $sPath . $file;
         }
     } elseif ($del) {
         $this->delImgs();
         $files = array();
     } else {
         return true;
     }
     $this->storeData($entry, $request, $files);
 }
Ejemplo n.º 12
0
 /**
  * Save existing field
  */
 protected function save($clone = false)
 {
     $sets = array();
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $fid = SPRequest::int('fid');
     $field = SPFactory::Model('field', true);
     if ($fid) {
         $f = $this->loadField($fid);
         $field->extend($f);
     } else {
         $field->loadType(SPRequest::cmd('field_fieldType'));
     }
     $nid = SPRequest::cmd('field_nid');
     if (!$nid || !strstr($nid, 'field_')) {
         /** give me my spaces back!!! */
         $nid = strtolower(str_replace('-', '_', SPLang::nid('field_' . SPRequest::string('field_name'))));
         SPRequest::set('field_nid', $nid);
     }
     $this->getRequest();
     $this->validate($field);
     if ($clone || !$fid) {
         try {
             $fid = $field->saveNew($this->attr);
             $field->save($this->attr);
         } catch (SPException $x) {
             $this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $x->getMessage(), false, SPC::ERROR_MSG);
         }
     } else {
         try {
             $field->save($this->attr);
         } catch (SPException $x) {
             $this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $x->getMessage(), false, SPC::ERROR_MSG);
         }
     }
     $alias = $field->get('nid');
     $fieldSets = $field->get('sets');
     if (is_array($fieldSets) && count($fieldSets)) {
         $sets = array_merge($fieldSets, $sets);
     }
     $sets['fid'] = $field->get('fid');
     $sets['field.nid'] = $alias;
     /* in case we are changing the sort by field */
     if (Sobi::Cfg('list.entries_ordering') == $alias && $field->get('nid') != $alias) {
         SPFactory::config()->saveCfg('list.entries_ordering', $field->get('nid'));
     }
     SPFactory::cache()->cleanSection();
     if ($this->_task == 'apply' || $clone) {
         if ($clone) {
             $msg = Sobi::Txt('FM.FIELD_CLONED');
             $this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $msg);
         } else {
             $msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
             $this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $msg, false, 'success', array('sets' => $sets));
         }
     } else {
         $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'));
     }
 }
Ejemplo n.º 13
0
 /**
  */
 protected function view()
 {
     /* @var SPdb $db */
     $db = SPFactory::db();
     SPRequest::set('task', 'category.view');
     /* 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 */
     $e = $this->_model->getChilds();
     $c = $this->_model->getChilds('category');
     // 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();
     SPLoader::loadClass('models.dbobject');
     /* 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', 'position.asc', $Limit, $LimStart, $c);
             $db->select('*', 'spdb_object', array('id' => $c, 'oType' => 'category'), $cOrder, $Limit, $LimStart);
             $results = $db->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);
             // new $cClass();
             //$categories[ $i ]->extend( $category );
         }
     }
     /* if there are entries in the root */
     if (count($e)) {
         try {
             $LimStart = $eLimStart ? ($eLimStart - 1) * $eLimit : $eLimStart;
             $Limit = $eLimit > 0 ? $eLimit : 0;
             $eOrder = $this->parseOrdering('entries', 'eorder', 'position.asc', $Limit, $LimStart, $e);
             $entries = $db->select('*', '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__);
         }
     }
     $entriesName = SPFactory::config()->nameField()->get('name');
     $entriesField = SPFactory::config()->nameField()->get('nid');
     /* create menu */
     SPLoader::loadClass('views.adm.menu');
     $menu = new SPAdmSiteMenu('section.' . $this->_task, SPRequest::sid());
     /* 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);
         }
     }
     /* create new SigsiuTree */
     $tree = SPLoader::loadClass('mlo.tree');
     $tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'position.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'), SPRequest::sid());
     /* add the tree into the menu */
     $menu->addCustom('AMN.ENT_CAT', $tree->getTree());
     /* get view class */
     $view = SPFactory::View('category', true);
     $view->assign($eLimit, '$eLimit')->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($this->_model, 'category')->assign($categories, 'categories')->assign($entries, 'entries')->assign($this->customCols(), 'fields')->assign($entriesName, 'entries_name')->assign($entriesField, 'entries_field')->assign($menu, 'menu')->assign(Sobi::GetUserState('entries.eorder', 'eorder', 'position.asc'), 'eorder')->assign(Sobi::GetUserState('categories.corder', 'corder', 'position.asc'), 'corder')->assign($this->_model->get('name'), 'category_name')->addHidden(Sobi::Section(), 'pid')->addHidden(SPRequest::sid(), 'sid');
     Sobi::Trigger('Category', 'View', array(&$view));
     $view->display();
 }
Ejemplo n.º 14
0
 /**
  * @return bool
  */
 public function execute()
 {
     $r = false;
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     switch ($this->_task) {
         /* if someone want edit an object - just check if it is not checked out */
         case 'edit':
             if ($this->_model && $this->_model->isCheckedOut()) {
                 Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), Sobi::Txt('MSG.OBJ_CHECKED_OUT', array('type' => Sobi::Txt($this->_type))), SPC::ERROR_MSG, true);
                 exit;
             }
             break;
         case 'hide':
         case 'publish':
             $r = true;
             $this->state($this->_task == 'publish');
             break;
         case 'toggle.enabled':
         case 'toggle.approval':
             $r = true;
             $this->toggleState();
             break;
         case 'apply':
         case 'save':
         case 'saveAndNew':
             $r = true;
             $this->save($this->_task == 'apply');
             break;
         case 'cancel':
             if (defined('SOBI_ADM_PATH')) {
                 $this->checkIn(SPRequest::sid(), false);
                 $this->response(Sobi::Back());
             }
             $this->checkIn(SPRequest::int('sid'));
             $r = true;
             if (SPRequest::int('sid')) {
                 $url = Sobi::Url(array('sid' => SPRequest::sid()));
             } elseif (SPRequest::int('pid')) {
                 $url = Sobi::Url(array('sid' => SPRequest::int('pid')));
             } else {
                 $url = Sobi::Url(array('sid' => Sobi::Section()));
             }
             $this->response($url);
             break;
         case 'delete':
             if ($this->_model->get('owner') == Sobi::My('id') && $this->authorise('delete', 'own') || $this->authorise('delete', '*')) {
                 $r = true;
                 if ($this->_model->get('id')) {
                     $this->_model->delete();
                     if ($this->_type == 'entry' && !defined('SOBIPRO_ADM')) {
                         if (SPRequest::int('pid')) {
                             $url = Sobi::Url(array('sid' => SPRequest::int('pid')));
                         } else {
                             $url = Sobi::Url(array('sid' => Sobi::Section()));
                         }
                     } else {
                         $url = Sobi::Back();
                     }
                     $this->response($url, Sobi::Txt('MSG.OBJ_DELETED', array('type' => Sobi::Txt($this->_type))), false);
                 } else {
                     $this->response(Sobi::Back(), Sobi::Txt('CHANGE_NO_ID'), false, SPC::ERROR_MSG);
                 }
             }
             break;
         case 'view':
             $r = true;
             $this->visible();
             $this->view();
             break;
         case 'resetCounter':
             if ($this->authorise('edit', '*')) {
                 $this->_model->countVisit(true);
                 exit(true);
             }
             break;
         default:
             $r = Sobi::Trigger('Execute', $this->name(), array(&$this));
             break;
     }
     return $r;
 }
Ejemplo n.º 15
0
 protected function parseXml()
 {
     $header = $this->_xml->getElementsByTagName('header')->item(0);
     if ($header->hasChildNodes()) {
         foreach ($header->childNodes as $node) {
             if (!strstr($node->nodeName, '#')) {
                 $params = array();
                 $this->parseParams($node, $params);
                 $this->callHeader($node->nodeName, $params[$node->nodeName]);
             }
         }
     }
     $data = $this->_xml->getElementsByTagName('cache-data')->item(0);
     if ($data && $data->hasChildNodes()) {
         foreach ($data->childNodes as $node) {
             if (!strstr($node->nodeName, '#')) {
                 $params = array();
                 $this->parseParams($node, $params);
                 if (isset($params['hidden']) && is_array($params['hidden']) && count($params['hidden'])) {
                     foreach ($params['hidden'] as $k => $v) {
                         $this->addHidden($v, $k);
                     }
                 }
                 if (isset($params['request']) && is_array($params['request']) && count($params['request'])) {
                     foreach ($params['request'] as $k => $v) {
                         SPRequest::set($k, $v, 'get');
                     }
                 }
                 if (isset($params['pathway']) && is_array($params['pathway']) && count($params['pathway'])) {
                     foreach ($params['pathway'] as $v) {
                         SPFactory::mainframe()->addToPathway($v['name'], $v['url']);
                     }
                 }
             }
         }
     }
     $visitor = $this->visitorArray(SPFactory::user()->getCurrent());
     if (is_array($visitor) && isset($visitor['_data'])) {
         $this->importData($this->_xml->documentElement, $visitor, 'visitor');
     }
     $messages = SPFactory::message()->getMessages();
     $info = array();
     if (count($messages)) {
         foreach ($messages as $type => $content) {
             $info[$type] = array_values($content);
         }
     }
     if (is_array($info)) {
         $this->importData($this->_xml->documentElement, $info, 'messages');
     }
     $this->_xml->formatOutput = true;
 }
Ejemplo n.º 16
0
 /**
  * Switching error reporting and displaying of errors compl. off
  * For e.g JavaScript, or XML output where the document structure is very sensible
  *
  */
 public function &cleanBuffer()
 {
     error_reporting(0);
     ini_set('display_errors', 'off');
     SPRequest::set('tmpl', 'component');
     JResponse::setBody(null);
     while (ob_get_length()) {
         ob_end_clean();
     }
     return $this;
 }
Ejemplo n.º 17
0
 /**
  * @param DOMNodeList $xml
  * @return void
  */
 protected function parseDefinition(DOMNodeList $xml)
 {
     /** @var DOMNode $node */
     foreach ($xml as $node) {
         if (strstr($node->nodeName, '#')) {
             continue;
         }
         if (!$this->xmlCondition($node)) {
             continue;
         }
         switch ($node->nodeName) {
             case 'header':
                 $this->xmlHeader($node->childNodes);
                 break;
             case 'config':
                 $this->xmlConfig($node->childNodes);
                 break;
             case 'toolbar':
                 $this->xmlToolbar($node);
                 break;
             case 'body':
                 if ($node->attributes->getNamedItem('disable-menu') && $node->attributes->getNamedItem('disable-menu')->nodeValue == 'true') {
                     SPRequest::set('hidemainmenu', 1);
                 }
                 $this->xmlBody($node->childNodes, $this->_output['data']);
                 break;
             case 'definition':
                 $this->parseDefinition($node->childNodes);
                 break;
         }
     }
     Sobi::Trigger('afterParseDefinition', $this->name(), array(&$this));
 }
Ejemplo n.º 18
0
 /**
  * Gets the value of a user state variable.
  * @param    string $key     - The key of the user state variable.
  * @param    string $request - The name of the variable passed in a request.
  * @param    string $default - The default value for the variable if not found. Optional.
  * @param    string $type    - Filter for the variable.
  * @return    mixed
  */
 public function &getUserState($key, $request, $default = null, $type = 'none')
 {
     $r = JFactory::getApplication()->getUserStateFromRequest("com_sobipro.{$key}", $request, $default, $type);
     SPRequest::set($request, $r);
     return $r;
 }
Ejemplo n.º 19
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');
         SPRequest::set('uid', $this->uid);
     }
     $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();
 }