/**
  * Returns a pages change frequency calculated by pages age and number of 
  * versions. Google expects always, hourly, daily, weekly, monthly, yearly 
  * or never as values.
  * 
  * @see http://support.google.com/webmasters/bin/answer.py?hl=en&answer=183668&topic=8476&ctx=topic
  *
  * @return SS_Datetime
  */
 public function getChangeFrequency()
 {
     if ($freq = GoogleSitemap::get_frequency_for_class($this->owner->class)) {
         return $freq;
     }
     $date = date('Y-m-d H:i:s');
     $created = new SS_Datetime();
     $created->value = $this->owner->Created ? $this->owner->Created : $date;
     $now = new SS_Datetime();
     $now->value = $date;
     $versions = $this->owner->Version ? $this->owner->Version : 1;
     $timediff = $now->format('U') - $created->format('U');
     // Check how many revisions have been made over the lifetime of the
     // Page for a rough estimate of it's changing frequency.
     $period = $timediff / ($versions + 1);
     if ($period > 60 * 60 * 24 * 365) {
         $freq = 'yearly';
     } elseif ($period > 60 * 60 * 24 * 30) {
         $freq = 'monthly';
     } elseif ($period > 60 * 60 * 24 * 7) {
         $freq = 'weekly';
     } elseif ($period > 60 * 60 * 24) {
         $freq = 'daily';
     } elseif ($period > 60 * 60) {
         $freq = 'hourly';
     } else {
         $freq = 'always';
     }
     return $freq;
 }
 /**
  * Specific controller action for displaying a particular list of links 
  * for a class
  * 
  * @return mixed
  */
 public function sitemap()
 {
     $class = $this->request->param('ID');
     $page = $this->request->param('OtherID');
     if (GoogleSitemap::enabled() && $class && $page) {
         Config::inst()->update('SSViewer', 'set_source_file_comments', false);
         $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
         $this->getResponse()->addHeader('X-Robots-Tag', 'noindex');
         $items = GoogleSitemap::get_items($class, $page);
         $this->extend('updateGoogleSitemapItems', $items, $class, $page);
         return array('Items' => $items);
     } else {
         return new SS_HTTPResponse('Page not found', 404);
     }
 }
 public function testAccess()
 {
     Config::inst()->update('GoogleSitemap', 'enabled', true);
     $response = $this->get('sitemap.xml');
     $this->assertEquals(200, $response->getStatusCode(), 'Sitemap returns a 200 success when enabled');
     $this->assertEquals('application/xml; charset="utf-8"', $response->getHeader('Content-Type'));
     GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
     $response = $this->get('sitemap.xml/sitemap/GoogleSitemapTest_DataObject/1');
     $this->assertEquals(200, $response->getStatusCode(), 'Sitemap returns a 200 success when enabled');
     $this->assertEquals('application/xml; charset="utf-8"', $response->getHeader('Content-Type'));
     Config::inst()->remove('GoogleSitemap', 'enabled');
     Config::inst()->update('GoogleSitemap', 'enabled', false);
     $response = $this->get('sitemap.xml');
     $this->assertEquals(404, $response->getStatusCode(), 'Sitemap index returns a 404 when disabled');
     $response = $this->get('sitemap.xml/sitemap/GoogleSitemapTest_DataObject/1');
     $this->assertEquals(404, $response->getStatusCode(), 'Sitemap file returns a 404 when disabled');
 }
    $prevent = $prevent_result->fields;
    if ($prevent['configuration_value'] == date("Ymd")) {
        die('Halt! Already executed - should not execute more than once a day.');
    } else {
        $configurationtable = $oostable['configuration'];
        $dbconn->Execute("UPDATE $configurationtable SET configuration_value = '" . date("Ymd") . "' WHERE configuration_key = 'CRON_GOOGLE_RUN'");
    }
} else {
      $configurationtable = $oostable['configuration'];
      $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id) VALUES ('CRON_GOOGLE_RUN', '" . date("Ymd") . "', '6')");
}


require_once MYOOS_INCLUDE_PATH . '/includes/classes/class_googlesitemap.php';

$oGoogle = new GoogleSitemap;

$submit = true;
echo '<pre>';

