Typo3 : datetime +2 hour gap issue - typo3

I have an extension to create events and I can set hours for the start and end of the event.
When I display my hours, there is a gap of +2 hour. When I set 10:00, it display 12:00 .
there is my debug :
I display it like that, and I found a temporary but ugly solution by adding "-2 hours" :
<div class="date mb-4 mb-md-0">
<f:format.date format="%d %B %Y">{atelier.date}</f:format.date>
<f:format.date format="H:i" base="{atelier.heuredebut}">-2 hours</f:format.date>
-
<f:format.date format="H:i" base="{atelier.heurefin}">-2 hours</f:format.date>
</div>
If it can help, there is my model :
protected $heuredebut;
/**
* #return \DateTime
*/
public function getHeuredebut()
{
return $this->heuredebut;
}
/**
* #param \DateTime $heuredebut
*/
public function setHeuredebut($heuredebut)
{
$this->heuredebut = $heuredebut;
}
and my TCA :
'heuredebut' => [
'exclude' => true,
'label' => 'LLL:EXT:reservationatelier/Resources/Private/Language/locallang_db.xlf:tx_reservationatelier_domain_model_atelier.heuredebut',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'dbType' => 'time',
'eval' => 'time, int, null',
],
],
I checked my settings of my server and my php version, everything was ok.
So that's not the problem, do you have any idea where it could be?
thanks you

There's a configuration variable $GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘phpTimeZone’]. Start-/Stoptime are calculated based on this timezone.
For instances hosted/maintained in Germany it's $GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘phpTimeZone’] = 'Europe/Berlin' (winter: UTC/GMT +1, summer: UTC/GMT +2).

Related

Magento2 - Require validation issue for a new checkbox on onepage checkout form

I am using Magento 2.2.3 and i added a new checkbox field with require validation in address onepage checkout form by custom plugin.
I follow this guide:
https://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_new_field.html
Now I display checkbox but validation does not work well.
Require validation only works when customer uncheck the field after checking it.
I need validation to work even when checkbox has never been checked like on first load of the form
Below is my code of LayoutProcessor:
class LayoutProcessor
{
/**
* #param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
* #param array $jsLayout
* #return array
*/
public function afterProcess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
array $jsLayout
) {
$customAttributeCode = 'custom_field';
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']
['shipping-address-fieldset']['children'][$customAttributeCode] = [
'component' => 'Magento_Ui/js/form/element/single-checkbox',
'config' => [
'customScope' => 'shippingAddress.custom_attributes',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/components/single/checkbox',
],
'label' => 'Bla bla bla bla.....',
'dataScope' => 'shippingAddress.custom_attributes' . '.' . $customAttributeCode,
'provider' => 'checkoutProvider',
'sortOrder' => 251,
'required' => true,
'validation' => [
'required-entry' => true
],
'description'=>null,
'value' => '1',
];
return $jsLayout;
}
}

How to update images stored as strings in extbase?

I have recently created an extension that has a file upload feature. I decided to store it as a string. I have used it like this:
In the controller:
public function initializeAction() {
if ($this->arguments->hasArgument('blog')) {
$this->arguments->getArgument('blog')->getPropertyMappingConfiguration()->setTargetTypeForSubProperty('image', 'array');
}
}
In the model:
/**
* Returns the image
*
* #return string $image
*/
public function getImage()
{
return $this->image;
}
/**
* Sets the image
*
* #param \array $image
* #return void
*/
public function setImage(array $image)
{
die(debug::var_dump($image));
if (!empty($image['name']))
{
$imageName = $image['name'];
$imageTempName = $image['tmp_name'];
$basicFileUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
$imageNameNew = $basicFileUtility->getUniqueName($imageName, \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('uploads/tx_myextension/'));
\TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move($imageTempName, $imageNameNew);
$this->image = basename($imageNameNew);
}
}
The TCA:
'config' => [
'type' => 'group',
'internal_type' => 'file',
'uploadfolder' => 'uploads/tx_myextension',
'show_thumbs' => 1,
'size' => 1,
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'disallowed' => ''
],
In my form:
<f:form action="update" name="blog" object="{blog}" >
<f:form.upload property="image" class="form-control" />
...
Now this works perfectly when a new object is created, however when I try to change this image (using updateAction), I get the this error message:
Exception while property mapping at property path "image":
No converter found which can be used to convert from "string" to "array".
I would like to avoid uploading via FAL or writing my own conversion. I'm hoping that I just missed something trivial.
Take an look to an update script from tt_address to see how to make an update.
To make it short: You must read all entries of your files and move them from upload dir to your file storage and then you must add an file_reference which connect the sys_file with your domain model:
GeneralUtility::upload_copy_move(
PATH_site . 'uploads/tx_myextension/' . $imageName,
PATH_site . 'fileadmin/tx_myextension/' . $imageName);
$fileObject = $this->storage->getFile('fileadmin/tx_myextension/' . $imageName);
if ($fileObject instanceof \TYPO3\CMS\Core\Resource\File) {
$this->fileRepository->add($fileObject);
$dataArray = [
'uid_local' => $fileObject->getUid(),
'tablenames' => 'tx_your_domain_model',
'fieldname' => 'image',
'uid_foreign' => 'your model uid',
'table_local' => 'sys_file',
'cruser_id' => 999,
'pid' => 'your_model_pid',
'sorting_foreign' => $imageCount,
'sys_language_uid' => 0
];
if ($this->getDatabaseConnection()->exec_INSERTquery('sys_file_reference', $dataArray)) {
$imageCount++;
}
}
It was a very stupid and simple mistake from my part. In the edit form I forgot to add this: enctype="multipart/form-data"
<f:form action="update" enctype="multipart/form-data" name="blog" object="{blog}" >

