Skip to content

Instantly share code, notes, and snippets.

View pduersteler's full-sized avatar

Pascal Dürsteler pduersteler

View GitHub Profile
require_once(PATH_tslib.'class.tslib_fe.php');
require_once(PATH_t3lib.'class.t3lib_userauth.php' );
require_once(PATH_tslib.'class.tslib_feuserauth.php');
require_once(PATH_t3lib.'class.t3lib_cs.php');
require_once(PATH_tslib.'class.tslib_content.php') ;
require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
class tx_extname_eid extends tslib_pibase
@pduersteler
pduersteler / ModelController.php
Last active October 28, 2021 10:28
Extbase Multistep form example. Not finished, not perfect.
<?php
namespace Foo\Bar\Controller;
class ModelController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* New action.
*
* Displays form in its current step.
*
* @param \Foo\Bar\Domain\Model\Model $model
# Aim: load all activities having the same customer.
#
# PublicActivity::Activity(id: integer, trackable_id: integer, trackable_type: string, ...)
# => belongs_to :trackable, polymorphic: true
# => trackable is either Project or Service
PublicActivity::Activity.joins(:trackable)
# ActiveRecord::EagerLoadPolymorphicError: Can not eagerly load the polymorphic association :trackable
class CredentialsController < ApplicationController
before_filter :assign_encryption_key
before_filter :request_encryption_key, unless: "Credential.key_present?", except: [:set_encryption_key]
def new
@credential = Credential.new
end
def create
module MyGem
module MyClassExtension
extend ActiveSupport::Concern
module ClassMethods
def does_something_to(modifiers = {}, *args)
cattr_accessor :my_gem_modifiers
self.my_gem_modifiers = modifiers
end
end
# in app/controllers/application_controller.rb
require 'thing/exceptions'
class ApplicationController < ActionController::Base
end
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
require 'myapp/exceptions'
include MyApp::Exceptions
end
# config/application.rb
module Myapp
class Application < Rails::Application
<header_images>
<TCEforms type="array">
<config type="array">
<type>group</type>
<internal_type>file</internal_type>
<allowed>gif,png,jpg,jpeg</allowed>
<max_size>1000</max_size>
<uploadfolder>uploads/media</uploadfolder>
<show_thumbs>5</show_thumbs>
<size>5</size>
resources :recordings do
get '/:year/:month/:day', :on => :collection, :action => :index, :constraints => {:day => /\D{1,2}/, :month => /\D{1,2}/, :year => /\D{4}/}
end
<%= link_to 'previous day', recordings_path(:year => (@date-1.day).year, :month => (@date-1.day).month, :day => (@date-1.day).day) %>
# generates <a href="/recordings?year=yyy&month=mm&day=dd">
# desired: <a href="/recordings/yyyy/mm/dd"></a>
$(function()
{
applyUiTo('body');
$('a[data-modal=true]').on('click', function(event)
{
$.get($(this).attr('href'), function(data) {
$(data).modal({
// No problem here because I have a selector