Skip to content
Snippets Groups Projects
Commit 14a2c7ae authored by Fabian Galinski's avatar Fabian Galinski :pouting_cat:
Browse files

[FEATURE] Adaptation for TYPO3 7.6 and release of version 2.0.0

parent 7231ba4a
No related branches found
Tags 2.0.0
No related merge requests found
......@@ -83,17 +83,13 @@ abstract class AbstractController extends ActionController {
/** @var FileReference $teaserImage */
/** @var FileReference $singleNewsImage */
$objectForData = $news;
$teaserImage = $singleNewsImage = NULL;
$teaserImage = $singleNewsImage = $singleNewsImageObject = $teaserImageObject = NULL;
$singleNewsImages = $news->getTeaser2Image();
$useImageCropForSingleNews = $news->getUseImage2Crop();
if (count($singleNewsImages)) {
$singleNewsImage = $singleNewsImages->current();
} else {
$singleNewsImages = $category->getTeaser2Image();
$useImageCropForSingleNews = $category->getUseImage2Crop();
if (count($singleNewsImages)) {
$singleNewsImage = $singleNewsImages->current();
$objectForData = $category;
......@@ -102,16 +98,10 @@ abstract class AbstractController extends ActionController {
$imageHeadlineColor = 0;
if ($singleNewsImage) {
if (!$useImageCropForSingleNews) {
$originalResource = $singleNewsImage->getOriginalResource();
$singleNewsImage = $originalResource->getPublicUrl();
} else {
$coordinates = $objectForData->getTeaser2Coordinates();
$imageHeadlineColor = $objectForData->getTeaser2HeaderColor();
$singleNewsImage = $this->imageService->cropFirstMediaImage(
$singleNewsImage, $coordinates, 'fileadmin/sgNews/', $news->getTitle()
);
}
$singleNewsImageObject = $singleNewsImage;
$originalResource = $singleNewsImage->getOriginalResource();
$singleNewsImage = $originalResource->getPublicUrl();
$imageHeadlineColor = $objectForData->getTeaser2HeaderColor();
if ($singleNewsImage) {
$singleNewsImage = $GLOBALS['TSFE']->absRefPrefix . $singleNewsImage;
......@@ -120,14 +110,10 @@ abstract class AbstractController extends ActionController {
$objectForData = $news;
$teaserImages = $news->getTeaser1Image();
$useImageCropForTeaser = $news->getUseImageCrop();
if (count($teaserImages)) {
$teaserImage = $teaserImages->current();
} else {
$teaserImages = $category->getTeaser1Image();
$useImageCropForTeaser = $category->getUseImageCrop();
if (count($teaserImages)) {
$teaserImage = $teaserImages->current();
$objectForData = $category;
......@@ -136,16 +122,10 @@ abstract class AbstractController extends ActionController {
$teaserImageHeadlineColor = 0;
if ($teaserImage) {
if (!$useImageCropForTeaser) {
$originalResource = $teaserImage->getOriginalResource();
$teaserImage = $originalResource->getPublicUrl();
} else {
$coordinates = $objectForData->getTeaser1Coordinates();
$teaserImageHeadlineColor = $objectForData->getTeaser1HeaderColor();
$teaserImage = $this->imageService->cropFirstMediaImage(
$teaserImage, $coordinates, 'fileadmin/sgNews/', 'teaser-' . $news->getTitle()
);
}
$teaserImageObject = $teaserImage;
$originalResource = $teaserImage->getOriginalResource();
$teaserImage = $originalResource->getPublicUrl();
$teaserImageHeadlineColor = $objectForData->getTeaser1HeaderColor();
if ($teaserImage) {
$teaserImage = $GLOBALS['TSFE']->absRefPrefix . $teaserImage;
......@@ -156,7 +136,9 @@ abstract class AbstractController extends ActionController {
'category' => $category,
'news' => $news,
'image' => $singleNewsImage,
'imageObject' => $singleNewsImageObject,
'teaserImage' => $teaserImage,
'teaserImageObject' => $teaserImageObject,
'imageHeadlineColor' => $imageHeadlineColor,
'teaserImageHeadlineColor' => $teaserImageHeadlineColor,
];
......
......@@ -26,7 +26,6 @@ namespace SGalinski\SgNews\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
......@@ -36,16 +35,6 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
* Abstract Category and news
*/
abstract class CategoryAndNews extends AbstractEntity {
/**
* @var string
*/
protected $teaser1Coordinates = '';
/**
* @var string
*/
protected $teaser2Coordinates = '';
/**
* @var int
*/
......@@ -56,16 +45,6 @@ abstract class CategoryAndNews extends AbstractEntity {
*/
protected $teaser2HeaderColor = 0;
/**
* @var boolean
*/
protected $useImageCrop = FALSE;
/**
* @var boolean
*/
protected $useImage2Crop = FALSE;
/**
* @var string
*/
......@@ -158,86 +137,6 @@ abstract class CategoryAndNews extends AbstractEntity {
return ($this->subtitle !== '' ? $this->subtitle : $this->title);
}
/**
* Teaser1Coordinates is an comma separated list like this: 1,2,3,4...
*
* @param array $teaser1Coordinates
* @return void
*/
public function setTeaser1Coordinates(array $teaser1Coordinates) {
$this->teaser1Coordinates = implode(',', $teaser1Coordinates);
}
/**
* Returning array structure:
* array (
* 'x1' => string,
* 'y1' => string,
* 'x2' => string,
* 'y2' => string,
* 'w' => string,
* 'h' => string,
* )
*
* @return array
*/
public function getTeaser1Coordinates() {
$mappedCoordinates = [];
$explodedCoordinates = GeneralUtility::intExplode(',', $this->teaser1Coordinates);
if (count($explodedCoordinates) === 6) {
$mappedCoordinates = [
'x1' => $explodedCoordinates[0],
'y1' => $explodedCoordinates[1],
'x2' => $explodedCoordinates[2],
'y2' => $explodedCoordinates[3],
'w' => $explodedCoordinates[4],
'h' => $explodedCoordinates[5],
];
}
return $mappedCoordinates;
}
/**
* Teaser2Coordinates is an comma separated list like this: 1,2,3,4...
*
* @param array $teaser2Coordinates
* @return void
*/
public function setTeaser2Coordinates(array $teaser2Coordinates) {
$this->teaser2Coordinates = implode(',', $teaser2Coordinates);
}
/**
* Returning array structure:
* array (
* 'x1' => string,
* 'y1' => string,
* 'x2' => string,
* 'y2' => string,
* 'w' => string,
* 'h' => string,
* )
*
* @return array
*/
public function getTeaser2Coordinates() {
$mappedCoordinates = [];
$explodedCoordinates = GeneralUtility::intExplode(',', $this->teaser2Coordinates);
if (count($explodedCoordinates) === 6) {
$mappedCoordinates = [
'x1' => $explodedCoordinates[0],
'y1' => $explodedCoordinates[1],
'x2' => $explodedCoordinates[2],
'y2' => $explodedCoordinates[3],
'w' => $explodedCoordinates[4],
'h' => $explodedCoordinates[5],
];
}
return $mappedCoordinates;
}
/**
* @param int $teaser1HeaderColor
* @return void
......@@ -354,34 +253,6 @@ abstract class CategoryAndNews extends AbstractEntity {
$this->teaser2Image->detach($teaser2Image);
}
/**
* @param boolean $useImageCrop
*/
public function setUseImageCrop($useImageCrop) {
$this->useImageCrop = ($useImageCrop == TRUE);
}
/**
* @return boolean
*/
public function getUseImageCrop() {
return $this->useImageCrop;
}
/**
* @param boolean $useImage2Crop
*/
public function setUseImage2Crop($useImage2Crop) {
$this->useImage2Crop = ($useImage2Crop == TRUE);
}
/**
* @return boolean
*/
public function getUseImage2Crop() {
return $this->useImage2Crop;
}
/**
* @return int
*/
......
......@@ -25,6 +25,7 @@ namespace SGalinski\SgNews\TCA;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Form\Element\UserElement;
use TYPO3\CMS\Backend\Form\FormEngine;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\DataHandling\DataHandler;
......@@ -106,81 +107,6 @@ class TcaProvider implements SingletonInterface {
}
}
}
/**
* Allows the selection of the coordinates from the first attached image of the configured sourceFieldName like
* media. The selection is added into a hidden field by javascript that is saved by TYPO3.
*
* @param array $parameters
* @param FormEngine $formEngine
* @return string
*/
public function coordinatePicker(array $parameters, FormEngine $formEngine) {
// add Jcrop
$requestHost = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST');
$jsFile = GeneralUtility::getFileAbsFileName('EXT:sg_news/Resources/Public/Contrib/Jcrop/jquery.Jcrop.min.js');
$jsFile = $requestHost . '/' . PathUtility::stripPathSitePrefix($jsFile);
$cssFile = 'EXT:sg_news/Resources/Public/Contrib/Jcrop/jquery.Jcrop.min.css';
$cssFile = GeneralUtility::getFileAbsFileName($cssFile);
$cssFile = $requestHost . '/' . PathUtility::stripPathSitePrefix($cssFile);
$formEngine->additionalCode_pre['rsNewsCoordinatePicker'] = '
<script src="' . $jsFile . '" type="text/javascript"></script>
<link rel="stylesheet" href="' . $cssFile . '" type="text/css" />
';
// add hidden form field content
$hash = uniqid('tx-sgnews-');
$field = $parameters['field'];
$column = 'data[pages][' . $parameters['row']['uid'] . '][' . $field . ']';
$content = '<input id="' . $hash . '-input" name="' . $column .
'" value="' . $parameters['row'][$field] . '" type="hidden" />';
// add jcrop instance javascript
$coordinates = GeneralUtility::intExplode(',', $parameters['row'][$field], TRUE);
$width = (int) $parameters['fieldConf']['config']['parameters']['width'];
$height = (int) $parameters['fieldConf']['config']['parameters']['height'];
$coordinates = (!count($coordinates) ? [0, 0, $width, $height] : $coordinates);
$aspectRatio = $parameters['fieldConf']['config']['parameters']['aspectRatio'];
$formEngine->additionalJS_pre['rsNewsCoordinatePicker' . $hash] = '
(function($) {
$(document).ready(function() {
var writeCoords = function (coordinates) {
var result = coordinates.x + "," + coordinates.y + "," + coordinates.x2 + "," +
coordinates.y2 + "," + coordinates.w + "," + coordinates.h;
$("#' . $hash . '-input").val(result);
};
$("#' . $hash . '-source").Jcrop({
onChange: writeCoords,
onSelect: writeCoords,
boxWidth: 800,
boxHeight: 600,
aspectRatio: ' . htmlspecialchars($aspectRatio) . ',
minSize: [' . $width . ',' . $height . '],
setSelect: [' . implode(',', $coordinates) . ']
});
});
})(TYPO3.jQuery);
';
// add image for jcrop
$sourceFieldName = $parameters['fieldConf']['config']['parameters']['sourceFieldName'];
$firstImageReferenceId = GeneralUtility::intExplode(',', $parameters['row'][$sourceFieldName])[0];
try {
$fileReference = ResourceFactory::getInstance()->getFileReferenceObject($firstImageReferenceId);
if ($fileReference) {
$file = $requestHost . '/' . $fileReference->getPublicUrl();
$content .= '<img src="' . $file . '" alt="" id="' . $hash . '-source" />';
}
} catch (\Exception $exception) {
/** @var LanguageService $languageService */
$languageService = $GLOBALS['LANG'];
$languageService->includeLLFile('EXT:sg_news/Resources/Private/Language/locallang_backend.xlf');
$content = '<strong>' . $languageService->getLL('coordinatePicker.missingImage') . '</strong>';
}
return $content;
}
}
?>
......@@ -54,6 +54,11 @@ class ExtendedIfViewHelper extends AbstractConditionViewHelper {
$condition, $or = FALSE, $or2 = FALSE, $or3 = FALSE, $or4 = FALSE,
$and = TRUE, $and2 = TRUE, $and3 = TRUE, $and4 = TRUE, $negate = FALSE
) {
if ($this->evaluateConditionFunctionExists()) {
return parent::render();
}
// @todo Remove the following part if only > 7.5 support.
$conditionResult = ($condition || $or || $or2 || $or3 || $or4) && $and && $and2 && $and3 && $and4;
if ($negate ? !$conditionResult : $conditionResult) {
return $this->renderThenChild();
......@@ -61,6 +66,37 @@ class ExtendedIfViewHelper extends AbstractConditionViewHelper {
return $this->renderElseChild();
}
}
/**
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
*
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
* @return bool
*/
static protected function evaluateCondition($arguments = NULL) {
$conditionResult = (
isset($arguments['condition']) && $arguments['condition'] ||
isset($arguments['or']) && $arguments['or'] ||
isset($arguments['or2']) && $arguments['or2'] ||
isset($arguments['or3']) && $arguments['or3'] ||
isset($arguments['or4']) && $arguments['or4']
) && isset($arguments['and']) && $arguments['and'] &&
isset($arguments['and2']) && $arguments['and2'] &&
isset($arguments['and3']) && $arguments['and3'] &&
isset($arguments['and4']) && $arguments['and4'];
return isset($arguments['negate']) && $arguments['negate'] ? !$conditionResult : $conditionResult;
}
/**
* Returns true, if the function evaluateCondition exists in the AbstractConditionViewHelper class.
*
* @deprecated Remove this function if only > 7.5 support.
* @return boolean
*/
protected function evaluateConditionFunctionExists() {
return method_exists('TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper', 'evaluateCondition');
}
}
?>
\ No newline at end of file
?>
......@@ -15,9 +15,6 @@
['', ''],
],
'wizards' => [
'_PADDING' => 5,
'_VALIGN' => 'middle',
'_VERTICAL' => 0,
'edit' => [
'type' => 'popup',
'title' => 'Edit',
......@@ -57,54 +54,6 @@
'type' => 'check',
],
],
'tx_sgnews_use_image_crop' => [
'exclude' => TRUE,
'l10n_exclude' => TRUE,
'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_use_image_crop',
'config' => [
'type' => 'check',
],
],
'tx_sgnews_use_image2_crop' => [
'exclude' => TRUE,
'l10n_exclude' => TRUE,
'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_use_image_crop',
'config' => [
'type' => 'check',
],
],
'tx_sgnews_teaser1_coordinates' => [
'exclude' => TRUE,
'l10n_exclude' => TRUE,
'displayCond' => 'FIELD:tx_sgnews_use_image_crop:REQ:TRUE',
'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_teaser1_coordinates',
'config' => [
'type' => 'user',
'userFunc' => 'EXT:sg_news/Classes/TCA/TcaProvider.php:SGalinski\SgNews\TCA\TcaProvider->coordinatePicker',
'parameters' => [
'width' => 240,
'height' => 140,
'aspectRatio' => '12 / 7',
'sourceFieldName' => 'tx_sgnews_teaser1_image',
],
],
],
'tx_sgnews_teaser2_coordinates' => [
'exclude' => TRUE,
'l10n_exclude' => TRUE,
'displayCond' => 'FIELD:tx_sgnews_use_image2_crop:REQ:TRUE',
'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_teaser2_coordinates',
'config' => [
'type' => 'user',
'userFunc' => 'EXT:sg_news/Classes/TCA/TcaProvider.php:SGalinski\SgNews\TCA\TcaProvider->coordinatePicker',
'parameters' => [
'width' => 764,
'height' => 356,
'aspectRatio' => '191 / 89',
'sourceFieldName' => 'tx_sgnews_teaser2_image',
],
],
],
'tx_sgnews_teaser1_header_color' => [
'exclude' => TRUE,
'l10n_exclude' => TRUE,
......@@ -152,6 +101,7 @@
'default' => $GLOBALS['EXEC_TIME'],
]
],
// @todo Set the image crop ratio for both sgnews images.
'tx_sgnews_teaser1_image' => [
'exclude' => TRUE,
'l10n_mode' => 'exclude',
......@@ -243,11 +193,6 @@
]
);
$fields = $GLOBALS['TCA']['pages']['ctrl']['requestUpdate'];
$newFields = 'tx_sgnews_use_image_crop, tx_sgnews_use_image2_crop';
$requestUpdate = (!$fields ? $newFields : $fields .= $newFields);
$GLOBALS['TCA']['pages']['ctrl']['requestUpdate'] = $requestUpdate;
$GLOBALS['TCA']['pages']['palettes']['editorialWithNewsAuthor'] = [
'showitem' => 'tx_sgnews_author;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author.inPalette,
author;LLL:EXT:cms/locallang_tca.xlf:pages.author_formlabel,
......@@ -263,13 +208,13 @@ $GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = [
$GLOBALS['TCA']['pages']['palettes']['mediaWithCoordinationPicker'] = [
'showitem' => 'tx_sgnews_teaser2_image, --linebreak--,
tx_sgnews_teaser2_header_color, tx_sgnews_use_image2_crop, --linebreak--, tx_sgnews_teaser2_coordinates',
tx_sgnews_teaser2_header_color',
'canNotCollapse' => 1,
];
$GLOBALS['TCA']['pages']['palettes']['mediaWithCoordinationPicker2'] = [
'showitem' => 'tx_sgnews_teaser1_image, --linebreak--,
tx_sgnews_teaser1_header_color, tx_sgnews_use_image_crop, --linebreak--, tx_sgnews_teaser1_coordinates',
tx_sgnews_teaser1_header_color',
'canNotCollapse' => 1,
];
......
......@@ -13,12 +13,8 @@ config.tx_extbase {
crdate.mapOnProperty = creationDate
tx_sgnews_teaser1_image.mapOnProperty = teaser1Image
tx_sgnews_teaser2_image.mapOnProperty = teaser2Image
tx_sgnews_teaser1_coordinates.mapOnProperty = teaser1Coordinates
tx_sgnews_teaser1_header_color.mapOnProperty = teaser1HeaderColor
tx_sgnews_teaser2_coordinates.mapOnProperty = teaser2Coordinates
tx_sgnews_teaser2_header_color.mapOnProperty = teaser2HeaderColor
tx_sgnews_use_image_crop.mapOnProperty = useImageCrop
tx_sgnews_use_image2_crop.mapOnProperty = useImage2Crop
}
}
}
......@@ -29,12 +25,8 @@ config.tx_extbase {
columns {
tx_sgnews_teaser1_image.mapOnProperty = teaser1Image
tx_sgnews_teaser2_image.mapOnProperty = teaser2Image
tx_sgnews_teaser1_coordinates.mapOnProperty = teaser1Coordinates
tx_sgnews_teaser1_header_color.mapOnProperty = teaser1HeaderColor
tx_sgnews_teaser2_coordinates.mapOnProperty = teaser2Coordinates
tx_sgnews_teaser2_header_color.mapOnProperty = teaser2HeaderColor
tx_sgnews_use_image_crop.mapOnProperty = useImageCrop
tx_sgnews_use_image2_crop.mapOnProperty = useImage2Crop
}
}
}
......
......@@ -20,10 +20,10 @@
</f:comment>
<f:alias map="{singleViewUri: '{f:uri.page(pageUid: \'{newsMetaData.news.uid}\')}'}">
<f:if condition="{newsMetaData.teaserImage}">
<f:if condition="{newsMetaData.teaserImageObject}">
<div class="tx-sgnews-teaser-image">
<a href="{singleViewUri}">
<img src="{newsMetaData.teaserImage}" alt="" />
<f:image image="{newsMetaData.teaserImageObject}" alt="" />
</a>
</div>
</f:if>
......@@ -72,4 +72,4 @@
</f:if>
</div>
</div>
</f:alias>
\ No newline at end of file
</f:alias>
......@@ -6,9 +6,9 @@
<f:section name="main">
<div class="tx-sgnews-single">
<div class="tx-sgnews-teaser">
<f:if condition="{newsMetaData.image}">
<f:if condition="{newsMetaData.imageObject}">
<div class="tx-sgnews-single-image">
<img src="{newsMetaData.image}" alt="" />
<f:image image="{newsMetaData.imageObject}" alt="" />
</div>
</f:if>
......@@ -116,4 +116,4 @@
</div>
</div>
</f:section>
\ No newline at end of file
</f:section>
{
"name": "sgalinski/sg-news",
"type": "typo3-cms-extension",
"description": "News System",
"homepage": "https://www.sgalinski.de",
"license": ["GPL-2.0+"],
"version": "2.0.0",
"support": {
},
"require": {
"typo3/cms-core": "*"
},
"replace": {
"sg-news": "*"
},
"autoload": {
"psr-4": {
"SGalinski\\SgNews\\": "Classes/"
}
}
}
......@@ -19,14 +19,15 @@ $EM_CONF[$_EXTKEY] = array(
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '1.0.0',
'version' => '2.0.0',
'constraints' => array(
'depends' => array(
'typo3' => '6.2.0-6.2.99',
'php' => '5.4.0-5.6.99',
'typo3' => '7.6.0-7.6.99',
'php' => '5.5.0-5.6.99',
'pw_comments' => '3.0.0-3.9.99',
'rx_shariff' => '2.1.0-',
'project_base' => '1.0.0-'
'rx_shariff' => '5.0.1-',
'project_base' => '1.0.0-',
'pagebrowse' => '1.3.4-',
),
'conflicts' => array(),
'suggests' => array(),
......
......@@ -6,10 +6,6 @@ CREATE TABLE pages (
tx_sgnews_teaser2_image int(11) unsigned DEFAULT '0' NOT NULL,
tx_sgnews_teaser1_header_color int(11) unsigned DEFAULT '0' NOT NULL,
tx_sgnews_teaser2_header_color int(11) unsigned DEFAULT '0' NOT NULL,
tx_sgnews_teaser1_coordinates varchar(255) DEFAULT '' NOT NULL,
tx_sgnews_teaser2_coordinates varchar(255) DEFAULT '' NOT NULL,
tx_sgnews_use_image_crop tinyint(4) unsigned DEFAULT '0' NOT NULL,
tx_sgnews_use_image2_crop tinyint(4) unsigned DEFAULT '0' NOT NULL,
KEY author (tx_sgnews_author)
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment