Skip to content

Commit

Permalink
Move the default image densities into the page layout (see #545)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Jul 5, 2019
1 parent 147cbec commit ed1d67e
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 137 deletions.
35 changes: 21 additions & 14 deletions core-bundle/src/Resources/contao/dca/tl_layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
'palettes' => array
(
'__selector__' => array('rows', 'cols', 'addJQuery', 'addMooTools', 'static'),
'default' => '{title_legend},name;{header_legend},rows;{column_legend},cols;{sections_legend:hide},sections;{webfonts_legend:hide},webfonts;{style_legend},framework,stylesheet,external,loadingOrder,combineScripts;{modules_legend},modules;{script_legend},scripts,analytics,externalJs,script;{jquery_legend:hide},addJQuery;{mootools_legend:hide},addMooTools;{static_legend:hide},static;{expert_legend:hide},template,minifyMarkup,viewport,titleTag,cssClass,onload,lightboxSize,head'
'default' => '{title_legend},name;{header_legend},rows;{column_legend},cols;{sections_legend:hide},sections;{webfonts_legend:hide},webfonts;{image_legend:hide},lightboxSize,defaultImageDensities;{style_legend},framework,stylesheet,external,loadingOrder,combineScripts;{modules_legend},modules;{script_legend},scripts,analytics,externalJs,script;{jquery_legend:hide},addJQuery;{mootools_legend:hide},addMooTools;{static_legend:hide},static;{expert_legend:hide},template,minifyMarkup,viewport,titleTag,cssClass,onload,head'
),

// Subpalettes
Expand Down Expand Up @@ -279,6 +279,26 @@
'eval' => array('decodeEntities'=>true, 'maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'lightboxSize' => array
(
'exclude' => true,
'inputType' => 'imageSize',
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'),
'options_callback' => function ()
{
return Contao\System::getContainer()->get('contao.image.image_sizes')->getOptionsForUser(Contao\BackendUser::getInstance());
},
'sql' => "varchar(255) NOT NULL default ''"
),
'defaultImageDensities' => array
(
'inputType' => 'text',
'explanation' => 'imageSizeDensities',
'exclude' => true,
'eval' => array('helpwizard'=>true, 'maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'viewport' => array
(
'exclude' => true,
Expand Down Expand Up @@ -433,19 +453,6 @@
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(32) NOT NULL default 'center'"
),
'lightboxSize' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_layout']['lightboxSize'],
'exclude' => true,
'inputType' => 'imageSize',
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'),
'options_callback' => function ()
{
return Contao\System::getContainer()->get('contao.image.image_sizes')->getOptionsForUser(Contao\BackendUser::getInstance());
},
'sql' => "varchar(255) NOT NULL default ''"
)
)
);
Expand Down
10 changes: 1 addition & 9 deletions core-bundle/src/Resources/contao/dca/tl_theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
// Palettes
'palettes' => array
(
'default' => '{title_legend},name,author;{config_legend},folders,screenshot,templates;{image_legend:hide},defaultImageDensities;{vars_legend},vars'
'default' => '{title_legend},name,author;{config_legend},folders,screenshot,templates;{vars_legend},vars'
),

// Fields
Expand Down Expand Up @@ -193,14 +193,6 @@
'inputType' => 'keyValueWizard',
'exclude' => true,
'sql' => "text NULL"
),
'defaultImageDensities' => array
(
'inputType' => 'text',
'explanation' => 'imageSizeDensities',
'exclude' => true,
'eval' => array('helpwizard'=>true, 'maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
)
)
);
Expand Down
21 changes: 15 additions & 6 deletions core-bundle/src/Resources/contao/languages/en/tl_layout.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@
<trans-unit id="tl_layout.webfonts.1">
<source>Here you can add Google web fonts to your website. Specify the font families without the base URL (e.g. &lt;em&gt;Ubuntu|Ubuntu+Mono&lt;/em&gt;).</source>
</trans-unit>
<trans-unit id="tl_layout.lightboxSize.0">
<source>Lightbox image size</source>
</trans-unit>
<trans-unit id="tl_layout.lightboxSize.1">
<source>Here you can select an image size for the images shown in the lightbox.</source>
</trans-unit>
<trans-unit id="tl_layout.defaultImageDensities.0">
<source>Default image pixel densities</source>
</trans-unit>
<trans-unit id="tl_layout.defaultImageDensities.1">
<source>Here you can define the default pixel densities, e.g. &lt;em&gt;1x, 1.5x, 2x&lt;/em&gt;.</source>
</trans-unit>
<trans-unit id="tl_layout.modules.0">
<source>Included modules</source>
</trans-unit>
Expand Down Expand Up @@ -323,6 +335,9 @@
<trans-unit id="tl_layout.webfonts_legend">
<source>Web fonts</source>
</trans-unit>
<trans-unit id="tl_layout.image_legend">
<source>Image sizes</source>
</trans-unit>
<trans-unit id="tl_layout.style_legend">
<source>Style sheets</source>
</trans-unit>
Expand Down Expand Up @@ -377,12 +392,6 @@
<trans-unit id="tl_layout.analytics_piwik">
<source>Piwik</source>
</trans-unit>
<trans-unit id="tl_layout.lightboxSize.0">
<source>Lightbox image size</source>
</trans-unit>
<trans-unit id="tl_layout.lightboxSize.1">
<source>Image size used for images shown in the lightbox.</source>
</trans-unit>
<trans-unit id="tl_layout.new.0">
<source>New</source>
</trans-unit>
Expand Down
9 changes: 0 additions & 9 deletions core-bundle/src/Resources/contao/languages/en/tl_theme.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
<trans-unit id="tl_theme.vars.1">
<source>Here you can define global variables for the style sheets of the theme (e.g. &lt;em&gt;$red&lt;/em&gt; -&gt; &lt;em&gt;c00&lt;/em&gt; or &lt;em&gt;$margin&lt;/em&gt; -&gt; &lt;em&gt;12px&lt;/em&gt;).</source>
</trans-unit>
<trans-unit id="tl_theme.defaultImageDensities.0">
<source>Default image pixel densities</source>
</trans-unit>
<trans-unit id="tl_theme.defaultImageDensities.1">
<source>Here you can define the default pixel densities, e.g. &lt;em&gt;1x, 1.5x, 2x&lt;/em&gt;.</source>
</trans-unit>
<trans-unit id="tl_theme.source.0">
<source>Source files</source>
</trans-unit>
Expand All @@ -62,9 +56,6 @@
<trans-unit id="tl_theme.config_legend">
<source>Configuration</source>
</trans-unit>
<trans-unit id="tl_theme.image_legend">
<source>Image sizes</source>
</trans-unit>
<trans-unit id="tl_theme.vars_legend">
<source>Global variables</source>
</trans-unit>
Expand Down
8 changes: 8 additions & 0 deletions core-bundle/src/Resources/contao/models/LayoutModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* @property string $template
* @property string $minifyMarkup
* @property string $webfonts
* @property string $lightboxSize
* @property string $defaultImageDensities
* @property string $viewport
* @property string $titleTag
* @property string $cssClass
Expand Down Expand Up @@ -80,6 +82,8 @@
* @method static LayoutModel|null findOneByTemplate($val, array $opt=array())
* @method static LayoutModel|null findOneByMinifyMarkup($val, array $opt=array())
* @method static LayoutModel|null findOneByWebfonts($val, array $opt=array())
* @method static LayoutModel|null findOneByLightboxSize($val, array $opt=array())
* @method static LayoutModel|null findOneByDefaultImageDensities($val, array $opt=array())
* @method static LayoutModel|null findOneByViewport($val, array $opt=array())
* @method static LayoutModel|null findOneByTitleTag($val, array $opt=array())
* @method static LayoutModel|null findOneByCssClass($val, array $opt=array())
Expand Down Expand Up @@ -120,6 +124,8 @@
* @method static Collection|LayoutModel[]|LayoutModel|null findByTemplate($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByMinifyMarkup($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByWebfonts($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByLightboxSize($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByDefaultImageDensities($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByViewport($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByTitleTag($val, array $opt=array())
* @method static Collection|LayoutModel[]|LayoutModel|null findByCssClass($val, array $opt=array())
Expand Down Expand Up @@ -164,6 +170,8 @@
* @method static integer countByTemplate($val, array $opt=array())
* @method static integer countByMinifyMarkup($val, array $opt=array())
* @method static integer countByWebfonts($val, array $opt=array())
* @method static integer countByLightboxSize($val, array $opt=array())
* @method static integer countByDefaultImageDensities($val, array $opt=array())
* @method static integer countByViewport($val, array $opt=array())
* @method static integer countByTitleTag($val, array $opt=array())
* @method static integer countByCssClass($val, array $opt=array())
Expand Down
4 changes: 0 additions & 4 deletions core-bundle/src/Resources/contao/models/ThemeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* @property string $screenshot
* @property string $templates
* @property string $vars
* @property string $defaultImageDensities
*
* @method static ThemeModel|null findById($id, array $opt=array())
* @method static ThemeModel|null findByPk($id, array $opt=array())
Expand All @@ -36,7 +35,6 @@
* @method static ThemeModel|null findOneByScreenshot($val, array $opt=array())
* @method static ThemeModel|null findOneByTemplates($val, array $opt=array())
* @method static ThemeModel|null findOneByVars($val, array $opt=array())
* @method static ThemeModel|null findOneByDefaultImageDensities($val, array $opt=array())
*
* @method static Collection|ThemeModel[]|ThemeModel|null findByTstamp($val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findByName($val, array $opt=array())
Expand All @@ -45,7 +43,6 @@
* @method static Collection|ThemeModel[]|ThemeModel|null findByScreenshot($val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findByTemplates($val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findByVars($val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findByDefaultImageDensities($val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findMultipleByIds($val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findBy($col, $val, array $opt=array())
* @method static Collection|ThemeModel[]|ThemeModel|null findAll(array $opt=array())
Expand All @@ -58,7 +55,6 @@
* @method static integer countByScreenshot($val, array $opt=array())
* @method static integer countByTemplates($val, array $opt=array())
* @method static integer countByVars($val, array $opt=array())
* @method static integer countByDefaultImageDensities($val, array $opt=array())
*
* @author Leo Feyer <https://github.com/leofeyer>
*/
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/contao/pages/PageRegular.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function prepare($objPage)
$objTheme = $objLayout->getRelated('pid');

// Set the default image densities
$container->get('contao.image.picture_factory')->setDefaultDensities($objTheme->defaultImageDensities);
$container->get('contao.image.picture_factory')->setDefaultDensities($objLayout->defaultImageDensities);

// Store the layout ID
$objPage->layoutId = $objLayout->id;
Expand Down
Loading

0 comments on commit ed1d67e

Please sign in to comment.