forked from exploreimpact/contao-i18nl10n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exploreimpact#76 Bugfix: Refactoring handling of page type. Creating …
…callbacks to show page type in dca select and to update dca palettes.
- Loading branch information
1 parent
607e2b7
commit 3288693
Showing
3 changed files
with
65 additions
and
41 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* @copyright Copyright (c) 2014-2015 Verstärker, Patric Eberle | ||
* @author Patric Eberle <[email protected]> | ||
* @package i18nl10n config | ||
* @version 1.5.1 | ||
* @version 1.5.2 | ||
* @license LGPLv3 http://www.gnu.org/licenses/lgpl-3.0.html | ||
*/ | ||
|
||
|
@@ -67,8 +67,6 @@ public function run() | |
$this->removeDeprecatedSettings(); | ||
|
||
$this->updateChildPageLanguage(); | ||
|
||
$this->recoverPageType(); | ||
} | ||
|
||
/** | ||
|
@@ -217,21 +215,6 @@ private function updateChildPageLanguage() | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Recover type field information | ||
* | ||
* The type field of tl_page_i18nl10n was removed a few version back. But | ||
* it's needed as a DCA field selector. | ||
*/ | ||
private function recoverPageType() | ||
{ | ||
// Create field if not existing | ||
$this->Database->query('ALTER TABLE tl_page_i18nl10n ADD type varchar(32) NOT NULL default ""'); | ||
|
||
// Set field value if not existing | ||
$this->Database->query('UPDATE tl_page_i18nl10n as pi SET type = (SELECT p.type FROM tl_page as p WHERE p.id = pi.pid) WHERE pi.type = "";'); | ||
} | ||
} | ||
|
||
$objI18nl10nRunOnceJob = new I18nl10nRunOnceJob(); | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* @copyright Copyright (c) 2014-2015 Verstärker, Patric Eberle | ||
* @author Patric Eberle <[email protected]> | ||
* @package i18nl10n dca | ||
* @version 1.2.1 | ||
* @version 1.5.2 | ||
* @license LGPLv3 http://www.gnu.org/licenses/lgpl-3.0.html | ||
*/ | ||
|
||
|
@@ -246,19 +246,19 @@ function($value) { | |
} | ||
|
||
$fields = array( | ||
'pid' => $dc->id, | ||
'sorting' => 0, | ||
'tstamp' => time(), | ||
'title' => $dc->activeRecord->title, | ||
'pageTitle' => $dc->activeRecord->pageTitle, | ||
'description' => $dc->activeRecord->description, | ||
'cssClass' => $dc->activeRecord->cssClass, | ||
'pid' => $dc->id, | ||
'sorting' => 0, | ||
'tstamp' => time(), | ||
'title' => $dc->activeRecord->title, | ||
'pageTitle' => $dc->activeRecord->pageTitle, | ||
'description' => $dc->activeRecord->description, | ||
'cssClass' => $dc->activeRecord->cssClass, | ||
'i18nl10n_published' => $dc->activeRecord->published, | ||
'start' => $dc->activeRecord->start, | ||
'stop' => $dc->activeRecord->stop, | ||
'dateFormat' => $dc->activeRecord->dateFormat, | ||
'timeFormat' => $dc->activeRecord->timeFormat, | ||
'datimFormat' => $dc->activeRecord->datimFormat | ||
'start' => $dc->activeRecord->start, | ||
'stop' => $dc->activeRecord->stop, | ||
'dateFormat' => $dc->activeRecord->dateFormat, | ||
'timeFormat' => $dc->activeRecord->timeFormat, | ||
'datimFormat' => $dc->activeRecord->datimFormat | ||
); | ||
|
||
// Now make copies in each language | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* @copyright Copyright (c) 2014-2015 Verstärker, Patric Eberle | ||
* @author Patric Eberle <[email protected]> | ||
* @package i18nl10n dca | ||
* @version 1.5.1 | ||
* @version 1.5.2 | ||
* @license LGPLv3 http://www.gnu.org/licenses/lgpl-3.0.html | ||
*/ | ||
|
||
|
@@ -56,7 +56,8 @@ | |
array('tl_page', 'addBreadcrumb'), | ||
array('tl_page_i18nl10n', 'displayLanguageMessage'), | ||
array('tl_page_i18nl10n', 'localizeAllHandler'), | ||
array('tl_page_i18nl10n', 'checkPermission') | ||
array('tl_page_i18nl10n', 'checkPermission'), | ||
array('tl_page_i18nl10n', 'modifyPalettes'), | ||
), | ||
'sql' => array | ||
( | ||
|
@@ -141,19 +142,13 @@ | |
// Palettes | ||
'palettes' => array | ||
( | ||
'__selector__' => array('type'), | ||
'default' => '{i18nl10n_menuLegend},title,alias;' | ||
'default' => '{i18nl10n_menuLegend},title,type,alias;' | ||
. '{i18nl10n_metaLegend},pageTitle,description;' | ||
. '{i18nl10n_timeLegend:hide},dateFormat,timeFormat,datimFormat;' | ||
. '{i18nl10n_expertLegend:hide},cssClass;' | ||
. '{publish_legend},start,stop;' | ||
. '{i18nl10n_legend},language,i18nl10n_published', | ||
'redirect' => '{i18nl10n_menuLegend},title,alias;' | ||
. '{i18nl10n_metaLegend},pageTitle;' | ||
. '{redirect_legend},url;' | ||
. '{i18nl10n_expertLegend:hide},cssClass;' | ||
. '{publish_legend},start,stop;' | ||
. '{i18nl10n_legend},language,i18nl10n_published' | ||
// Redirect palette is created by onload callback | ||
), | ||
// Fields | ||
'fields' => array | ||
|
@@ -219,6 +214,11 @@ | |
$GLOBALS['TL_DCA']['tl_page_i18nl10n']['fields']['url']['eval']['tl_class'] = 'long'; | ||
$GLOBALS['TL_DCA']['tl_page_i18nl10n']['fields']['i18nl10n_published']['eval']['tl_class'] = 'w50 m12'; | ||
|
||
// Update type field definition | ||
$GLOBALS['TL_DCA']['tl_page_i18nl10n']['fields']['type']['eval']['disabled'] = true; | ||
$GLOBALS['TL_DCA']['tl_page_i18nl10n']['fields']['type']['load_callback'][] = array('tl_page_i18nl10n', 'getPageType'); | ||
unset($GLOBALS['TL_DCA']['tl_page_i18nl10n']['fields']['type']['sql']); | ||
|
||
// Splice in localize all in case languages are available | ||
if ($enableCreate) { | ||
$additionalFunctions = array( | ||
|
@@ -248,6 +248,11 @@ | |
class tl_page_i18nl10n extends tl_page | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $pageType; | ||
|
||
/** | ||
* Generate a localization icon for treeview | ||
* | ||
|
@@ -943,4 +948,40 @@ private function userHasPermissionToEditPage($arrRow, $strTable = 'tl_page_i18nl | |
return $this->User->isAdmin | ||
|| ($this->userHasPermissionToEditLanguage($arrRow) && $this->userHasPermissionToEditPageType($arrRow, $strTable)); | ||
} | ||
|
||
/** | ||
* Modify dca palette according to parent page type | ||
* | ||
* @param $dc | ||
*/ | ||
public function modifyPalettes($dc) | ||
{ | ||
$arrPage = \Database::getInstance() | ||
->prepare('SELECT type FROM tl_page WHERE id = (SELECT pid FROM tl_page_i18nl10n WHERE id = ?)') | ||
->limit(1) | ||
->execute($dc->id) | ||
->fetchAssoc(); | ||
|
||
// Save type for later use | ||
$this->pageType = $arrPage['type']; | ||
|
||
if ($this->pageType === 'redirect') { | ||
$GLOBALS['TL_DCA']['tl_page_i18nl10n']['palettes']['default'] = '{i18nl10n_menuLegend},title,type,alias;' | ||
. '{i18nl10n_metaLegend},pageTitle;' | ||
. '{redirect_legend},url;' | ||
. '{i18nl10n_expertLegend:hide},cssClass;' | ||
. '{publish_legend},start,stop;' | ||
. '{i18nl10n_legend},language,i18nl10n_published'; | ||
} | ||
} | ||
|
||
/** | ||
* Get page type for onload_callback of type field | ||
* | ||
* @return string | ||
*/ | ||
public function getPageType() | ||
{ | ||
return $this->pageType; | ||
} | ||
} |