2013-08-26 02:24:36 +02:00
|
|
|
<?php
|
|
|
|
|
2014-07-28 01:23:33 +02:00
|
|
|
if(!class_exists('AbstractQueuedJob')) return;
|
|
|
|
|
2013-08-26 02:24:36 +02:00
|
|
|
/**
|
2014-07-24 04:20:48 +02:00
|
|
|
* A Job for running a external link check for published pages
|
2013-08-26 02:24:36 +02:00
|
|
|
*
|
|
|
|
*/
|
2014-07-24 04:20:48 +02:00
|
|
|
class CheckExternalLinksJob extends AbstractQueuedJob implements QueuedJob {
|
2013-08-26 02:24:36 +02:00
|
|
|
|
|
|
|
public function getTitle() {
|
2014-07-28 01:23:33 +02:00
|
|
|
return _t('CheckExternalLiksJob.TITLE', 'Checking for external broken links');
|
2013-08-26 02:24:36 +02:00
|
|
|
}
|
|
|
|
|
2014-07-24 04:20:48 +02:00
|
|
|
public function getJobType() {
|
|
|
|
return QueuedJob::QUEUED;
|
|
|
|
}
|
|
|
|
|
2013-08-26 02:24:36 +02:00
|
|
|
public function getSignature() {
|
|
|
|
return md5(get_class($this));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-24 04:20:48 +02:00
|
|
|
* Check a individual page
|
2013-08-26 02:24:36 +02:00
|
|
|
*/
|
|
|
|
public function process() {
|
2013-08-26 02:53:01 +02:00
|
|
|
$task = new CheckExternalLinks();
|
2014-08-04 00:10:59 +02:00
|
|
|
$pages = Versioned::get_by_stage('SiteTree', 'Live');
|
|
|
|
// set the limit so each page is done individually
|
|
|
|
$task->limit = 1;
|
|
|
|
$this->totalSteps = $pages->count();
|
|
|
|
foreach ($pages as $page) {
|
|
|
|
$this->currentStep++;
|
|
|
|
$task->run();
|
|
|
|
}
|
2014-07-31 06:49:20 +02:00
|
|
|
$this->isComplete = true;
|
|
|
|
return;
|
2013-08-26 02:24:36 +02:00
|
|
|
}
|
2014-07-24 04:20:48 +02:00
|
|
|
|
|
|
|
}
|