234 $successfullyExecuted = TRUE;
236 && !empty($this->email)
238 if ($this->emailTemplateFile ===
'EXT:linkvalidator/res/mailtemplate.html') {
240 $this->emailTemplateFile =
'EXT:linkvalidator/Resources/Private/Templates/mailtemplate.html';
243 throw new \InvalidArgumentException(
244 $GLOBALS[
'LANG']->sL(
'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidEmailTemplateFile'),
249 $htmlFile = GeneralUtility::getURL($file);
254 $this->isDifferentToLastRun = FALSE;
257 if (is_array($pageList)) {
258 foreach ($pageList as
$page) {
259 $pageSections .= $this->checkPageLinks($page);
262 if ($this->totalBrokenLink != $this->oldTotalBrokenLink) {
263 $this->isDifferentToLastRun = TRUE;
265 if ($this->totalBrokenLink > 0 && (!$this->emailOnBrokenLinkOnly || $this->isDifferentToLastRun) && !empty($this->email)) {
266 $successfullyExecuted = $this->reportEmail($pageSections, $modTs);
268 return $successfullyExecuted;
277 protected function checkPageLinks(
$page) {
281 $oldLinkCounts = array();
288 $rootLineHidden = FALSE;
290 $pageRow =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'*',
'pages',
'uid=' .
$page);
291 $rootLineHidden = $processor->getRootLineIsHidden($pageRow);
293 if (!$rootLineHidden || $modTs[
'checkhidden'] == 1) {
294 $pageIds = $processor->extGetTreeList(
$page, $this->depth, 0,
'1=1', $modTs[
'checkhidden']);
295 if (isset($pageRow) && $pageRow[
'hidden'] == 0 || $modTs[
'checkhidden'] == 1) {
300 if (!empty($pageIds)) {
301 $processor->init($searchFields, $pageIds);
302 if (!empty($this->email)) {
303 $oldLinkCounts = $processor->getLinkCounts(
$page);
304 $this->oldTotalBrokenLink += $oldLinkCounts[
'brokenlinkCount'];
306 $processor->getLinkStatistics($linkTypes, $modTs[
'checkhidden']);
307 if (!empty($this->email)) {
308 $linkCounts = $processor->getLinkCounts(
$page);
309 $this->totalBrokenLink += $linkCounts[
'brokenlinkCount'];
310 $pageSections = $this->
buildMail(
$page, $pageIds, $linkCounts, $oldLinkCounts);
313 return $pageSections;
326 $parseObj->parse($this->configuration);
327 if (count($parseObj->errors) > 0) {
328 $parseErrorMessage =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidTSconfig') .
'<br />';
329 foreach ($parseObj->errors as $errorInfo) {
330 $parseErrorMessage .= $errorInfo[0] .
'<br />';
332 throw new \Exception($parseErrorMessage,
'1295476989');
334 $tsConfig = $parseObj->setup;
335 $modTs = $modTs[
'properties'];
336 $overrideTs = $tsConfig[
'mod.'][
'tx_linkvalidator.'];
337 if (is_array($overrideTs)) {
351 foreach ($modTS[
'searchFields.'] as $table => $fieldList) {
353 foreach ($fields as $field) {
354 $searchFields[$table][] = $field;
357 return isset($searchFields) ? $searchFields : array();
367 $linkTypes = array();
369 if (is_array($typesTmp)) {
370 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'checkLinks']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'checkLinks'])) {
371 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'checkLinks'] as $type => $value) {
372 if (in_array($type, $typesTmp)) {
373 $linkTypes[$type] = 1;
389 protected function reportEmail($pageSections, array $modTsConfig) {
392 $markerArray = array();
394 $validEmailList = array();
400 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'reportEmailMarkers'])) {
401 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'reportEmailMarkers'] as $userFunc) {
404 'markerArray' => $markerArray
407 if (is_array($newMarkers)) {
416 if (empty($modTsConfig[
'mail.'][
'fromemail'])) {
419 if (empty($modTsConfig[
'mail.'][
'fromname'])) {
423 $mail->setFrom(array($modTsConfig[
'mail.'][
'fromemail'] => $modTsConfig[
'mail.'][
'fromname']));
425 throw new \Exception(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidFromEmail'),
'1295476760');
428 $mail->setReplyTo(array($modTsConfig[
'mail.'][
'replytoemail'] => $modTsConfig[
'mail.'][
'replytoname']));
430 if (!empty($modTsConfig[
'mail.'][
'subject'])) {
431 $mail->setSubject($modTsConfig[
'mail.'][
'subject']);
433 throw new \Exception(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.noSubject'),
'1295476808');
435 if (!empty($this->email)) {
437 foreach ($emailList as $emailAdd) {
439 throw new \Exception(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidToEmail'),
'1295476821');
441 $validEmailList[] = $emailAdd;
445 if (is_array($validEmailList) && !empty($validEmailList)) {
446 $mail->setTo($validEmailList);
451 $mail->setBody($content,
'text/html');
466 protected function buildMail($curPage, $pageList, array $markerArray, array $oldBrokenLink) {
469 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'buildMailMarkers'])) {
470 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'linkvalidator'][
'buildMailMarkers'] as $userFunc) {
472 'curPage' => $curPage,
473 'pageList' => $pageList,
474 'markerArray' => $markerArray,
475 'oldBrokenLink' => $oldBrokenLink,
479 if (is_array($newMarkers)) {
485 if (is_array($markerArray)) {
486 foreach ($markerArray as $markerKey => $markerValue) {
487 if (empty($oldBrokenLink[$markerKey])) {
488 $oldBrokenLink[$markerKey] = 0;
490 if ($markerValue != $oldBrokenLink[$markerKey]) {
491 $this->isDifferentToLastRun = TRUE;
493 $markerArray[$markerKey .
'_old'] = $oldBrokenLink[$markerKey];
498 BackendUtility::getRecord(
'pages', $curPage)
501 if ($markerArray[
'brokenlinkCount'] > 0) {
513 $_SERVER[
'argv'] = array(
515 'tx_link_scheduler_link',
520 '--sleepAfterFinish',
521 $this->sleepAfterFinish,
getLinkTypes(array $modTS)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static getModTSconfig($id, $TSref)
setEmailOnBrokenLinkOnly($emailOnBrokenLinkOnly)
static validEmail($email)
static makeInstance($className)
static getSystemFromAddress()
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
setEmailTemplateFile($emailTemplateFile)
static getSubpart($content, $marker)
static substituteMarkerArray($content, $markContentArray, $wrap='', $uppercase=FALSE, $deleteUnused=FALSE)
static substituteSubpart($content, $marker, $subpartContent, $recursive=TRUE, $keepMarker=FALSE)
static getSystemFromName()
static array_merge(array $arr1, array $arr2)
buildMail($curPage, $pageList, array $markerArray, array $oldBrokenLink)
setConfiguration($configuration)
getSearchField(array $modTS)
getEmailOnBrokenLinkOnly()
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)