Project

General

Profile

Bug #18607 ยป ux_class.tslib_content.php

Administrator Admin, 2008-08-18 18:33

 
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Contains classes for Content Rendering based on TypoScript Template configuration
*
* $Id: class.tslib_content.php 3660 2008-05-18 12:47:19Z masi $
* Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
* XHTML compliant
*
* class tslib_cObj : All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
* class tslib_controlTable : Makes a table CTABLE (TS cObject)
* class tslib_tableOffset : Makes a table-offset (TS)
* class tslib_frameset : Generates framesets (TS)
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*
*
* 256: class tslib_cObj
* 353: function start($data,$table='')
* 387: function setParent($data,$currentRecord)
*
* SECTION: CONTENT_OBJ:
* 412: function getCurrentVal()
* 423: function setCurrentVal($value)
* 436: function cObjGet($setup,$addKey='')
* 460: function cObjGetSingle($name,$conf,$TSkey='__')
*
* SECTION: Functions rendering content objects (cObjects)
* 629: function HTML($conf)
* 640: function TEXT($conf)
* 651: function CLEARGIF($conf)
* 670: function COBJ_ARRAY($conf,$ext='')
* 706: function USER($conf,$ext='')
* 733: function FILE($conf)
* 749: function IMAGE($conf)
* 768: function IMG_RESOURCE($conf)
* 780: function IMGTEXT($conf)
* 1203: function CONTENT($conf)
* 1290: function RECORDS($conf)
* 1370: function HMENU($conf)
* 1402: function CTABLE ($conf)
* 1440: function OTABLE ($conf)
* 1455: function COLUMNS ($conf)
* 1534: function HRULER ($conf)
* 1559: function CASEFUNC ($conf)
* 1584: function LOAD_REGISTER($conf,$name)
* 1624: function FORM($conf,$formData='')
* 2145: function SEARCHRESULT($conf)
* 2311: function PHP_SCRIPT($conf,$ext='')
* 2354: function TEMPLATE($conf)
* 2505: function MULTIMEDIA($conf)
*
* SECTION: Various helper functions for content objects:
* 2592: function getSlidePids($pidList, $pidConf)
* 2623: function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
* 2641: function cImage($file,$conf)
* 2669: function getBorderAttr($borderAttr)
* 2685: function imageLinkWrap($string,$imageFile,$conf)
* 2765: function fileResource($fName, $addParams='alt="" title=""')
* 2788: function lastChanged($tstamp)
* 2805: function linkWrap($content,$wrap)
* 2824: function getAltParam($conf, $longDesc=true)
* 2859: function cleanFormName($name)
* 2875: function getATagParams($conf, $addGlobal=1)
*
* SECTION: HTML template processing functions
* 2922: function getSubpart($content, $marker)
* 2938: function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
* 2951: function substituteMarker($content,$marker,$markContent)
* 2971: function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
* 3069: function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
* 3081: function substituteMarkerInObject(&$tree, $markContentArray)
* 3104: function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
*
* SECTION: "stdWrap" + sub functions
* 3167: function stdWrap($content,$conf)
* 3364: function numRows($conf)
* 3388: function listNum($content,$listNum,$char)
* 3408: function checkIf($conf)
* 3471: function filelist($data)
* 3553: function clean_directory($theDir)
* 3571: function HTMLparser_TSbridge($theValue, $conf)
* 3585: function dataWrap($content,$wrap)
* 3598: function insertData($str)
* 3628: function prefixComment($str,$conf,$content)
* 3652: function substring($content,$options)
* 3670: function crop($content,$options)
* 3702: function removeBadHTML($text, $conf)
* 3746: function textStyle($theValue, $conf)
* 3813: function tableStyle($theValue, $conf)
* 3854: function addParams($content,$conf)
* 3895: function filelink($theValue, $conf)
* 3966: function locDataJU($jumpUrl,$conf)
* 3997: function calc($val)
* 4026: function calcIntExplode($delim, $string)
* 4046: function splitObj($value, $conf)
* 4108: function parseFunc($theValue, $conf, $ref='')
* 4218: function _parseFunc ($theValue, $conf)
* 4424: function encaps_lineSplit($theValue, $conf)
* 4507: function http_makelinks($data,$conf)
* 4574: function mailto_makelinks($data,$conf)
* 4617: function getImgResource($file,$fileArray)
*
* SECTION: Data retrieval etc.
* 4810: function getFieldVal($field)
* 4830: function getData($string,$fieldArray)
* 4975: function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
* 4997: function getGlobal($var, $source=NULL)
* 5033: function getKey($key,$arr)
* 5056: function TCAlookup($inputValue,$conf)
*
* SECTION: Link functions (typolink)
* 5116: function typoLink($linktxt, $conf)
* 5481: function typoLink_URL($conf)
* 5499: function getTypoLink($label,$params,$urlParameters=array(),$target='')
* 5526: function getTypoLink_URL($params,$urlParameters=array(),$target='')
* 5538: function typolinkWrap($conf)
* 5551: function currentPageUrl($urlParameters=array(),$id=0)
* 5564: function getClosestMPvalueForPage($pageId, $raw=FALSE)
* 5619: function getMailTo($mailAddress,$linktxt,$initP='?')
* 5658: function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE)
*
* SECTION: Miscellaneous functions, stand alone
* 5754: function wrap($content,$wrap,$char='|')
* 5770: function noTrimWrap($content,$wrap)
* 5784: function wrapSpace($content, $wrap)
* 5810: function callUserFunction($funcName,$conf,$content)
* 5851: function processParams($params)
* 5869: function keywords($content)
* 5886: function caseshift($theValue, $case)
* 5911: function HTMLcaseshift($theValue, $case)
* 5940: function bytes($sizeInBytes,$labels)
* 5951: function calcAge($seconds,$labels)
* 5983: function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
* 6010: function URLqMark($url,$params)
* 6026: function checkEmail($email)
* 6038: function clearTSProperties($TSArr,$propList)
* 6057: function mergeTSRef($confArr,$prop)
* 6080: function joinTSarrays($conf,$old_conf)
* 6103: function gifBuilderTextBox($gifbuilderConf, $conf, $text)
* 6159: function linebreaks($string,$chars,$maxLines=0)
* 6190: function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
*
* SECTION: Database functions, making of queries
* 6260: function DBgetDelete($table, $uid, $doExec=FALSE)
* 6292: function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
* 6334: function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
* 6371: function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
* 6411: function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
* 6451: function enableFields($table,$show_hidden=0)
* 6475: function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
* 6583: function whereSelectFromList($field,$value)
* 6601: function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
* 6628: function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
* 6649: function searchWhere($sw,$searchFieldList,$searchTable='')
* 6685: function exec_getQuery($table, $conf)
* 6703: function getQuery($table, $conf, $returnQueryArray=FALSE)
* 6783: function getWhere($table,$conf, $returnQueryArray=FALSE)
* 6878: function checkPidArray($listArr)
* 6902: function checkPid($uid)
*
* SECTION: Frontend editing functions
* 6959: function editPanel($content, $conf, $currentRecord='', $dataArr=array())
* 7146: function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
* 7228: function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')
* 7270: function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
* 7298: function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())
* 7320: function isDisabled($table,$row)
*
*
* 7351: class tslib_frameset
* 7361: function make($setup)
* 7398: function frameParams($setup, $typeNum)
* 7426: function framesetParams($setup)
*
*
* 7459: class tslib_tableOffset
* 7471: function start($content,$offset)
*
*
* 7549: class tslib_controlTable
* 7584: function start($offset,$cMargins)
*
* TOTAL FUNCTIONS: 135
* (This index is automatically created/updated by the extension "extdeveval")
*
*/


