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();
 }
Exemple #2
0
 /**
  * @return void
  */
 public function storeMessages()
 {
     Sobi::SetUserData('messages-queue', $this->messages);
 }
Exemple #3
0
 /**
  * @param string $eOrder
  * @param int $eLimit
  * @param int $eLimStart
  * @param bool $count
  * @param array $conditions
  * @param bool $entriesRecursive
  * @param int $pid
  * @return array
  */
 public function getEntries($eOrder, $eLimit = null, $eLimStart = null, $count = false, $conditions = array(), $entriesRecursive = false, $pid = 0)
 {
     /* var SPDb $db */
     $db = SPFactory::db();
     $entries = array();
     $eDir = 'asc';
     $oPrefix = null;
     $conditions = is_array($conditions) ? $conditions : array();
     /* get the ordering and the direction */
     if (strstr($eOrder, '.')) {
         $eOr = explode('.', $eOrder);
         $eOrder = array_shift($eOr);
         $eDir = implode('.', $eOr);
     }
     $pid = $pid ? $pid : SPRequest::sid();
     /* if sort by name, then sort by the name field */
     if ($eOrder == 'name') {
         $eOrder = SPFactory::config()->nameField()->get('fid');
     }
     if ($entriesRecursive) {
         $pids = $this->_model->getChilds('category', true);
         if (is_array($pids)) {
             $pids = array_keys($pids);
         }
         $pids[] = SPRequest::sid();
         $conditions['sprl.pid'] = $pids;
     } else {
         $conditions['sprl.pid'] = $pid;
     }
     if ($pid == -1) {
         unset($conditions['sprl.pid']);
     }
     /* sort by field */
     if (strstr($eOrder, 'field_')) {
         static $field = null;
         $specificMethod = false;
         if (!$field) {
             try {
                 $fType = $db->select('fieldType', 'spdb_field', array('nid' => $eOrder, 'section' => Sobi::Section()))->loadResult();
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             }
             if ($fType) {
                 $field = SPLoader::loadClass('opt.fields.' . $fType);
             }
         }
         if ($field && method_exists($field, 'customOrdering')) {
             $table = null;
             $oPrefix = null;
             $specificMethod = call_user_func_array(array($field, 'customOrdering'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
         } elseif ($field && method_exists($field, 'sortBy')) {
             $table = null;
             $oPrefix = null;
             $specificMethod = call_user_func_array(array($field, 'sortBy'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
         }
         if (!$specificMethod) {
             $table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id'))));
             $oPrefix = 'spo.';
             $conditions['spo.oType'] = 'entry';
             $conditions['fdef.nid'] = $eOrder;
             $eOrder = 'baseData.' . $eDir;
         }
     } elseif (strstr($eOrder, 'counter')) {
         $table = $db->join(array(array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id'), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('spo.id', 'sprl.id')), array('table' => 'spdb_counter', 'as' => 'spcounter', 'key' => array('spo.id', 'spcounter.sid'))));
         $oPrefix = 'spo.';
         $conditions['spo.oType'] = 'entry';
         if (strstr($eOrder, '.')) {
             $cOrder = explode('.', $eOrder);
             $eOrder = 'spcounter.counter.' . $cOrder[1];
         } else {
             $eOrder = 'spcounter.counter.desc';
         }
     } else {
         $table = $db->join(array(array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
         $conditions['spo.oType'] = 'entry';
         $eOrder = $eOrder . '.' . $eDir;
         $oPrefix = 'spo.';
         if (strstr($eOrder, 'valid')) {
             $eOrder = $oPrefix . $eOrder;
         }
     }
     /* check user permissions for the visibility */
     if (Sobi::My('id')) {
         $this->userPermissionsQuery($conditions, $oPrefix);
         if (isset($conditions[$oPrefix . 'state']) && $conditions[$oPrefix . 'state']) {
             $conditions['sprl.copy'] = 0;
         }
     } else {
         $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince')));
         $conditions['sprl.copy'] = '0';
     }
     try {
         $results = $db->select($oPrefix . 'id', $table, $conditions, $eOrder, $eLimit, $eLimStart, true)->loadResultArray();
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     Sobi::Trigger($this->name(), 'AfterGetEntries', array(&$results, $count));
     if (count($results) && !$count) {
         foreach ($results as $i => $sid) {
             // it needs too much memory moving the object creation to the view
             //$entries[ $i ] = SPFactory::Entry( $sid );
             $entries[$i] = $sid;
         }
     }
     if ($count) {
         Sobi::SetUserData('currently-displayed-entries', $results);
         return $results;
     }
     return $entries;
 }
Exemple #4
0
 public function getEntries($eLimit, $site, $ids = false)
 {
     $conditions = array();
     $entries = array();
     /* get the site to display */
     $eLimStart = ($site - 1) * $eLimit;
     if (isset($this->_letter[1]) && $this->_letter[1] == '-') {
         $this->_letter = "[{$this->_letter[0]}-{$this->_letter[2]}]";
     }
     $db = SPFactory::db();
     /*
      * Don't know exactly why but on Windows servers there seems to be some problem with unicode chars
      *     - strtolower/strtoupper is destroying these chars completely
      *     - MySQL seems to be suddenly case sensitive with non-latin chars so we need to ask both
      *
      * Wed, Apr 4, 2012: Apparently it's not only Windows related
      */
     if (!preg_match('/^[\\x20-\\x7f]*$/D', $this->_letter) && function_exists('mb_strtolower')) {
         // if we have multibyte string support - ask both cases ...
         $baseCondition = "REGEXP:^{$this->_letter}|^" . mb_strtoupper($this->_letter);
     } else {
         // if no unicode - great, it'll work.
         // if we don't have MB - shit happens
         $baseCondition = "REGEXP:^{$this->_letter}";
     }
     switch ($this->_fieldType) {
         case 'chbxgroup':
         case 'select':
         case 'multiselect':
             $eOrder = 'sValue';
             $table = $db->join(array(array('table' => 'spdb_field_option_selected', 'as' => 'opts'), array('table' => 'spdb_language', 'as' => 'lang', 'key' => array('opts.optValue', 'lang.sKey')), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('opts.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('opts.sid', 'sprl.id'))));
             $oPrefix = 'spo.';
             $conditions['spo.oType'] = 'entry';
             $conditions['opts.fid'] = $this->_field;
             $conditions['lang.sValue'] = $baseCondition;
             break;
         default:
             $eOrder = 'baseData';
             $table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id'))));
             $oPrefix = 'spo.';
             $conditions['spo.oType'] = 'entry';
             $conditions['fdef.fid'] = $this->_field;
             $conditions['fdata.baseData'] = $baseCondition;
             break;
     }
     $this->_field = $this->_field ? $this->_field : Sobi::Cfg('alphamenu.primary_field', SPFactory::config()->nameField()->get('id'));
     /* check user permissions for the visibility */
     if (Sobi::My('id')) {
         $this->userPermissionsQuery($conditions, $oPrefix);
     } else {
         $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince')));
     }
     $conditions['sprl.copy'] = '0';
     try {
         $db->select($oPrefix . 'id', $table, $conditions, $eOrder, $eLimit, $eLimStart, true);
         $results = $db->loadResultArray();
     } catch (SPException $x) {
         Sobi::Error('AlphaListing', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     if ($ids) {
         Sobi::SetUserData('currently-displayed-entries', $results);
         return $results;
     }
     if (count($results)) {
         foreach ($results as $i => $sid) {
             // it needs too much memory moving the object creation to the view
             //$entries[ $i ] = SPFactory::Entry( $sid );
             $entries[$i] = $sid;
         }
     }
     Sobi::Trigger($this->name(), 'AfterGetEntries', array(&$entries, false));
     return $entries;
 }
Exemple #5
0
 protected function getResults($ssid, $template)
 {
     $results = array();
     /* case some plugin overwrites this method */
     Sobi::Trigger('GetResults', 'Search', array(&$results, &$ssid, &$template));
     if (count($results)) {
         return $results;
     }
     /* get limits - if defined in template config - otherwise from the section config */
     $eLimit = $this->tKey($template, 'entries_limit', Sobi::Cfg('search.entries_limit', Sobi::Cfg('list.entries_limit', 2)));
     $eInLine = $this->tKey($template, 'entries_in_line', Sobi::Cfg('search.entries_in_line', Sobi::Cfg('list.entries_in_line', 2)));
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLimStart = ($site - 1) * $eLimit;
     try {
         $this->_db->select(array('entriesResults', 'requestData'), 'spdb_search', array('ssid' => $ssid));
         $r = $this->_db->loadAssocList();
         if (strlen($r[0]['entriesResults'])) {
             $store = SPConfig::unserialize($r[0]['entriesResults']);
             if ($store['results']) {
                 $this->_results = array_unique(explode(',', $store['results']));
                 $this->_resultsByPriority = $store['resultsByPriority'];
             }
             $this->_resultsCount = count($this->_results);
         }
         $this->_request = SPConfig::unserialize($r[0]['requestData']);
         SPFactory::registry()->set('requestcache', $this->_request);
         if (count($this->_results)) {
             $r = array_slice($this->_results, $eLimStart, $eLimit);
             /* so we have a results */
             foreach ($r as $i => $sid) {
                 $results[$i] = (int) $sid;
                 //$results[ $i ] = new $eClass();
                 //$results[ $i ]->init( $sid );
             }
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_GET_SESSION_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     Sobi::SetUserData('currently-displayed-entries', $results);
     return $results;
 }