Skip to content

Instantly share code, notes, and snippets.

View benjaminrau's full-sized avatar

Benjamin Rau benjaminrau

View GitHub Profile
/**
* @var Tx_Acme_Repository_AcmeRepository
*/
protected $repository;
/**
* @return void
*/
public function initializeObject() {
@benjaminrau
benjaminrau / DateInterval Comparision
Created January 23, 2013 14:18
Compare two DateInterval objects with dynamic operator
/**
* Compare Date Intervals
*
* @param DateInterval $dateInterval1
* @param DateInterval $dateInterval2
* @param string $operator
* @return boolean
*/
private function compareDateIntervals(DateInterval $dateInterval1, DateInterval $dateInterval2, $operator) {
$newDate = new DateTime();
@benjaminrau
benjaminrau / In Array Viewhelper
Last active September 26, 2017 19:22
An ViewHelper for extbase/fluid equivalent to php´s in_array() function.
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Benjamin Rau <rau@codearts.at>, codearts
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
@benjaminrau
benjaminrau / gist:4721948
Last active December 12, 2015 05:28
Remove all objects from a mn relation / objectstorage
/**
* action update
*
* @param Tx_Hcbookings_Domain_Model_Item
* @dontverifyrequesthash
* @return void
*/
public function updateAction(Tx_Hcbookings_Domain_Model_Item $item) {
// Empty storage if no got submitted by form / last one has been removed
@benjaminrau
benjaminrau / Edit objectstorage inline
Last active December 14, 2015 07:09
Edit objectstorage inline
Model:
-----
Item
Property: availabilityRanges
@var ObjectStorage<availabilityRanges>
Annotations on the updateAction:
--------------------------------
@benjaminrau
benjaminrau / gist:5067763
Last active December 14, 2015 09:50
Select Options are Empty on File Reference TYPO3 Version: 6.0.2
Core Patch i applied:
---------------------
https://review.typo3.org/#/c/17159/
(only change on core that differs from 6.0.2 release)
Example Backend HTML Source:
---------------------------
<select id="tceforms-multiselect-5131163e80d21" size="5" class="formField tceforms-multiselect"
multiple="multiple" name="data[tt_content][13][pi_flexform][data][options][lDEF][sliderImages][vDEF]_list"
style="width:310px;">
@benjaminrau
benjaminrau / gist:5081550
Last active December 14, 2015 11:49
Create Menu from List of Page UIDs
{namespace v=Tx_Vhs_ViewHelpers}
<f:if condition="{showRelated}">
<f:if condition="{v:iterator.explode(glue:',',content:relatedPageUid)->f:count()}>0">
<v:page.menu.list pages="{relatedPageUid}"></v:page.menu.list>
</f:if>
</f:if>
@benjaminrau
benjaminrau / Genitive
Created June 7, 2013 11:51
Frame the genitive of a name
function genitive($name) {
$suffix = 's';
$name = trim($name);
if('ce' == substr($name, -2)) {
$suffix = '’';
}
elseif (in_array(substr($name, -1), array('s', 'ß', 'x', 'z'))) {
$suffix = '’';
@benjaminrau
benjaminrau / gist:5927125
Last active December 19, 2015 08:39
Vhs HTML5 Audioplayer Viewhelper
<?php
/***************************************************************
* Copyright notice
*
* (c) 2013 Björn Fromme <fromme@dreipunktnull.com>, dreipunktnull
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
@benjaminrau
benjaminrau / htaccess
Last active December 19, 2015 09:39
Rewrite old plugin urls to new ones in typo3
RewriteCond %{REQUEST_URI} ^/tonstudio/sprecher_liste\.html
RewriteCond %{QUERY_STRING} ^tx_speakerdb_pi1\[showUid\]=([0-9]+)
RewriteRule ^(.*)$ http://www.domain.com/tonstudio/sprecher-liste.html?tx_speakerdb2_speakers[speaker]=%1&tx_speakerdb2_speakers[action]=show [L,R=301]