TYPO3 6.2 LTS using FAL and TCA

I have the following problem and I'm sure some of you will mark this question as duplicate but I couldn't find a specific answer for my problem.
I have an extension and I want to add images / pdf's etc. using the FAL.
According to tutorials I have to config the TCA. Well, the docs are sh.. about that point and the tutorials are based on the knowledge of TCA.
I also have to use some TypoScript, which I haven't used to this point.
Ok, as far as I got here's my question:
Where do I edit the TCA?
I have a file named ext_tables where I can see $GLOBALS['TCA'].
I also have a directory TCA with some files in it (only filled with $GLOBALES['TCA'].
And after that, how do I access these datas? I need to build a tree in the inside of a modal (pop-up is also possible)
I know these questions sound horribly easy but I couldn't find a tutorial which could explain anything at all.
I appreciate all help :)
Thanks a lot.
Your question is king of vague:
What exactly did you try so far?
Which files did you change?
Do you need the files inside your FLUIDTEMPLATE, inside your extbase controller or somewhere else?
Steps to add FAL fields to your extension
Extend the database (typo3conf/ext/yourExtFolder/ext_tables.sql):
CREATE TABLE your_database_table (
your_fal_field int(11) unsigned DEFAULT '0' NOT NULL
)
Extend the TCA:
If you extend an existing table from another extension you have the extend the TCA inside typo3conf/ext/yourExtFolder/Configuration/TCA/Overrides/your_database_table.php
Example (extend tt_content):
$newColumn = [
'field_name' => [
'image' => [
'label' => 'Image',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('image', [
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference',
],
'minitems' => 0,
'maxitems' => 1,
], $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $newColumn);
If you add the field to your own extension your have to extend typo3conf/ext/yourExtFolder/Configuration/TCA/your_database_table.php.
Example (from TYPO3 core be_users TCA - shortened version):
return [
'ctrl' => [
'label' => 'username',
'descriptionColumn' => 'description',
],
'columns' => [
'username' => [
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:be_users.username',
'config' => [
'type' => 'input',
'size' => 20,
'max' => 50,
'eval' => 'nospace,trim,lower,unique,required',
'autocomplete' => false,
]
],
'avatar' => [
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:be_users.avatar',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'avatar',
['maxitems' => 1],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
)
],
],
// Removed more `columns`, `types` and `palettes` config
];
The important part is the definition of avatar which uses the getFileFieldTCAConfig function.
Extend your extbase model (typo3conf/ext/yourExtFolder/Classes/Domain/Model/YourClass.php)
Simplified snippet from keinerweiss.de:
class YourClass extends TheModelYouWantToExtend or \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
// ...
/**
* #var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $yourField;
/**
* Returns the image
*
* #return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image
*/
public function getYourField() {
return $this->yourField;
}
/**
* Sets the image
*
* #param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image
* #return void
*/
public function setYourField($image) {
$this->yourField = $yourField;
}
}
Use your images in Fluid (From t3-developer.com):
<f:for each="{mymodel.mypictures}" as="picture">
<f:image src="{mypicture.image.uid}" alt="" treatIdAsReference="TRUE" />
</f:for>
More links (english):
https://gist.github.com/maddy2101/5668835
http://blog.scwebs.in/typo3/typo3-fal-file-abstraction-layer-in-extbasefluid-extension
More links(german):
http://keinerweiss.de/755-typo3-fal-in-einer-eigenen-extbasefluid-extension-einsetzen.html
http://t3-developer.com/ext-programmierung/techniken-in-extensions/fal-in-typo3-extensions-verwenden/
http://t3g.at/extbase-bilder-fal-in-extension-integrieren/

