mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
FEATURE Added SiteTreeMaintenanceTask
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@64417 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
62e7970a3a
commit
d113768d7b
29
tasks/SiteTreeMaintenanceTask.php
Normal file
29
tasks/SiteTreeMaintenanceTask.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package cms
|
||||||
|
* @subpackage tasks
|
||||||
|
*/
|
||||||
|
class SiteTreeMaintenanceTask extends Task {
|
||||||
|
static $allowed_actions = array(
|
||||||
|
'*' => 'ADMIN'
|
||||||
|
);
|
||||||
|
|
||||||
|
function makelinksunique() {
|
||||||
|
$badURLs = "'" . implode("', '", DB::query("SELECT URLSegment, count(*) FROM SiteTree GROUP BY URLSegment HAVING count(*) > 1")->column()) . "'";
|
||||||
|
$pages = DataObject::get("SiteTree", "URLSegment IN ($badURLs)");
|
||||||
|
|
||||||
|
foreach($pages as $page) {
|
||||||
|
echo "<li>$page->Title: ";
|
||||||
|
$urlSegment = $page->URLSegment;
|
||||||
|
$page->write();
|
||||||
|
if($urlSegment != $page->URLSegment) {
|
||||||
|
echo sprintf(_t('SiteTree.LINKSCHANGEDTO', " changed %s -> %s"), $urlSegment, $page->URLSegment);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo sprintf(_t('SiteTree.LINKSALREADYUNIQUE', " %s is already unique"), $urlSegment);
|
||||||
|
}
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user