Skip to content

Instantly share code, notes, and snippets.

View kitzberger's full-sized avatar

Philipp Kitzberger kitzberger

View GitHub Profile
@kitzberger
kitzberger / fix-typo3-72779.ts
Last active November 22, 2017 13:41
TYPO3 8.7: Workaround for broken rel attribute of lightbox links
# Workaround for broken rel attribute of lightbox links in TYPO3 8.7
# See https://forge.typo3.org/issues/72779
lib.contentElement.variables.10 = LOAD_REGISTER
lib.contentElement.variables.10.content_uid = TEXT
lib.contentElement.variables.10.content_uid.field = uid
lib.contentElement.settings.media.popup.linkParams.ATagParams.dataWrap = class="{$styles.content.textmedia.linkWrap.lightboxCssClass}" rel="{$styles.content.textmedia.linkWrap.lightboxRelAttribute}[{register:content_uid}]"
lib.contentElement.stdWrap.append = RESTORE_REGISTER
# Help based on https://gist.github.com/prwhite/8168133 thanks to @nowox and @prwhite
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([\w-]+)\s*:.*\#\#(?:@([\w-]+))?\s(.*)$$/ }; \
print "\nusage: make [target ...]\n\n"; \
for (keys %help) { \
print "$$_:\n"; \
<?php
namespace Vendor\Extension\View\Record;
class ListJson extends \TYPO3\CMS\Extbase\Mvc\View\JsonView {
private static $uriBuilder = null;
public function typolink($page, $uid = null) {
if ($page) {
if (self::$uriBuilder === null) {
@kitzberger
kitzberger / mysql-csv-export.sql
Created July 20, 2018 12:57
Export MySQL into CSV file
-- Wanna export a joined result?
SELECT a.id, a.name, b.name
FROM tableA a
JOIN tableB b ON a.id = b.rel_id
WHERE a.deleted=0 and b.deleted=0
ORDER BY a.name, b.nane
INTO OUTFILE '/var/lib/mysql-files/xxxx.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
-- Find out what charset and collation the DB has:
SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation'
FROM information_schema.SCHEMATA;
-- Find out what charset and collation the tables have:
SELECT T.table_name, CCSA.character_set_name, CCSA.collation_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
-- Change charset and collation of DB:
@kitzberger
kitzberger / XyzRepository.php
Last active October 26, 2018 17:05
Debug Extbase Queries (TYPO3 8.7)
<?php
namespace Vendor\ExtensionName\Domain\Repository;
class XyzRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
public function findByFoo($value)
{
$query = $this->createQuery();
#$query->setFancyConstrations(...)
$this->debugQuery($query);
@kitzberger
kitzberger / XyzRepository.php
Created November 8, 2018 17:03
Debug Extbase Queries (TYPO3 6+7)
<?php
namespace Vendor\ExtensionName\Domain\Repository;
class XyzRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
public function findByFoo($value)
{
$query = $this->createQuery();
#$query->setFancyConstrations(...)
$this->debugQuery($query->execute());
@kitzberger
kitzberger / department.php
Last active December 10, 2018 15:19
TYPO3 TCA example for enriched inline/irre relations
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
$GLOBALS['TCA']['tx_customext_domain_model_department'] = array(
'ctrl' => array(
'title' => 'LLL:EXT:custom_ext/Resources/Private/Language/locallang_db.xlf:tx_custom_ext_domain_model_department',
// title prefixed by department_id
'label' => 'department_id',
@kitzberger
kitzberger / php-compatibility-check.sh
Created February 5, 2019 20:09
PHP Compatibility Check
# -------------------------
# PHP-Compatibility
# -------------------------
# Add dev requirements
composer require --dev phpcompatibility/php-compatibility
# List installed configs (should be none)
bin/phpcs --config-show
@kitzberger
kitzberger / version-compare.php
Created February 19, 2019 12:56
TYPO3/PHP version compare
if (version_compare(PHP_VERSION, '7.0.0', '>=') {
...
}
if (version_compare(TYPO3_version, '8.7.0', '>=') {
...
}