コード例 #1
0
ファイル: urls.php プロジェクト: lautarodragan/ideary
 /**
  * Purge urls from database (and cache)
  * either all automatic, or according to current
  * sef url list page select options as stored in
  * in session
  * @param unknown_type $type
  */
 public function purge($type = 'auto')
 {
     // make sure we use latest user state
     $this->_updateContextData();
     // call the appropriate sub-method to get the db query
     $methodName = '_getPurgeQuery' . ucfirst($type);
     if (is_callable(array($this, $methodName))) {
         $deleteQuery = $this->{$methodName}();
     } else {
         $this->setError('Invalid method call _purge' . $type);
         return;
     }
     // then run the query
     $this->_db->setQuery($deleteQuery);
     $this->_db->query();
     // store error
     $error = $this->_db->getErrorNum();
     if (!empty($error)) {
         $this->setError('Internal database error # ' . $error);
     }
     // delete from cache : we delete the whole cache anyway, except for 404 pages
     // which are not in the cache
     if ($type != '404') {
         Sh404sefHelperCache::purge();
     }
     // reset limit and limitstart variables, to avoid
     // issue when displaying again results
     $this->_setState('limitstart', 0);
     $this->_setState('limit', 0);
     // reprocess custom urls, checking there is still at least one per group
     // of identical SEF url with a rank = 0
     // as the "main" url for this group was possibly deleted during the purge
     $query = 'select ?? from (select * from ?? where ?? <> ? order by ?? asc) as tmp_table group by ??';
     $nameQuoted = array('id', '#__sh404sef_urls', 'dateadd', 'rank', 'oldurl');
     $quoted = array('0000-00-00');
     try {
         // select custom with lowest rank
         $customs = Sh404sefHelperDb::queryQuoteOnly($query, $nameQuoted, $quoted)->eLoadResultArray();
         // make sure there is at least one of those with rank = 0
         if (!empty($customs)) {
             Sh404sefHelperDb::updateIn('#__sh404sef_urls', array('rank' => 0), 'id', $customs);
         }
     } catch (Sh404sefExceptionDefault $e) {
         $this->setError('Internal database error # ' . $e->getMessage());
     }
 }
コード例 #2
0
 private function _changeErrorPageCategory($pageTitle = '__404__')
 {
     // try find this old category
     $catid = Sh404sefHelperDb::selectResult('#__categories', array('id'), 'parent_id > 0 and extension = ? and path = ? and level = ?', array('com_content', 'uncategorised', 1));
     if (empty($catid)) {
         return false;
     }
     // we have cat id, try to read article
     $ids = Sh404sefHelperDb::selectAssoc('#__content', array('id'), array('catid' => $catid, 'title' => $pageTitle));
     if (empty($ids)) {
         return false;
     }
     // we indeed have one or more such articles (possibly one per language: move them to new category)
     Sh404sefHelperDb::updateIn('#__content', array('catid' => $this->_errorPageCatId), 'id', $ids);
     return true;
 }