-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show the version conflict message on a separate page (see #809).
- Loading branch information
Showing
11 changed files
with
621 additions
and
8 deletions.
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,121 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Contao. | ||
* | ||
* Copyright (c) 2005-2017 Leo Feyer | ||
* | ||
* @license LGPL-3.0+ | ||
*/ | ||
|
||
namespace Contao\CoreBundle\Controller; | ||
|
||
use Contao\Backend; | ||
use Contao\BackendTemplate; | ||
use Contao\Config; | ||
use Contao\Controller as ContaoController; | ||
use Contao\CoreBundle\Framework\ContaoFrameworkInterface; | ||
use Contao\Environment; | ||
use Contao\StringUtil; | ||
use Contao\System; | ||
use Contao\Versions; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* Shows an information screen if there is a version conflict. | ||
* | ||
* @author Leo Feyer <https://github.com/leofeyer> | ||
*/ | ||
class VersionConflictController extends Controller | ||
{ | ||
/** | ||
* @var ContaoFrameworkInterface | ||
*/ | ||
private $framework; | ||
|
||
/** | ||
* Adds the diff view and referer URL. | ||
* | ||
* @param Request $request | ||
* | ||
* @return Response | ||
* | ||
* @Route("/contao/conflict", name="contao_backend_conflict") | ||
*/ | ||
public function indexAction(Request $request) | ||
{ | ||
$this->framework = $this->get('contao.framework'); | ||
$this->framework->initialize(); | ||
|
||
$template = $this->getTemplate(); | ||
|
||
$template->explain1 = sprintf( | ||
$GLOBALS['TL_LANG']['MSC']['versionConflict1'], | ||
(int) $request->query->get('theirs'), | ||
(int) $request->query->get('mine') | ||
); | ||
|
||
$template->explain2 = sprintf( | ||
$GLOBALS['TL_LANG']['MSC']['versionConflict2'], | ||
(int) $request->query->get('theirs') + 1, | ||
(int) $request->query->get('theirs') | ||
); | ||
|
||
$session = $this->get('session'); | ||
|
||
if ($session->has('versionConflictUrl')) { | ||
$template->href = $session->get('versionConflictUrl'); | ||
} else { | ||
$template->href = $this->get('router')->generate('contao_backend'); | ||
} | ||
|
||
$versions = new Versions($request->query->get('table'), (int) $request->query->get('id')); | ||
|
||
$template->diff = $versions->compare(true); | ||
|
||
return $template->getResponse(); | ||
} | ||
|
||
/** | ||
* Returns the template object. | ||
* | ||
* @return BackendTemplate|object | ||
*/ | ||
private function getTemplate() | ||
{ | ||
/** @var System $system */ | ||
$system = $this->framework->getAdapter(System::class); | ||
$system->loadLanguageFile('default'); | ||
|
||
/** @var ContaoController $controller */ | ||
$controller = $this->framework->getAdapter(ContaoController::class); | ||
$controller->setStaticUrls(); | ||
|
||
/** @var BackendTemplate|object $template */ | ||
$template = $this->framework->createInstance(BackendTemplate::class, ['be_conflict']); | ||
$template->language = $GLOBALS['TL_LANGUAGE']; | ||
$template->h1 = $GLOBALS['TL_LANG']['MSC']['versionConflict']; | ||
$template->back = $GLOBALS['TL_LANG']['MSC']['backBT']; | ||
$template->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['versionConflict']); | ||
|
||
/** @var Backend $backend */ | ||
$backend = $this->framework->getAdapter(Backend::class); | ||
|
||
$template->theme = $backend->getTheme(); | ||
|
||
/** @var Config $config */ | ||
$config = $this->framework->getAdapter(Config::class); | ||
|
||
$template->charset = $config->get('characterSet'); | ||
|
||
/** @var Environment $environment */ | ||
$environment = $this->framework->getAdapter(Environment::class); | ||
|
||
$template->base = $environment->get('base'); | ||
|
||
return $template; | ||
} | ||
} |
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
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,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="<?= $this->language ?>"> | ||
<head> | ||
|
||
<meta charset="<?= $this->charset ?>"> | ||
<title><?= $this->title ?> - Contao Open Source CMS</title> | ||
<base href="<?= $this->base ?>"> | ||
<meta name="generator" content="Contao Open Source CMS"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no"> | ||
<meta name="referrer" content="origin"> | ||
|
||
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/fonts.css"> | ||
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/basic.css"> | ||
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/diff.css"> | ||
<link rel="stylesheet" href="<?= TL_ASSETS_URL ?>system/themes/<?= $this->theme ?>/conflict.css"> | ||
<?= $this->stylesheets ?> | ||
|
||
<script><?= $this->getLocaleString() ?></script> | ||
<script src="<?= TL_ASSETS_URL ?>assets/mootools/js/mootools.min.js"></script> | ||
<script src="<?= TL_ASSETS_URL ?>bundles/contaocore/mootao.min.js"></script> | ||
<script src="<?= TL_ASSETS_URL ?>bundles/contaocore/core.min.js"></script> | ||
<script><?= $this->getDateString() ?></script> | ||
<?= $this->javascripts ?> | ||
|
||
</head> | ||
<body class="<?= $this->ua ?>"> | ||
|
||
<div id="container" class="cf"> | ||
<div id="main"> | ||
<h1><?= $this->h1 ?></h1> | ||
<p><?= $this->explain1 ?></p> | ||
<p><?= $this->explain2 ?></p> | ||
<div id="diff"><?= $this->diff ?></div> | ||
<p><a href="<?= $this->href ?>" class="tl_submit"><?= $this->back ?></a></p> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,54 @@ | ||
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2017 Leo Feyer | ||
* | ||
* @license LGPL-3.0+ | ||
*/ | ||
|
||
/* Body */ | ||
body { | ||
background:#eaeaea url("icons/stop.svg") center 3em no-repeat; | ||
} | ||
|
||
/* Container */ | ||
#container { | ||
width:640px; | ||
margin:14em auto 0; | ||
background:#fff; | ||
} | ||
#main { | ||
padding-bottom:6px; | ||
} | ||
|
||
/* Elements */ | ||
h1 { | ||
padding:14px 18px 12px; | ||
line-height:22px; | ||
border-bottom:1px solid #ddd; | ||
} | ||
p { | ||
line-height:1.3; | ||
} | ||
p a { | ||
vertical-align:middle; | ||
} | ||
#diff { | ||
margin:18px 0; | ||
} | ||
#diff,#main > p { | ||
padding-left:18px; | ||
padding-right:18px; | ||
} | ||
#main > p:first-of-type { | ||
margin:18px 0 9px; | ||
} | ||
|
||
/* Handheld */ | ||
@media (max-width:767px) { | ||
#container { | ||
width:auto; | ||
margin-left:10px; | ||
margin-right:10px; | ||
} | ||
} |
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
Oops, something went wrong.