Você está na página 1de 76

Inside TYPOlight

Overview

Part 1: TYPOlight folders

Part 2: TYPOlight framework

Part 3: Libraries

Part 4: Life ccle of a front end re!"est

Part #: $ata container arras

Part %: &"stomi'ing TYPOlight



Part 1: TYPOlight folders

Part 1: TYPOlight folders

(l"gins

sstem

tem(lates

tl)files

t(olight

sstem

config

drivers

html

libraries

logs

mod"les

themes

tm(

Part 1: TYPOlight folders

(l"gins

*+ternal scri(ts that are "sed sstem,wide -Tin.&*/ .ooTools/


012ob3ect/ (h(mailer etc45

tem(lates

&"stom tem(lates/ incl"de files/ 06L d"m(s

The folder is not to"ched b the live "(date scri(t

tl)files

&entral file management

t(olight

7dministration area in a s"bfolder allows for additional (rotection


via 4htaccess file

Part 1: TYPOlight folders

sstem8config

&entral storage location for config"ration files

sstem8drivers

.i+t"re between controller/ model and view -e4g4 $&)Table4(h(5

$atabase ada(ters -e4g4 $9).s!l4(h(/ $9)Oracle4(h(5

sstem8html

&ache director that is accessible via :TTP -e4g4 th"mbnails5

sstem8libraries

Libraries abstract vario"s tasks like database comm"nication/ file


o(erations -0.:5/ safel retrieving "ser in("t/ sending e,mails/
calc"lating dates etc4

Part 1: TYPOlight folders

sstem8logs

0torage location for log files -not accessible via :TTP5

sstem8mod"les

&entral storage location for mod"les

*ven the back end itself is ;3"st< a mod"le

The core can be e+tended b an f"nctionalit

sstem8themes

0torage location for back end themes

sstem8tm(

&ache director that is not accessible via :TTP



Part 2: TYPOlight
framework

Part 2: TYPOlight framework

TYPOlight and .=&

.=& > .odel,=iew,&ontroller

.=& elements e+ist in TYPOlight

0till it is not a classic .=& framework

$eviation list

.odels are onl "sed for "sers

$rivers are a combination of controller/ model and view with


e+tended &?@$ f"nctionalit -create/ read/ "(date/ delete5

9ack end views -e4g4 forms5 are being rendered a"tomaticall

Ao t(ical @?I ro"ting in favor of search,engine,friendl @?Ls in


the front end

Part 2: TYPOlight framework B .odels

.odels

Onl im(lemented for "sers in TYPOlight

$this->import('BackendUser', 'User');
echo $this->User->isAdmin; // False
$this->User->admin = 1;
$this->User->sae();
echo $this->User->isAdmin; // !r"e

.odels onl (la a minor (art/ beca"se the goal was to (rogram
com(rehensive drivers that can create different views and (rocess
forms on the basis of meta informations

Instead of creating a model/ a controller and several views for


ever table/ the driver is s"((osed to cover it all a"tomaticall

Part 2: TYPOlight framework B =iews

=iews

Layouts -e4g4 fe)(age5

Views -e4g4 mod)newslist5

Partials -e4g4 lao"t)short5

The ;TYPOlight vocab"lar< does not draw this distinctionC the


term ;tem(late< is "sed for all kinds of views

Loading views

TYPOlight searches the ;tem(lates< folder first

Then all active mod"les

2irst hit wins -if the tem(late e4g4 e+ists in the ;backend< mod"le/
another tem(late with the same name in the ;news< mod"le will
never be loaded5

Part 2: TYPOlight framework B =iews

Parsing views

Template::parse() loads a view

re(laces the wildcards within it

ret"rns the res"lt as string

O"t("tting views

Template::output() loads a view

re(laces the wildcards within it

e+ec"tes additional actions

(rints the res"lt to the screen



Part 2: TYPOlight framework B =iews

9ackendTem(late::o"t("t-5

Loads the rich te+t editor config"ration

Inserts the dnamic Dava0cri(t and &00 files

*+ec"tes the ;o"t("t9ackendTem(late<,:ook

7dds the co(right notice

&hecks and enables the EFi( com(ression

0ends the :TTP headers

O"t("ts the G:T.L code

Prints the deb"g information -if active5



Part 2: TYPOlight framework B =iews

2rontendTem(late::o"t("t-5

Eenerates the search inde+ @?L

?eads the article kewords

*+ec"tes the ;o"t("t2rontendTem(late<,:ook

0tores the cache file and sends the cache header

?e(laces the insert tags -if active5

7dds the file to the search inde+ -if active5

Inserts the co(right notice

&hecks and enables the EFi( com(ression

0ends the :TTP header

O"t("ts the G:T.L code

Prints the deb"g information -if active5



Part 2: TYPOlight framework B =iews

$namic scri(ts

TL_CSS: 7llows o" to add &00 files

TL_JAVASCRIPT: 7llows o" to add Dava0cri(t files

TL_HEAD: 7llows o" to add individ"al code

$#$%BA$&''!$()&&'*'* = 's+stem/mod"les/ne,s/st+le-css';

7"tomatic back end views

List iew: Lists the records of a table

Pare!t iew: Lists the child records of a (arent record

Tree iew: Lists hierarchical records as a tree

7"tomatic form rendering saves "s from having to create a


se(arate view for ever table and ever action

Part 2: TYPOlight framework B &ontroller

&ontroller f"nctionalit -&?@$5

list(): Lists all records

s"ow(): Lists a single record

#reate(): ?enders a form to create a new record

sae(): 0aves a new record

e$it(): ?enders a form to edit an e+isting record

up$ate(): @(dates an e+isting record

$elete(): $eletes a record



Part 2: TYPOlight framework B &ontroller

7dditional TYPOlight driver f"nctions

#ut(): .oves a record

#opy(): $"(licates a record

$eleteAll(): $eletes m"lti(le records at once

e$itAll(): *dits m"lti(le records at once

u!$o(): ?estores a deleted record

?estoration of former versions of a record

;=irt"al controller<

7t r"n time/ a virt"al controller is created on the basis of the $&7


config"ration/ which takes care of rendering forms/ validating "ser
in("t and saving data to the database

Offers more f"nctionalit than a &?@$ controller



Part 3: Libraries

Part 3: Libraries
0stem
.odel &ontroller
@ser 9ackend 2rontend Tem(late 1idget
9ackend@ser
2rontend@ser
73a+
7"tomator
$ata&ontainer
H
&ontent*lement
:brid
.od"le
Page?oot
Page?eg"lar
H
9ackendTem(late
2rontendTem(late
&heck9o+
2ileTree
PageTree
?adio9"tton
0elect.en"
Te+t7rea
Te+t2ield
H
I 0stem architect"re

Part 3: Libraries B 0stem

9ase class J0stem;

&ontains sstem,wide methods

import() instantiates other ob3ects

lo%() adds an entr to the log table

reloa$() reloads the c"rrent (age

re$ire#t() redirects to another (age

parseDate() ret"rns a formatted date

setCoo&ie() writes a cookie

7dvantages of 0stem::im(ort-5

$etects 0ingletons a"tomaticall

&hecks whether an ob3ect alread e+ists



Part 3: Libraries B &ontroller

class &ontroller e+tends 0stem

%et'ro!te!$(o$ule() ret"rns a front end mod"le

%etArti#le() ret"rns an article

%etCo!te!tEleme!t() ret"rns a content element

resi)eIma%e() generates a th"mbnail in sstem8html

pri!tArti#leAsP$*() e+(orts an article as P$2 file

repla#eI!sertTa%s() re(laces insert tags

se!$'ileTo+rowser() triggers the ;save as H< dialog"e

%et'ro!te!$,rl() generates a front end @?L

remoe-l$'ee$s() removes de(recated G.L files

H

Part 3: Libraries B &ontroller

class 9ackend e+tends &ontroller

%et+a#&e!$(o$ule() ret"rns a back end mod"le

%etSear#"a.lePa%es() ret"rns all searchable (ages

#reatePa%eList() ret"rns the (ages as dro(,down men"

#reate'ileList() ret"rns the files as dro(,down men"

class 2rontend e+tends &ontroller

%etPa%eI$'rom,rl() ret"rns the I$ of the c"rrent (age

%etRootI$'rom,rl() ret"rns the I$ of the c"rrent root (age

/umpTo-rReloa$() reloads the (age or redirects to another one

%etLo%i!Status() checks whether a "ser is logged in

parse(eta'ile() (arses a ;meta4t+t< file



Part 3: Libraries B $atabase abstraction

$atabase abstraction

06LK2 standard as common denominator

Onl s(ecific f"nctions like LI.IT are enca(s"lated in e+tra


methods which are defined (er ada(ter

Th"s/ the interface remains "ncom(licated and fle+ible

$d. = $this->/ata.ase;
$stmt = $d.->prepare('&0$0)! 1 F2%3 tl("ser 45020 name=6');
$stmt->limit(1); // 7nconsistent, there8ore encaps"lated
$"ser = $stmt->e9ec"te('!heo !est');
,hile ($"ser->ne9t())
:
echo $"ser->name;
;

*as access to the fields of the res"lt set



Part 3: Libraries B $atabase abstraction

7dvantages of the $9 abstraction librar

0"((orts com(le+ !"eries like 3oins or s"b!"eries

7"tomatic esca(ing (revents 06L in3ections

La' initiali'ation of res"lt sets

&onsistent and database,inde(endent interface

?estrictions of the $9 abstraction librar

Ao abstraction laer to create and modif tables

The abstraction librar does not (rovide for the s(ecial


re!"irements of 9LO98&LO9 fields in Oracle

Onl .06L is in fact com(letel s"((orted

Ao control whether a (rogrammer abides b the 06LK2 standard


-it is (ossible to write s(ecific !"eries5

Part 3: Libraries B 2ile o(erations

2ile (ermissions and the 0afe .ode :ack

P:P as an 7(ache mod"le t(icall r"ns "nder the "ser


;wwwr"n</ ;nobod< or ;www,data<

:owever/ files that have been "(loaded via 2TP t(icall belong
to the 2TP "ser -e4g4 ;web#< or ;+a23LM<5

The server denies the P:P (rocess -and th"s TYPOlight5 access
to the s"((osedl alien files

0ol"tions

?"n P:P as &EI with s"P:P

?"n the P:P (rocess "nder the same "ser who owns the files
that have been "(loaded via 2TP

*+ec"te file o(erations via 2TP -0afe .ode :ack5



Part 3: Libraries B 2ile o(erations

7bstraction laer J2iles;

$e(ending on the config"ration settings/ the 2iles librar loads a


P:P or 2TP ada(ter to modif files

m&$ir() creates a new director

rm$ir() removes a director

*ope!() o(ens a file

*puts() writes to a file

*#lose() closes a file

re!ame() renames a file or folder

#opy() d"(licates a file or folder

$elete() deletes a file

#"mo$() changes the access rights of a file or folder



Part 3: Libraries B 2ile o(erations

2ile modification via ;2iles<

1orks similar to the native P:P f"nctions

$this->import('Files');
$8h = $this->Files->8open('s+stem/tmp/test-t9t', ',.');
$this->Files->8p"ts($8h, '!his is a test-');
$this->Files->8close($8h);

2ile (aths have to be relativeN

*as o(eration via ;2ile< and ;2older<

@tilit classes to modif files or folders

0"((orts creating folders rec"rsivel

Provides file information like (ath/ e+tension/ access time/ width


and height or .I.* t(e

Part 3: Libraries B 0ec"rit in TYPOlight

0ec"rit in TYPOlight

In("t librar enca(s"lates reading "ser in("t

Step 0: :T.L entities are being decoded

Step 1: @nicode entities are being decoded -G00 (revention5

Step 2: Dava0cri(t sni((ets are being removed -in Jstrict mode; all
event attrib"tes are being removed as well5

Step 3: $isallowed :T.L tags are being removed

Step 4: Potentiall dangero"s characters are being encoded

7dditional G00 (rotection

$o !ot add the Oscri(tP tag to the list of allowed tags

Otherwise it is (ossible to embed Dava0cri(t in all :T.L fields



Part 3: Libraries B 0ec"rit in TYPOlight

?eading the server environment

The *nvironment librar allows o" to read the server


environment inde(endentl from the o(erating sstem

Potentiall dangero"s code is being removed -e4g4


$(&02<02''5!!=(U&02(A#0>!'* can contain Dava0cri(t code5

0ec"ring forms

If a form is being s"bmitted/ TYPOlight checks whether it act"all


comes from the same site -referer check5

0ome anonmi'ers and sec"rit tools hide the referer address


which leads to an error message in TYPOlight

If the referer check is being disabled -never recommended5/ all


forms sho"ld at least contain a sec"rit !"estion -&a(tcha5

7 ca(tcha additionall (rotects o" against s(am



Part 3: Libraries B 0ec"rit in TYPOlight

Login and a"thentication

7 TYPOlight session is bo"nd to the P:P session and the IP


address of the "ser

IP binding can be disabled in version 24M -not recommended5

7ctive sessions are stored in the database

The cookie onl contains a checks"m and no relevant data like


e+(iration time/ I$ or other "ser information

?ecall e+tension allows for (ersistent logins in the front end

0witching acco"nts and (reviewing the front end

The im(lementation s"((orts session switching

7dministrators can switch to other "sers -both in the back end as


well as in the front end (review5

Part 3: Libraries B 0ec"rit in TYPOlight

0toring encr(ted data

*ver field can be stored encr(ted

&onfig"rable in the data container arra

$#$%BA$&''!$(/)A'*?''eal'*''encr+pt'* = tr"e;

*ncr(tion re!"ires an encr(tion ke that is set "( d"ring the


installation (rocess -once data is encr(ted/ it can onl be
decr(ted with this keN5

?e!"ires the P:P mod"le ;mcr(t<

*ncr(tion in the TYPOlight core

*ncr(tion is not being "sed in the core so far

&"stom mod"les that store sensitive data -e4g4 credit card


information5 sho"ld "se this feat"re

Part 3: Libraries B 1idgets

1idgets

1idgets > form fields

0tandard fields like Te+t2ield/ &heck9o+/ 0elect.en"

TYPOlight,s(ecific fields like PageTree/ 2ileTree or wi'ards

9ase class J1idget;

Provides common f"nctionalit

%e!erate() ret"rns a form field

ali$ate() validates the "ser in("t

"asErrors() checks whether there have been errors

%etErrors() ret"rns the error messages as arra



Part 3: Libraries B 1idgets

O"t("tting widgets

%e!erateLa.el() ret"rns the label

@la.el 8or=Actrl(nameA>>ame@/la.el>

%e!erate() ret"rns the field

@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />

%e!erate5it"Error() ret"rns the field with error message

@p class=AerrorA>=lease 8ill in the 8ield-@/p>


@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />

%e!erate5it"Error(tr"e) reverses the order

@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />


@p class=AerrorA>=lease 8ill in the 8ield-@/p>

Part 3: Libraries B 1idgets

O"t("tting error messages

%etErrors() ret"rns the error messages as arra

%etErrorAsStri!%() ret"rns the first error message

%etErrorAsStri!%(2) ret"rns the third error message

%etErrorsAsStri!%() ret"rns all error messages as string/


se(arated b a line break -@.r />5

%etErrorsAsStri!%(Q/ Q) ret"rns all error messages as string/


se(arated b a comma

%etErrorAsHT(L() ret"rns the first error message as :T.L string


-@p class=AerrorA>?@/p>5

%etErrorAsHT(L(2) ret"rns the third error message



Part 3: Libraries B 1idgets
@B-- <ie, (act"all+ partial) -->
@6php echo $this->Cenerate$a.el(); 6>
@6php echo $this->Cenerate4ith0rror(); 6>
@B-- %"tp"t -->
@la.el 8or=Actrl(nameA>Do"r name@/la.el>
@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />
@B-- %"tp"t ,ith error messaCe -->
@la.el 8or=Actrl(nameA>Do"r name@/la.el>
@p class=AerrorA>=lease 8ill in the 8ield-@/p>
@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />
@B-- 2eerse order E Cenerate4ith0rror(tr"e) -->
@la.el 8or=Actrl(nameA>Do"r name@/la.el>
@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />
@p class=AerrorA>=lease 8ill in the 8ield-@/p>
I $efa"lt view

Part 3: Libraries B 1idgets
@B-- <ie, (act"all+ partial) -->
@8ieldset>
@6php i8 ($this->has0rrors())F 6>
@p class=A8lashA>@6php echo $this->Cet0rrorAs&trinC(); 6>@/p>
@6php endi8; 6>
@di>
@6php echo $this->Cenerate$a.el(); 6>@.r />
@6php echo $this->Cenerate4ith0rror(); 6>
@/di>
@/8ieldset>
@B-- %"tp"t -->
@8ieldset>
@p class=A8lashA>=lease 8ill in the 8ield-@/p>
@di>
@la.el 8or=Actrl(nameA>Do"r name@/la.el>@.r />
@inp"t t+pe=Ate9tA id=Actrl(nameA name=AnameA />
@/di>
@/8ieldset>
I &om(le+ e+am(le

Part 3: Libraries B 1idgets

In("t validation

(a!$atory *iel$: the field m"st not be em(t

(i!imum le!%t": m"st not contain less than n characters

(a6imum le!%t": m"st not contain more than n characters

Di%its 7 letters: onl digits and letters are allowed

Date 7 time: onl date and time formats are allowed

E8mail a$$ress: in("t m"st be a valid e,mail address

P"o!e !um.er: in("t m"st be a valid (hone n"mber

,RL: in("t m"st be a valid @?L or domain

Per#e!t: in("t m"st be a n"mber between R and 1RR

Individ"al reg"lar e+(ressions can be added "sing the


;add&"stom?ege+(< hook

Part 3: Libraries B &reating feeds

class 2eed e+tends 0stem

Eetter and setter methods for (ro(erties

a$$Item() adds a 2eedItem

%e!erateRss() ret"rns the feed in ?00 format

%e!erateAtom() ret"rns the feed in 7tom format

class 2eedItem e+tends 0stem

Eetter and setter methods for (ro(erties

a$$E!#losure() adds an enclos"re to the item



Part 3: Libraries B &reating feeds
@6php
$8eed = ne, Feed();
$8eed->title = '!D=%liCht "ser meetinC GHHI';
$8eed->description = '7n8ormation a.o"t the "ser meetinC';
$item = ne, 7tem();
$item->title = '2ecord participation';
$item->description = '3ore than JH participantsB';
$8eed->add7tem($item);
echo $8eed->Cenerate2ss();
6>
I 0im(lified e+am(le

Part 3: Libraries B &reating feeds
@69ml ersion=A1-HA encodinC=AU!F-KA6>
@rss ersion=AG-HA>
@channel>
@title>!D=%liCht "ser meetinC GHHI@/title>
@description>7n8ormation a.o"t the "ser ?@/description>
@link>?@/link>
@lanC"aCe>?@/lanC"aCe>
@p"./ate>?@/p"./ate>
@item>
@title>2ecord participation@/title>
@description>@B')/A!A'3ore than JH ?**>@/description>
@link>?@/link>
@p"./ate>?@/p"./ate>
@C"id>?@/C"id>
@/item>
@/channel>
@/rss>
I ?00 o"t("t

Part 3: Libraries B Periodic command sched"ler

Periodic command sched"ler

7"tomatic scri(t e+ec"tion in certain intervals

0"((orts ho"rl/ dail and weekl e+ec"tion

$oes not s"((ort e+act sched"ling like cron 3obs

&an be "sed in c"stom e+tensions

$#$%BA$&''!$()2%>'*''ho"rl+'*'* = arra+('2ates', '"pdate');

$ail e+ec"tion

?ecreation of the feed files

P"rging of the tem(orar director

1eekl e+ec"tion

?ecreation of the stle sheets and G.L sitema(s



Part 3: Libraries B Periodic command sched"ler

@sage with a real cron 3ob

The P&. can be triggered b a real cron 3ob

:o"rl e+ec"tion of the cron4(h( file in the TYPOlight folder

H 1 1 1 1 php /home/,,,/t+poliCht/cron-php

?emoving the triggers

Lao"ts be)login4t(l and fe)(age4t(l

@B-- inde9erFFstop -->


@imC src=A@6php echo $this->.ase; 6>cron-phpA ? />
@B-- inde9erFFcontin"e -->

The three lines need to be removed com(letel



Part 4: Life ccle of a
front end re!"est

Part 4: Life ccle of a 2* re!"est B Initiali'ation

))a"toload-5

&lasses are loaded a"tomaticall in TYPOlight

The ;libraries< folder is being searched first

Then all mod"les folders

0trict al(habetical order and no distinction between active and


inactive mod"les/ beca"se the &onfig ob3ect does not even e+ist
at the time the a"toloader is defined

$O.P$2)a"toload -if installed5

7n e+ce(tion is thrown if the class cannot be fo"nd

&ontroller::class2ile*+ists-5

&hecks whether a class or class file e+ists

&onsiders active and inactive mod"les



Part 4: Life ccle of a 2* re!"est B Initiali'ation

scan-5

0cans a folder for s"bfolders and files

Like scandir-5/ b"t does not ret"rn Q4Q and Q44Q

9"ilt,in cache and o(en)basedir com(atibilit

s(ecialchars-5

&onverts s(ecial characters into :T.L entities

Like htmls(ecialchars-5/ b"t does not modif am(ersands to


(revent do"ble conversions -Lamp;amp;5

deseriali'e-5

?econverts a seriali'ed arra into an arra

Like "nseriali'e-5/ b"t ret"rns the arg"ment in case of an error



Part 4: Life ccle of a 2* re!"est B Initiali'ation

trims(lit-5

0(lits a string b a reg"lar e+(ression

Like (reg)s(lit-5/ b"t additionall e+ec"tes trim-5

am(ersand-5

&onverts all am(ersands in a string into entities -arg"ment tr"e5 or


single am(ersand characters -arg"ment false5

natcaseksort-5

*+tends the P:P f"nction natcasesort-5

7llows o" to sort an arra b kes/ "sing a case insensitive


Snat"ral orderS algorithm

Part 4: Life ccle of a 2* re!"est B Initiali'ation

arra)insert-5

Inserts a val"e at a certain (osition within an arra

The val"e can be another arra

arra)d"(licate-5

$"(licates a certain arra member

The co( is added right after the original

arra)move)"(-5

.oves a certain arra member one (osition "(

*!"ates to e+changing two members



Part 4: Life ccle of a 2* re!"est B Initiali'ation

arra)move)down-5

.oves a certain arra member one (osition down

*!"ates to e+changing two members

arra)delete-5

?emoves a certain arra member

?ecalc"lates the arra kes

arra)is)assoc-5

&hecks whether an arra is associative

If the kes are n"meric and in a contin"o"s ascending order/ the


arra is considered not to be associative

Part 4: Life ccle of a 2* re!"est B Initiali'ation

mbstring4(h(

0"bstit"te librar for the P:P ;mbstring< librar

*4g4 re!"ired on 0trato shared hosting acco"nts

Provides f"nctions to binar,safel modif international strings and


non 70&II characters

.ost im(ortant: "tfL)strtolower-5 and "tfL)strto"((er-5

(h(4ini c"stomi'ation

0"((ress session I$s in @?Ls -P:P0*00I$5

$efine an error and e+ce(tion handler

0et the (ath to the error4log file

0tarting the P:P session



Part 4: Life ccle of a 2* re!"est B &onfig"ration

Loading the &onfig ob3ect

The localconfig4(h( file is being loaded first to check whether


there are an inactive e+tensions

sstem8mod"les8backend8config8config4(h(

sstem8mod"les8frontend8config8config4(h(

Then the config"ration files -config4(h(5 of the other active


e+tensions are being loaded in al(habetical order

7t last/ the localconfig4(h( file is being loaded again to override


the defa"lt config"ration with the local settings

Inactive e+tensions

7re neither searched nor initiali'ed

The more inactive e+tensions/ the better the (erformance



Part 4: Life ccle of a 2* re!"est B &onfig"ration

&onfig"ration arras

9ack end mod"les


$#$%BA$&''!$()%>F7#'*''B0(3%/'*

9ack end form fields


$#$%BA$&''!$()%>F7#'*''B0(FF$'*

9ack end (age t(es


$#$%BA$&''!$()%>F7#'*''!$(=!D'*

2ront end mod"les


$#$%BA$&''!$()%>F7#'*''F0(3%/'*

&ontent elements
$#$%BA$&''!$()%>F7#'*''!$()!0'*

2ront end form fields


$#$%BA$&''!$()%>F7#'*''!$(FF$'*

Part 4: Life ccle of a 2* re!"est B &onfig"ration

Loading the defa"lt ob3ects

*nvironment ob3ect to read the server environment

In("t ob3ect to (rocess "ser in("t

2"rther config"ration

*rror)re(orting is set according to the localconfig4(h( file

The time 'one is set according to the localconfig4(h( file

The relative (ath to TYPOlight is calc"lated -if not set et5

The mbstring encoding is set according to the localconfig4(h( file

The browser lang"age is determined and stored

?eferer check

Onl if there is form data



Part 4: Life ccle of a 2* re!"est B 2inding a (age

Loading (ages from the cache

TYPOlight looks for a cached version

&hecks the e+(iration time and o"t("ts it if it is valid

If the (age is loaded from the cache/ we are done

7ll following ste(s can be saved b "sing the cacheN

Loading the 2rontend@ser ob3ect

7 database connection is being established

The @ser ob3ect is onl initiali'ed at this (oint

Aeither a"thenticate-5 nor login-5 are e+ec"ted

$etermining the login stat"s

&hecks whether a back end or front end "ser is logged in



Part 4: Life ccle of a 2* re!"est B 2inding a (age

2inding the (age b the @?L

The I$ or alias of the (age is being e+tracted from the @?L

The corres(onding (age is loaded from the database

7nd ma((ed to a website root (age if the alias is not "ni!"e

7t last/ the settings from the (arent (ages are inherited

7"thenticating the "ser

The "ser session is validated on the basis of the cookie

On (rotected (ages/ the "serQs (ermissions are validated as well



Part 4: Life ccle of a 2* re!"est B Loading a (age

Loading the (age ob3ect

$efa"lts to Page?eg"lar -reg"lar (age5

Loading the (age lao"t

$oct(e $efinition and meta robots tags

TYPOlight &00 framework

$namic scri(ts -&00,8Dava0cri(t/ OheadP tags5

Eoogle 7naltics I$

Loading the mod"les

Order: header/ left/ main/ right/ footer/ c"stom sections

The article mod"le loads articles and content elements

The (age title and descri(tion are being added at the end

Part 4: Life ccle of a 2* re!"est B Printing a (age

O"t("tting the (age

Tem(late::o"t("t-5 (rints the (age to the screen

The tem(late ob3ect takes care of

7dding the (age to the search inde+

&reating or "(dating the cache version

0ending the :TTP headers

*nabling the EFi( com(ression

O"t("tting the view

-c(4 Part 2: TYPOlight framework5



Part #: $ata
container arras

Part #: $ata container arras B 2"nction

Table meta data

7 data container arra describes a table

Table config"ration/ table relations/ field config"ration

9 this meta data/ TYPOlight determines how to list8save records

9ack end forms are also rendered on the basis of this meta data

Loading $&7 files

The $&7 files of the active mod"les are loaded one after the other
-backend/ frontend and then in al(habetical order5

*ver mod"le can override the e+isting config"ration

The dcaconfig4(h( file is incl"ded at the end/ loading local


modifications that are not to"ched b the live "(date

Part #: $ata container arras B 0tr"ct"re

&onfig"ration

&onfig"ration of the table itself

?elations to other tables

=ersioning

9ehavio"r when data is edited or deleted

Listing

$efines how records are listed

JList view;/ J(arent view; or Jtree view;

$efines the defa"lt sorting order

2ilter config"ration -search/ filter/ sort/ limit5



Part #: $ata container arras B 0tr"ct"re

O(erations

O(erations -e4g4 edit or delete5

Elobal o(erations -e4g4 edit m"lti(le5

7ccess control via b"tton callbacks

Palettes

7 (alette is a set of form fields

2orm fields can be gro"(ed and aligned

Onl allowed fields are shown/ so (alettes can look differentl


de(ending on the "serQs (ermissions

Palettes can change dnamicall e4g4 de(ending on the t(e of


mod"le or content element

0"b(arts of the form can be loaded interactivel via 73a+



Part #: $ata container arras B 0tr"ct"re

2ields

$efines the s(ecific table fields

The in("t t(e determines the t(e of form field

*val"ation

$etailed field config"ration

In("t validation -e4g4 mandator field or date field5

2ield si'e -e4g4 rows and col"mns of a te+tarea5

2ield a((earance -e4g4 stle5

?ich te+t editor config"ration

$ata encr(tion

H

Part #: $ata container arras B &allbacks

onload)callback

Part of the Jconfig"ration; section

*+ec"ted when the $ata&ontainer ob3ect is initiali'ed

7llows o" to e4g4 check (ermissions or to modif the data


container arra dnamicall at r"ntime

ons"bmit)callback

Part of the Jconfig"ration; section

*+ec"ted when a back end form is s"bmitted

7llows o" to e4g4 modif the form data before it is written to the
database -"sed to calc"late intervals in the calendar e+tension5

Part #: $ata container arras B &allbacks

ondelete)callback

Part of the Jconfig"ration; section

*+ec"ted when a record is being deleted

?"ns before the records are act"all removed from the database

(aste)b"tton)callback

Part of the Jlisting; section

7llows for individ"al (aste b"ttons

*4g4 "sed in the site str"ct"re to enable or disable b"ttons


de(ending on the access (ermissions

7dditional check via load)callback re!"ired/ beca"se the


command can still be entered directl in the @?LN

Part #: $ata container arras B &allbacks

child)record)callback

Part of the Jlisting; section

$efines how child elements are rendered in ;(arent view<

2rom version 24M/ child elements can be moved via $rag T $ro(
-e4g4 content elements/ format definitions/ 276s etc45

label)callback

Part of the Jlisting; section

7llows for individ"al labels in the list

*4g4 "sed in the "ser mod"le to add stat"s icons to the "ser list
-administrator8"ser/ active8inactive5

Part #: $ata container arras B &allbacks

b"tton)callback

Part of the Jo(erations; section

7llows for individ"al navigation icons

*4g4 "sed in the site str"ct"re to enable or disable b"ttons


de(ending on the "ser (ermissions

7dditional check via load)callback re!"ired/ beca"se the


command can still be entered directl in the @?LN

o(tions)callback

Part of the Jfields; section

7llows o" to define an individ"al f"nction to load data into a dro(,


down men" or checkbo+ list

@sef"l for e4g4 conditional foreinUe,relations



Part #: $ata container arras B &allbacks

in("t)field)callback

Part of the Jfields; section

7llows for the creation of individ"al form fields

*4g4 "sed in the back end mod"le ;(ersonal data< to generate the
;("rge data< widget

7ttention: the field is not saved a"tomaticallN

load)callback

Part of the Jfields; section

*+ec"ted when a form field is initiali'ed

&an be "sed to e4g4 load a defa"lt val"e



Part #: $ata container arras B &allbacks

save)callback

Part of the Jfields; section

*+ec"ted when a field is s"bmitted

&an be "sed to e4g4 add an individ"al validation ro"tine

The ret"rn val"e of the callback f"nction is being saved/ so it


sho"ld alwas be setN

Part %: &"stomi'ing
TYPOlight

Part %: &"stomi'ing TYPOlight

&overed in the TYPOlight book

:ow to create a c"stom Tin.&* config"ration file and integrate it


into the data container arra

:ow to c"stomi'e labels and store the changes "(date,safe in the


sstem8config8langconfig4(h( file

:ow to c"stomi'e data container arras and store the changes


"(date,safe in the sstem8config8dcaconfig4(h( file

:ow to create a c"stom e+tension that defines an additional field


and adds it to an e+isting table

In this worksho(

P"r(ose of the different hooks

:ow to e+tend classes and override methods



Part %: &"stomi'ing TYPOlight B :ooks

@ser registration

#reate9ew,ser: e+ec"ted when a new "ser registers at the front


end -the acco"nt can still be inactive5

a#tiateA##ou!t: e+ec"ted when a newl registered front end


acco"nt is activated

set9ewPasswor$: e+ec"ted when a (assword is changed

Login and logo"t

#"e#&Cre$e!tials: e+ec"ted if the login fails d"e to a wrong


(assword -allows o" to e4g4 check against another database5

import,ser: e+ec"ted if a "ser acco"nt cannot be fo"nd -allows


o" to e4g4 im(ort "sers from an L$7P server5

postLo%i!:postLo%out: e+ec"ted when a "ser logs into or off the


front end

Part %: &"stomi'ing TYPOlight B :ooks

2orms

loa$'orm'iel$: e+ec"ted when a form field is loaded

ali$ate'orm'iel$: allows o" to add an individ"al validation


ro"tine to a form field

a$$CustomRe%e6p: allows o" to add an individ"al reg"lar


e+(ression to the widget validator

post,ploa$: e+ec"ted after a file has been "(loaded in a form

pro#ess'ormData: e+ec"ted after a form has been s"bmitted



Part %: &"stomi'ing TYPOlight B :ooks

@?L generation

%etPa%eI$'rom,rl: allows o" to add a c"stom ro"tine to e+tract


the (age I$ from the @?L

%e!erate'ro!te!$,rl: allows o" to add a c"stom ro"tine to


generate front end @?Ls

Tem(lates

parse+a#&e!$Template: (arses a back end tem(late

output+a#&e!$Template: o"t("ts a back end tem(late

parse'ro!te!$Template: (arses a front end tem(late

output'ro!te!$Template: o"t("ts a front end tem(late



Part %: &"stomi'ing TYPOlight B :ooks

.iscellaneo"s

%etAllEe!ts: allows o" to add a c"stom ro"tine to !"er events


in a front end mod"le

%etSear#"a.lePa%es: allows o" to add c"stom @?Ls to the


search inde+ -@?Ls sho"ld (oint to valid (ages5

postDow!loa$: e+ec"ted after a file has been downloaded -e4g4


"sed in the download statistics e+tension5

repla#eI!sertTa%s: allows o" to add c"stom insert tags



Part %: &"stomi'ing TYPOlight B *+tending classes

&"stomi'ing the navigation mod"le

The navigation mod"le shall be modified to alwas dis(la even if


there are no s"b(ages/ in which case a note shall be (rinted

The f"nctionalit of the original class shall be (reserved/ so f"t"re


"(dates do not re!"ire maintenance

&reating a c"stom e+tension

.od"le folder ;+c"stom< -will be loaded last5

:olds a file named .od"le.Aavigation4(h(

1hich defines the class .od"le.Aavigation

&lass .od"le.Aavigation e+tends class .od"leAavigation

Onl the generate-5 method will be overridden



Part %: &"stomi'ing TYPOlight B *+tending classes
@6php
class 3od"le3+>aiCation e9tends 3od"le>aiCation
:
p".lic 8"nction Cenerate()
:
// 09ec"te the oriCinal method
$."88er = parentFFCenerate();
i8 ($."88er == '')
:
$."88er = '!here are no s".paCes';
;
ret"rn $."88er;
;
;
6>
I class .od"le.Aavigation

Part %: &"stomi'ing TYPOlight B *+tending classes

?egistering the new class

TYPOlight needs to know abo"t the new class

Therefore we override the global config"ration arra 2*).O$ in


the sstem8mod"les8+c"stom8config8config4(h( file

$#$%BA$&''!$()%>F7#'*''F0(3%/'*''naiCation3en"'*
''naiCation'* = '3od"le3+>aiCation';

$namic config"ration

Thanks to the dnamic config"ration/ TYPOlight a"tomaticall


loads the new class "(on the ne+t re!"est

The navigation mod"le now (rints the notice ;There are no


s"b(ages< instead of not showing at all

The modification is "(date,safe and does not re!"ire maintenance

Você também pode gostar