// Includes this classes since it is used for parsing HTML
require_once(PATH_t3lib."class.t3lib_parsehtml.php");

// Object TypoScript library included:
if(t3lib_extMgm::isLoaded('obts')) {
require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
}

















/**
* This class contains all main TypoScript features.
* This includes the rendering of TypoScript content objects (cObjects).
* Is the backbone of TypoScript Template rendering.
*
* There are lots of functions you can use from your include-scripts.
* The class "tslib_cObj" is normally instantiated and referred to as "cObj".
* When you call your own PHP-code typically through a USER or USER_INT cObject then it is this class that instantiates the object and calls the main method. Before it does so it will set (if you are using classes) a reference to itself in the internal variable "cObj" of the object. Thus you can access all functions and data from this class by $this->cObj->... from within you classes written to be USER or USER_INT content objects.
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
* @package TYPO3
* @subpackage tslib
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
*/

class ux_tslib_cObj extends tslib_cObj {


/**
* Implements the stdWrap property, "parseFunc".
* This is a function with a lot of interesting uses. In classic TypoScript this is used to process text from the bodytext field; This included highlighting of search words, changing http:// and mailto: prefixed strings into links, parsing <typolist>, <typohead> and <typocode> tags etc.
* It is still a very important function for processing of bodytext which is normally stored in the database in a format which is not fully ready to be outputted. This situation has not become better by having a RTE around...
*
* This function is actually just splitting the input content according to the configuration of "external blocks". This means that before the input string is actually "parsed" it will be splitted into the parts configured to BE parsed (while other parts/blocks should NOT be parsed). Therefore the actual processing of the parseFunc properties goes on in ->_parseFunc()
*
* @param string The value to process.
* @param array TypoScript configuration for parseFunc
* @param string Reference to get configuration from. Eg. "< lib.parseFunc" which means that the configuration of the object path "lib.parseFunc" will be retrieved and MERGED with what is in $conf!
* @return string The processed value
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=327&cHash=33331f0396
* @see _parseFunc()
*/
function parseFunc($theValue, $conf, $ref='') {
// Fetch / merge reference, if any
if ($ref) {
$temp_conf = array(
'parseFunc' => $ref,
'parseFunc.' => $conf
);
$temp_conf = $this->mergeTSRef($temp_conf, 'parseFunc');
$conf = $temp_conf['parseFunc.'];
}

// Process:
if (strcmp($conf['externalBlocks'],'')) {
$tags = strtolower(implode(',',t3lib_div::trimExplode(',',$conf['externalBlocks'])));
$htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
$parts = $htmlParser->splitIntoBlock($tags,$theValue);

reset($parts);
while(list($k,$v)=each($parts)) {
if ($k%2) { // font:
$tagName=strtolower($htmlParser->getFirstTagName($v));
$cfg=$conf['externalBlocks.'][$tagName.'.'];
if ($cfg['stripNLprev'] || $cfg['stripNL']) {
$parts[$k-1]=ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $parts[$k-1]);
}
if ($cfg['stripNLnext'] || $cfg['stripNL']) {
$parts[$k+1]=ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $parts[$k+1]);
}
}
}

reset($parts);
while(list($k,$v)=each($parts)) {
if ($k%2) {
$tag=$htmlParser->getFirstTag($v);
$tagName=strtolower($htmlParser->getFirstTagName($v));
$cfg=$conf['externalBlocks.'][$tagName.'.'];
if ($cfg['callRecursive']) {
$parts[$k]=$this->parseFunc($htmlParser->removeFirstAndLastTag($v), $conf);
if (!$cfg['callRecursive.']['dontWrapSelf']) {
if ($cfg['callRecursive.']['alternativeWrap']) {
$parts[$k] = $this->wrap($parts[$k], $cfg['callRecursive.']['alternativeWrap']);
} else {
if (is_array($cfg['callRecursive.']['tagStdWrap.'])) {
$tag = $this->stdWrap($tag,$cfg['callRecursive.']['tagStdWrap.']);
}
$parts[$k]=$tag.$parts[$k].'</'.$tagName.'>';
}
}
} elseif($cfg['HTMLtableCells']) {
$rowParts = $htmlParser->splitIntoBlock('tr',$parts[$k]);
$splitBlockLabel[] = 'td';
$splitBlockLabel[] = 'th';
foreach($splitBlockLabel as $value) {
reset($rowParts);
while(list($kk,$vv)=each($rowParts)) {
if ($kk%2) {
$colParts = $htmlParser->splitIntoBlock($value,$vv);
reset($colParts);
$cc=0;
while(list($kkk,$vvv)=each($colParts)) {
if ($kkk%2) {
$cc++;
$tag=$htmlParser->getFirstTag($vvv);
$tagName=strtolower($htmlParser->getFirstTagName($vvv));
$colParts[$kkk] = $htmlParser->removeFirstAndLastTag($vvv);
if ($cfg['HTMLtableCells.'][$cc.'.']['callRecursive'] || (!isset($cfg['HTMLtableCells.'][$cc.'.']['callRecursive']) && $cfg['HTMLtableCells.']['default.']['callRecursive'])) {
if ($cfg['HTMLtableCells.']['addChr10BetweenParagraphs']) $colParts[$kkk]=str_replace('</p><p>','</p>'.chr(10).'<p>',$colParts[$kkk]);
$colParts[$kkk] = $this->parseFunc($colParts[$kkk], $conf);
}
$tagStdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.']:$cfg['HTMLtableCells.']['default.']['tagStdWrap.'];
if (is_array($tagStdWrap)) {
$tag = $this->stdWrap($tag,$tagStdWrap);
}
$stdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['stdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['stdWrap.']:$cfg['HTMLtableCells.']['default.']['stdWrap.'];
if (is_array($stdWrap)) {
$colParts[$kkk] = $this->stdWrap($colParts[$kkk],$stdWrap);
}
$colParts[$kkk]=$tag.$colParts[$kkk].'</'.$tagName.'>';
}
}
$rowParts[$kk] = implode('',$colParts);
}
}
}
$parts[$k] = implode('',$rowParts);
}

if (is_array($cfg['stdWrap.'])) {
$parts[$k] = $this->stdWrap($parts[$k],$cfg['stdWrap.']);
}
} else {
$parts[$k]=$this->_parseFunc($parts[$k], $conf);
}
}

return implode('',$parts);
} else return $this->_parseFunc($theValue, $conf);
}
}


if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']);
}
?>
    (1-1/1)