Feature #12340 » 12340_v5.diff
classes/class.tx_linkvalidator_processing.php (working copy) | ||
---|---|---|
class tx_linkvalidator_processing {
|
||
protected $searchFields = array(); // array of tables and fields to search for broken links
|
||
protected $pidList = ''; // list of pidlist (rootline downwards)
|
||
protected $linkCounts = array(); // array of tables containing number of external link
|
||
protected $brokenLinkCounts = array(); // array of tables containing number of broken external link
|
||
protected $recordsWithBrokenLinks = array(); // array of tables and records containing broken links
|
||
protected $hookObjectsArr = array(); // array for hooks for own checks
|
||
/**
|
||
* Array of tables and fields to search for broken links.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $searchFields = array();
|
||
/**
|
||
* List of comma seperated page uids (rootline downwards).
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $pidList = '';
|
||
/**
|
||
* Array of tables and the number of external links they contain.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $linkCounts = array();
|
||
/**
|
||
* Array of tables and the number of broken external links they contain.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $brokenLinkCounts = array();
|
||
/**
|
||
* Array of tables and records containing broken links.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $recordsWithBrokenLinks = array();
|
||
/**
|
||
* Array for hooks for own checks.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $hookObjectsArr = array();
|
||
/**
|
||
* Array with information about the current page.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $extPageInTreeInfo = array();
|
||
/**
|
||
* Fill hookObjectsArr with different link types and possible XClasses.
|
classes/linktypes/class.tx_linkvalidator_linktypes_abstract.php (working copy) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage linkvalidator
|
||
*/
|
||
abstract class tx_linkvalidator_linkTypes_Abstract {
|
||
abstract class tx_linkvalidator_linkTypes_Abstract implements tx_linkvalidator_linkTypes_Interface {
|
||
/**
|
||
* Contains parameters needed for the rendering of the error message
|
||
*
|
||
* @var array
|
||
*/
|
||
private $errorParams = array();
|
||
protected $errorParams = array();
|
||
/**
|
||
* Base type fetching method, based on the type that softRefParserObj returns.
|
||
... | ... | |
* @param array all parameters needed for the rendering of the error message
|
||
* @return void
|
||
*/
|
||
public function setErrorParams(array $value) {
|
||
protected function setErrorParams(array $value) {
|
||
$this->errorParams = $value;
|
||
}
|
||
classes/linktypes/class.tx_linkvalidator_linktypes_external.php (working copy) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage linkvalidator
|
||
*/
|
||
class tx_linkvalidator_linkTypes_External extends tx_linkvalidator_linkTypes_Abstract implements tx_linkvalidator_linkTypes_Interface {
|
||
class tx_linkvalidator_linkTypes_External extends tx_linkvalidator_linkTypes_Abstract {
|
||
var $url_reports = array();
|
||
var $url_error_params = array();
|
||
/**
|
||
* Cached list of the URLs, which were already checked for the current processing.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $url_reports = array();
|
||
/**
|
||
* Cached list of all error parameters of the URLs, which were already checked for the current processing.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $url_error_params = array();
|
||
/**
|
||
* Checks a given URL + /path/filename.ext for validity
|
||
... | ... | |
*
|
||
* @param array $value: reference properties
|
||
* @param string $type: current type
|
||
* @return string fetched type
|
||
* @param string $key: validator hook name
|
||
* @return string fetched type
|
||
*/
|
||
public function fetchType($value, $type) {
|
||
public function fetchType($value, $type, $key) {
|
||
preg_match_all('/((?:http|https|ftp|ftps))(?::\/\/)(?:[^\s<>]+)/i', $value['tokenValue'], $urls, PREG_PATTERN_ORDER);
|
||
if (!empty($urls[0][0])) {
|
classes/linktypes/class.tx_linkvalidator_linktypes_file.php (working copy) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage linkvalidator
|
||
*/
|
||
class tx_linkvalidator_linkTypes_File extends tx_linkvalidator_linkTypes_Abstract implements tx_linkvalidator_linkTypes_Interface {
|
||
class tx_linkvalidator_linkTypes_File extends tx_linkvalidator_linkTypes_Abstract {
|
||
/**
|
||
* Checks a given URL + /path/filename.ext for validity.
|
classes/linktypes/class.tx_linkvalidator_linktypes_interface.php (working copy) | ||
---|---|---|
*/
|
||
public function checkLink($url, $softRefEntry, $reference);
|
||
/**
|
||
* Base type fetching method, based on the type that softRefParserObj returns.
|
||
*
|
||
* @param array $value: reference properties
|
||
* @param string $type: current type
|
||
* @param string $key: validator hook name
|
||
* @return string fetched type
|
||
*/
|
||
public function fetchType($value, $type, $key);
|
||
/**
|
||
* Get the value of the private property errorParams.
|
||
*
|
||
* @return array all parameters needed for the rendering of the error message
|
||
*/
|
||
public function getErrorParams();
|
||
/**
|
||
* Base url parsing
|
||
*
|
||
* @param array $row: broken link record
|
||
* @return string parsed broken url
|
||
*/
|
||
public function getBrokenUrl($row);
|
||
}
|
||
?>
|
classes/linktypes/class.tx_linkvalidator_linktypes_internal.php (working copy) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage linkvalidator
|
||
*/
|
||
class tx_linkvalidator_linkTypes_Internal extends tx_linkvalidator_linkTypes_Abstract implements tx_linkvalidator_linkTypes_Interface {
|
||
class tx_linkvalidator_linkTypes_Internal extends tx_linkvalidator_linkTypes_Abstract {
|
||
const DELETED = 'deleted';
|
||
const HIDDEN = 'hidden';
|
||
const MOVED = 'moved';
|
||
const NOTEXISTING = 'notExisting';
|
||
var $errorParams = array();
|
||
/**
|
||
* All parameters needed for rendering the error message.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $errorParams = array();
|
||
/**
|
||
* Result of the check, if the current page uid is valid or not.
|
||
*
|
||
* @var boolean
|
||
*/
|
||
protected $responsePage = TRUE;
|
||
var $responsePage = TRUE;
|
||
var $responseContent = TRUE;
|
||
/**
|
||
* Result of the check, if the current content uid is valid or not.
|
||
*
|
||
* @var boolean
|
||
*/
|
||
protected $responseContent = TRUE;
|
||
/**
|
||
* Checks a given URL + /path/filename.ext for validity
|
||
... | ... | |
* @param object $reference: parent instance of tx_linkvalidator_processing
|
||
* @return string TRUE on success or FALSE on error
|
||
*/
|
||
public function checkPage($page, $softRefEntry, $reference) {
|
||
protected function checkPage($page, $softRefEntry, $reference) {
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'uid, title, deleted, hidden, starttime, endtime',
|
||
'pages',
|
||
... | ... | |
* @param object $reference: parent instance of tx_linkvalidator_processing
|
||
* @return string TRUE on success or FALSE on error
|
||
*/
|
||
public function checkContent($page, $anchor, $softRefEntry, $reference) {
|
||
protected function checkContent($page, $anchor, $softRefEntry, $reference) {
|
||
// Get page ID on which the content element in fact is located
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'uid, pid, header, deleted, hidden, starttime, endtime',
|
classes/linktypes/class.tx_linkvalidator_linktypes_linkhandler.php (working copy) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage linkvalidator
|
||
*/
|
||
class tx_linkvalidator_linkTypes_LinkHandler extends tx_linkvalidator_linkTypes_Abstract implements tx_linkvalidator_linkTypes_Interface {
|
||
class tx_linkvalidator_linkTypes_LinkHandler extends tx_linkvalidator_linkTypes_Abstract {
|
||
public $tsconfig;
|
||
const DELETED = 'deleted';
|
||
/**
|
||
* Get TsConfig on loading of the class
|
||
* TSconfig of the module tx_linkhandler.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $tsconfig;
|
||
/**
|
||
* Get TSconfig when loading the class.
|
||
*/
|
||
function __construct() {
|
||
$this->tsconfig = t3lib_BEfunc::getModTSconfig(1, 'mod.tx_linkhandler');
|
||
... | ... | |
*
|
||
* @param array $value: reference properties
|
||
* @param string $type: current type
|
||
* @param string $key: validator hook name
|
||
* @return string fetched type
|
||
*/
|
||
public function fetchType($value, $type) {
|
||
public function fetchType($value, $type, $key) {
|
||
if ($type == 'string' && strtolower(substr($value['tokenValue'], 0, 7)) == 'record:') {
|
||
$type = 'linkhandler';
|
||
}
|
classes/tasks/class.tx_linkvalidator_tasks_validate.php (working copy) | ||
---|---|---|
public $countInARun;
|
||
/**
|
||
* Total number of broken links.
|
||
*
|
||
* @var integer
|
||
*/
|
||
public $totalBrokenLink = 0;
|
||
... | ... | |
public $totalBrokenLink = 0;
|
||
/**
|
||
* Total number of broken links from the last run.
|
||
*
|
||
* @var integer
|
||
*/
|
||
public $oldTotalBrokenLink = 0;
|
||
... | ... | |
*/
|
||
public $oldTotalBrokenLink = 0;
|
||
/**
|
||
* Mail template fetched from the given template file.
|
||
*
|
||
* @var string
|
||
*/
|
||
public $templateMail;
|
||
|
||
/**
|
||
* specific TSconfig for this task.
|
||
*
|
||
* @var array
|
||
*/
|
||
public $configuration = array();
|
||
/**
|
||
* Shows if number of result was diferent from the result of the last check or not.
|
||
*
|
||
* @var boolean
|
||
*/
|
||
public $dif;
|
||
/**
|
||
* Template to be used for the email.
|
||
*
|
||
* @var string
|
||
*/
|
||
public $emailTemplateFile;
|
||
/**
|
||
* Level of pages the task should check.
|
||
*
|
||
* @var integer
|
||
*/
|
||
public $depth;
|
||
/**
|
||
* UID of the start page for this task.
|
||
*
|
||
* @var integer
|
||
*/
|
||
public $page;
|
||
/**
|
||
* Email address to which an email report is sent.
|
||
*
|
||
* @var string
|
||
*/
|
||
public $email;
|
||
/**
|
||
* Only send an email, if new broken links were found.
|
||
*
|
||
* @var boolean
|
||
*/
|
||
public $emailOnBrokenLinkOnly;
|
||
/**
|
||
* Function executed from the Scheduler.
|
||
... | ... | |
public function execute() {
|
||
$this->setCliArguments();
|
||
$file = t3lib_div::getFileAbsFileName($this->emailfile);
|
||
if (!file_exists($file = t3lib_div::getFileAbsFileName($this->emailTemplateFile)) && !empty($this->email)) {
|
||
$failure = t3lib_div::makeInstance(
|
||
'Exception',
|
||
$GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidEmailTemplateFile'),
|
||
t3lib_FlashMessage::ERROR
|
||
);
|
||
throw $failure;
|
||
}
|
||
$htmlFile = t3lib_div::getURL($file);
|
||
$this->templateMail = t3lib_parsehtml::getSubpart($htmlFile, '###REPORT_TEMPLATE###');
|
||
... | ... | |
$modTS = t3lib_BEfunc::getModTSconfig($page, 'mod.linkvalidator');
|
||
$parseObj = t3lib_div::makeInstance('t3lib_TSparser');
|
||
$parseObj->parse($this->configuration);
|
||
if(count($parseObj->errors) > 0){
|
||
$parseErrorMessage = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidTSconfig') . '<br />';
|
||
foreach($parseObj->errors as $errorInfo){
|
||
$parseErrorMessage .= $errorInfo[0] . '<br />';
|
||
}
|
||
$failure = t3lib_div::makeInstance(
|
||
'Exception',
|
||
$parseErrorMessage,
|
||
t3lib_FlashMessage::ERROR
|
||
);
|
||
throw $failure;
|
||
}
|
||
$TSconfig = $parseObj->setup;
|
||
$modTS = $modTS['properties'];
|
||
$overrideTs = $TSconfig['mod.']['tx_linkvalidator.'];
|
||
... | ... | |
$this->dif = TRUE;
|
||
}
|
||
if ($this->totalBrokenLink > 0
|
||
&& (!$this->emailonbrokenlinkonly || $this->dif)
|
||
&& (!$this->emailOnBrokenLinkOnly || $this->dif)
|
||
&& !empty($this->email)
|
||
) {
|
||
$this->reportEmail($pageSections, $modTS);
|
classes/tasks/class.tx_linkvalidator_tasks_validateadditionalfieldprovider.php (working copy) | ||
---|---|---|
}
|
||
}
|
||
if (empty($taskInfo['emailonbrokenlinkonly'])) {
|
||
if (empty($taskInfo['emailOnBrokenLinkOnly'])) {
|
||
if ($schedulerModule->CMD == 'add') {
|
||
$taskInfo['emailonbrokenlinkonly'] = 1;
|
||
$task->emailonbrokenlinkonly = 1;
|
||
$taskInfo['emailOnBrokenLinkOnly'] = 1;
|
||
$task->emailOnBrokenLinkOnly = 1;
|
||
} elseif ($schedulerModule->CMD == 'edit') {
|
||
$taskInfo['emailonbrokenlinkonly'] = $task->emailonbrokenlinkonly;
|
||
$taskInfo['emailOnBrokenLinkOnly'] = $task->emailOnBrokenLinkOnly;
|
||
} else {
|
||
$taskInfo['emailonbrokenlinkonly'] = $task->emailonbrokenlinkonly;
|
||
$taskInfo['emailOnBrokenLinkOnly'] = $task->emailOnBrokenLinkOnly;
|
||
}
|
||
}
|
||
if (empty($taskInfo['emailfile'])) {
|
||
if (empty($taskInfo['emailTemplateFile'])) {
|
||
if ($schedulerModule->CMD == 'add') {
|
||
$taskInfo['emailfile'] = 'EXT:linkvalidator/res/mailtemplate.html';
|
||
$taskInfo['emailTemplateFile'] = 'EXT:linkvalidator/res/mailtemplate.html';
|
||
} elseif ($schedulerModule->CMD == 'edit') {
|
||
$taskInfo['emailfile'] = $task->emailfile;
|
||
$taskInfo['emailTemplateFile'] = $task->emailTemplateFile;
|
||
} else {
|
||
$taskInfo['emailfile'] = $task->emailfile;
|
||
$taskInfo['emailTemplateFile'] = $task->emailTemplateFile;
|
||
}
|
||
}
|
||
... | ... | |
'code' => $fieldCode,
|
||
'label' => $label
|
||
);
|
||
$fieldID = 'task_emailonbrokenlinkonly';
|
||
$fieldCode = '<input type="checkbox" name="tx_scheduler[emailonbrokenlinkonly]" id="' . $fieldID . '" ' . ($taskInfo['emailonbrokenlinkonly'] ? 'checked="checked"' : '') . ' />';
|
||
$label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.emailonbrokenlinkonly');
|
||
$fieldID = 'task_emailOnBrokenLinkOnly';
|
||
$fieldCode = '<input type="checkbox" name="tx_scheduler[emailOnBrokenLinkOnly]" id="' . $fieldID . '" ' . ($taskInfo['emailOnBrokenLinkOnly'] ? 'checked="checked"' : '') . ' />';
|
||
$label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.emailOnBrokenLinkOnly');
|
||
$label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
|
||
$additionalFields[$fieldID] = array(
|
||
'code' => $fieldCode,
|
||
'label' => $label
|
||
);
|
||
$fieldID = 'task_emailfile';
|
||
$fieldCode = '<input type="text" name="tx_scheduler[emailfile]" id="' . $fieldID . '" value="' . $taskInfo['emailfile'] . '" />';
|
||
$label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.emailfile');
|
||
$fieldID = 'task_emailTemplateFile';
|
||
$fieldCode = '<input type="text" name="tx_scheduler[emailTemplateFile]" id="' . $fieldID . '" value="' . $taskInfo['emailTemplateFile'] . '" />';
|
||
$label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.emailTemplateFile');
|
||
$label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
|
||
$additionalFields[$fieldID] = array(
|
||
'code' => $fieldCode,
|
||
... | ... | |
$task->depth = $submittedData['depth'];
|
||
$task->page = $submittedData['page'];
|
||
$task->email = $submittedData['email'];
|
||
$task->emailonbrokenlinkonly = $submittedData['emailonbrokenlinkonly'];
|
||
$task->emailOnBrokenLinkOnly = $submittedData['emailOnBrokenLinkOnly'];
|
||
$task->configuration = $submittedData['configuration'];
|
||
$task->emailfile = $submittedData['emailfile'];
|
||
$task->emailTemplateFile = $submittedData['emailTemplateFile'];
|
||
}
|
||
locallang.xml (working copy) | ||
---|---|---|
<label index="tasks.validate.depth">Depth</label>
|
||
<label index="tasks.validate.conf">Overwrite TSconfig</label>
|
||
<label index="tasks.validate.email">Send email report to</label>
|
||
<label index="tasks.validate.emailonbrokenlinkonly">Send email on new broken links only</label>
|
||
<label index="tasks.validate.emailfile">Email template file</label>
|
||
<label index="tasks.validate.emailOnBrokenLinkOnly">Send email on new broken links only</label>
|
||
<label index="tasks.validate.emailTemplateFile">Email template file</label>
|
||
<label index="tasks.validate.invalidEmail">Invalid email format!</label>
|
||
<label index="tasks.validate.invalidPage">Invalid page uid, please enter a valid page uid!</label>
|
||
<label index="tasks.validate.invalidDepth">There is no depth set, please set it to one of the offered values!</label>
|
||
<label index="tasks.error.invalidTSconfig">Invalid TSconfig in the task configuration!</label>
|
||
<label index="tasks.error.invalidEmailTemplateFile">The email template file is not existing!</label>
|
||
|
||
</languageKey>
|
||
</data>
|
||
</T3locallang>
|
modfunc1/class.tx_linkvalidator_modfunc1.php (working copy) | ||
---|---|---|
protected $relativePath;
|
||
/**
|
||
* Information about the current page record.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $pageRecord = array();
|
||
... | ... | |
protected $pageRecord = array();
|
||
/**
|
||
* Information, if the module is accessible for the current user or not.
|
||
*
|
||
* @var boolean
|
||
*/
|
||
protected $isAccessibleForCurrentUser = FALSE;
|
||
... | ... | |
protected $isAccessibleForCurrentUser = FALSE;
|
||
/**
|
||
* Depth for the recursivity of the link validation.
|
||
*
|
||
* @var integer
|
||
*/
|
||
protected $search_level;
|
||
/**
|
||
* Link validation class.
|
||
*
|
||
* @var tx_linkvalidator_processing
|
||
*/
|
||
protected $processing;
|
||
... | ... | |
protected $processing;
|
||
/**
|
||
* TSconfig of the current module.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $modTS = array();
|
||
/**
|
||
* List of available link types to check defined in the TSconfig.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $availableOptions = array();
|
||
/**
|
||
* List of link types currently chosen in the Statistics table.
|
||
* Used to show broken links of these types only.
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $checkOpt = array();
|
||
/**
|
||
* Hint message displayed on top of the module.
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $firstSteps;
|
||
/**
|
||
* Html for the button "Check Links".
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $updateListHtml;
|
||
/**
|
||
* Html for the button "Refresh Display".
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $refreshListHtml;
|
||
/**
|
||
* Html for the Statistics table with the checkboxes of the link types and the numbers of broken links.
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $checkOptHtml;
|
||
/**
|
||
* Complete content (html) to be displayed.
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $content;
|
||
/**
|
||
* Main method of modfunc1
|
||
*
|
||
* @return string Module content
|