Skip to content

Commit

Permalink
Merge branch contao-4 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Jun 24, 2015
2 parents c663edf + 8824f5a commit e54bbc3
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 29 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
},
"require":{
"php":">=5.3",
"contao/core":">=3.1,<4",
"contao-community-alliance/composer-installer":"*",
"madeyourday/contao-rocksolid-columns":"~1.0",
"madeyourday/contao-rocksolid-icon-picker":"~1.0"
},
Expand Down
14 changes: 9 additions & 5 deletions config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
'MadeYourDay\\Contao\\Widget\\Hidden' => 'system/modules/rocksolid-custom-elements/src/MadeYourDay/Contao/Widget/Hidden.php',
));

$templatesFolder = version_compare(VERSION, '4.0', '>=')
? 'vendor/madeyourday/contao-rocksolid-custom-elements/templates'
: 'system/modules/rocksolid-custom-elements/templates';

TemplateLoader::addFiles(array(
'form_rsce_plain' => 'system/modules/rocksolid-custom-elements/templates',
'be_rsce_list' => 'system/modules/rocksolid-custom-elements/templates',
'be_rsce_group' => 'system/modules/rocksolid-custom-elements/templates',
'be_rsce_hidden' => 'system/modules/rocksolid-custom-elements/templates',
'be_rsce_convert' => 'system/modules/rocksolid-custom-elements/templates',
'form_rsce_plain' => $templatesFolder,
'be_rsce_list' => $templatesFolder,
'be_rsce_group' => $templatesFolder,
'be_rsce_hidden' => $templatesFolder,
'be_rsce_convert' => $templatesFolder,
));
80 changes: 62 additions & 18 deletions src/MadeYourDay/Contao/CustomElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,13 @@ protected function prepareSaveData($fieldPrefix, $fieldsConfig)
*/
protected function createDca($dc, $type, $createFromPost = false, $tmpField = null)
{
$assetsDir = version_compare(VERSION, '4.0', '>=')
? 'bundles/rocksolidcustomelements'
: 'system/modules/rocksolid-custom-elements/assets';

if (TL_MODE === 'BE') {
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rocksolid-custom-elements/assets/js/be_main.js';
$GLOBALS['TL_CSS'][] = 'system/modules/rocksolid-custom-elements/assets/css/be_main.css';
$GLOBALS['TL_JAVASCRIPT'][] = $assetsDir . '/js/be_main.js';
$GLOBALS['TL_CSS'][] = $assetsDir . '/css/be_main.css';
}

$paletteFields = array();
Expand Down Expand Up @@ -627,9 +631,18 @@ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$palet
* @param \DataContainer $dc Data container
* @return string Page picker button html code
*/
public function pagePicker($dc) {
public function pagePicker($dc)
{
if (version_compare(VERSION, '4.0', '>=')) {
$url = \System::getContainer()->get('router')->generate('contao_backend_page');
}
else {
$url = 'contao/page.php';
}

return ' <a'
. ' href="contao/page.php'
. ' href="'
. $url
. '?do=' . \Input::get('do')
. '&amp;table=' . $dc->table
. '&amp;field=' . $dc->field
Expand Down Expand Up @@ -923,21 +936,46 @@ protected static function getDcaFieldValue($dc, $fieldName, $fromDb = false)
}

/**
* Purge cache file system/cache/rocksolid_custom_elements_config.php
* Purge cache file rocksolid_custom_elements_config.php
*
* @return void
*/
public static function purgeCache()
{
$filePath = 'system/cache/rocksolid_custom_elements_config.php';
$fileFullPath = TL_ROOT . '/' . $filePath;
$filePaths = static::getCacheFilePaths();

if (file_exists($fileFullPath)) {
$file = new \File($filePath, true);
if (file_exists($filePaths['fullPath'])) {
$file = new \File($filePaths['path'], true);
$file->write('');
$file->close();
static::refreshOpcodeCache($fileFullPath);
static::refreshOpcodeCache($filePaths['fullPath']);
}
}

/**
* Get path and fullPath to the cache file
*
* @return string
*/
public static function getCacheFilePaths()
{
if (version_compare(VERSION, '4.0', '>=')) {
$cacheDir = \System::getContainer()->getParameter('kernel.cache_dir') . '/contao';
}
else {
$cacheDir = TL_ROOT . '/system/cache';
}

$fileFullPath = $cacheDir . '/rocksolid_custom_elements_config.php';
$filePath = $fileFullPath;
if (substr($filePath, 0, strlen(TL_ROOT) + 1) === TL_ROOT . '/') {
$filePath = substr($filePath, strlen(TL_ROOT) + 1);
}

return array(
'path' => $filePath,
'fullPath' => $fileFullPath,
);
}

/**
Expand All @@ -949,21 +987,27 @@ public static function purgeCache()
public static function loadConfig($bypassCache = false)
{
// Don't load the config in the install tool
if (\Environment::get('script') === 'contao/install.php') {
return;
if (version_compare(VERSION, '4.0', '>=')) {
if (\System::getContainer()->get('request')->get('_route') === 'contao_backend_install') {
return;
}
}
else {
if (\Environment::get('script') === 'contao/install.php') {
return;
}
}

$filePath = 'system/cache/rocksolid_custom_elements_config.php';
$fileFullPath = TL_ROOT . '/' . $filePath;
$filePaths = static::getCacheFilePaths();

$cacheHash = md5(implode(',', array_merge(
glob(TL_ROOT . '/templates/rsce_*') ?: array(),
glob(TL_ROOT . '/templates/*/rsce_*') ?: array()
)));

