Merge pull request #94 from helpfulrobot/convert-to-psr-2

Converted to PSR-2
This commit is contained in:
Damian Mooyman 2015-12-18 10:02:57 +13:00
commit 289ed77139
5 changed files with 941 additions and 880 deletions

View File

@ -37,7 +37,8 @@
*
* @package googlesitemaps
*/
class GoogleSitemap extends Object {
class GoogleSitemap extends Object
{
/**
* List of {@link DataObject} class names to include. As well as the change
@ -69,7 +70,8 @@ class GoogleSitemap extends Object {
*
* @return void
*/
public static function register_dataobject($className, $changeFreq = 'monthly', $priority = '0.6') {
public static function register_dataobject($className, $changeFreq = 'monthly', $priority = '0.6')
{
if (!self::is_registered($className)) {
$className::add_extension('GoogleSitemapExtension');
@ -93,8 +95,9 @@ class GoogleSitemap extends Object {
*
* @return void
*/
public static function register_dataobjects($dataobjects, $changeFreq = 'monthly', $priority = '0.6') {
foreach($dataobjects as $obj) {
public static function register_dataobjects($dataobjects, $changeFreq = 'monthly', $priority = '0.6')
{
foreach ($dataobjects as $obj) {
self::register_dataobject($obj, $changeFreq, $priority);
}
}
@ -106,7 +109,8 @@ class GoogleSitemap extends Object {
*
* @return bool
*/
public static function is_registered($className) {
public static function is_registered($className)
{
return isset(self::$dataobjects[$className]);
}
@ -115,7 +119,8 @@ class GoogleSitemap extends Object {
*
* @param string
*/
public static function unregister_dataobject($className) {
public static function unregister_dataobject($className)
{
unset(self::$dataobjects[$className]);
}
@ -124,7 +129,8 @@ class GoogleSitemap extends Object {
*
* @return void
*/
public static function clear_registered_dataobjects() {
public static function clear_registered_dataobjects()
{
self::$dataobjects = array();
}
@ -137,7 +143,8 @@ class GoogleSitemap extends Object {
*
* @return void
*/
public static function register_route($route, $changeFreq = 'monthly', $priority = '0.6') {
public static function register_route($route, $changeFreq = 'monthly', $priority = '0.6')
{
self::$routes = array_merge(self::$routes, array(
$route => array(
'frequency' => ($changeFreq) ? $changeFreq : 'monthly',
@ -156,8 +163,9 @@ class GoogleSitemap extends Object {
*
* @return void
*/
public static function register_routes($routes, $changeFreq = 'monthly', $priority = '0.6') {
foreach($routes as $route) {
public static function register_routes($routes, $changeFreq = 'monthly', $priority = '0.6')
{
foreach ($routes as $route) {
self::register_route($route, $changeFreq, $priority);
}
}
@ -167,7 +175,8 @@ class GoogleSitemap extends Object {
*
* @return void
*/
public static function clear_registered_routes() {
public static function clear_registered_routes()
{
self::$routes = array();
}
@ -181,7 +190,8 @@ class GoogleSitemap extends Object {
*
* @return ArrayList
*/
public function getItems($class, $page = 1) {
public function getItems($class, $page = 1)
{
//normalise the class name
try {
$reflectionClass = new ReflectionClass($class);
@ -197,20 +207,19 @@ class GoogleSitemap extends Object {
// todo migrate to extension hook or DI point for other modules to
// modify state filters
if(class_exists('Translatable')) {
if (class_exists('Translatable')) {
Translatable::disable_locale_filter();
}
if($class == "SiteTree") {
if ($class == "SiteTree") {
$filter = ($filter) ? "\"ShowInSearch\" = 1" : "";
$instances = Versioned::get_by_stage('SiteTree', 'Live', $filter);
}
else if($class == "GoogleSitemapRoute") {
} elseif ($class == "GoogleSitemapRoute") {
$instances = array_slice(self::$routes, ($page - 1) * $count, $count);
$output = new ArrayList();
if($instances) {
foreach($instances as $route => $config) {
if ($instances) {
foreach ($instances as $route => $config) {
$output->push(new ArrayData(array(
'AbsoluteLink' => Director::absoluteURL($route),
'ChangeFrequency' => $config['frequency'],
@ -220,8 +229,7 @@ class GoogleSitemap extends Object {
}
return $output;
}
else {
} else {
$instances = new DataList($class);
}
@ -232,9 +240,9 @@ class GoogleSitemap extends Object {
($page - 1) * $count
);
if($instances) {
foreach($instances as $obj) {
if($obj->canIncludeInGoogleSitemap()) {
if ($instances) {
foreach ($instances as $obj) {
if ($obj->canIncludeInGoogleSitemap()) {
$output->push($obj);
}
}
@ -252,7 +260,8 @@ class GoogleSitemap extends Object {
* @return ArrayList
* @deprecated Please create an instance and call ->getSitemaps() instead.
*/
public static function get_items($class, $page = 1) {
public static function get_items($class, $page = 1)
{
return static::inst()->getItems($class, $page);
}
@ -267,9 +276,10 @@ class GoogleSitemap extends Object {
*
* @return string
*/
public static function get_frequency_for_class($class) {
foreach(self::$dataobjects as $type => $config) {
if($class == $type) {
public static function get_frequency_for_class($class)
{
foreach (self::$dataobjects as $type => $config) {
if ($class == $type) {
return $config['frequency'];
}
}
@ -284,9 +294,10 @@ class GoogleSitemap extends Object {
*
* @return float
*/
public static function get_priority_for_class($class) {
foreach(self::$dataobjects as $type => $config) {
if($class == $type) {
public static function get_priority_for_class($class)
{
foreach (self::$dataobjects as $type => $config) {
if ($class == $type) {
return $config['priority'];
}
}
@ -301,15 +312,16 @@ class GoogleSitemap extends Object {
*
* @return ArrayList
*/
public function getSitemaps() {
public function getSitemaps()
{
$countPerFile = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
$sitemaps = new ArrayList();
$filter = Config::inst()->get('GoogleSitemap', 'use_show_in_search');
if(class_exists('SiteTree')) {
if (class_exists('SiteTree')) {
// move to extension hook. At the moment moduleexists config hook
// does not work.
if(class_exists('Translatable')) {
if (class_exists('Translatable')) {
Translatable::disable_locale_filter();
}
@ -321,8 +333,7 @@ class GoogleSitemap extends Object {
$neededForPage = ceil($count / $countPerFile);
for($i = 1; $i <= $neededForPage; $i++) {
for ($i = 1; $i <= $neededForPage; $i++) {
$lastEdited = $instances
->limit($countPerFile, ($i - 1) * $countPerFile)
->sort(array())
@ -338,14 +349,14 @@ class GoogleSitemap extends Object {
}
}
if(count(self::$dataobjects) > 0) {
foreach(self::$dataobjects as $class => $config) {
if (count(self::$dataobjects) > 0) {
foreach (self::$dataobjects as $class => $config) {
$list = new DataList($class);
$list = $list->sort('LastEdited ASC');
$this->extend("alterDataList", $list, $class);
$neededForClass = ceil($list->count() / $countPerFile);
for($i = 1; $i <= $neededForClass; $i++) {
for ($i = 1; $i <= $neededForClass; $i++) {
// determine the last modified date for this slice
$sliced = $list
->limit($countPerFile, ($i - 1) * $countPerFile)
@ -362,10 +373,10 @@ class GoogleSitemap extends Object {
}
}
if(count(self::$routes) > 0) {
if (count(self::$routes) > 0) {
$needed = ceil(count(self::$routes) / $countPerFile);
for($i = 1; $i <= $needed; $i++) {
for ($i = 1; $i <= $needed; $i++) {
$sitemaps->push(new ArrayData(array(
'ClassName' => 'GoogleSitemapRoute',
'Page' => $i
@ -382,7 +393,8 @@ class GoogleSitemap extends Object {
* @return ArrayList
* @deprecated Please create an instance and call ->getSitemaps() instead.
*/
public static function get_sitemaps() {
public static function get_sitemaps()
{
return static::inst()->getSitemaps();
}
@ -398,15 +410,16 @@ class GoogleSitemap extends Object {
*
* @return string Response text
*/
public static function ping() {
if(!self::enabled()) {
public static function ping()
{
if (!self::enabled()) {
return false;
}
// Don't ping if the site has disabled it, or if the site is in dev mode
$active = Config::inst()->get('GoogleSitemap', 'google_notification_enabled');
if(!$active || Director::isDev()) {
if (!$active || Director::isDev()) {
return;
}
@ -427,7 +440,8 @@ class GoogleSitemap extends Object {
*
* @return String Response text
*/
protected static function send_ping($host, $path, $query) {
protected static function send_ping($host, $path, $query)
{
$socket = fsockopen($host, 80, $errno, $error);
if (!$socket) {
return $error;
@ -447,7 +461,8 @@ class GoogleSitemap extends Object {
*
* @return boolean
*/
public static function enabled() {
public static function enabled()
{
return (Config::inst()->get('GoogleSitemap', 'enabled', Config::INHERITED));
}
@ -457,8 +472,8 @@ class GoogleSitemap extends Object {
*
* @return GoogleSitemap
*/
public static function inst() {
public static function inst()
{
return GoogleSitemap::create();
}
}

View File

@ -12,7 +12,8 @@
*
* @package googlesitemaps
*/
class GoogleSitemapController extends Controller {
class GoogleSitemapController extends Controller
{
/**
* @var array
@ -29,8 +30,9 @@ class GoogleSitemapController extends Controller {
*
* @return mixed
*/
public function index($url) {
if(GoogleSitemap::enabled()) {
public function index($url)
{
if (GoogleSitemap::enabled()) {
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
@ -53,11 +55,12 @@ class GoogleSitemapController extends Controller {
*
* @return mixed
*/
public function sitemap() {
public function sitemap()
{
$class = $this->request->param('ID');
$page = $this->request->param('OtherID');
if(GoogleSitemap::enabled() && $class && $page) {
if (GoogleSitemap::enabled() && $class && $page) {
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');

View File

@ -6,28 +6,30 @@
*
* @package googlesitemaps
*/
class GoogleSitemapExtension extends DataExtension {
class GoogleSitemapExtension extends DataExtension
{
/**
* @return boolean
*/
public function canIncludeInGoogleSitemap() {
public function canIncludeInGoogleSitemap()
{
$can = true;
if($this->owner->hasMethod('AbsoluteLink')) {
if ($this->owner->hasMethod('AbsoluteLink')) {
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
if($objHttp != $hostHttp) {
if ($objHttp != $hostHttp) {
$can = false;
}
}
if($can) {
if ($can) {
$can = $this->owner->canView();
}
if($can) {
if ($can) {
$can = $this->owner->getGooglePriority();
}
@ -40,14 +42,16 @@ class GoogleSitemapExtension extends DataExtension {
/**
* @return void
*/
public function onAfterPublish() {
public function onAfterPublish()
{
GoogleSitemap::ping();
}
/**
* @return void
*/
public function onAfterUnpublish() {
public function onAfterUnpublish()
{
GoogleSitemap::ping();
}
@ -58,10 +62,11 @@ class GoogleSitemapExtension extends DataExtension {
*
* @return mixed
*/
public function getGooglePriority() {
public function getGooglePriority()
{
$field = $this->owner->hasField('Priority');
if(isset($this->Priority) || ($field && $this->Priority = $this->owner->getField('Priority'))) {
if (isset($this->Priority) || ($field && $this->Priority = $this->owner->getField('Priority'))) {
return ($this->Priority < 0) ? false : $this->Priority;
}
@ -77,8 +82,9 @@ class GoogleSitemapExtension extends DataExtension {
*
* @return SS_Datetime
*/
public function getChangeFrequency() {
if($freq = GoogleSitemap::get_frequency_for_class($this->owner->class)) {
public function getChangeFrequency()
{
if ($freq = GoogleSitemap::get_frequency_for_class($this->owner->class)) {
return $freq;
}

View File

@ -3,7 +3,8 @@
/**
* @package googlesitemaps
*/
class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension
{
/**
* @var array
@ -15,7 +16,8 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
/**
* @param FieldList
*/
public function updateSettingsFields(&$fields) {
public function updateSettingsFields(&$fields)
{
$prorities = array(
'-1' => _t('GoogleSitemaps.PRIORITYNOTINDEXED', "Not indexed"),
'1.0' => '1 - ' . _t('GoogleSitemaps.PRIORITYMOSTIMPORTANT', "Most important"),
@ -51,7 +53,8 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
*
* @return void
*/
public function updateFieldLabels(&$labels) {
public function updateFieldLabels(&$labels)
{
parent::updateFieldLabels($labels);
$labels['Priority'] = _t('GoogleSitemaps.METAPAGEPRIO', "Page Priority");
@ -62,14 +65,19 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
*
* @return boolean
*/
public function hasPublishedParent() {
public function hasPublishedParent()
{
// Skip root pages
if(empty($this->owner->ParentID)) return true;
if (empty($this->owner->ParentID)) {
return true;
}
// Ensure direct parent exists
$parent = $this->owner->Parent();
if(empty($parent) || !$parent->exists()) return false;
if (empty($parent) || !$parent->exists()) {
return false;
}
// Check ancestry
return $parent->hasPublishedParent();
@ -78,10 +86,13 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
/**
* @return boolean
*/
public function canIncludeInGoogleSitemap() {
public function canIncludeInGoogleSitemap()
{
// Check that parent page is published
if(!$this->owner->hasPublishedParent()) return false;
if (!$this->owner->hasPublishedParent()) {
return false;
}
$result = parent::canIncludeInGoogleSitemap();
$result = ($this->owner instanceof ErrorPage) ? false : $result;
@ -92,11 +103,12 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
/**
* @return mixed
*/
public function getGooglePriority() {
public function getGooglePriority()
{
setlocale(LC_ALL, "en_US.UTF8");
$priority = $this->owner->getField('Priority');
if(!$priority) {
if (!$priority) {
$parentStack = $this->owner->parentStack();
$numParents = is_array($parentStack) ? count($parentStack) - 1 : 0;
@ -104,7 +116,7 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
$result = str_replace(",", ".", $num);
return $result;
} else if ($priority == -1) {
} elseif ($priority == -1) {
return false;
} else {
return (is_numeric($priority) && $priority <= 1.0) ? $priority : 0.5;

View File

@ -6,7 +6,8 @@
* @package googlesitemaps
* @subpackage tests
*/
class GoogleSitemapTest extends FunctionalTest {
class GoogleSitemapTest extends FunctionalTest
{
public static $fixture_file = 'googlesitemaps/tests/GoogleSitemapTest.yml';
@ -16,10 +17,11 @@ class GoogleSitemapTest extends FunctionalTest {
'GoogleSitemapTest_UnviewableDataObject'
);
public function setUp() {
public function setUp()
{
parent::setUp();
if(class_exists('Page')) {
if (class_exists('Page')) {
$this->loadFixture('googlesitemaps/tests/GoogleSitemapPageTest.yml');
}
@ -27,25 +29,28 @@ class GoogleSitemapTest extends FunctionalTest {
GoogleSitemap::clear_registered_routes();
}
public function tearDown() {
public function tearDown()
{
parent::tearDown();
GoogleSitemap::clear_registered_dataobjects();
GoogleSitemap::clear_registered_routes();
}
public function testIndexFileWithCustomRoute() {
public function testIndexFileWithCustomRoute()
{
GoogleSitemap::register_route('/test/');
$response = $this->get('sitemap.xml');
$body = $response->getBody();
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapRoute/1") ."</loc>";
$this->assertEquals(1, substr_count($body, $expected) , 'A link to the custom routes exists');
$this->assertEquals(1, substr_count($body, $expected), 'A link to the custom routes exists');
}
public function testGetItems() {
public function testGetItems()
{
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject", '');
$items = GoogleSitemap::get_items('GoogleSitemapTest_DataObject', 1);
@ -63,7 +68,8 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertEquals(0, GoogleSitemap::get_items('GoogleSitemapTest_UnviewableDataObject', 1)->count());
}
public function testGetItemsWithCustomRoutes() {
public function testGetItemsWithCustomRoutes()
{
GoogleSitemap::register_routes(array(
'/test-route/',
'/someother-route/',
@ -74,7 +80,8 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertEquals(3, $items->count());
}
public function testAccessingSitemapRootXMLFile() {
public function testAccessingSitemapRootXMLFile()
{
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
GoogleSitemap::register_dataobject("GoogleSitemapTest_OtherDataObject");
@ -84,19 +91,20 @@ class GoogleSitemapTest extends FunctionalTest {
// the sitemap should contain <loc> to both those files and not the other
// dataobject as it hasn't been registered
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_DataObject/1") ."</loc>";
$this->assertEquals(1, substr_count($body, $expected) , 'A link to GoogleSitemapTest_DataObject exists');
$this->assertEquals(1, substr_count($body, $expected), 'A link to GoogleSitemapTest_DataObject exists');
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_OtherDataObject/1") ."</loc>";
$this->assertEquals(1, substr_count($body, $expected) , 'A link to GoogleSitemapTest_OtherDataObject exists');
$this->assertEquals(1, substr_count($body, $expected), 'A link to GoogleSitemapTest_OtherDataObject exists');
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_UnviewableDataObject/2") ."</loc>";
$this->assertEquals(0, substr_count($body, $expected) , 'A link to a GoogleSitemapTest_UnviewableDataObject does not exist');
$this->assertEquals(0, substr_count($body, $expected), 'A link to a GoogleSitemapTest_UnviewableDataObject does not exist');
}
public function testLastModifiedDateOnRootXML() {
public function testLastModifiedDateOnRootXML()
{
Config::inst()->update('GoogleSitemap', 'enabled', true);
if(!class_exists('Page')) {
if (!class_exists('Page')) {
$this->markTestIncomplete('No cms module installed, page related test skipped');
}
@ -116,10 +124,11 @@ class GoogleSitemapTest extends FunctionalTest {
$expected = '<lastmod>2014-03-14</lastmod>';
$this->assertEquals(1, substr_count($body, $expected) , 'The last mod date should use most recent LastEdited date');
$this->assertEquals(1, substr_count($body, $expected), 'The last mod date should use most recent LastEdited date');
}
public function testIndexFilePaginatedSitemapFiles() {
public function testIndexFilePaginatedSitemapFiles()
{
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
@ -127,15 +136,16 @@ class GoogleSitemapTest extends FunctionalTest {
$response = $this->get('sitemap.xml');
$body = $response->getBody();
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_DataObject/1") ."</loc>";
$this->assertEquals(1, substr_count($body, $expected) , 'A link to the first page of GoogleSitemapTest_DataObject exists');
$this->assertEquals(1, substr_count($body, $expected), 'A link to the first page of GoogleSitemapTest_DataObject exists');
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_DataObject/2") ."</loc>";
$this->assertEquals(1, substr_count($body, $expected) , 'A link to the second page GoogleSitemapTest_DataObject exists');
$this->assertEquals(1, substr_count($body, $expected), 'A link to the second page GoogleSitemapTest_DataObject exists');
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
}
public function testRegisterRoutesIncludesAllRoutes() {
public function testRegisterRoutesIncludesAllRoutes()
{
GoogleSitemap::register_route('/test/');
GoogleSitemap::register_routes(array(
'/test/', // duplication should be replaced
@ -150,7 +160,8 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertEquals(3, substr_count($body, "<loc>"));
}
public function testAccessingNestedSiteMap() {
public function testAccessingNestedSiteMap()
{
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
@ -163,7 +174,8 @@ class GoogleSitemapTest extends FunctionalTest {
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
}
public function testAccessingNestedSiteMapCaseInsensitive() {
public function testAccessingNestedSiteMapCaseInsensitive()
{
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
@ -176,8 +188,9 @@ class GoogleSitemapTest extends FunctionalTest {
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
}
public function testGetItemsWithPages() {
if(!class_exists('Page')) {
public function testGetItemsWithPages()
{
if (!class_exists('Page')) {
$this->markTestIncomplete('No cms module installed, page related test skipped');
}
@ -206,7 +219,8 @@ class GoogleSitemapTest extends FunctionalTest {
), GoogleSitemap::get_items('SiteTree'), "There should be only 1 page, other is logged in only");
}
public function testAccess() {
public function testAccess()
{
Config::inst()->update('GoogleSitemap', 'enabled', true);
$response = $this->get('sitemap.xml');
@ -229,8 +243,9 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertEquals(404, $response->getStatusCode(), 'Sitemap file returns a 404 when disabled');
}
public function testDecoratorAddsFields() {
if(!class_exists("Page")) {
public function testDecoratorAddsFields()
{
if (!class_exists("Page")) {
$this->markTestIncomplete('No cms module installed, page related test skipped');
}
@ -244,8 +259,9 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertInstanceOf('LiteralField', $tab->fieldByName('GoogleSitemapIntro'));
}
public function testGetPriority() {
if(!class_exists("Page")) {
public function testGetPriority()
{
if (!class_exists("Page")) {
$this->markTestIncomplete('No cms module installed, page related test skipped');
}
@ -264,9 +280,9 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertFalse($page->getGooglePriority());
}
public function testUnpublishedPage() {
if(!class_exists('SiteTree')) {
public function testUnpublishedPage()
{
if (!class_exists('SiteTree')) {
$this->markTestSkipped('Test skipped; CMS module required for testUnpublishedPage');
}
@ -288,7 +304,7 @@ class GoogleSitemapTest extends FunctionalTest {
$this->assertEmpty($orphanedPage->canIncludeInGoogleSitemap());
$this->assertNotEmpty($rootPage->hasPublishedParent());
$this->assertNotEmpty($rootPage->canIncludeInGoogleSitemap());
} catch(Exception $ex) {
} catch (Exception $ex) {
Versioned::set_reading_mode($oldMode);
throw $ex;
} // finally {
@ -301,17 +317,20 @@ class GoogleSitemapTest extends FunctionalTest {
* @package googlesitemaps
* @subpackage tests
*/
class GoogleSitemapTest_DataObject extends DataObject implements TestOnly {
class GoogleSitemapTest_DataObject extends DataObject implements TestOnly
{
public static $db = array(
'Priority' => 'Varchar(10)'
);
public function canView($member = null) {
public function canView($member = null)
{
return true;
}
public function AbsoluteLink() {
public function AbsoluteLink()
{
return Director::absoluteBaseURL();
}
}
@ -320,17 +339,20 @@ class GoogleSitemapTest_DataObject extends DataObject implements TestOnly {
* @package googlesitemaps
* @subpackage tests
*/
class GoogleSitemapTest_OtherDataObject extends DataObject implements TestOnly {
class GoogleSitemapTest_OtherDataObject extends DataObject implements TestOnly
{
public static $db = array(
'Priority' => 'Varchar(10)'
);
public function canView($member = null) {
public function canView($member = null)
{
return true;
}
public function AbsoluteLink() {
public function AbsoluteLink()
{
return Director::absoluteBaseURL();
}
}
@ -339,17 +361,20 @@ class GoogleSitemapTest_OtherDataObject extends DataObject implements TestOnly {
* @package googlesitemaps
* @subpackage tests
*/
class GoogleSitemapTest_UnviewableDataObject extends DataObject implements TestOnly {
class GoogleSitemapTest_UnviewableDataObject extends DataObject implements TestOnly
{
public static $db = array(
'Priority' => 'Varchar(10)'
);
public function canView($member = null) {
public function canView($member = null)
{
return false;
}
public function AbsoluteLink() {
public function AbsoluteLink()
{
return Director::absoluteBaseURL();
}
}