if ($oGoogle->GenerateProductSitemap()){
    echo 'Generated Google Product Sitemap Successfully' . "\n\n";
} else {
    $submit = false;
    echo 'ERROR: Google Product Sitemap Generation FAILED!' . "\n\n";
}

if ($oGoogle->GenerateCategorySitemap()){
    echo 'Generated Google Category Sitemap Successfully' . "\n\n";
} else {
    $submit = false;
Esempio n. 5
0
 function unpublish()
 {
     $SQL_id = Convert::raw2sql($_REQUEST['ID']);
     $page = DataObject::get_by_id("SiteTree", $SQL_id);
     $page->deleteFromStage('Live');
     $page->flushCache();
     $page = DataObject::get_by_id("SiteTree", $SQL_id);
     $page->Status = "Unpublished";
     $page->write();
     GoogleSitemap::ping();
     return $this->tellBrowserAboutPublicationChange($page, sprintf(_t('CMSMain.REMOVEDPAGE', "Removed '%s' from the published site"), $page->Title));
 }
Esempio n. 6
0
 function createGoogleSitemap()
 {
     $google = new GoogleSitemap();
     $submit = true;
     $product_sitemap = false;
     if (SITEMAP_PRODUCTEN == '1') {
         $product_sitemap = true;
         if ($google->GenerateProductSitemap()) {
             //echo 'De producten sitemap is succesvol aangemaakt!' . "<br />";
         } else {
             $prods_query = tep_db_query('SELECT products_id FROM products limit 1');
             if (tep_db_num_rows($prods_query) > 0) {
                 $submit = false;
                 echo 'ERROR: De producten sitemap is niet correct aangemaakt!' . "<br />";
             } else {
                 $product_sitemap = false;
                 echo 'OPGELET: De producten sitemap is niet aangemaakt! Er zijn geen producten!' . "<br />";
             }
         }
     }
     $category_sitemap = false;
     if (SITEMAP_CATEGORIEEN == '1') {
         $category_sitemap = true;
         if ($google->GenerateCategorySitemap()) {
             //echo 'De Categorie&euml;n sitemap is succesvol aangemaakt!' . "<br />";
         } else {
             $cats_query = tep_db_query('SELECT categories_id FROM categories limit 1');
             if (tep_db_num_rows($cats_query) > 0) {
                 $submit = false;
                 echo 'ERROR: De categorie&euml;n sitemap is niet correct aangemaakt!' . "<br />";
             } else {
                 $category_sitemap = false;
                 echo 'OPGELET: De categorie&euml;n sitemap is niet aangemaakt! Er zijn geen categorie&euml;n!' . "<br />";
             }
         }
     }
     $showManufacturers = false;
     if (SITEMAP_FABRIKANTEN == '1') {
         $showManufacturers = true;
         if ($google->GenerateManufacturerSitemap()) {
             //echo 'De fabrikanten sitemap is succesvol aangemaakt!' . "<br />";
         } else {
             $manufacturers_query = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS . " limit 1");
             if (tep_db_num_rows($manufacturers_query) > 0) {
                 $submit = false;
                 echo 'ERROR: De fabrikanten sitemap is niet correct aangemaakt!' . "<br />";
             } else {
                 $showManufacturers = false;
                 echo 'OPGELET: De fabrikanten sitemap is niet aangemaakt! Er zijn geen fabrikanten!' . "<br />";
             }
         }
     }
     $showSpecials = false;
     if (SITEMAP_PROMOTIES == '1') {
         $showSpecials = true;
         if ($google->GenerateSpecialsSitemap($languages_id)) {
             //echo 'De promotie sitemap is succesvol aangemaakt!' . "<br />";
         } else {
             $specials_query = tep_db_query("select products_id from specials WHERE expires_date > NOW() AND status = '1' limit 1");
             if (tep_db_num_rows($specials_query) > 0) {
                 $submit = false;
                 echo 'ERROR: De promotie sitemap is niet correct aangemaakt!' . "<br />";
             } else {
                 $showSpecials = false;
                 echo 'OPGELET: De promotie sitemap is niet aangemaakt! Er zijn geen promoties!' . "<br />";
             }
         }
     }
     $showInfopages = false;
     if (SITEMAP_INFOPAGINA == '1') {
         $showInfopages = true;
         if ($google->GeneratePagesSitemap()) {
             //echo 'De infopagina sitemap is succesvol aangepast!' . "<br />";
         } else {
             $infopages_query = tep_db_query("select infopages_id from infopages WHERE infopages_status = '1' limit 1");
             if (tep_db_num_rows($infopages_query) > 0) {
                 $submit = false;
                 echo 'ERROR: De infopagina sitemap is niet correct aangemaakt!' . "<br />";
             } else {
                 $showInfopages = false;
                 echo 'OPGELET: De infopagina sitemap is niet aangemaakt! Er zijn geen infopagina\'s!' . "<br />";
             }
         }
     }
     if ($google->GenerateSitemapIndex($showInfopages, $showManufacturers, $showSpecials, $category_sitemap, $product_sitemap)) {
         //echo 'De index sitemap is succesvol aangemaakt!' . "<br />";
     } else {
         $submit = false;
     }
     if ($submit) {
         //echo "<br />".'Alle sitemaps zijn correct aangemaakt!' . "<br /><br />";
         /*echo 'Dit is de index sitemap: ' . $google->base_url . 'sitemapindex.xml' . "<br />";
         		if ($product_sitemap)
         			echo 'Dit is de producten sitemap: ' . $google->base_url . 'sitemapproducts.xml' . "<br />";
         		if ($category_sitemap)
         			echo 'Dit is de categorie&euml;n sitemap: ' . $google->base_url . 'sitemapcategories.xml' . "<br />";
         		if ($showManufacturers)
         			echo 'Dit is de fabrikanten sitemap: ' . $google->base_url . 'sitemapmanufacturers.xml' . "<br />";
         		if ($showSpecials)
         			echo 'Dit is de promotie sitemap: ' . $google->base_url . 'sitemapspecials.xml' . "<br />";
         		if ($showInfopages)
         			echo 'Dit is de infopagina sitemap: ' . $google->base_url . 'sitemappages.xml' . "<br />";
         		*/
     } else {
         echo '<pre>';
         print_r($google->debug);
         echo '</pre>';
     }
 }
