Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • GoogleSitemap
  • GoogleSitemapDecorator
 1 <?php
 2 
 3 /**
 4  * Decorate the page object to provide google sitemaps with 
 5  * additionally options and configuration.
 6  * 
 7  * @package googlesitemaps
 8  */
 9 class GoogleSitemapDecorator extends SiteTreeDecorator {
10     
11     function extraStatics() {
12         return array(
13             'db' => array(
14                 "Priority" => "Varchar(5)",
15             )
16         );
17     }
18     
19     function updateCMSFields(&$fields) {
20         $pagePriorities = array(
21             '' => _t('SiteTree.PRIORITYAUTOSET','Auto-set based on page depth'),
22             '-1' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"), // We set this to -ve one because a blank value implies auto-generation of Priority
23             '1.0' => '1 - ' . _t('SiteTree.PRIORITYMOSTIMPORTANT', "Most important"),
24             '0.9' => '2',
25             '0.8' => '3',
26             '0.7' => '4',
27             '0.6' => '5',
28             '0.5' => '6',
29             '0.4' => '7',
30             '0.3' => '8',
31             '0.2' => '9',
32             '0.1' => '10 - ' . _t('SiteTree.PRIORITYLEASTIMPORTANT', "Least important")
33         );
34         
35         $fields->addFieldsToTab('Root.Content.Metadata', array(
36             new LiteralField(
37                 "GoogleSitemapIntro", 
38                 "<p>" .
39                 sprintf(
40                     _t(
41                         'SiteTree.METANOTEPRIORITY', 
42                         "Manually specify a Google Sitemaps priority for this page (%s)"
43                     ),
44                     '<a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=71936#prioritize" target="_blank">?</a>'
45                 ) .
46                 "</p>"
47             ), 
48             new DropdownField("Priority", $this->owner->fieldLabel('Priority'), $pagePriorities)
49         ));
50     }
51     
52     function updateFieldLabels(&$labels) {
53         parent::updateFieldLabels($labels);
54         
55         $labels['Priority'] = _t('SiteTree.METAPAGEPRIO', "Page Priority");
56     }
57     
58     function onAfterPublish() {
59         GoogleSitemap::ping();
60     }
61     
62     function onAfterUnpublish() {
63         GoogleSitemap::ping();
64     }
65     
66     /**
67      * The default value of the priority field depends on the depth of the page in
68      * the site tree, so it must be calculated dynamically.
69      */
70     function getPriority() {
71         if ($this->owner->getField('Priority')) 
72             return $this->owner->getField('Priority');
73 
74         if ($this->owner->Parent()->Priority < 0) 
75             return -1;
76         $parentStack = $this->owner->parentStack();
77         $numParents = is_array($parentStack) ? count($parentStack) - 1: 0;
78         return max(0.1, 1.0 - ($numParents / 10));
79     }
80 }
81 
82 
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0