-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: Adding report link to setup new queued job
- Loading branch information
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
Name: externallink | ||
After: framework/routes | ||
--- | ||
Director: | ||
rules: | ||
'admin/externallinks//$Action': 'CMSExternalLinks_Controller' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
class CMSExternalLinks_Controller extends Controller { | ||
|
||
private static $allowed_actions = array('createQueuedReport'); | ||
|
||
|
||
public function createQueuedReport() { | ||
if (!Permission::check('ADMIN')) return; | ||
|
||
// setup external links job | ||
$externalLinks = new CheckExternalLinksJob(); | ||
$job = singleton('QueuedJobService'); | ||
$jobID = $job->queueJob($externalLinks); | ||
|
||
// redirect to the jobs page | ||
$admin = QueuedJobsAdmin::create(); | ||
$this->Redirect($admin->Link()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/** | ||
* Content side-report listing pages with external broken links | ||
* @package externallinks | ||
* @subpackage content | ||
*/ | ||
|
||
class BrokenExternalLinksReport extends SS_Report { | ||
|
||
/** | ||
* Columns in the report | ||
* | ||
* @var array | ||
* @config | ||
*/ | ||
private static $columns = array( | ||
'Created' => 'Checked', | ||
'Link' => 'External Link', | ||
'HTTPCode' => 'HTTP Error Code', | ||
'PageLink' => array( | ||
'title' => 'Page link is on', | ||
'link' => true | ||
), | ||
); | ||
|
||
public function init() { | ||
parent::init(); | ||
} | ||
|
||
/** | ||
* Returns the report title | ||
* | ||
* @return string | ||
*/ | ||
public function title() { | ||
return _t('ExternalBrokenLinksReport.EXTERNALBROKENLINKS',"External broken links report"); | ||
} | ||
|
||
/** | ||
* Returns the column names of the report | ||
* | ||
* @return array | ||
*/ | ||
public function columns() { | ||
return self::$columns; | ||
} | ||
|
||
/** | ||
* Alias of columns(), to support the export to csv action | ||
* in {@link GridFieldExportButton} generateExportFileData method. | ||
* @return array | ||
*/ | ||
public function getColumns() { | ||
return $this->columns(); | ||
} | ||
|
||
public function sourceRecords() { | ||
$returnSet = new ArrayList(); | ||
$links = BrokenExternalLinks::get(); | ||
foreach ($links as $link) { | ||
$link->PageLink = $link->Page()->Title; | ||
$returnSet->push($link); | ||
} | ||
return $returnSet; | ||
} | ||
|
||
public function getCMSFields() { | ||
$fields = parent::getCMSFields(); | ||
if (class_exists('AbstractQueuedJob')) { | ||
$button = '<a href = "%s"><button class="externalLinksReport" type="button">%s</button></a>'; | ||
$runReportButton = new LiteralField( | ||
'runReport', | ||
sprintf( | ||
$button, | ||
'admin/externallinks/createQueuedReport', | ||
_t('ExternalBrokenLinksReport.RUNREPORT', 'Create new report') | ||
) | ||
); | ||
$fields->push($runReportButton); | ||
$reportResultSpan = '<span id="ReportHolder"></span></ br><span id="ReportProgress"></span>'; | ||
$reportResult = new LiteralField('ResultTitle', $reportResultSpan); | ||
$fields->push($reportResult); | ||
} | ||
return $fields; | ||
} | ||
} |