|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Example class showing how one could make XML export of page content elements in TYPO3 00029 * 00030 * $Id: xmlversionLib.inc 9758 2010-12-05 11:25:36Z stephenking $ 00031 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj 00032 * 00033 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00034 */ 00035 /** 00036 * [CLASS/FUNCTION INDEX of SCRIPT] 00037 * 00038 * 00039 * 00040 * 96: class user_xmlversion 00041 * 107: function main_xmlversion($content,$conf) 00042 * 137: function getContentResult($table) 00043 * 00044 * TOTAL FUNCTIONS: 2 00045 * (This index is automatically created/updated by the extension "extdeveval") 00046 * 00047 */ 00048 /** 00049 * Class that creates the current page and content element records as an XML structure using the library "t3lib_xml" 00050 * It is demonstrated in use in the testsite package on page "59" 00051 * The static template "plugin.alt.xml" is used to trigger this XML creation as well. That template contains this set of TypoScript lines which triggers the XML creation and disables all regular HTML headers 00052 * 00053 * ## Set up page/type number: 00054 * alt_xml > 00055 * alt_xml = PAGE 00056 * alt_xml { 00057 * typeNum=96 00058 * config.disableAllHeaderCode = 1 00059 * config.additionalHeaders = Content-type: text/xml 00060 * 00061 * ## Includes the newsLib: 00062 * includeLibs.alt_xml = media/scripts/xmlversionLib.inc 00063 * 00064 * ## Inserting the USER cObject for XML rendering 00065 * 10 = USER 00066 * 10 { 00067 * userFunc = user_xmlversion->main_xmlversion 00068 * } 00069 * } 00070 * 00071 * @package TYPO3 00072 * @subpackage tslib 00073 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00074 */ 00075 class user_xmlversion { 00076 var $cObj; // The backReference to the mother cObj object set at call time 00077 00078 00079 /** 00080 * Main function, called from TypoScript 00081 * 00082 * @param string Empty, ignore. 00083 * @param array TypoScript properties for this content object/function call 00084 * @return string XML content 00085 */ 00086 function main_xmlversion($content,$conf) { 00087 $xmlObj = t3lib_div::makeInstance('t3lib_xml', 'typo3_page'); 00088 $xmlObj->XMLdebug=0; 00089 $xmlObj->setRecFields('pages','doktype,title,alias,hidden,starttime,endtime,fe_group,url,target,no_cache,shortcut,keywords,description,abstract,author,author_email,newUntil,lastUpdated,cache_timeout'); 00090 $xmlObj->setRecFields('tt_content','CType,header,header_link,bodytext,image,imagewidth,imageorient,media,records,colPos,starttime,endtime,fe_group'); 00091 00092 // Creating top level object 00093 $xmlObj->renderHeader(); 00094 00095 // Add page information 00096 $xmlObj->addRecord('pages',$GLOBALS['TSFE']->page); 00097 00098 // Add page content information 00099 $xmlObj->newLevel('content_records',1); 00100 $xmlObj->renderRecords('pages',$this->getContentResult('pages')); 00101 $xmlObj->renderRecords('tt_content',$this->getContentResult('tt_content')); 00102 $xmlObj->newLevel('content_records'); 00103 00104 $xmlObj->renderFooter(); 00105 00106 return $xmlObj->getResult(); 00107 } 00108 00109 /** 00110 * Selects all records from $table having the current page id as PID (records belonging to that page) 00111 * 00112 * @param string A tablename found in $TCA 00113 * @return pointer A database resource pointer 00114 */ 00115 function getContentResult($table) { 00116 global $TCA; 00117 if ($TCA[$table]) { 00118 $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby']; 00119 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid='.intval($GLOBALS['TSFE']->id).$this->cObj->enableFields($table), '', $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy)); 00120 return $res; 00121 } 00122 } 00123 } 00124 00125 00126 00127 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/xmlversionLib.inc'])) { 00128 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/xmlversionLib.inc']); 00129 } 00130 ?>
1.8.0