From 65c59fc020bd54b5a3077a3b8d38e004e2857e1b Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 13 Jun 2011 11:16:07 +1200 Subject: [PATCH] ENHANCEMENT: added ability to define a custom prority to dataobjects. --- code/GoogleSitemap.php | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/code/GoogleSitemap.php b/code/GoogleSitemap.php index ccdbcb2..7d30ce3 100644 --- a/code/GoogleSitemap.php +++ b/code/GoogleSitemap.php @@ -10,7 +10,7 @@ * sitemap whenever the GoogleBot visits your website. * * Enabling notification of Google after every publish (in your _config.php): - + * * * GoogleSitemap::enable_google_notificaton(); * @@ -55,37 +55,40 @@ class GoogleSitemap extends Controller { */ public static $google_sitemap_dataobjects_changefreq = array(); - /** - * List of DataObjects priority - * - * @var array - */ - public static $google_sitemap_dataobjects_priority = array(); + /** + * List of DataObjects priority + * + * @var array + */ + public static $google_sitemap_dataobjects_priority = array(); - /** + /** * Decorates the given DataObject with {@link GoogleSitemapDecorator} * and pushes the class name to the registered DataObjects. * Note that all registered DataObjects need the method AbsoluteLink(). * * @param string $className name of DataObject to register * @param string $changeFreq how often is this DataObject updated? - * Possible values: - * always, hourly, daily, weekly, monthly, yearly, never - * @param string $priority How important is this DataObject in comparison to other urls? - * Possible values: 0.1, 0.2 ... , 0.9, 1.0 + * Possible values: + * always, hourly, daily, weekly, monthly, yearly, never + * @param string $priority How important is this DataObject in comparison to other urls? + * Possible values: 0.1, 0.2 ... , 0.9, 1.0 * * @return void */ public static function register_dataobject($className, $changeFreq = 'monthly', $priority = '0.6') { if (!self::is_registered($className)) { Object::add_extension($className, 'GoogleSitemapDecorator'); + self::$google_sitemap_dataobjects[] = $className; - if ($changeFreq === null) { - self::$google_sitemap_dataobjects_changefreq[] = "monthly"; - } else { - self::$google_sitemap_dataobjects_changefreq[] = $changeFreq; - } - self::$google_sitemap_dataobjects_priority[] = $priority; + + if (!$changeFreq) { + self::$google_sitemap_dataobjects_changefreq[] = "monthly"; + } else { + self::$google_sitemap_dataobjects_changefreq[] = $changeFreq; + } + + self::$google_sitemap_dataobjects_priority[] = $priority; } } @@ -132,7 +135,7 @@ class GoogleSitemap extends Controller { /** * Returns all the links to {@link SiteTree} pages and - * {@link DataObject} urls on the page + * {@link DataObject} urls on the page. * * @return DataObjectSet */