Skip to content

Instantly share code, notes, and snippets.

View tristanlins's full-sized avatar

Tristan Lins tristanlins

View GitHub Profile
@tristanlins
tristanlins / gist:1883699
Last active October 1, 2015 00:07
Avisota E-Mail Benachrichtigung bei Anmeldung, Aktivierung und Abmeldung für Anbieter
// config.php
<?php
$GLOBALS['TL_HOOKS']['avisotaSubscribe'][] = array('CustomAvisotaNotification', 'hookAvisotaSubscribe');
$GLOBALS['TL_HOOKS']['avisotaActivateSubscribtion'][] = array('CustomAvisotaNotification', 'hookAvisotaActivateSubscribtion');
$GLOBALS['TL_HOOKS']['avisotaUnsubscribe'][] = array('CustomAvisotaNotification', 'hookAvisotaUnsubscribe');
?>
// CustomAvisotaNotification.php
interface Media
{
Media static get(String file);
bool isImage();
bool isPDF();
bool isVideo();
bool isAudio();
bool hasThumb();
Media getThumb(Size size);
@tristanlins
tristanlins / gist:4584976
Last active December 11, 2015 10:09
~/bin/composer
#!/bin/bash
if [[ ! -f $HOME/workspace/composer.phar ]]; then
mkdir -p $HOME/workspace
curl -s https://getcomposer.org/installer | php -- --install-dir=$HOME/workspace
fi
php $HOME/workspace/composer.phar "$@"
// system/modules/avisota-extend/config/database.sql
CREATE TABLE `tl_avisota_recipient` (
`myfield` varchar(255) NOT NULL default '',
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
// system/modules/avisota-extend/dca/tl_avisota_recipient.php
<?php
$GLOBALS['TL_DCA']['tl_avisota_recipient']['palettes']['default'] .= ';{zusatzfelder_legend},myfield';
$GLOBALS['TL_DCA']['tl_avisota_recipient']['fields']['myfield'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_avisota_recipient']['myfield'],
@tristanlins
tristanlins / example.php
Last active December 20, 2015 22:19
[Avisota 2 Example] how to use the dependency injection container
<?php
global $container;
// access the avisota subscription manager
/** @var \Avisota\Contao\SubscriptionManager $subscriptionManager */
$subscriptionManager = $container['avisota.subscription'];
// subscribe global
$subscriptionManager->subscribe('me@example.com');
@tristanlins
tristanlins / example.php
Last active December 20, 2015 22:19
[Avisota 2 Example] search for recipients
<?php
// access the entity manager and get the recipient repository
/** @var \Contao\Doctrine\ORM\EntityHelper $entityManager */
$entityManager = EntityHelper::getEntityManager();
$repository = $entityManager->getRepository('Avisota\Contao:Recipient');
// search recipient by email
/** @var \Avisota\Contao\Entity\Recipient $recipient */
$recipient = $repository->findOneBy(array('email' => 'me@example.com'));
@tristanlins
tristanlins / example.php
Last active July 18, 2018 02:33
[Avisota 2 Example] subscribe to events
<?php
$GLOBALS['TL_EVENTS']['avisota-recipient-subscribe'][] = function(
\Avisota\Contao\Event\SubscribeEvent $event
) {
/** @var \Avisota\Contao\Entity\Recipient $recipient */
$recipient = $event->getRecipient();
/** @var \Avisota\Contao\Entity\RecipientSubscription $subscription */
$subscription = $event->getSubscription();
@tristanlins
tristanlins / Date.toW3CString.js
Last active February 29, 2024 19:44
Date.toW3CString() method to convert date objects into W3C date time format: yyyy-mm-ddThh:ii:ss+zz:zz
/**
* Convert a Date object to a string, according to W3C date time format: yyyy-mm-ddThh:ii:ss+zz:zz
*
* @memberOf Date
* @access public
* @license MIT
* @copyright 2013 Tristan Lins
* @author Tristan Lins <tristan.lins@bit3.de>
* @link https://gist.github.com/tristanlins/6585391
*/
@tristanlins
tristanlins / APrototypedClass.class.php
Last active December 23, 2015 07:09
PHP Prototype Theory
<?php
class APrototypedClass extends Prototype
{
}
APrototypedClass::$prototype['getId'] = function() {
return $this->id;
};
{
"repositories": [
{
"type": "package",
"package": {
"name": "components/jquery-transit",
"type": "component",
"version": "0.9.9",
"homepage": "https://github.com/rstacruz/jquery.transit",
"require": {