if (!$bypassCache && file_exists($fileFullPath)) {
if (!$bypassCache && file_exists($filePaths['fullPath'])) {
$fileCacheHash = null;
include $fileFullPath;
include $filePaths['fullPath'];
if ($fileCacheHash === $cacheHash) {
// the cache file is valid and loaded
return;
Expand Down Expand Up @@ -1156,10 +1200,10 @@ function ($count) {

}

$file = new \File($filePath, true);
$file = new \File($filePaths['path'], true);
$file->write(implode("\n", $contents));
$file->close();
static::refreshOpcodeCache($fileFullPath);
static::refreshOpcodeCache($filePaths['fullPath']);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/MadeYourDay/Contao/Element/CustomElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function rsceGetBackendOutput()
$method = $entry['class'] . '::' . $entry['function'];
if (
$entry['file'] === TL_ROOT . '/system/modules/newsletter/classes/Newsletter.php'
|| $entry['file'] === TL_ROOT . '/vendor/contao/newsletter-bundle/src/Resources/contao/classes/Newsletter.php'
|| $method === 'Contao\\Newsletter::send'
|| $method === 'tl_newsletter::listNewsletters'
) {
Expand Down
1 change: 1 addition & 0 deletions src/MadeYourDay/Contao/Resources/contao
1 change: 1 addition & 0 deletions src/MadeYourDay/Contao/Resources/public
20 changes: 20 additions & 0 deletions src/MadeYourDay/Contao/RockSolidCustomElementsBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MadeYourDay\Contao;

use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* Configures the RockSolid Custom Elements bundle.
*
* @author Martin Auswöger <[email protected]>
*/
class RockSolidCustomElementsBundle extends Bundle
{
}
12 changes: 12 additions & 0 deletions src/MadeYourDay/Contao/Template/CustomTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
*/
class CustomTemplate extends \FrontendTemplate
{
/**
* {@inheritdoc}
*/
protected function getTemplatePath($template, $format = 'html5', $default = false)
{
if ($default) {
return parent::getTemplatePath($template, $format, $default);
}

return static::getTemplate($template, $format);
}

/**
* Get the template path
*
Expand Down
8 changes: 4 additions & 4 deletions src/MadeYourDay/Contao/Widget/ListItemStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public function generate()
$fieldIndex = (int) $fieldIndex[count($fieldIndex) - 1];

$toolbar = '<div class="rsce_list_toolbar">';
$toolbar .= '<a href="" class="rsce_list_toolbar_up" onclick="rsceMoveElement(this, -1);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '"><img width="13" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '" src="system/themes/default/images/up.gif"></a> ';
$toolbar .= '<a href="" class="rsce_list_toolbar_down" onclick="rsceMoveElement(this, 1);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '"><img width="13" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '" src="system/themes/default/images/down.gif"></a> ';
$toolbar .= '<a href="" class="rsce_list_toolbar_up" onclick="rsceMoveElement(this, -1);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '"><img width="13" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_up'] . '" src="system/themes/' . \Controller::getTheme() . '/images/up.gif"></a> ';
$toolbar .= '<a href="" class="rsce_list_toolbar_down" onclick="rsceMoveElement(this, 1);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '"><img width="13" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_down'] . '" src="system/themes/' . \Controller::getTheme() . '/images/down.gif"></a> ';
$toolbar .= \Controller::generateImage('drag.gif', '', 'class="drag-handle rsce_list_toolbar_drag" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"') . ' ';
$toolbar .= '<a href="" class="rsce_list_toolbar_delete" onclick="rsceDeleteElement(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '"><img width="14" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '" src="system/themes/default/images/delete.gif"></a> ';
$toolbar .= '<a href="" class="rsce_list_toolbar_new" onclick="rsceNewElementAfter(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '"><img width="12" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '" src="system/themes/default/images/new.gif"></a> ';
$toolbar .= '<a href="" class="rsce_list_toolbar_delete" onclick="rsceDeleteElement(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '"><img width="14" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_delete'] . '" src="system/themes/' . \Controller::getTheme() . '/images/delete.gif"></a> ';
$toolbar .= '<a href="" class="rsce_list_toolbar_new" onclick="rsceNewElementAfter(this);return false;" title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '" data-rsce-title="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '"><img width="12" height="16" alt="' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['list_item_new'] . '" src="system/themes/' . \Controller::getTheme() . '/images/new.gif"></a> ';
$toolbar .= '</div>';

return '<div class="rsce_list_item'
Expand Down

0 comments on commit e54bbc3

Please sign in to comment.