TYPO3 Transition Tool

32
Welcome

description

t's time to think about content migration from TYPO3v4 to Phoenix. Therefore, last year a Google Summer of Code Project was initiated which was about figuring out whether XSLT-driven transformations of v4 XML contents to Phoenix-ready structures were feasible for production use. Until the T3DD12 workshop, a first prototype will be released which already brings some framework-alike structures, ready for testing on an existing v4-instance. Nonetheless, for covering the major part of all existing TYPO3v4 instances, there is still a lot of thoughts and development to be done. Thus, we want to recruit some interested developers and testers to the project for making the huge step forwards to Phoenix as nice and easy as it can possibly be. Therefore, we will introduce the audience to the problem, our general idea of solving it and provide some initial thoughts and directions to invest some work on.

Transcript of TYPO3 Transition Tool

Page 1: TYPO3 Transition Tool

Welcome

www.princexml.com
Prince - Non-commercial License
This document was created with Prince, a great way of getting web content onto paper.
Page 2: TYPO3 Transition Tool

What's this about?• The Berlin Manifesto constitutes that the transition from v4v6 to Phoenix will be easily possible

• Content Transition is a big part of that

• Last year a GSoC project was initiated for working on that problem

• Therefore: This is for presenting first solutions and inviting some man-power

Page 3: TYPO3 Transition Tool

Warmup Questionnaire• Who of you proably wants to use Phoenix in future?

• Who wants a nice way of reusing her existing content in Phoenix?

• Who knows XSLT?

• Who has development experience with XSLT

• Who thinks i should stop bugging you with silly questions?

Page 4: TYPO3 Transition Tool

OverviewAbout meThe Project

• Lessen the Gap from v4 v6 to Phoenix

• The initial idea

• Google Summer of Code 2011

• Problems & Solutions

Current Status

• A prototypical v4 v6 Extension being able to export contents of pages and tt_content

Page 5: TYPO3 Transition Tool

Shameless self-plug• Nicolas Forgerit

• Student/Freelancer from Karlsruhe

• Love sports & coffee

• Crawl the web for information way too much of my time

github.com/crusoe

[email protected]

@forgerit

• My mentor: Christian Müller

• Core Dev TYPO3/Freelancer from Bonn

• Owner of kitsunet.de

Page 6: TYPO3 Transition Tool

The ProjectLessen the Gap from v4 v6 to Phoenix

• Content Transition

• Export contents of a v4 v6 instance and import to Phoenix

• Use existing interfaces

• Make it flexible and configurable

Page 7: TYPO3 Transition Tool

What again was this GSoC stuff?

• fellowship given out by Google to provide Open Source projects

• TYPO3 had been a sub-project 4 years in a row until 2011

• Unfortunately, TYPO3 hasn't been accepted for 2012 :( (Drupal was, WP not)

Page 8: TYPO3 Transition Tool

The initial idea

• use the well-known SYSEXT:impexp for generating XML data

• make exported data Phoenix-ready

• use XSLT to transform the exported data

• provide generated data as Phoenix packet and/or webservice

Page 9: TYPO3 Transition Tool

Problems & Solutions

• PHPs XSLTProcessor is rather old -> fill missing gaps with PHP+Regex

• Phoenix CTypes were not ready until about 3 weeks ago -> make CTypes configurable as"Snippets"

• XSLTProcessor's debug output is rather "un-verbose" -> no solution yet :( (use Saxon for XSLTdevelopment)

• ...

Page 10: TYPO3 Transition Tool

Current StatusTYPO3 Transition Tool

• A prototypical v4 v6 Extension

• Do the (common) work in just a few clicks

• Make it extendable (via XSLT & PHP)

• Try to make the code looking clean

Page 11: TYPO3 Transition Tool

The Transition Steps

• Step 1: Preparing the data

◦ Set Output Filename

◦ Select to-be-exported Database Tables

◦ Set Initial Page-Subtree Node (usually pid 0 for getting the whole Pagetree)

• Step 2: Transform the data

◦ Provide v4 v6 => Phoenix Content Type configuration

◦ Select to-be-used PHP-Hooks

• Step 3: Export the data

◦ Download Sites.xml

◦ Download packet

◦ Publish generated Data as Webservice

Page 12: TYPO3 Transition Tool

General Transformation Procedure

• have a base stylsheet which does the general procedure

• fetch all the user-chosen snippets and copy them into the base

• execute defined "pre-transformation" PHP-Hooks on the data

• run the XSLT Processor

• execute defined "post-transformation" PHP-Hooks on the xslt-processed data

Page 14: TYPO3 Transition Tool

Base XSLT Stylesheet

• kind of a "base" stylesheet containing several markers

• applies the general rules

• holds several markers which are to be replaced by the right snippets/contents

Page 16: TYPO3 Transition Tool

Content Types XSLT Snippets

• non-valid XSLT scripts (slices of them)

• work just in context of T3TT

• modular and independent from each other

• automagically fetched and traversed by the XSLT Processor

Page 18: TYPO3 Transition Tool

PHP Hooks

• filling gaps of XSLT v1

• kinda "meta-language" for XSLT