Symfony Forms Invalidad Date

Currently i'm working with PHP 5.6.2 in my laptop and the server has 5.5.0 both has configurated timezone to "America/Bogota"
the entity has a field like
/**
* #var \DateTime
* #Column(name="start_date", type="datetime")
* #NotNull()
*/
protected $startDate;
and the entity type is defined like
$builder
->add('startDate', 'date', array(
'input' => 'datetime',
'widget' => 'single_text',
));
the data passed is formatted like 2015-01-15T06:11:37-0500 in my laptop that date is correct but in the server is invalid
I don't know why you are facing this problem, but I would advice you to specify the date format in the form like follows:
Also change date to datetime.
$builder
->add('startDate', 'datetime', array(
'input' => 'datetime',
'widget' => 'single_text',
'format' => 'yyyy-MM-ddThh:ii:ss'
));
Hope this helps.

Extbase ObjectStorage returns a hashcode. But why?

I was just extending an existing Typo3 4.7 Extension with two own Model classes.
It runs quite well, Backendforms look like expected BUT when I try to access some SubObjects of my Model Classes in the templates via Object Accessor {class.subclass.attribute} I am not able to access the attribute. The problem that showed me, is that the Object for the Attribute "mainColor" for example in the Object Storage is a HashCode, which contains the Actual Object I want to access ( the object following the hashcode is the correct related object from the database ).
Does anyone of you have an Idea where the problem might be ?
If any more Code Snippets are needed, I will deliver them. But since I really don't know where the problem comes from, I prefer to not deliver a wall of Code.
Domain/Model/Cluster.php
/**
* Main Color of Cluster
* #var Tx_Extbase_Persistence_ObjectStorage<Tx_Alp_Domain_Model_ColorCombination> $mainColor
*/
protected $mainColor;
/**
* Subcolors of Cluster
* #var Tx_Extbase_Persistence_ObjectStorage<Tx_Alp_Domain_Model_ColorCombination> $subColors
*/
protected $subColors;
/**
* Constructor
* #return void
*/
public function __construct() {
$this->initStorageObjects();
}
/**
* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
* #return void
*/
protected function initStorageObjects() {
$this->subColors = new Tx_Extbase_Persistence_ObjectStorage();
$this->mainColor = new Tx_Extbase_Persistence_ObjectStorage();
}
TCA/Cluster.php
'sub_colors' => array(
'exclude' => 1,
'label' => 'Sub-Colors',
'config' => array(
// edited
'type' => 'inline',
'internal_type' => 'db',
'allowed' => 'tx_alp_domain_model_colorcombination',
'foreign_table' => 'tx_alp_domain_model_colorcombination',
'MM' => 'tx_alp_cluster_subcolorcombination_mm',
'MM_opposite_field' => 'parent_cluster',
'size' => 6,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'selectedListStyle' => 'width:250px;',
'wizards' => array(
'_PADDING' => 5,
'_VERTICAL' => 1,
'suggest' => array(
'type' => 'suggest',
),
),
),
),
Fluid Debug Output can be found here:
http://i60.tinypic.com/28kluub.jpg
Thanks for any help :(
And sorry for my bad English and this is my first question here, hope I did it right ;)
Unless you have a 1:1 relation from a model to a sub model, you cannot access the sub model because the sub model is an ObjectStorage.
Example:
Domain/Model/Cluster.php
/**
* Main Color of Cluster
* #var Tx_Alp_Domain_Model_ColorCombination $mainColor
*/
protected $mainColor;
This means that the Cluster model has exacly one main color (mind the annotation), this is a 1:1 relation.
Therefore using {cluster.mainColor.property} will work.
What you are doing is:
Domain/Model/Cluster.php
/**
* Main Color of Cluster
* #var Tx_Extbase_Persistence_ObjectStorage<Tx_Alp_Domain_Model_ColorCombination> $mainColor
*/
protected $mainColor;
This means that every Cluster can have multiple main colors, this is a 1:n relation. Therefore you must iterate through the mainColors (and call the property $mainColors):
<f:for each="{cluster.mainColors}" as="mainColor">
{mainColor.property}
</f:for>