Last active
July 11, 2016 21:45
-
-
Save koernchen02/825cd0a16dcb2ea17f38 to your computer and use it in GitHub Desktop.
Problems with DateTime Timezones in Extbase and Fluid
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
{namespace as=Portachtzig\Asapp\ViewHelpers} | |
<div class="form-wrap white black-text"> | |
<div class="row" xmlns:f="http://www.w3.org/1999/XSL/Transform"> | |
<div class="col-sm-12"> | |
<label for="draft"> | |
<f:translate key="tx_asapp_domain_model_project.draft" /> | |
</label><br /> | |
<f:form.checkbox property="draft" value="1" /><br /> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-lg-6"> | |
<label for="start"> | |
<f:translate key="tx_asapp_domain_model_project.start" /> | |
</label><br /> | |
<f:form.textfield property="start" id="datepickerstart" class="form-control" value="{project.start->f:format.date( format: 'Y-m-d H:i:s' )}" /><br /> | |
</div> | |
<div class="col-lg-6"> | |
<label for="end"> | |
<f:translate key="tx_asapp_domain_model_project.end" /> | |
</label><br /> | |
<f:form.textfield property="end" id="datepickerend" class="form-control" value="{project.end->f:format.date(format: 'Y-m-d H:i:s')}" /><br /> | |
</div> | |
</div> | |
<f:debug>{project.start}</f:debug> | |
<div class="row"> | |
<div class="col-sm-12"> | |
<label for="title" /> | |
<f:translate key="tx_asapp_domain_model_project.title" /> <span class="required">(required)</span> | |
</label><br /> | |
<f:form.textfield class="form-control" property="title" /><br /> | |
<div class="wysihtml5-toolbar"></div> | |
<label for="summary"> | |
<f:translate key="tx_asapp_domain_model_project.summary" /> | |
</label><br /> | |
<f:form.textarea id="textarea-summary" class="form-control" property="summary" cols="40" rows="8" /><br /> | |
<br/> | |
<label for="description"> | |
<f:translate key="tx_asapp_domain_model_project.description" /> | |
</label><br /> | |
<f:form.textarea id="textarea-description" class="form-control" property="description" cols="40" rows="15" /><br /> | |
<f:if condition="{sessionUser}"> | |
<script>$(document).ready(function(){ | |
$('#textarea-description').wysihtml5({ | |
"font-styles": true, //Font styling, e.g. h1, h2, etc. Default true | |
"emphasis": true, //Italics, bold, etc. Default true | |
"html": true, //Button which allows you to edit the generated HTML. Default false | |
"link": true, //Button to insert a link. Default true | |
"image": false, //Button to insert an image. Default true, | |
"color": false, //Button to change color of font | |
"size": 'sm', //Button size like sm, xs etc. | |
"lists": true | |
}); | |
}); | |
</script> | |
</f:if> | |
<label for="videoembed"> | |
<f:translate key="tx_asapp_domain_model_project.videoembed" /> | |
</label><br /> | |
<f:form.textarea cols="40" rows="5" class="form-control" property="videoembed" /><br /> | |
<label for="audioembed"> | |
<f:translate key="tx_asapp_domain_model_project.audioembed" /> | |
</label><br /> | |
<f:form.textarea cols="40" rows="5" class="form-control" property="audioembed" /><br /> | |
<br/> | |
<div class="col-sm-12"> | |
<f:if condition="{edit} == '1'"> | |
<f:link.action id="remove-all-images"action="removeAllImagesAjax" arguments="{project : project}" class="pull-right btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove">all</span></f:link.action> | |
<as:ajaxRemoveAllImages /> | |
</f:if> | |
<label for="gallery"> | |
<f:translate key="tx_asapp_domain_model_project.gallery" /> | |
</label> | |
<as:form.multiUpload property="gallery" name="gallery" edit="{edit}" plugin="tx_asapp_dates" object="Project" additionalAttributes="{multiple : true}" > | |
<f:if condition="{resource}"> | |
<div class="col-lg-12"> | |
<f:link.action action="removeImageAjax" id="resource-{resource.uid}" arguments="{project : project, image : resource}"> | |
<span class="delete-image white-text pull-right"> | |
<span class="glyphicon glyphicon-remove"></span> | |
</span> | |
</f:link.action> | |
<as:ajaxRemoveImage resource="{resource}" /> | |
<f:image image="{resource}" alt="" width="100c" height="100c" class="thumb" /> | |
</div> | |
<span class="mini">{resource.originalResource.originalFile.name}</span> | |
</f:if> | |
</as:form.multiUpload><br /> | |
<f:for each="{resource}" as="image"> | |
<label for="caption" /> | |
description | |
</label><br /> | |
<f:form.textfield class="form-control" property="description" /><br /> | |
</f:for> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
$('#datepickerstart').datetimepicker({ | |
format:'Y-m-d H:i:s', | |
inline:false, | |
lang:'de', | |
step: 15 | |
}); | |
$('#datepickerend').datetimepicker({ | |
format:'Y-m-d H:i:s', | |
inline:false, | |
lang:'de', | |
step: 15 | |
}); | |
</script> |
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
<f:layout name="Default" /> | |
<f:section name="main"> | |
<f:flashMessages renderMode="div" /> | |
<h1>{project.astypestring}-Element bearbeiten</h1> | |
<f:render partial="FormErrors" arguments="{object:Project}" /> | |
<f:form action="update" id="ajaxform" enctype="multipart/form-data" name="project" object="{project}"> | |
<f:if condition="{project.astype} == 1"> | |
<f:render partial="Project/DateForm" arguments="{project : project, sessionUser:sessionUser, edit : '1'}" /> | |
</f:if> | |
<f:if condition="{project.astype} == 2"> | |
<f:render partial="Project/AtelierForm" arguments="{project : project, sessionUser:sessionUser, edit : '1'}"/> | |
</f:if> | |
<f:if condition="{project.astype} == 3"> | |
<f:render partial="Project/StageForm" arguments="{project : project, sessionUser:sessionUser, edit : '1'}"/> | |
</f:if> | |
<f:if condition="{project.astype} == 4"> | |
<f:render partial="Project/DesktopForm" arguments="{project : project, sessionUser:sessionUser, edit : '1'}"/> | |
</f:if> | |
<br/> | |
<f:form.submit id="submit" class="btn btn-default" value="speichern" /> | |
<f:if condition="{project.astype} == 1"> | |
<f:link.action action="listDates" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
<f:if condition="{project.astype} == 2"> | |
<f:link.action action="listAteliers" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
<f:if condition="{project.astype} == 3"> | |
<f:link.action action="listStages" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
<f:if condition="{project.astype} == 4"> | |
<f:link.action action="listDesktops" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
</f:form> | |
<script type="text/javascript"> | |
$(':file').change(function(){ | |
var file = this.files[0]; | |
var name = file.name; | |
var size = file.size; | |
var type = file.type; | |
//Your validation | |
console.log('changed'); | |
console.log(name, size, type); | |
}); | |
$('#submit').click(function(){ | |
$('#ajaxform').submit(function(e){ | |
console.log('click'); | |
var formData = new FormData(this); | |
$.ajax({ | |
url: $('#ajaxform').attr('action'), //Server script to process data | |
type: "POST", | |
xhr: function(){ // Custom XMLHttpRequest | |
var myXhr = $.ajaxSettings.xhr(); | |
if(myXhr.upload){ // Check if upload property exists | |
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload | |
} | |
console.log('uploading...'); | |
return myXhr; | |
}, | |
//Ajax events | |
//beforeSend: beforeSendHandler, | |
success: function(data){ | |
console.log("success"); | |
console.log(data); | |
$('#progress-in-percent').html('finished!'); | |
$('.progress-bar').removeClass('progress-bar-warning'); | |
$('.progress-bar').addClass('progress-bar-success'); | |
setTimeout(function(){ | |
location.reload(); | |
}, 500); | |
}, | |
// Form data | |
data: formData, | |
cache: false, | |
processData:false, | |
contentType:false | |
}) | |
e.preventDefault(); | |
}); | |
}); | |
function progressHandlingFunction(e){ | |
if(e.lengthComputable){ | |
$('.progress-bar').attr({"aria-valuenow":e.loaded,"aria-valuemax":e.total}); | |
var totalamount = e.total; | |
var currentamount = (e.loaded * 100)/ e.total; | |
var currentamountrounded = Math.round(currentamount); | |
$('.progress-bar').css( "width" , currentamount + '%'); | |
$('#progress-in-percent').html('uploading...' + currentamountrounded + ' / 100%' ); | |
if (e.loaded == e.total){ | |
console.log('upload finshed!'); | |
$('#progress-in-percent').html('processing uploaded files...'); | |
$('.progress-bar').removeClass('progress-bar-info'); | |
$('.progress-bar').addClass('progress-bar-warning'); | |
} | |
} | |
} | |
console.log('ready'); | |
</script> | |
<script> | |
$(function() { | |
$( "#sortable" ).sortable({ | |
opacity: 0.6, | |
cursor: 'move' | |
}); | |
$( "#sortable" ).disableSelection(); | |
}); | |
</script> | |
</f:section> |
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
<f:layout name="Default" /> | |
<f:section name="main"> | |
<f:flashMessages renderMode="div" /> | |
<h1>Neues {newProject.astypestring}-Element</h1> | |
<f:render partial="FormErrors" arguments="{object:NewProject}" /> | |
<f:form action="create" id="ajaxform" enctype="multipart/form-data" name="newProject" object="{newProject}" arguments="{astype : astype}"> | |
<f:if condition="{newProject.astype} == 1"> | |
<f:render partial="Project/DateForm" arguments="{project : newProject, sessionUser:sessionUser}" /> | |
</f:if> | |
<f:if condition="{newProject.astype} == 2"> | |
<f:render partial="Project/AtelierForm" arguments="{project : newProject, sessionUser:sessionUser}"/> | |
</f:if> | |
<f:if condition="{newProject.astype} == 3"> | |
<f:render partial="Project/StageForm" arguments="{project : newProject, sessionUser:sessionUser}"/> | |
</f:if> | |
<f:if condition="{newProject.astype} == 4"> | |
<f:render partial="Project/DesktopForm" arguments="{project : newProject, sessionUser:sessionUser}"/> | |
</f:if> | |
<f:form.submit id="submit" class="btn btn-default" value="speichern" /> | |
<f:if condition="{newProject.astype} == 1"> | |
<f:link.action action="listDates" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
<f:if condition="{newProject.astype} == 2"> | |
<f:link.action action="listAteliers" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
<f:if condition="{newProject.astype} == 3"> | |
<f:link.action action="listStages" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
<f:if condition="{newProject.astype} == 4"> | |
<f:link.action action="listDesktops" class="btn btn-default">schließen</f:link.action> | |
</f:if> | |
</f:form> | |
<br/> | |
<script type="text/javascript"> | |
$(':file').change(function(){ | |
var file = this.files[0]; | |
var name = file.name; | |
var size = file.size; | |
var type = file.type; | |
//Your validation | |
console.log('changed'); | |
console.log(name, size, type); | |
}); | |
$('#submit').click(function(){ | |
$('#submit').fadeOut(300, function() { $(this).remove(); }); | |
$('#ajaxform').submit(function(e){ | |
console.log('click'); | |
var formData = new FormData(this); | |
$.ajax({ | |
url: $('#ajaxform').attr('action'), //Server script to process data | |
type: "POST", | |
xhr: function(){ // Custom XMLHttpRequest | |
var myXhr = $.ajaxSettings.xhr(); | |
if(myXhr.upload){ // Check if upload property exists | |
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload | |
} | |
console.log('uploading...'); | |
return myXhr; | |
}, | |
//Ajax events | |
//beforeSend: beforeSendHandler, | |
success: function(data){ | |
console.log("success"); | |
$('#progress-in-percent').html('finished!'); | |
$('.progress-bar').removeClass('progress-bar-warning'); | |
$('.progress-bar').addClass('progress-bar-success'); | |
}, | |
// Form data | |
data: formData, | |
cache: false, | |
processData:false, | |
contentType:false | |
}) | |
e.preventDefault(); | |
}); | |
}); | |
function progressHandlingFunction(e){ | |
if(e.lengthComputable){ | |
$('.progress-bar').attr({"aria-valuenow":e.loaded,"aria-valuemax":e.total}); | |
var totalamount = e.total; | |
var currentamount = (e.loaded * 100)/ e.total; | |
var currentamountrounded = Math.round(currentamount); | |
$('.progress-bar').css( "width" , currentamount + '%'); | |
$('#progress-in-percent').html('uploading...' + currentamountrounded + ' / 100%' ); | |
if (e.loaded == e.total){ | |
console.log('upload finshed!'); | |
$('#progress-in-percent').html('processing uploaded files...'); | |
$('.progress-bar').removeClass('progress-bar-info'); | |
$('.progress-bar').addClass('progress-bar-warning'); | |
} | |
} | |
} | |
console.log('ready'); | |
</script> | |
</f:section> |
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
<?php | |
namespace Portachtzig\Asapp\Domain\Model; | |
/*************************************************************** | |
* | |
* Copyright notice | |
* | |
* | |
* All rights reserved | |
* | |
* This script is part of the TYPO3 project. The TYPO3 project is | |
* free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* The GNU General Public License can be found at | |
* http://www.gnu.org/copyleft/gpl.html. | |
* | |
* This script is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* This copyright notice MUST APPEAR in all copies of the script! | |
***************************************************************/ | |
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; | |
/** | |
* Project | |
*/ | |
class Project extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { | |
/** | |
* Projekttyp | |
* | |
* @var integer | |
*/ | |
protected $astype; | |
/** | |
* Status der Veröffentlichung | |
* | |
* @var boolean | |
*/ | |
protected $draft = TRUE; | |
/** | |
* Startdatum | |
* | |
* @var \DateTime | |
*/ | |
protected $start = NULL; | |
/** | |
* Enddatum | |
* | |
* @var \DateTime | |
*/ | |
protected $end = NULL; | |
/** | |
* Titel | |
* | |
* @var string | |
* @validate NotEmpty | |
*/ | |
protected $title = ''; | |
/** | |
* Kurzbeschreibung | |
* | |
* @var string | |
*/ | |
protected $summary = ''; | |
/** | |
* Projektbeschreibung | |
* | |
* @var string | |
*/ | |
protected $description = ''; | |
/** | |
* Titelbild | |
* | |
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference | |
*/ | |
protected $coverimage; | |
/** | |
* Galerie | |
* | |
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> | |
*/ | |
protected $gallery; | |
/** | |
* Videoembed | |
* | |
* @var string | |
*/ | |
protected $videoembed = ''; | |
/** | |
* Audioembed | |
* | |
* @var string | |
*/ | |
protected $audioembed = ''; | |
/** | |
* Autor des Projekts (FrontendUser) | |
* | |
* @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser | |
*/ | |
protected $author = NULL; | |
/** | |
* Constructor. | |
*/ | |
public function __construct() { | |
$this->initStorageObjects(); | |
} | |
/** | |
* Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties. | |
* | |
* @return void | |
*/ | |
protected function initStorageObjects() { | |
$this->gallery = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); | |
} | |
/** | |
* Returns the astype | |
* | |
* @return integer $astype | |
*/ | |
public function getAstype() { | |
return $this->astype; | |
} | |
/** | |
* Returns an astype as string | |
* | |
* @return string $astype | |
*/ | |
public function getAstypestring() { | |
$astypestrings = array( | |
1 => 'Termin', | |
2 => 'Atelier', | |
3 => 'Bühne', | |
4 => 'Schreibtisch', | |
5 => 'Hörspiel', | |
6 => 'Theater' | |
); | |
return $astypestrings[$this->astype]; | |
} | |
/** | |
* Sets the astype | |
* | |
* @param integer $astype | |
* @return void | |
*/ | |
public function setAstype($astype) { | |
$this->astype = $astype; | |
} | |
/** | |
* Returns the draft | |
* | |
* @return boolean $draft | |
*/ | |
public function getDraft() { | |
return $this->draft; | |
} | |
/** | |
* Sets the draft | |
* | |
* @param boolean $draft | |
* @return void | |
*/ | |
public function setDraft($draft) { | |
$this->draft = $draft; | |
} | |
/** | |
* Returns the boolean state of draft | |
* | |
* @return boolean | |
*/ | |
public function isDraft() { | |
return $this->draft; | |
} | |
/** | |
* Returns the start | |
* | |
* @return \DateTime $start | |
*/ | |
public function getStart() { | |
return $this->start; | |
} | |
/** | |
* Returns the year | |
* | |
* @return string $year | |
*/ | |
public function getYear() { | |
return $this->start->format('Y'); | |
} | |
/** | |
* Sets the start | |
* | |
* @param \DateTime $start | |
* @return void | |
*/ | |
public function setStart(\DateTime $start) { | |
$this->start = $start; | |
} | |
/** | |
* Returns the end | |
* | |
* @return \DateTime $end | |
*/ | |
public function getEnd() { | |
return $this->end; | |
} | |
/** | |
* Sets the end | |
* | |
* @param \DateTime $end | |
* @return void | |
*/ | |
public function setEnd(\DateTime $end) { | |
$this->end = $end; | |
} | |
/** | |
* Returns the title | |
* | |
* @return string $title | |
*/ | |
public function getTitle() { | |
return $this->title; | |
} | |
/** | |
* Sets the title | |
* | |
* @param string $title | |
* @return void | |
*/ | |
public function setTitle($title) { | |
$this->title = $title; | |
} | |
/** | |
* Returns the summary | |
* | |
* @return string $summary | |
*/ | |
public function getSummary() { | |
return $this->summary; | |
} | |
/** | |
* Sets the summary | |
* | |
* @param string $summary | |
* @return void | |
*/ | |
public function setSummary($summary) { | |
$this->summary = $summary; | |
} | |
/** | |
* Returns the description | |
* | |
* @return string $description | |
*/ | |
public function getDescription() { | |
return $this->description; | |
} | |
/** | |
* Sets the description | |
* | |
* @param string $description | |
* @return void | |
*/ | |
public function setDescription($description) { | |
$this->description = $description; | |
} | |
/** | |
* Returns the coverimage | |
* | |
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $coverimage | |
*/ | |
public function getCoverimage() { | |
$key = 0; | |
foreach($this->gallery as $coverimage ){ | |
if($key < 1){ | |
return $coverimage; | |
$key++; | |
}else{ | |
return null; | |
} | |
} | |
} | |
/** | |
* Sets the coverimage | |
* | |
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $coverimage | |
* @return void | |
*/ | |
public function setCoverimage($coverimage) { | |
$this->coverimage = $coverimage; | |
} | |
/** | |
* Returns the gallery | |
* | |
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> | |
*/ | |
public function getGallery() { | |
return $this->gallery; | |
} | |
/** | |
* Sets the gallery | |
* | |
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $gallery | |
* @return void | |
*/ | |
public function setGallery($gallery) { | |
$this->gallery = $gallery; | |
} | |
/** | |
* removes an image from the gallery | |
* | |
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image | |
* @return void | |
*/ | |
public function removeGalleryImage($image) { | |
$this->gallery->detach($image); | |
} | |
/** | |
* Returns the videoembed | |
* | |
* @return string $videoembed | |
*/ | |
public function getVideoembed() { | |
return $this->videoembed; | |
} | |
/** | |
* Sets the videoembed | |
* | |
* @param string $videoembed | |
* @return void | |
*/ | |
public function setVideoembed($videoembed) { | |
$this->videoembed = $videoembed; | |
} | |
/** | |
* Returns the audioembed | |
* | |
* @return string $audioembed | |
*/ | |
public function getAudioembed() { | |
return $this->audioembed; | |
} | |
/** | |
* Sets the audioembed | |
* | |
* @param string $audioembed | |
* @return void | |
*/ | |
public function setAudioembed($audioembed) { | |
$this->audioembed = $audioembed; | |
} | |
/** | |
* Returns the author | |
* | |
* @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $author | |
*/ | |
public function getAuthor() { | |
return $this->author; | |
} | |
/** | |
* Sets the author | |
* | |
* @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $author | |
* @return void | |
*/ | |
public function setAuthor(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $author) { | |
$this->author = $author; | |
} | |
} |
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
<?php | |
namespace Portachtzig\Asapp\Controller; | |
/*************************************************************** | |
* | |
* Copyright notice | |
* | |
* All rights reserved | |
* | |
* This script is part of the TYPO3 project. The TYPO3 project is | |
* free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* The GNU General Public License can be found at | |
* http://www.gnu.org/copyleft/gpl.html. | |
* | |
* This script is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* This copyright notice MUST APPEAR in all copies of the script! | |
***************************************************************/ | |
use Portachtzig\Asapp\Property\TypeConverter\UploadedFileReferenceConverter; | |
use TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration; | |
use TYPO3\CMS\Core\Utility\GeneralUtility; | |
/** | |
* ProjectController | |
*/ | |
class ProjectController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController { | |
/** | |
* Astypes: | |
* 1 = Dates | |
* 2 = Ateliers | |
* 3 = Stages | |
* 4 = Desktops | |
* 5 = Audiodramas | |
* 6 = Theatres | |
*/ | |
/** | |
* projectRepository | |
* | |
* @var \Portachtzig\Asapp\Domain\Repository\ProjectRepository | |
* @inject | |
*/ | |
protected $projectRepository; | |
/** | |
* @var \TYPO3\CMS\Core\Resource\StorageRepository | |
* @inject | |
*/ | |
protected $storageRepository; | |
/** | |
* frontendUserRepository | |
* | |
* @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository | |
* @inject | |
*/ | |
protected $frontendUserRepository; | |
/** | |
* checkAuthAction | |
* checks for and eventually returns FE-User | |
* | |
* @return void | |
*/ | |
public function checkAuthAction() { | |
$feuserId = $GLOBALS['TSFE']->fe_user->user['uid']; | |
if($feuserId != NULL){ | |
return $this->frontendUserRepository->findByUid($feuserId); | |
}else{ | |
return null; | |
} | |
} | |
/** | |
* action list | |
* @param int $astype | |
* @return void | |
*/ | |
public function listAction($astype) { | |
if ($astype === 1) { | |
$this->redirect('listDates'); | |
} | |
if ($astype === 2) { | |
$this->redirect('listAteliers'); | |
} | |
if ($astype === 3) { | |
$this->redirect('listStages'); | |
} | |
if ($astype === 4) { | |
$this->redirect('listDesktops'); | |
} | |
if ($astype === 5) { | |
$this->redirect('listAudiodramas'); | |
} | |
if ($astype === 6) { | |
$this->redirect('listTheatres'); | |
} | |
} | |
/** | |
* action listDates | |
*/ | |
public function listTeaserAction(){ | |
$firstDate = $this->projectRepository->findFirstByAstype(1); | |
$firstMosaic = $this->projectRepository->findFirstByAstype(2); | |
$firstCalligraphy = $this->projectRepository->findFirstByAstype(3); | |
$firstBook = $this->projectRepository->findFirstByAstype(4); | |
$firstAudiodrama = $this->projectRepository->findFirstByAstype(5); | |
$firstTheatre = $this->projectRepository->findFirstByAstype(6); | |
$allProjects = $this->projectRepository->findAll(); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('firstDate', $firstDate); | |
$this->view->assign('firstMosaic', $firstMosaic); | |
$this->view->assign('firstCalligraphy', $firstCalligraphy); | |
$this->view->assign('firstBook', $firstBook); | |
$this->view->assign('firstAudiodrama', $firstAudiodrama); | |
$this->view->assign('firstTheatre', $firstTheatre); | |
$this->view->assign('allProjects', $allProjects); | |
} | |
/** | |
* action listDates | |
*/ | |
public function listDatesAction(){ | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
if ($this->checkAuthAction() != NULL){ | |
$projects = $this->projectRepository->findByAstype(1); | |
}else{ | |
$projects = $this->projectRepository->findNotDraftByAstype(1); | |
} | |
$this->view->assign('projects', $projects); | |
} | |
/** | |
* action listAteliers | |
*/ | |
public function listAteliersAction(){ | |
$projects = $this->projectRepository->findByAstype(2); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('projects', $projects); | |
} | |
/** | |
* action listStages | |
*/ | |
public function listStagesAction(){ | |
$projects = $this->projectRepository->findByAstype(3); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('projects', $projects); | |
} | |
/** | |
* action listDesktops | |
*/ | |
public function listDesktopsAction(){ | |
$projects = $this->projectRepository->findByAstype(4); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('projects', $projects); | |
} | |
/** | |
* action listAudiodramas | |
*/ | |
public function listAudiodramasAction(){ | |
$projects = $this->projectRepository->findByAstype(5); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('projects', $projects); | |
} | |
/** | |
* action listTheatres | |
*/ | |
public function listTheatresAction(){ | |
$projects = $this->projectRepository->findByAstype(6); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('projects', $projects); | |
} | |
/** | |
* action show | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action showDate | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showDateAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action showAtelier | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showAtelierAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action showStage | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showStageAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action showDesktop | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showDesktopAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action showAudiodrama | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showAudiodramaAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action showTheatre | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function showTheatreAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('project', $project); | |
} | |
/** | |
* action new | |
* | |
* @param int $astype | |
* @return void | |
*/ | |
public function newAction($astype) { | |
$newProject = new \Portachtzig\Asapp\Domain\Model\Project(); | |
$newProject->setAstype($astype); | |
$newProject->setStart(new \DateTime()); | |
$newProject->setEnd(new \DateTime('1970-01-01 00:00:00')); | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('newProject', $newProject); | |
$this->view->assign('astype', $astype); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeCreateAction() { | |
$this->setTypeConverterConfigurationForImageUpload('newProject'); | |
if (isset($this->arguments['newProject'])) { | |
$this->arguments['newProject'] | |
->getPropertyMappingConfiguration() | |
->forProperty('start') | |
->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d H:i:s'); | |
$this->arguments['newProject'] | |
->getPropertyMappingConfiguration() | |
->forProperty('end') | |
->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d H:i:s'); | |
} | |
} | |
/** | |
* action create | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $newProject | |
* @param int $astype | |
* @return void | |
*/ | |
public function createAction(\Portachtzig\Asapp\Domain\Model\Project $newProject, $astype) { | |
$this->addFlashMessage('<br /><div class="alert alert-success alert-dismissible" role="alert"> | |
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | |
<strong>Achtung!</strong> Das Projekt "' .$newProject->getTitle() . '" wurde erstellt! </div>', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK); | |
$this->projectRepository->add($newProject); | |
$newProject->setAstype($astype); | |
$persistenceManager = GeneralUtility::makeInstance('Tx_Extbase_Persistence_Manager'); | |
$persistenceManager->persistAll(); | |
if ($astype === 1){ | |
$this->redirect('showDate', 'Project', 'asapp', array('project' => $newProject) ); | |
} | |
if ($astype === 2){ | |
$this->redirect('showAtelier', 'Project', 'asapp', array('project' => $newProject) ); | |
} | |
if ($astype === 3){ | |
$this->redirect('showStage', 'Project', 'asapp', array('project' => $newProject) ); | |
} | |
if ($astype === 4){ | |
$this->redirect('showDesktop', 'Project', 'asapp', array('project' => $newProject) ); | |
} | |
if ($astype === 5){ | |
$this->redirect('showAudioDrama', 'Project', 'asapp', array('project' => $newProject) ); | |
} | |
if ($astype === 6){ | |
$this->redirect('showTheatre', 'Project', 'asapp', array('project' => $newProject) ); | |
} | |
} | |
/** | |
* action edit | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function editAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->view->assign('sessionUser', $this->checkAuthAction()); | |
$this->view->assign('project', $project); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeUpdateAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeAjaxupdateAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
} | |
/** | |
* action update | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function updateAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->projectRepository->update($project); | |
$this->addFlashMessage('The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See <a href="http://wiki.typo3.org/T3Doc/Extension_Builder/Using_the_Extension_Builder#1._Model_the_domain" target="_blank">Wiki</a>', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR); | |
$astype = $project->getAstype(); | |
if ($astype === 1){ | |
$this->redirect('showDate', 'Project', 'asapp', array('project' => $project) ); | |
} | |
if ($astype === 2){ | |
$this->redirect('showAtelier', 'Project', 'asapp', array('project' => $project) ); | |
} | |
if ($astype === 3){ | |
$this->redirect('showStage', 'Project', 'asapp', array('project' => $project) ); | |
} | |
if ($astype === 4){ | |
$this->redirect('showDesktop', 'Project', 'asapp', array('project' => $project) ); | |
} | |
if ($astype === 5){ | |
$this->redirect('showAudioDrama', 'Project', 'asapp', array('project' => $project) ); | |
} | |
if ($astype === 6){ | |
$this->redirect('showTheatre', 'Project', 'asapp', array('project' => $project) ); | |
} | |
} | |
/** | |
* action ajaxupdate | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return bool|string | |
*/ | |
public function ajaxupdateAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->projectRepository->update($project); | |
# $this->addFlashMessage('The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See <a href="http://wiki.typo3.org/T3Doc/Extension_Builder/Using_the_Extension_Builder#1._Model_the_domain" target="_blank">Wiki</a>', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR); | |
$astype = $project->getAstype(); | |
Header('Content-Type: text/plain'); | |
echo 'OK'; | |
exit; | |
} | |
/** | |
* action delete | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function deleteAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
$this->addFlashMessage('<br /><div class="alert alert-danger alert-dismissible" role="alert"> | |
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | |
<strong>Achtung!</strong> Das Projekt "' .$project->getTitle() . '" wurde gelöscht! </div>', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR); | |
$this->projectRepository->remove($project); | |
$astype = $project->getAstype(); | |
if ($astype === 1){ | |
$this->redirect('listDates'); | |
} | |
if ($astype === 2){ | |
$this->redirect('listAteliers'); | |
} | |
if ($astype === 3){ | |
$this->redirect('listStages'); | |
} | |
if ($astype === 4){ | |
$this->redirect('listDesktops'); | |
} | |
if ($astype === 5){ | |
$this->redirect('listAudioDramas'); | |
} | |
if ($astype === 6){ | |
$this->redirect('listTheatres'); | |
} | |
} | |
/** | |
* action remove all images from gallery (objectStorage) | |
* remove images from gallery | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function removeAllImagesAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
/** | |
* Strange ;-o | |
* | |
* http://forge.typo3.org/issues/51859 | |
* Update by Marc Bastian Heinrichs 2013-09-11 | |
* | |
*/ | |
$clonedStorage = clone $project->getGallery(); | |
$project->getGallery()->removeAll($clonedStorage); | |
$this->projectRepository->update($project); | |
$persistenceManager = GeneralUtility::makeInstance('Tx_Extbase_Persistence_Manager'); | |
$persistenceManager->persistAll(); | |
$this->redirect('showDate', 'Project', 'asapp', array('project' => $project) ); | |
} | |
/** | |
* action remove all images from gallery (objectStorage) | |
* remove images from gallery | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @return void | |
*/ | |
public function removeAllImagesAjaxAction(\Portachtzig\Asapp\Domain\Model\Project $project) { | |
/** | |
* Strange ;-o | |
* | |
* http://forge.typo3.org/issues/51859 | |
* Update by Marc Bastian Heinrichs 2013-09-11 | |
* | |
*/ | |
$clonedStorage = clone $project->getGallery(); | |
$project->getGallery()->removeAll($clonedStorage); | |
$this->projectRepository->update($project); | |
$persistenceManager = GeneralUtility::makeInstance('Tx_Extbase_Persistence_Manager'); | |
$persistenceManager->persistAll(); | |
return true; | |
exit; | |
} | |
/** | |
* action removes a single images from gallery (objectStorage) | |
* remove image from gallery | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image | |
* @return void | |
*/ | |
public function removeImageAction(\Portachtzig\Asapp\Domain\Model\Project $project, \TYPO3\CMS\Extbase\Domain\Model\FileReference $image) { | |
$storage = $this->storageRepository->findByUid(1); | |
$file = $storage->getFile($image->getOriginalResource()->getIdentifier()); | |
$storage->deleteFile($file); | |
//$this->storageRepository->remove($storage); | |
//$project->getGallery()->removeAll($clonedStorage); | |
$this->projectRepository->update($project); | |
$persistenceManager = GeneralUtility::makeInstance('Tx_Extbase_Persistence_Manager'); | |
$persistenceManager->persistAll(); | |
$this->redirect('showDate', 'Project', 'asapp', array('project' => $project) ); | |
} | |
/** | |
* action removes a single images from gallery (objectStorage) | |
* remove image from gallery | |
* | |
* @param \Portachtzig\Asapp\Domain\Model\Project $project | |
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image | |
* @return void | |
*/ | |
public function removeImageAjaxAction(\Portachtzig\Asapp\Domain\Model\Project $project, \TYPO3\CMS\Extbase\Domain\Model\FileReference $image) { | |
$storage = $this->storageRepository->findByUid(1); | |
$file = $storage->getFile($image->getOriginalResource()->getIdentifier()); | |
$storage->deleteFile($file); | |
//$this->storageRepository->remove($storage); | |
//$project->getGallery()->removeAll($clonedStorage); | |
$this->projectRepository->update($project); | |
$persistenceManager = GeneralUtility::makeInstance('Tx_Extbase_Persistence_Manager'); | |
$persistenceManager->persistAll(); | |
return true; | |
exit; | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeRemoveImageAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
$this->setTypeConverterConfigurationForImageUpload('image'); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeRemoveImageAjaxAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
$this->setTypeConverterConfigurationForImageUpload('image'); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeCoverImageImageAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
$this->setTypeConverterConfigurationForImageUpload('image'); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeRemoveAllImagesAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
} | |
/** | |
* Set TypeConverter option for image upload | |
*/ | |
public function initializeRemoveAllImagesAjaxAction() { | |
$this->setTypeConverterConfigurationForImageUpload('project'); | |
} | |
/** | |
* | |
*/ | |
protected function setTypeConverterConfigurationForImageUpload($argumentName) { | |
$uploadConfiguration = array( | |
UploadedFileReferenceConverter::CONFIGURATION_ALLOWED_FILE_EXTENSIONS => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], | |
UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER => '1:/asapp/', | |
UploadedFileReferenceConverter::CONFIGURATION_REPLACE_RESOURCE => TRUE, | |
); | |
/** @var PropertyMappingConfiguration $newProjectConfiguration */ | |
$newProjectConfiguration = $this->arguments[$argumentName]->getPropertyMappingConfiguration(); | |
for ($i=0; $i <= 80; $i++ ){ | |
$newProjectConfiguration->forProperty('gallery')->allowProperties($i); | |
$newProjectConfiguration->forProperty('gallery.'.$i) | |
->setTypeConverterOptions( | |
'Portachtzig\\Asapp\\Property\\TypeConverter\\UploadedFileReferenceConverter', | |
$uploadConfiguration | |
); | |
} | |
$newProjectConfiguration->allowAllProperties('gallery'); | |
$newProjectConfiguration->forProperty('coverimage') | |
->setTypeConverterOptions( | |
'Portachtzig\\Asapp\\Property\\TypeConverter\\UploadedFileReferenceConverter', | |
$uploadConfiguration | |
); | |
$newProjectConfiguration->forProperty('image') | |
->setTypeConverterOptions( | |
'Portachtzig\\Asapp\\Property\\TypeConverter\\UploadedFileReferenceConverter', | |
$uploadConfiguration | |
); | |
$newProjectConfiguration->forProperty('gallery') | |
->setTypeConverterOptions( | |
'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\ObjectStorageConverter', | |
$uploadConfiguration | |
); | |
} | |
/** | |
* Initializes the current action | |
* @return void | |
*/ | |
protected function initializeAction() { | |
$uploadConfiguration = array( | |
UploadedFileReferenceConverter::CONFIGURATION_ALLOWED_FILE_EXTENSIONS => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], | |
UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER => '1:/asapp/', | |
UploadedFileReferenceConverter::CONFIGURATION_REPLACE_RESOURCE => TRUE, | |
); | |
if (isset($this->arguments['project'])) { | |
$this->arguments['project'] | |
->getPropertyMappingConfiguration() | |
->forProperty('start') | |
->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d H:i:s'); | |
$this->arguments['project'] | |
->getPropertyMappingConfiguration() | |
->forProperty('end') | |
->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d H:i:s'); | |
} | |
if (isset($this->arguments['image'])) { | |
$this->arguments['image'] | |
->getPropertyMappingConfiguration() | |
->setTypeConverterOption( | |
'Portachtzig\\Asapp\\Property\\TypeConverter\\UploadedFileReferenceConverter', | |
$uploadConfiguration | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment