예제 #1
0
    /**
     * Clear outdated and invalid pages from sitemap table
     */
    public static function expire()
    {
        global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS;
        #####################
        # Expired pages
        #####################
        $expireDays = (int) tx_tqseo_tools::getExtConf('sitemap_pageSitemapExpireDays', 60);
        $tstamp = time() - $expireDays * 24 * 60 * 60;
        $query = 'DELETE FROM tx_tqseo_sitemap WHERE tstamp <= ' . (int) $tstamp;
        $res = $TYPO3_DB->sql_query($query);
        #####################
        # Deleted or
        # excluded pages
        #####################
        $deletedSitemapPages = array();
        $query = 'SELECT
						ts.uid
					FROM
						tx_tqseo_sitemap ts
						LEFT JOIN pages p
							ON		p.uid = ts.page_uid
								AND	p.deleted = 0
								AND p.hidden = 0
					WHERE
						p.uid IS NULL';
        $res = $TYPO3_DB->sql_query($query);
        while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
            $deletedSitemapPages[$row['uid']] = $row['uid'];
        }
        // delete pages
        if (!empty($deletedSitemapPages)) {
            $query = 'DELETE FROM tx_tqseo_sitemap WHERE uid IN (' . implode(',', $deletedSitemapPages) . ')';
            $TYPO3_DB->sql_query($query);
        }
    }
예제 #2
0
 /**
  * Hook: Index Page Content
  *
  * @param	object	$pObj	Object
  */
 public function hook_indexContent(&$pObj)
 {
     $this->addPageToSitemapIndex();
     $possibility = (int) tx_tqseo_tools::getExtConf('sitemap_clearCachePossibility', 0);
     if ($possibility > 0) {
         $clearCacheChance = ceil(mt_rand(0, $possibility));
         if ($clearCacheChance == 1) {
             tx_tqseo_sitemap::expire();
         }
     }
 }