• can be easily added to a PHP file

• T3TT splits the to-be-altered Datafile into lines

• ... which can be changed e.g. via PCRE

Page 19: TYPO3 Transition Tool

PHP Hooks (pt. 2)

• needed before as well as after the XSLT transformation

• provide a way to do some quick'n'dirty adjustments

Some example hooks

killIndexColons (pre)

1 <!-- transform -->2 <tablerow index="tt_content:1" type="array">3 <!-- to -->4 <tablerow index="tt_content" id="1" type="array">

since XSLT v1 cannot "regex" attribute values. (v2 can!)

Page 20: TYPO3 Transition Tool

PHP Hooks (pt. 3)unescapeHtmlSpecialCharsOfFlexformValues (pre)

make Flexform transformations XSLT applicable (i.e. undo HSC) (currently not working :[ )

1 <!-- transform -->2 &lt;T3FlexForms&gt;3 &lt;data&gt;4 &lt;sheet index=&quot;sDEF&quot;&gt;5 ...6 <!-- to -->7 <T3FlexForms>8 <data>9 <sheet index="sDEF">

10 ...

normalizeNodeNames (post)

check that nodeName="{value}" contains Phoenix-compatible characters

!assert that nodeName-value

- is not empty- matches ([-_a-zA-Z0-9])- contains no whitespaces- ...

Page 22: TYPO3 Transition Tool

XSLT Intro• Why XSLT?

• The big pic:

◦ XPath

◦ <xsl:element> and <xsl:value-of>

◦ declarative

◦ pseudo-functional

• Tools

◦ Saxon

◦ XSLTCake

◦ Oxygen Editor (expensive!)

◦ phpStorm can execute XPath expressions

◦ Your Browser!

Page 23: TYPO3 Transition Tool

XSLT Intro (pt. 2)• Resources

◦ en.wikipedia.org on XSLT

◦ Beginning XSLT and XPath - Transforming XML Documents and Data

◦ XSLT (O'Reilly)

◦ XSLT Cookbook

◦ W3C XSLT v1

◦ W3C XSLT v2

Page 24: TYPO3 Transition Tool

XPath on an HTML DOM• Selecting the html node: / (root node)

• Select title node: /head/title

• Axes: child::* (standard), self::* , parent::* and attribute::/@

• Restrict the Selection to a div containing the attribute class="visible" : [@class='visible']

• Link several restrictions logically with and and or

Page 25: TYPO3 Transition Tool

Some built-in XSLT Functions• On currently selected node:

◦ name: name()

◦ value: text()

◦ concatenate strings: concat()

Page 26: TYPO3 Transition Tool

Important XSL TagsOutput

1 <!-- select a node's value -->2 <xsl:value-of select="{nodePath}"/>34 <!-- construct a div with class 'visible' -->5 <xsl:element name="{elementName}">6 <xsl:attribute name="class">visible</xsl:attribute>7 </xsl:element>

Page 27: TYPO3 Transition Tool

Important XSL Tags (pt. 2)(Sub-)Templates (~ Functions)

1 <!-- 'myTemplate' can only be manually called by another function -->2 <xsl:template name="myTemplate"> <!-- do stuff --></xsl:template>34 <!-- 'div' is called whenever a function uses <xsl:apply-templates select="/path/to/div/element" -->5 <xsl:template match="div"> <!-- do stuff --> </xsl:template>67 <!-- apply templates on selected nodes -->8 <xsl:apply-templates select="/path/to/div/element"/>

Page 28: TYPO3 Transition Tool

Important XSL Tags (pt. 3)Some Imperatives

1 <!-- loop over each node of selected node set 'myNodes'-->2 <xsl:for-each select="/path/to/myNodes"><!-- do stuff --></xsl:for-each>34 <!-- switch-case-alike -->5 <xsl:choose>6 <xsl:when test="ContitionA">7 <!-- do stuff when ConditionA is true -->8 </xsl:when>9 <xsl:when test="ConditionB">

10 <!-- do stuff when ConditionB is true -->11 </xsl:when>12 <xsl:otherwise>13 <!-- stuff that is done if neither ConditionA nor ConditionB were true -->14 </xsl:otherwise>15 </xsl:choose>1617 <!-- if -->18 <xsl:if test="someTestCondition"> <!-- do stuff if if is true --> </xsl:if>

Page 29: TYPO3 Transition Tool

Important XSL Tags (pt. 4)Initial Declarations

1 <?xml version="1.0" encoding="UTF-8"?>2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">3 <xsl:output4 method="xml"5 version="1.0"6 encoding="UTF-8"7 omit-xml-declaration="no"8 indent="yes"9 cdata-section-elements="source text"

10 />

Page 30: TYPO3 Transition Tool

Fooling around with XSLTSome possible tasks

• Use XSLTCake.com

• Format your v4 v6 Contents to browsable HTML

• Make a .PDF containing all your v4 v6 Pages

• Look at Phoenix CTypes and how to generate them

Page 31: TYPO3 Transition Tool

We need you!Participation

• Test the T3TT extension and send in bug reports

• Add support for new extensions

Page 32: TYPO3 Transition Tool

Thank you!