Пример #1
0
 /**
  * Hook: Index Page Content
  *
  * @param    object $pObj    Object
  */
 public function hook_indexContent(&$pObj)
 {
     $this->addPageToSitemapIndex();
     $possibility = (int) \Metaseo\Metaseo\Utility\GeneralUtility::getExtConf('sitemap_clearCachePossibility', 0);
     if ($possibility > 0) {
         $clearCacheChance = ceil(mt_rand(0, $possibility));
         if ($clearCacheChance == 1) {
             \Metaseo\Metaseo\Utility\SitemapUtility::expire();
         }
     }
 }
Пример #2
0
 /**
  * Clear outdated and invalid pages from sitemap table
  */
 public static function expire()
 {
     // #####################
     // Expired pages
     // #####################
     $expireDays = (int) \Metaseo\Metaseo\Utility\GeneralUtility::getExtConf('sitemap_pageSitemapExpireDays', 60);
     if (empty($expireDays)) {
         $expireDays = 60;
     }
     // No negative days allowed
     $expireDays = abs($expireDays);
     $tstamp = time() - $expireDays * 24 * 60 * 60;
     $query = 'DELETE FROM tx_metaseo_sitemap
                     WHERE tstamp <= ' . (int) $tstamp . '
                       AND is_blacklisted = 0';
     DatabaseUtility::exec($query);
     // #####################
     //  Deleted or
     // excluded pages
     // #####################
     $query = 'SELECT
                     ts.uid
                 FROM
                     tx_metaseo_sitemap ts
                     LEFT JOIN pages p
                         ON p.uid = ts.page_uid
                        AND p.deleted = 0
                        AND p.hidden = 0
                        AND p.tx_metaseo_is_exclude = 0
                 WHERE
                     p.uid IS NULL';
     $deletedSitemapPages = DatabaseUtility::getColWithIndex($query);
     // delete pages
     if (!empty($deletedSitemapPages)) {
         $query = 'DELETE FROM tx_metaseo_sitemap
                         WHERE uid IN (' . implode(',', $deletedSitemapPages) . ')
                           AND is_blacklisted = 0';
         DatabaseUtility::exec($query);
     }
 }