Example #1
0
 public function validateCache()
 {
     static $remove = array('name', 'nid', 'metaDesc', 'metaKeys', 'metaRobots', 'options', 'oType', 'parent');
     $core = SPFactory::object($this->id);
     foreach ($core as $a => $v) {
         if (!in_array($a, $remove)) {
             $this->_set($a, $v);
         }
     }
 }
Example #2
0
 /**
  * @deprecated since 1.1 replaced by {@link #Initialise()}
  * @param int $sid - section id
  * @param null $root - root of Joomla!
  * @param null $lang - language
  * @return null
  */
 public static function Init($root = null, $lang = null, $sid = 0)
 {
     static $loaded = false;
     if (!$loaded) {
         if (!defined('SOBI_CMS')) {
             define('SOBI_CMS', version_compare(JVERSION, '3.0.0', 'ge') ? 'joomla3' : (version_compare(JVERSION, '1.6.0', 'ge') ? 'joomla16' : 'joomla15'));
         }
         defined('SOBIPRO') || define('SOBIPRO', true);
         defined('SOBI_TASK') || define('SOBI_TASK', 'task');
         defined('SOBI_DEFLANG') || define('SOBI_DEFLANG', $lang);
         defined('SOBI_ACL') || define('SOBI_ACL', 'front');
         defined('SOBI_ROOT') || define('SOBI_ROOT', $root);
         defined('SOBI_MEDIA') || define('SOBI_MEDIA', implode('/', array($root, 'media', 'sobipro')));
         defined('SOBI_PATH') || define('SOBI_PATH', SOBI_ROOT . '/components/com_sobipro');
         defined('SOBI_LIVE_PATH') || define('SOBI_LIVE_PATH', 'components/com_sobipro');
         require_once SOBI_PATH . '/lib/base/fs/loader.php';
         SPLoader::loadController('sobipro');
         SPLoader::loadController('interface');
         SPLoader::loadClass('base.exception');
         SPLoader::loadClass('base.const');
         SPLoader::loadClass('base.object');
         SPLoader::loadClass('base.filter');
         SPLoader::loadClass('base.request');
         SPLoader::loadClass('cms.base.lang');
         SPLoader::loadClass('models.dbobject');
         SPLoader::loadClass('base.factory');
         SPLoader::loadClass('base.config');
         SPLoader::loadClass('cms.base.fs');
         // in case it is a CLI call
         if (isset($_SERVER['REQUEST_URI'])) {
             SPFactory::config()->set('live_site', JURI::root());
         }
         $loaded = true;
     }
     if ($sid) {
         $section = null;
         if ($sid) {
             $path = array();
             $id = $sid;
             $path[] = (int) $id;
             while ($id > 0) {
                 try {
                     $id = SPFactory::db()->select('pid', 'spdb_relations', array('id' => $id))->loadResult();
                     if ($id) {
                         $path[] = (int) $id;
                     }
                 } catch (SPException $x) {
                     Sobi::Error('ExtCoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
                 }
             }
             $path = array_reverse($path);
             $section = SPFactory::object($path[0]);
         }
         /* set current section in the registry */
         SPFactory::registry()->set('current_section', $section->id);
         $_config =& SPFactory::config();
         /* load basic configuration settings */
         $_config->addIniFile('etc.config', true);
         $_config->addTable('spdb_config', $sid);
         /* initialise interface config setting */
         SPFactory::mainframe()->getBasicCfg();
         /* initialise config */
         $_config->init();
     }
 }
Example #3
0
 /**
  * @return bool
  */
 private function routeObj()
 {
     if ($this->_model instanceof stdClass && isset($this->_model->id)) {
         if ($this->_sid && $this->_model->id != $this->_sid) {
             $this->_model = SPFactory::object($this->_sid);
         }
     }
     try {
         $ctrl = SPFactory::Controller($this->_model->oType, true);
         if ($ctrl instanceof SPController) {
             $this->setController($ctrl);
             $this->_ctrl->setModel(SPLoader::loadModel($this->_model->oType));
             /** @noinspection PhpParamsInspection */
             $this->_ctrl->extend($this->_model);
             $this->_ctrl->setTask($this->_task);
         }
     } catch (SPException $x) {
         Sobi::Error('CoreCtrl', SPLang::e('Cannot route object: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     return true;
 }
Example #4
0
 public function &getInstance($id = 0)
 {
     static $instances = array();
     $id = $id ? $id : Sobi::Reg('current_section');
     if (!isset($instances[$id]) || !$instances[$id] instanceof self) {
         $instances[$id] = new self();
         $instances[$id]->extend(SPFactory::object($id));
     }
     return $instances[$id];
 }
Example #5
0
 public function fetchElement($name)
 {
     static $sid = 0;
     $selected = 0;
     $db = SPFactory::db();
     if (!$sid) {
         $sid = 0;
         if ($this->cid) {
             $link = $this->getLink();
             if (strstr($link, 'sid')) {
                 $query = array();
                 parse_str($link, $query);
                 $sid = $query['sid'];
                 if (isset($query['sptpl'])) {
                     $this->tpl = $query['sptpl'];
                 }
             }
             if ($sid) {
                 $section = SPFactory::object($sid);
                 if ($section->oType == 'section') {
                     $selected = $section->id;
                     $this->section = $selected;
                 } else {
                     $path = array();
                     $id = $sid;
                     while ($id > 0) {
                         try {
                             $db->select('pid', 'spdb_relations', array('id' => $id));
                             $id = $db->loadResult();
                             if ($id) {
                                 $path[] = (int) $id;
                             }
                         } catch (SPException $x) {
                         }
                     }
                     $path = array_reverse($path);
                     $selected = $path[0];
                     $this->section = $selected;
                 }
             } else {
                 // just to not repeating
                 $sid = -1;
             }
         }
     }
     $this->sid = $sid;
     $this->determineObjectType($sid);
     switch ($name) {
         case 'sid':
             $params = array('id' => 'sid', 'class' => 'input-mini', 'style' => 'text-align: center; margin-top: 10px; margin-left: 10px;', 'readonly' => 'readonly');
             return '<div class="SobiPro" id="jform_request_sid">' . SPHtml_Input::text('type', $this->oTypeName, array('id' => 'otype', 'class' => 'input-medium', 'style' => 'text-align: center; margin-top: 10px;', 'readonly' => 'readonly')) . SPHtml_Input::text('urlparams[sid]', $sid, $params) . '</div>';
             break;
         case 'cid':
             return $this->getCat();
             break;
         case 'eid':
             return $this->getEntry();
             break;
         case 'did':
         case 'date':
             return $this->getCalendar();
             break;
         case 'tpl':
         case 'sptpl':
             return $this->getTemplates();
             break;
     }
     $sections = array();
     $sout = array();
     try {
         $sections = $db->select('*', 'spdb_object', array('oType' => 'section'), 'id')->loadObjectList();
     } catch (SPException $x) {
         Sobi::Error($this->name(), $x->getMessage(), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     if (count($sections)) {
         SPLoader::loadClass('models.datamodel');
         SPLoader::loadClass('models.dbobject');
         SPLoader::loadModel('section');
         $sout[] = Sobi::Txt('SOBI_SELECT_SECTION');
         foreach ($sections as $section) {
             if (Sobi::Can('section', 'access', 'valid', $section->id)) {
                 $s = new SPSection();
                 $s->extend($section);
                 $sout[$s->get('id')] = $s->get('name');
             }
         }
     }
     $params = array('id' => 'spsection', 'class' => 'required');
     $field = SPHtml_Input::select('sid', $sout, $selected, false, $params);
     return "<div class=\"SobiPro\" style=\"margin-top: 2px;\">{$field}</div>";
 }
Example #6
0
 /**
  * @param int $id
  * @return \SPDBObject
  * @internal param \stdClass $obj
  */
 public function &init($id = 0)
 {
     Sobi::Trigger($this->name(), ucfirst(__FUNCTION__) . 'Start', array(&$id));
     $this->id = $id ? $id : $this->id;
     if ($this->id) {
         try {
             $obj = SPFactory::object($this->id);
             if (!empty($obj)) {
                 /* ensure that the id was right */
                 if ($obj->oType == $this->oType) {
                     $this->extend($obj);
                 } else {
                     $this->id = 0;
                 }
             }
             $this->createdTime = SPFactory::config()->date($this->createdTime);
             $this->validSince = SPFactory::config()->date($this->validSince);
             if ($this->validUntil) {
                 $this->validUntil = SPFactory::config()->date($this->validUntil);
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_GET_OBJECT_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
         $this->loadTable();
     }
     return $this;
 }
Example #7
0
 /**
  * @return bool
  */
 private function routeObj()
 {
     try {
         $ctrl = SPFactory::Controller($this->_model->oType);
         if ($ctrl instanceof SPController) {
             $this->setController($ctrl);
             if ($this->_model->id == SPRequest::sid()) {
                 // just to use the pre-fetched entry
                 if ($this->_model->oType == 'entry') {
                     $e = SPFactory::Entry($this->_model->id);
                     // object has been stored anyway in the SPFactory::object method
                     // and also already initialized
                     // therefore it will be now rewritten and because the init flag is set to true
                     // the name is getting lost
                     // $e->extend( $this->_model );
                     $this->_ctrl->setModel($e);
                 } else {
                     $this->_ctrl->setModel(SPLoader::loadModel($this->_model->oType));
                     $this->_ctrl->extend($this->_model);
                 }
             } else {
                 $this->_ctrl->extend(SPFactory::object(SPRequest::sid()));
             }
             $this->_ctrl->setTask($this->_task);
         }
     } catch (SPException $x) {
         if (defined('SOBI_TESTS')) {
             Sobi::Error('CoreCtrl', SPLang::e('Cannot set controller. %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         } else {
             SPFactory::mainframe()->setRedirect(Sobi::Reg('live_site'), SPLang::e('PAGE_NOT_FOUND'), SPC::ERROR_MSG, true);
         }
     }
     return true;
 }