mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
Merge pull request #94 from helpfulrobot/convert-to-psr-2
Converted to PSR-2
This commit is contained in:
commit
289ed77139
@ -37,7 +37,8 @@
|
|||||||
*
|
*
|
||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
*/
|
*/
|
||||||
class GoogleSitemap extends Object {
|
class GoogleSitemap extends Object
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of {@link DataObject} class names to include. As well as the change
|
* List of {@link DataObject} class names to include. As well as the change
|
||||||
@ -69,7 +70,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @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)) {
|
if (!self::is_registered($className)) {
|
||||||
$className::add_extension('GoogleSitemapExtension');
|
$className::add_extension('GoogleSitemapExtension');
|
||||||
|
|
||||||
@ -93,8 +95,9 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function register_dataobjects($dataobjects, $changeFreq = 'monthly', $priority = '0.6') {
|
public static function register_dataobjects($dataobjects, $changeFreq = 'monthly', $priority = '0.6')
|
||||||
foreach($dataobjects as $obj) {
|
{
|
||||||
|
foreach ($dataobjects as $obj) {
|
||||||
self::register_dataobject($obj, $changeFreq, $priority);
|
self::register_dataobject($obj, $changeFreq, $priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +109,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function is_registered($className) {
|
public static function is_registered($className)
|
||||||
|
{
|
||||||
return isset(self::$dataobjects[$className]);
|
return isset(self::$dataobjects[$className]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +119,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
*/
|
*/
|
||||||
public static function unregister_dataobject($className) {
|
public static function unregister_dataobject($className)
|
||||||
|
{
|
||||||
unset(self::$dataobjects[$className]);
|
unset(self::$dataobjects[$className]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +129,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function clear_registered_dataobjects() {
|
public static function clear_registered_dataobjects()
|
||||||
|
{
|
||||||
self::$dataobjects = array();
|
self::$dataobjects = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +143,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @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(
|
self::$routes = array_merge(self::$routes, array(
|
||||||
$route => array(
|
$route => array(
|
||||||
'frequency' => ($changeFreq) ? $changeFreq : 'monthly',
|
'frequency' => ($changeFreq) ? $changeFreq : 'monthly',
|
||||||
@ -156,8 +163,9 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function register_routes($routes, $changeFreq = 'monthly', $priority = '0.6') {
|
public static function register_routes($routes, $changeFreq = 'monthly', $priority = '0.6')
|
||||||
foreach($routes as $route) {
|
{
|
||||||
|
foreach ($routes as $route) {
|
||||||
self::register_route($route, $changeFreq, $priority);
|
self::register_route($route, $changeFreq, $priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +175,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function clear_registered_routes() {
|
public static function clear_registered_routes()
|
||||||
|
{
|
||||||
self::$routes = array();
|
self::$routes = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +190,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
public function getItems($class, $page = 1) {
|
public function getItems($class, $page = 1)
|
||||||
|
{
|
||||||
//normalise the class name
|
//normalise the class name
|
||||||
try {
|
try {
|
||||||
$reflectionClass = new ReflectionClass($class);
|
$reflectionClass = new ReflectionClass($class);
|
||||||
@ -197,20 +207,19 @@ class GoogleSitemap extends Object {
|
|||||||
|
|
||||||
// todo migrate to extension hook or DI point for other modules to
|
// todo migrate to extension hook or DI point for other modules to
|
||||||
// modify state filters
|
// modify state filters
|
||||||
if(class_exists('Translatable')) {
|
if (class_exists('Translatable')) {
|
||||||
Translatable::disable_locale_filter();
|
Translatable::disable_locale_filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($class == "SiteTree") {
|
if ($class == "SiteTree") {
|
||||||
$filter = ($filter) ? "\"ShowInSearch\" = 1" : "";
|
$filter = ($filter) ? "\"ShowInSearch\" = 1" : "";
|
||||||
$instances = Versioned::get_by_stage('SiteTree', 'Live', $filter);
|
$instances = Versioned::get_by_stage('SiteTree', 'Live', $filter);
|
||||||
}
|
} elseif ($class == "GoogleSitemapRoute") {
|
||||||
else if($class == "GoogleSitemapRoute") {
|
|
||||||
$instances = array_slice(self::$routes, ($page - 1) * $count, $count);
|
$instances = array_slice(self::$routes, ($page - 1) * $count, $count);
|
||||||
$output = new ArrayList();
|
$output = new ArrayList();
|
||||||
|
|
||||||
if($instances) {
|
if ($instances) {
|
||||||
foreach($instances as $route => $config) {
|
foreach ($instances as $route => $config) {
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
'AbsoluteLink' => Director::absoluteURL($route),
|
'AbsoluteLink' => Director::absoluteURL($route),
|
||||||
'ChangeFrequency' => $config['frequency'],
|
'ChangeFrequency' => $config['frequency'],
|
||||||
@ -220,8 +229,7 @@ class GoogleSitemap extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$instances = new DataList($class);
|
$instances = new DataList($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +240,9 @@ class GoogleSitemap extends Object {
|
|||||||
($page - 1) * $count
|
($page - 1) * $count
|
||||||
);
|
);
|
||||||
|
|
||||||
if($instances) {
|
if ($instances) {
|
||||||
foreach($instances as $obj) {
|
foreach ($instances as $obj) {
|
||||||
if($obj->canIncludeInGoogleSitemap()) {
|
if ($obj->canIncludeInGoogleSitemap()) {
|
||||||
$output->push($obj);
|
$output->push($obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +260,8 @@ class GoogleSitemap extends Object {
|
|||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
* @deprecated Please create an instance and call ->getSitemaps() instead.
|
* @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);
|
return static::inst()->getItems($class, $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,9 +276,10 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function get_frequency_for_class($class) {
|
public static function get_frequency_for_class($class)
|
||||||
foreach(self::$dataobjects as $type => $config) {
|
{
|
||||||
if($class == $type) {
|
foreach (self::$dataobjects as $type => $config) {
|
||||||
|
if ($class == $type) {
|
||||||
return $config['frequency'];
|
return $config['frequency'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,9 +294,10 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public static function get_priority_for_class($class) {
|
public static function get_priority_for_class($class)
|
||||||
foreach(self::$dataobjects as $type => $config) {
|
{
|
||||||
if($class == $type) {
|
foreach (self::$dataobjects as $type => $config) {
|
||||||
|
if ($class == $type) {
|
||||||
return $config['priority'];
|
return $config['priority'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,15 +312,16 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
public function getSitemaps() {
|
public function getSitemaps()
|
||||||
|
{
|
||||||
$countPerFile = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
$countPerFile = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
||||||
$sitemaps = new ArrayList();
|
$sitemaps = new ArrayList();
|
||||||
$filter = Config::inst()->get('GoogleSitemap', 'use_show_in_search');
|
$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
|
// move to extension hook. At the moment moduleexists config hook
|
||||||
// does not work.
|
// does not work.
|
||||||
if(class_exists('Translatable')) {
|
if (class_exists('Translatable')) {
|
||||||
Translatable::disable_locale_filter();
|
Translatable::disable_locale_filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,8 +333,7 @@ class GoogleSitemap extends Object {
|
|||||||
|
|
||||||
$neededForPage = ceil($count / $countPerFile);
|
$neededForPage = ceil($count / $countPerFile);
|
||||||
|
|
||||||
for($i = 1; $i <= $neededForPage; $i++) {
|
for ($i = 1; $i <= $neededForPage; $i++) {
|
||||||
|
|
||||||
$lastEdited = $instances
|
$lastEdited = $instances
|
||||||
->limit($countPerFile, ($i - 1) * $countPerFile)
|
->limit($countPerFile, ($i - 1) * $countPerFile)
|
||||||
->sort(array())
|
->sort(array())
|
||||||
@ -338,14 +349,14 @@ class GoogleSitemap extends Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count(self::$dataobjects) > 0) {
|
if (count(self::$dataobjects) > 0) {
|
||||||
foreach(self::$dataobjects as $class => $config) {
|
foreach (self::$dataobjects as $class => $config) {
|
||||||
$list = new DataList($class);
|
$list = new DataList($class);
|
||||||
$list = $list->sort('LastEdited ASC');
|
$list = $list->sort('LastEdited ASC');
|
||||||
$this->extend("alterDataList", $list, $class);
|
$this->extend("alterDataList", $list, $class);
|
||||||
$neededForClass = ceil($list->count() / $countPerFile);
|
$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
|
// determine the last modified date for this slice
|
||||||
$sliced = $list
|
$sliced = $list
|
||||||
->limit($countPerFile, ($i - 1) * $countPerFile)
|
->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);
|
$needed = ceil(count(self::$routes) / $countPerFile);
|
||||||
|
|
||||||
for($i = 1; $i <= $needed; $i++) {
|
for ($i = 1; $i <= $needed; $i++) {
|
||||||
$sitemaps->push(new ArrayData(array(
|
$sitemaps->push(new ArrayData(array(
|
||||||
'ClassName' => 'GoogleSitemapRoute',
|
'ClassName' => 'GoogleSitemapRoute',
|
||||||
'Page' => $i
|
'Page' => $i
|
||||||
@ -382,7 +393,8 @@ class GoogleSitemap extends Object {
|
|||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
* @deprecated Please create an instance and call ->getSitemaps() instead.
|
* @deprecated Please create an instance and call ->getSitemaps() instead.
|
||||||
*/
|
*/
|
||||||
public static function get_sitemaps() {
|
public static function get_sitemaps()
|
||||||
|
{
|
||||||
return static::inst()->getSitemaps();
|
return static::inst()->getSitemaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,15 +410,16 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return string Response text
|
* @return string Response text
|
||||||
*/
|
*/
|
||||||
public static function ping() {
|
public static function ping()
|
||||||
if(!self::enabled()) {
|
{
|
||||||
|
if (!self::enabled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't ping if the site has disabled it, or if the site is in dev mode
|
// 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');
|
$active = Config::inst()->get('GoogleSitemap', 'google_notification_enabled');
|
||||||
|
|
||||||
if(!$active || Director::isDev()) {
|
if (!$active || Director::isDev()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +440,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return String Response text
|
* @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);
|
$socket = fsockopen($host, 80, $errno, $error);
|
||||||
if (!$socket) {
|
if (!$socket) {
|
||||||
return $error;
|
return $error;
|
||||||
@ -447,7 +461,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function enabled() {
|
public static function enabled()
|
||||||
|
{
|
||||||
return (Config::inst()->get('GoogleSitemap', 'enabled', Config::INHERITED));
|
return (Config::inst()->get('GoogleSitemap', 'enabled', Config::INHERITED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,8 +472,8 @@ class GoogleSitemap extends Object {
|
|||||||
*
|
*
|
||||||
* @return GoogleSitemap
|
* @return GoogleSitemap
|
||||||
*/
|
*/
|
||||||
public static function inst() {
|
public static function inst()
|
||||||
|
{
|
||||||
return GoogleSitemap::create();
|
return GoogleSitemap::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
*
|
*
|
||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapController extends Controller {
|
class GoogleSitemapController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@ -29,8 +30,9 @@ class GoogleSitemapController extends Controller {
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function index($url) {
|
public function index($url)
|
||||||
if(GoogleSitemap::enabled()) {
|
{
|
||||||
|
if (GoogleSitemap::enabled()) {
|
||||||
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
|
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
|
||||||
|
|
||||||
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
|
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
|
||||||
@ -53,11 +55,12 @@ class GoogleSitemapController extends Controller {
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function sitemap() {
|
public function sitemap()
|
||||||
|
{
|
||||||
$class = $this->request->param('ID');
|
$class = $this->request->param('ID');
|
||||||
$page = $this->request->param('OtherID');
|
$page = $this->request->param('OtherID');
|
||||||
|
|
||||||
if(GoogleSitemap::enabled() && $class && $page) {
|
if (GoogleSitemap::enabled() && $class && $page) {
|
||||||
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
|
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
|
||||||
|
|
||||||
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
|
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
|
||||||
|
@ -6,28 +6,30 @@
|
|||||||
*
|
*
|
||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapExtension extends DataExtension {
|
class GoogleSitemapExtension extends DataExtension
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function canIncludeInGoogleSitemap() {
|
public function canIncludeInGoogleSitemap()
|
||||||
|
{
|
||||||
$can = true;
|
$can = true;
|
||||||
|
|
||||||
if($this->owner->hasMethod('AbsoluteLink')) {
|
if ($this->owner->hasMethod('AbsoluteLink')) {
|
||||||
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
|
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
|
||||||
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
|
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
|
||||||
|
|
||||||
if($objHttp != $hostHttp) {
|
if ($objHttp != $hostHttp) {
|
||||||
$can = false;
|
$can = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($can) {
|
if ($can) {
|
||||||
$can = $this->owner->canView();
|
$can = $this->owner->canView();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($can) {
|
if ($can) {
|
||||||
$can = $this->owner->getGooglePriority();
|
$can = $this->owner->getGooglePriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,14 +42,16 @@ class GoogleSitemapExtension extends DataExtension {
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onAfterPublish() {
|
public function onAfterPublish()
|
||||||
|
{
|
||||||
GoogleSitemap::ping();
|
GoogleSitemap::ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onAfterUnpublish() {
|
public function onAfterUnpublish()
|
||||||
|
{
|
||||||
GoogleSitemap::ping();
|
GoogleSitemap::ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,10 +62,11 @@ class GoogleSitemapExtension extends DataExtension {
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getGooglePriority() {
|
public function getGooglePriority()
|
||||||
|
{
|
||||||
$field = $this->owner->hasField('Priority');
|
$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;
|
return ($this->Priority < 0) ? false : $this->Priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +82,9 @@ class GoogleSitemapExtension extends DataExtension {
|
|||||||
*
|
*
|
||||||
* @return SS_Datetime
|
* @return SS_Datetime
|
||||||
*/
|
*/
|
||||||
public function getChangeFrequency() {
|
public function getChangeFrequency()
|
||||||
if($freq = GoogleSitemap::get_frequency_for_class($this->owner->class)) {
|
{
|
||||||
|
if ($freq = GoogleSitemap::get_frequency_for_class($this->owner->class)) {
|
||||||
return $freq;
|
return $freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
/**
|
/**
|
||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@ -15,7 +16,8 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
|||||||
/**
|
/**
|
||||||
* @param FieldList
|
* @param FieldList
|
||||||
*/
|
*/
|
||||||
public function updateSettingsFields(&$fields) {
|
public function updateSettingsFields(&$fields)
|
||||||
|
{
|
||||||
$prorities = array(
|
$prorities = array(
|
||||||
'-1' => _t('GoogleSitemaps.PRIORITYNOTINDEXED', "Not indexed"),
|
'-1' => _t('GoogleSitemaps.PRIORITYNOTINDEXED', "Not indexed"),
|
||||||
'1.0' => '1 - ' . _t('GoogleSitemaps.PRIORITYMOSTIMPORTANT', "Most important"),
|
'1.0' => '1 - ' . _t('GoogleSitemaps.PRIORITYMOSTIMPORTANT', "Most important"),
|
||||||
@ -51,7 +53,8 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function updateFieldLabels(&$labels) {
|
public function updateFieldLabels(&$labels)
|
||||||
|
{
|
||||||
parent::updateFieldLabels($labels);
|
parent::updateFieldLabels($labels);
|
||||||
|
|
||||||
$labels['Priority'] = _t('GoogleSitemaps.METAPAGEPRIO', "Page Priority");
|
$labels['Priority'] = _t('GoogleSitemaps.METAPAGEPRIO', "Page Priority");
|
||||||
@ -62,14 +65,19 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasPublishedParent() {
|
public function hasPublishedParent()
|
||||||
|
{
|
||||||
|
|
||||||
// Skip root pages
|
// Skip root pages
|
||||||
if(empty($this->owner->ParentID)) return true;
|
if (empty($this->owner->ParentID)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure direct parent exists
|
// Ensure direct parent exists
|
||||||
$parent = $this->owner->Parent();
|
$parent = $this->owner->Parent();
|
||||||
if(empty($parent) || !$parent->exists()) return false;
|
if (empty($parent) || !$parent->exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check ancestry
|
// Check ancestry
|
||||||
return $parent->hasPublishedParent();
|
return $parent->hasPublishedParent();
|
||||||
@ -78,10 +86,13 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
|||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function canIncludeInGoogleSitemap() {
|
public function canIncludeInGoogleSitemap()
|
||||||
|
{
|
||||||
|
|
||||||
// Check that parent page is published
|
// Check that parent page is published
|
||||||
if(!$this->owner->hasPublishedParent()) return false;
|
if (!$this->owner->hasPublishedParent()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$result = parent::canIncludeInGoogleSitemap();
|
$result = parent::canIncludeInGoogleSitemap();
|
||||||
$result = ($this->owner instanceof ErrorPage) ? false : $result;
|
$result = ($this->owner instanceof ErrorPage) ? false : $result;
|
||||||
@ -92,11 +103,12 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
|||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getGooglePriority() {
|
public function getGooglePriority()
|
||||||
|
{
|
||||||
setlocale(LC_ALL, "en_US.UTF8");
|
setlocale(LC_ALL, "en_US.UTF8");
|
||||||
$priority = $this->owner->getField('Priority');
|
$priority = $this->owner->getField('Priority');
|
||||||
|
|
||||||
if(!$priority) {
|
if (!$priority) {
|
||||||
$parentStack = $this->owner->parentStack();
|
$parentStack = $this->owner->parentStack();
|
||||||
$numParents = is_array($parentStack) ? count($parentStack) - 1 : 0;
|
$numParents = is_array($parentStack) ? count($parentStack) - 1 : 0;
|
||||||
|
|
||||||
@ -104,7 +116,7 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension {
|
|||||||
$result = str_replace(",", ".", $num);
|
$result = str_replace(",", ".", $num);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} else if ($priority == -1) {
|
} elseif ($priority == -1) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return (is_numeric($priority) && $priority <= 1.0) ? $priority : 0.5;
|
return (is_numeric($priority) && $priority <= 1.0) ? $priority : 0.5;
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapTest extends FunctionalTest {
|
class GoogleSitemapTest extends FunctionalTest
|
||||||
|
{
|
||||||
|
|
||||||
public static $fixture_file = 'googlesitemaps/tests/GoogleSitemapTest.yml';
|
public static $fixture_file = 'googlesitemaps/tests/GoogleSitemapTest.yml';
|
||||||
|
|
||||||
@ -16,10 +17,11 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
'GoogleSitemapTest_UnviewableDataObject'
|
'GoogleSitemapTest_UnviewableDataObject'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp()
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if(class_exists('Page')) {
|
if (class_exists('Page')) {
|
||||||
$this->loadFixture('googlesitemaps/tests/GoogleSitemapPageTest.yml');
|
$this->loadFixture('googlesitemaps/tests/GoogleSitemapPageTest.yml');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,25 +29,28 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
GoogleSitemap::clear_registered_routes();
|
GoogleSitemap::clear_registered_routes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown()
|
||||||
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
GoogleSitemap::clear_registered_dataobjects();
|
GoogleSitemap::clear_registered_dataobjects();
|
||||||
GoogleSitemap::clear_registered_routes();
|
GoogleSitemap::clear_registered_routes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndexFileWithCustomRoute() {
|
public function testIndexFileWithCustomRoute()
|
||||||
|
{
|
||||||
GoogleSitemap::register_route('/test/');
|
GoogleSitemap::register_route('/test/');
|
||||||
|
|
||||||
$response = $this->get('sitemap.xml');
|
$response = $this->get('sitemap.xml');
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
|
|
||||||
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapRoute/1") ."</loc>";
|
$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", '');
|
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject", '');
|
||||||
|
|
||||||
$items = GoogleSitemap::get_items('GoogleSitemapTest_DataObject', 1);
|
$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());
|
$this->assertEquals(0, GoogleSitemap::get_items('GoogleSitemapTest_UnviewableDataObject', 1)->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetItemsWithCustomRoutes() {
|
public function testGetItemsWithCustomRoutes()
|
||||||
|
{
|
||||||
GoogleSitemap::register_routes(array(
|
GoogleSitemap::register_routes(array(
|
||||||
'/test-route/',
|
'/test-route/',
|
||||||
'/someother-route/',
|
'/someother-route/',
|
||||||
@ -74,7 +80,8 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
$this->assertEquals(3, $items->count());
|
$this->assertEquals(3, $items->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAccessingSitemapRootXMLFile() {
|
public function testAccessingSitemapRootXMLFile()
|
||||||
|
{
|
||||||
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
||||||
GoogleSitemap::register_dataobject("GoogleSitemapTest_OtherDataObject");
|
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
|
// the sitemap should contain <loc> to both those files and not the other
|
||||||
// dataobject as it hasn't been registered
|
// dataobject as it hasn't been registered
|
||||||
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_DataObject/1") ."</loc>";
|
$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>";
|
$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>";
|
$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);
|
Config::inst()->update('GoogleSitemap', 'enabled', true);
|
||||||
|
|
||||||
if(!class_exists('Page')) {
|
if (!class_exists('Page')) {
|
||||||
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,10 +124,11 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
|
|
||||||
$expected = '<lastmod>2014-03-14</lastmod>';
|
$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');
|
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
||||||
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
|
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
|
||||||
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
||||||
@ -127,15 +136,16 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
$response = $this->get('sitemap.xml');
|
$response = $this->get('sitemap.xml');
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$expected = "<loc>". Director::absoluteURL("sitemap.xml/sitemap/GoogleSitemapTest_DataObject/1") ."</loc>";
|
$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>";
|
$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);
|
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRegisterRoutesIncludesAllRoutes() {
|
public function testRegisterRoutesIncludesAllRoutes()
|
||||||
|
{
|
||||||
GoogleSitemap::register_route('/test/');
|
GoogleSitemap::register_route('/test/');
|
||||||
GoogleSitemap::register_routes(array(
|
GoogleSitemap::register_routes(array(
|
||||||
'/test/', // duplication should be replaced
|
'/test/', // duplication should be replaced
|
||||||
@ -150,7 +160,8 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
$this->assertEquals(3, substr_count($body, "<loc>"));
|
$this->assertEquals(3, substr_count($body, "<loc>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAccessingNestedSiteMap() {
|
public function testAccessingNestedSiteMap()
|
||||||
|
{
|
||||||
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
||||||
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
|
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
|
||||||
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
||||||
@ -163,7 +174,8 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
|
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAccessingNestedSiteMapCaseInsensitive() {
|
public function testAccessingNestedSiteMapCaseInsensitive()
|
||||||
|
{
|
||||||
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
$original = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
||||||
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
|
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', 1);
|
||||||
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
GoogleSitemap::register_dataobject("GoogleSitemapTest_DataObject");
|
||||||
@ -176,8 +188,9 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
|
Config::inst()->update('GoogleSitemap', 'objects_per_sitemap', $original);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetItemsWithPages() {
|
public function testGetItemsWithPages()
|
||||||
if(!class_exists('Page')) {
|
{
|
||||||
|
if (!class_exists('Page')) {
|
||||||
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
$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");
|
), 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);
|
Config::inst()->update('GoogleSitemap', 'enabled', true);
|
||||||
|
|
||||||
$response = $this->get('sitemap.xml');
|
$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');
|
$this->assertEquals(404, $response->getStatusCode(), 'Sitemap file returns a 404 when disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDecoratorAddsFields() {
|
public function testDecoratorAddsFields()
|
||||||
if(!class_exists("Page")) {
|
{
|
||||||
|
if (!class_exists("Page")) {
|
||||||
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,8 +259,9 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
$this->assertInstanceOf('LiteralField', $tab->fieldByName('GoogleSitemapIntro'));
|
$this->assertInstanceOf('LiteralField', $tab->fieldByName('GoogleSitemapIntro'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPriority() {
|
public function testGetPriority()
|
||||||
if(!class_exists("Page")) {
|
{
|
||||||
|
if (!class_exists("Page")) {
|
||||||
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
$this->markTestIncomplete('No cms module installed, page related test skipped');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,9 +280,9 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
$this->assertFalse($page->getGooglePriority());
|
$this->assertFalse($page->getGooglePriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnpublishedPage() {
|
public function testUnpublishedPage()
|
||||||
|
{
|
||||||
if(!class_exists('SiteTree')) {
|
if (!class_exists('SiteTree')) {
|
||||||
$this->markTestSkipped('Test skipped; CMS module required for testUnpublishedPage');
|
$this->markTestSkipped('Test skipped; CMS module required for testUnpublishedPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +304,7 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
$this->assertEmpty($orphanedPage->canIncludeInGoogleSitemap());
|
$this->assertEmpty($orphanedPage->canIncludeInGoogleSitemap());
|
||||||
$this->assertNotEmpty($rootPage->hasPublishedParent());
|
$this->assertNotEmpty($rootPage->hasPublishedParent());
|
||||||
$this->assertNotEmpty($rootPage->canIncludeInGoogleSitemap());
|
$this->assertNotEmpty($rootPage->canIncludeInGoogleSitemap());
|
||||||
} catch(Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
Versioned::set_reading_mode($oldMode);
|
Versioned::set_reading_mode($oldMode);
|
||||||
throw $ex;
|
throw $ex;
|
||||||
} // finally {
|
} // finally {
|
||||||
@ -301,17 +317,20 @@ class GoogleSitemapTest extends FunctionalTest {
|
|||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapTest_DataObject extends DataObject implements TestOnly {
|
class GoogleSitemapTest_DataObject extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
|
||||||
public static $db = array(
|
public static $db = array(
|
||||||
'Priority' => 'Varchar(10)'
|
'Priority' => 'Varchar(10)'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function AbsoluteLink() {
|
public function AbsoluteLink()
|
||||||
|
{
|
||||||
return Director::absoluteBaseURL();
|
return Director::absoluteBaseURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,17 +339,20 @@ class GoogleSitemapTest_DataObject extends DataObject implements TestOnly {
|
|||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapTest_OtherDataObject extends DataObject implements TestOnly {
|
class GoogleSitemapTest_OtherDataObject extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
|
||||||
public static $db = array(
|
public static $db = array(
|
||||||
'Priority' => 'Varchar(10)'
|
'Priority' => 'Varchar(10)'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function AbsoluteLink() {
|
public function AbsoluteLink()
|
||||||
|
{
|
||||||
return Director::absoluteBaseURL();
|
return Director::absoluteBaseURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,17 +361,20 @@ class GoogleSitemapTest_OtherDataObject extends DataObject implements TestOnly {
|
|||||||
* @package googlesitemaps
|
* @package googlesitemaps
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class GoogleSitemapTest_UnviewableDataObject extends DataObject implements TestOnly {
|
class GoogleSitemapTest_UnviewableDataObject extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
|
||||||
public static $db = array(
|
public static $db = array(
|
||||||
'Priority' => 'Varchar(10)'
|
'Priority' => 'Varchar(10)'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function AbsoluteLink() {
|
public function AbsoluteLink()
|
||||||
|
{
|
||||||
return Director::absoluteBaseURL();
|
return Director::absoluteBaseURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user