Esempio n. 7
0
 /**
  * Disables pings to google when the sitemap changes
  * To use this, in your _config.php file simply include the line
  * GoogleSitemap::DisableGoogleNotification();
  */
 static function DisableGoogleNotification()
 {
     self::$pings = false;
 }
 /**
  * Clears registered routes
  *
  * @return void
  */
 public static function clear_registered_routes()
 {
     self::$routes = array();
 }
 /**
  * Convenience method for manufacturing an instance for hew instance-level methods (and for easier type definition).
  *
  * @return GoogleSitemap
  */
 public static function inst()
 {
     return GoogleSitemap::create();
 }
Esempio n. 10
0
        require_once DIR_WS_CLASSES . 'seo.class.php';
        $seo_urls = new SEO_URL($languages_id);
    }
    require_once DIR_WS_FUNCTIONS . 'html_output.php';
    if (file_exists(DIR_WS_CLASSES . 'cache.class.php')) {
        include DIR_WS_CLASSES . 'cache.class.php';
        $cache = new cache($languages_id);
        if (file_exists('includes/seo_cache.php')) {
            include 'includes/seo_cache.php';
        }
        $cache->get_cache('GLOBAL');
    }
}
# end if
require_once 'sitemap.class.php';
$google = new GoogleSitemap(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);
$submit = true;
echo '<p class="main">';
if ($google->GenerateProductSitemap()) {
    echo GOOGLE_SITEMAPS_PRODUCT_SUCCESS . "<br><br>";
} else {
    $submit = false;
    echo GOOGLE_SITEMAPS_PRODUCT_ERROR . "<br><br>";
}
if ($google->GenerateCategorySitemap()) {
    echo GOOGLE_SITEMAPS_CATEGORY_SUCCESS . "<br><br>";
} else {
    $submit = false;
    echo GOOGLE_SITEMAPS_CATEGORY_ERROR . "<br><br>";
}
if ($google->GenerateSitemapIndex()) {
Esempio n. 11
0
//prevent script from running more than once a day
$configurationtable = $oostable['configuration'];
$sql = "SELECT configuration_value FROM $configurationtable WHERE configuration_key = 'CRON_GOOGLE_RUN'";
$prevent_result = $dbconn->Execute($sql);

if ($prevent_result->RecordCount() > 0) {
    $prevent = $prevent_result->fields;
    if ($prevent['configuration_value'] == date("Ymd")) {
     #   die('Halt! Already executed - should not execute more than once a day.');
    } 
}


require_once MYOOS_INCLUDE_PATH . '/includes/classes/class_googlesitemap.php';

$oSitemap = new GoogleSitemap;

$submit = true;
echo '<pre>';

if ($oSitemap->GenerateProductSitemap()){
    echo 'Generated Google Product Sitemap Successfully' . "\n\n";
} else {
    $submit = false;
    echo 'ERROR: Google Product Sitemap Generation FAILED!' . "\n\n";
}

if ($oSitemap->GenerateCategorySitemap()){
    echo 'Generated Google Category Sitemap Successfully' . "\n\n";
} else {
    $submit = false;
Esempio n. 12
0
// ----------------------------------------------------------------------------
SilvercartGroupViewHandler::addGroupView('SilvercartGroupViewList');
SilvercartGroupViewHandler::addGroupView('SilvercartGroupViewTile');
SilvercartGroupViewHandler::addGroupHolderView('SilvercartGroupViewList');
SilvercartGroupViewHandler::addGroupHolderView('SilvercartGroupViewTile');
// ----------------------------------------------------------------------------
// set default group view if not existant
// ----------------------------------------------------------------------------
if (is_null(SilvercartGroupViewHandler::getDefaultGroupView())) {
    SilvercartGroupViewHandler::setDefaultGroupView('SilvercartGroupViewList');
}
if (is_null(SilvercartGroupViewHandler::getDefaultGroupHolderView())) {
    SilvercartGroupViewHandler::setDefaultGroupHolderView('SilvercartGroupViewList');
}
if (class_exists('GoogleSitemap') && method_exists('GoogleSitemap', 'register_dataobject')) {
    GoogleSitemap::register_dataobject('SilvercartProduct', null, '0.2');
}
// ----------------------------------------------------------------------------
// add silvercart branding if no other branding is set
// ----------------------------------------------------------------------------
if (Config::inst()->get('LeftAndMain', 'application_name') == 'SilverStripe') {
    Config::inst()->update('LeftAndMain', 'application_name', 'SilverCart - ' . SilvercartConfig::SilvercartFullVersion());
    Config::inst()->update('LeftAndMain', 'application_link', 'http://www.silvercart.org');
}
// ----------------------------------------------------------------------------
// Register menus for the storeadmin
// ----------------------------------------------------------------------------
SilvercartConfig::registerMenu('default', _t('SilvercartStoreAdminMenu.DEFAULT'));
SilvercartConfig::registerMenu('files', _t('SilvercartStoreAdminMenu.FILES'));
SilvercartConfig::registerMenu('orders', _t('SilvercartStoreAdminMenu.ORDERS'));
SilvercartConfig::registerMenu('products', _t('SilvercartStoreAdminMenu.PRODUCTS'));
 public static function disable()
 {
     self::$enabled = false;
 }
<?php

// Extentions
SiteConfig::add_extension('Ext_Commerce_SiteConfig');
Image::add_extension('Ext_Commerce_Image');
Controller::add_extension('Ext_Commerce_Controller');
Group::add_extension('Ext_Commerce_Group');
Member::add_extension('Ext_Commerce_Member');
if (class_exists('Users_Account_Controller')) {
    Users_Account_Controller::add_extension('Ext_Commerce_UsersController');
}
// If subsites is installed
if (class_exists('Subsite')) {
    Product::add_extension('Ext_Subsites_CommerceObject');
    ProductCategory::add_extension('Ext_Subsites_CommerceObject');
    Order::add_extension('Ext_Subsites_CommerceObject');
    CatalogueAdmin::add_extension('SubsiteMenuExtension');
    LocaliseAdmin::add_extension('SubsiteMenuExtension');
    OrderAdmin::add_extension('SubsiteMenuExtension');
}
LeftAndMain::add_extension('Ext_Commerce_LeftAndMain');
// Setup google sitemaps
if (class_exists("GoogleSitemap")) {
    GoogleSitemap::register_dataobject('Product');
    GoogleSitemap::register_dataobject('ProductCategory');
}
Esempio n. 15
0
<?php

// If subsites is installed
if (class_exists('Subsite')) {
    CatalogueProduct::add_extension('SubsiteCatalogueExtension');
    CatalogueCategory::add_extension('SubsiteCatalogueExtension');
    TaxRate::add_extension('SubsiteCatalogueExtension');
    CatalogueAdmin::add_extension('SubsiteMenuExtension');
}
// Setup google sitemaps
$catalogue_enabled = Catalogue::config()->enable_frontend;
if ($catalogue_enabled && class_exists("GoogleSitemap")) {
    GoogleSitemap::register_dataobject('CatalogueProduct');
    GoogleSitemap::register_dataobject('CatalogueCategory');
}
Esempio n. 16
0
        if ($info['size_download'] == 0) {
            message("cURL Error: Zero download size '" . $url . "'.", 'error');
            return false;
        }
        if (isset($info['download_content_length']) && $info['download_content_length'] > 0 && $info['download_content_length'] != $info['size_download']) {
            message("cURL Error: Reading less than page size '" . $url . "'. " . $info['size_download'] . "<" . $info['download_content_length'] . ". ", 'error');
            return false;
        }
    }
    $info['html_page'] = $html_page;
    return $info;
}
$inline = isset($_GET['inline']) && $_GET['inline'] == 'yes' ? true : false;
$silently = isset($_GET['silently']) && $_GET['silently'] == 'yes' || $inline ? true : false;
message('Google Sitemap Generation (' . GOOGLE_SITEMAP_VERSION . ') started<br /><br />' . "\n\n");
$google = new GoogleSitemap();
$submit = true;
if (!isset($_GET['genxml']) || $_GET['genxml'] != 'no') {
    message('<br />');
    if ($google->GenerateProductSitemap()) {
        message('Generated Google Product Sitemap Successfully' . ' - <a href="' . $google->base_url . 'sitemapproducts.xml" target="_blank">' . $google->base_url . 'sitemapproducts.xml</a><br />' . "\n");
    } else {
        $submit = false;
        message('<span style="font-weight: bold); color: red;">ERROR: Google Product Sitemap Generation FAILED!</span><br />' . "\n\n");
    }
    message('<br />');
    if ($google->GenerateCategorySitemap()) {
        message('Generated Google Category Sitemap Successfully' . ' - <a href="' . $google->base_url . 'sitemapcategories.xml" target="_blank">' . $google->base_url . 'sitemapcategories.xml</a><br />' . "\n");
    } else {
        $submit = false;
        message('<span style="font-weight: bold); color: red;">ERROR: Google Category Sitemap Generation FAILED!</span><br />' . "\n\n");
 function onAfterUnpublish()
 {
     GoogleSitemap::ping();
 }
<?php

Header('Content-type: text/html; charset=UTF-8');
ob_start();
require_once 'includes/application_top.php';
require_once 'includes/classes/sitemap.php';
$keys_query = tep_db_query('SELECT name, value FROM seo WHERE type="sitemap"');
while ($keys = tep_db_fetch_array($keys_query)) {
    define('SITEMAP_' . strtoupper(str_replace('&euml;', 'e', $keys['name'])), $keys['value']);
}
$google = new GoogleSitemap();
$submit = true;
/****************/
/*	Products	*/
/****************/
$product_sitemap = false;
if (SITEMAP_PRODUCTEN == '1') {
    $product_sitemap = true;
    if ($google->GenerateProductSitemap()) {
        echo 'De producten sitemap is succesvol aangemaakt!' . "<br />";
    } else {
        $prods_query = tep_db_query('SELECT products_id FROM products limit 1');
        if (tep_db_num_rows($prods_query) > 0) {
            $submit = false;
            echo 'ERROR: De producten sitemap is niet correct aangemaakt!' . "<br />";
        } else {
            $product_sitemap = false;
            echo 'OPGELET: De producten sitemap is niet aangemaakt! Er zijn geen producten!' . "<br />";
        }
    }
}