Code Duplication    Length = 30-30 lines in 4 locations

note.php 1 location

@@ 32-61 (lines=30) @@
29
$record     = Note::getInstance(Filter::get('nid', WT_REGEX_XREF), $WT_TREE);
30
$controller = new NoteController($record);
31
32
if ($controller->record && $controller->record->canShow()) {
33
	if ($controller->record->isPendingDeletion()) {
34
		if (Auth::isModerator($controller->record->getTree())) {
35
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
36
				'This note has been deleted. You should review the deletion and then %1$s or %2$s it.',
37
				'<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>',
38
				'<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'
39
			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
40
		} elseif (Auth::isEditor($controller->record->getTree())) {
41
			FlashMessages::addMessage(I18N::translate('This note has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
42
		}
43
	} elseif ($controller->record->isPendingAddtion()) {
44
		if (Auth::isModerator($controller->record->getTree())) {
45
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
46
				'This note has been edited. You should review the changes and then %1$s or %2$s them.',
47
				'<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>',
48
				'<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'
49
			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
50
		} elseif (Auth::isEditor($controller->record->getTree())) {
51
			FlashMessages::addMessage(I18N::translate('This note has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
52
		}
53
	}
54
	$controller->pageHeader();
55
} else {
56
	FlashMessages::addMessage(I18N::translate('This note does not exist or you do not have permission to view it.'), 'danger');
57
	http_response_code(404);
58
	$controller->pageHeader();
59
60
	return;
61
}
62
63
$families      = $controller->record->linkedFamilies('NOTE');
64
$individuals   = $controller->record->linkedIndividuals('NOTE');

repo.php 1 location

@@ 31-60 (lines=30) @@
28
$record     = Repository::getInstance(Filter::get('rid', WT_REGEX_XREF), $WT_TREE);
29
$controller = new RepositoryController($record);
30
31
if ($controller->record && $controller->record->canShow()) {
32
	if ($controller->record->isPendingDeletion()) {
33
		if (Auth::isModerator($controller->record->getTree())) {
34
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
35
				'This repository has been deleted. You should review the deletion and then %1$s or %2$s it.',
36
				'<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>',
37
				'<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'
38
			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
39
		} elseif (Auth::isEditor($controller->record->getTree())) {
40
			FlashMessages::addMessage(I18N::translate('This repository has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
41
		}
42
	} elseif ($controller->record->isPendingAddtion()) {
43
		if (Auth::isModerator($controller->record->getTree())) {
44
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
45
				'This repository has been edited. You should review the changes and then %1$s or %2$s them.',
46
				'<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>',
47
				'<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'
48
			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
49
		} elseif (Auth::isEditor($controller->record->getTree())) {
50
			FlashMessages::addMessage(I18N::translate('This repository has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
51
		}
52
	}
53
	$controller->pageHeader();
54
} else {
55
	FlashMessages::addMessage(I18N::translate('This repository does not exist or you do not have permission to view it.'), 'danger');
56
	http_response_code(404);
57
	$controller->pageHeader();
58
59
	return;
60
}
61
62
$sources = $controller->record->linkedSources('REPO');
63
$facts   = $controller->record->getFacts();

source.php 1 location

@@ 31-60 (lines=30) @@
28
$record     = Source::getInstance(Filter::get('sid', WT_REGEX_XREF), $WT_TREE);
29
$controller = new SourceController($record);
30
31
if ($controller->record && $controller->record->canShow()) {
32
	if ($controller->record->isPendingDeletion()) {
33
		if (Auth::isModerator($controller->record->getTree())) {
34
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
35
				'This source has been deleted. You should review the deletion and then %1$s or %2$s it.',
36
				'<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>',
37
				'<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'
38
			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
39
		} elseif (Auth::isEditor($controller->record->getTree())) {
40
			FlashMessages::addMessage(I18N::translate('This source has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
41
		}
42
	} elseif ($controller->record->isPendingAddtion()) {
43
		if (Auth::isModerator($controller->record->getTree())) {
44
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
45
				'This source has been edited. You should review the changes and then %1$s or %2$s them.',
46
				'<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>',
47
				'<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'
48
			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
49
		} elseif (Auth::isEditor($controller->record->getTree())) {
50
			FlashMessages::addMessage(I18N::translate('This source has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
51
		}
52
	}
53
	$controller->pageHeader();
54
} else {
55
	FlashMessages::addMessage(I18N::translate('This source does not exist or you do not have permission to view it.'), 'danger');
56
	http_response_code(404);
57
	$controller->pageHeader();
58
59
	return;
60
}
61
62
$families      = $controller->record->linkedFamilies('SOUR');
63
$individuals   = $controller->record->linkedIndividuals('SOUR');

mediaviewer.php 1 location

@@ 29-58 (lines=30) @@
26
$record     = Media::getInstance(Filter::get('mid', WT_REGEX_XREF), $WT_TREE);
27
$controller = new MediaController($record);
28
29
if ($controller->record && $controller->record->canShow()) {
30
	if ($controller->record->isPendingDeletion()) {
31
		if (Auth::isModerator($controller->record->getTree())) {
32
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */
33
				I18N::translate('This media object has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
34
		} elseif (Auth::isEditor($controller->record->getTree())) {
35
			FlashMessages::addMessage(I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
36
		}
37
	} elseif ($controller->record->isPendingAddtion()) {
38
		if (Auth::isModerator($controller->record->getTree())) {
39
			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */
40
				I18N::translate('This media object has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" class="alert-link" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" class="alert-link" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
41
		} elseif (Auth::isEditor($controller->record->getTree())) {
42
			FlashMessages::addMessage(I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
43
		}
44
	}
45
	$controller->pageHeader();
46
} else {
47
	FlashMessages::addMessage(I18N::translate('This media object does not exist or you do not have permission to view it.'), 'danger');
48
	http_response_code(404);
49
	$controller->pageHeader();
50
51
	return;
52
}
53
54
echo View::make('media-page', [
55
	'media'       => $controller->record,
56
	'individuals' => $controller->record->linkedIndividuals('OBJE'),
57
	'families'    => $controller->record->linkedFamilies('OBJE'),
58
	'sources'     => $controller->record->linkedSources('OBJE'),
59
	'notes'       => $controller->record->linkedNotes('OBJE'),
60
	'facts'       => array_filter($controller->getFacts(), function(Fact $fact) { return $fact->getTag() !== 'FILE'; }),
61
]);