With Extbase - a new framework for extension development introduced in TYPO3 4.3 - you are able to develop with the paradigms of FLOW3 today. During this talk, you get in touch with the features of the framework to understand how it supports your development process to develop clean code cost efficient in less time. Extbase is one cornerstone for a smooth transition to TYPO3 v5, another is reusable business domain knowledge in form of Generic Domain Models available in 4.x and 5.x. The Generic Domain Models will enable you to add a Semantic Web topping.
35. /**
* Main news function: calls the init_news() function and decides by the given CODEs which of the
* functions to display news should by called.
*
* @param string $content : function output is added to this
* @param array
$conf : configuration array
* @return string $content: complete content generated by the tt_news plugin
*/
function main_news($content, $conf) {
$this->local_cObj = t3lib_div::makeInstance('tslib_cObj'); // Local cObj.
$this->init($conf);
if ($this->conf['displayCurrentRecord']) {
$this->config['code'] = $this->conf['defaultCode']?trim($this->conf['defaultCode']):'SINGLE';
$this->tt_news_uid = $this->cObj->data['uid'];
}
// get codes and decide which function is used to process the content
$codes = t3lib_div::trimExplode(',', $this->config['code']?$this->config['code']:$this->conf['defaultCode'], 1);
if (!count($codes)) { // no code at all
$codes = array();
$noCode = true;
}
while (list(, $theCode) = each($codes)) {
$theCode = (string)strtoupper(trim($theCode));
$this->theCode = $theCode;
switch ($theCode) {
case 'SINGLE':
$content .= $this->displaySingle();
break;
case 'VERSION_PREVIEW':
$content .= $this->displayVersionPreview();
break;
case 'LATEST':
case 'LIST':
case 'SEARCH':
case 'XML':
$content .= $this->displayList();
break;
case 'AMENU':
$content .= $this->newsArchiveMenu();
break;
case 'CATMENU':
$content .= $this->displayCatMenu();
break;
default:
36. /**
* Displays the "single view" of a news article. Is also used when displaying single news records with the "insert records" content element.
*
* @return string html-code for the "single view"
*/
function displaySingle() {
$singleWhere = 'tt_news.uid=' . intval($this->tt_news_uid);
$singleWhere .= ' AND type NOT IN(1,2)' . $this->enableFields; // only real news -> type=0
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'tt_news',
$singleWhere);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
// get the translated record if the content language is not the default language
if ($GLOBALS['TSFE']->sys_language_content) {
$OLmode = ($this->sys_language_mode == 'strict'?'hideNonTranslated':'');
$row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_news', $row, $GLOBALS['TSFE']->sys_language_content, $OLmode);
}
if ($this->versioningEnabled) {
// get workspaces Overlay
$GLOBALS['TSFE']->sys_page->versionOL('tt_news',$row);
// fix pid for record from workspace
$GLOBALS['TSFE']->sys_page->fixVersioningPid('tt_news',$row);
}
$GLOBALS['TSFE']->displayedNews[]=$row['uid'];
if (is_array($row) && ($row['pid'] > 0 || $this->vPrev)) { // never display versions of a news record (having pid=-1) for normal website users
// Get the subpart code
if ($this->conf['displayCurrentRecord']) {
$item = trim($this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SINGLE_RECORDINSERT###'), $row));
}
if (!$item) {
$item = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SINGLE###'), $row);
}
// reset marker array
$wrappedSubpartArray = array();
// build the backToList link
if ($this->conf['useHRDates']) {
$pointerName = 'pointer';
$wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array(
'tt_news' => null,
'backPid' => null,
$this->config['singleViewPointerName'] => null,
'pS' => null,
'pL' => null), $this->allowCaching, ($this->conf['dontUseBackPid']?1:0), $this->config['backPid']));
37. if ($this->conf
['useHRDates']) {
$pointerName =
'pointer';
$wrappedSubpartArray
['###LINK_ITEM###'] =
explode('|', $this-
>pi_linkTP_keepPIvars
('|', array(
'tt_news' => null,
'backPid' => null,
$this->config
['singleViewPointerName
'] => null,
'pS' => null,
'pL' => null), $this-
>allowCaching, ($this-
>conf
['dontUseBackPid']?
1:0), $this->config
['backPid']));
} else {
$wrappedSubpartArray
['###LINK_ITEM###'] =
explode('|', $this-
>pi_linkTP_keepPIvars
('|', array(
'tt_news' => null,
'backPid' => null,
$this->config
['singleViewPointerName
'] => null), $this-
>allowCaching, ($this-
>conf
['dontUseBackPid']?
1:0), $this->config
['backPid']));
}
// set the title of the
single view page to the
title of the news
record
if ($this->conf
['substitutePagetitle']
) {
$GLOBALS['TSFE']->page
['title'] = $row
['title'];
// set pagetitle for
indexed search to news
title
$GLOBALS['TSFE']-
>indexedDocTitle = $row
['title'];
}
if ($this->conf
['displaySingle.']
['catOrderBy']) {
$this->config
['catOrderBy'] = $this-
>conf['displaySingle.']
['catOrderBy'];
}
$markerArray = $this-
>getItemMarkerArray
($row,
'displaySingle');
// Substitute
$content = $this->cObj-
>substituteMarkerArrayC
ached($item,
$markerArray, array(),
$wrappedSubpartArray);
} elseif ($this-
>sys_language_mode ==
'strict' && $this-
>tt_news_uid &&
$GLOBALS['TSFE']-
>sys_language_content)
{ // not existing
translation
$noTranslMsg = $this-
>local_cObj->stdWrap
($this->pi_getLL
('noTranslMsg'), $this-
>conf
['noNewsIdMsg_stdWrap.'
]);
$content =
$noTranslMsg;
} elseif ($row['pid'] <
0) { // a non-public
version of a record was
requested
$nonPlublicVersion =
$this->local_cObj-
>stdWrap($this-
>pi_getLL
('nonPlublicVersionMsg'
), $this->conf
['nonPlublicVersionMsg_
stdWrap.']);
$content =
$nonPlublicVersion;
} else { // if
singleview is shown
with no tt_news uid
given from GETvars
(&tx_ttnews[tt_news]=)
an error message is
displayed.
48. 1
2
userFunc
Request
BlogExample
Extbase
TYPO3 Dispatcher
Controller
3
findByTitle('MyBlog')
Repository
Domain Model
Blog
Post
Comment Tag
49. 1
2
userFunc
Request
BlogExample
Extbase
TYPO3 Dispatcher
Controller
3
findByTitle('MyBlog')
Blog
4
Repository
Domain Model
Blog
Post
Comment Tag
50. 1
2
userFunc
Request
BlogExample
Extbase
TYPO3 Dispatcher
Controller
3 assign(Blog)
findByTitle('MyBlog') render() 5
Blog
4 View
Repository
Domain Model
Blog
Post
Comment Tag
51. 1
2
userFunc
Request
BlogExample
Extbase
TYPO3 Dispatcher
HTML
Response Controller
6
3 assign(Blog)
findByTitle('MyBlog') render() 5
Blog
Response
4 View
Repository
Domain Model
Blog
Post
Comment Tag
52. 1
2
userFunc
Request
BlogExample
Extbase
TYPO3 Dispatcher
HTML
Response Controller
6
3 assign(Blog)
findByTitle('MyBlog') render() 5
Blog
Response
4 View
Repository
Domain Model
Blog
Post
Comment Tag
53. 1
2
userFunc
Request
BlogExample
Extbase
TYPO3 Dispatcher
HTML
Response Controller
6
3 assign(Blog)
findByTitle('MyBlog') render() 5
Blog
Response
4 View
Repository
Domain Model
Blog
Post
Comment Tag
54. Hmmm.
Much better.
Lasagna code
de
Spagh etti co
65. William Street Rajan United
States Virginia Indian
x
WRUVI
William Street
Rajan
United States Virginia Indian
66. William Street Rajan United
States Virginia Indian
x
WRUVI
William Street
Rajan
United States Virginia Indian
67. William Street Rajan United
States Virginia Indian
x
WRUVI
William Street
Rajan
United States Virginia Indian
68.
69.
70.
71. Organization
Date
Customer
Event
Invoice
Publication
Product
Price
Article Location
Number
Image
Your Model
72. Generic Domain Models
based on high quality, open standards
OASIS CIQ 3.0 for persons, organizations, addresses, names
BMEcat for product, suppliers, catalogs, prices
iCalendar for calendar, events, dates
etc.
challenges
XML2PHP
interoperability
consistent semantics
@jochen: it's time for an example
93. Knublauch, Holger. KBeans Specification: Semantic Transparency for Components and
Domain Models. Technical Report FAW-TR-01001, FAW Ulm, 2001.
94. Semantic annotations
/**
* A container for defining the unique characteristics of a person only
*
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
* @prefix foaf: <http://xmlns.com/foaf/0.1/>
* @prefix owl: <http://www.w3.org/2002/07/owl#>
* @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
* @prefix core: <http://www.typo3.org/semantic/core/>
* @prefix gen: <http://www.typo3.org/semantic/ext/generic/domain/model/>
* @semantic gen:Person rdfs:subClassOf gen:Party
* @semantic gen:Person owl:disjointWith gen:Organization
* @semantic gen:Person core:isMemberOf gen:Organization
*/
class Tx_Generic_Domain_Model_Person extends Tx_Generic_Domain_Model_Party {
/**
* Party Names
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_Generic_Domain_Model_PersonName>
* @semantic gen:partyNames gen:areOfType foaf:name
*/
protected $partyNames;
/**
95. Semantic Query with SPARQL
## Find all authors of News Articles that are posted on a page with the english title "Welcome"
PREFIX core:<http:://www.typo3.org/ontology/core/#>
PREFIX generic:<http:://www.typo3.org/ontology/ext/generic/#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT $person $article
FROM <http:://localhost/repository.rdf>
WHERE {
$person rdfs:type generic:Person .
$person core:authorOf $article .
$article rdfs:type core:NewsArticle .
$article core:isPlacedOn $page .
$page core:title "Welcome"@en .
}
96. [TYPO3-dev] The state of support for the Semantic Web / RDFA /
Web 3.0 in TYPO3
Jochen Rau jochen.rau at typoplanet.de
Mon Aug 31 16:26:51 CEST 2009
• Previous message: [TYPO3-dev] The state of support for the Semantic Web / RDFA / Web 3.0 in TYPO3
• Next message: [TYPO3-dev] The state of support for the Semantic Web / RDFA / Web 3.0 in TYPO3
• Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
get Extbase ready ;-)
de ne generic domain models
bind objects to an ontology
elaborate on the use cases of semantic content
make the integration of semantic web technology a movement of the community
97. Bastian Waidelich
Sebastian Kurfürst
Sebastian Gebhard
Than k You Steffen Kamper
Felix Oertel
Franz Ripfel and the TYPO3 V5 Team for all the inspiration
and the beautiful code
Ingmar Schlecht
Patrick Lobacher
Franz Koch
Xavier Perseguers