Commit 53797422 authored by Kasper Skårhøj's avatar Kasper Skårhøj
Browse files

Added <span title=""> to path in backend modules in Web main module; you can...

Added <span title=""> to path in backend modules in Web main module; you can now see the full path (non-truncated) as title text.
Added RTE API and changed the "rte" extension to use that.
Added t3lib_div::getUserObj() which returns an OBJECT , instead of executing a method call like callUserFunc() does.


git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@150 709f56b5-9817-0410-a4d7-c38de5d9e867
parent ab70ad57
2004-03-24 Kasper Skårhøj,,, <kasper@typo3.com>
* Added <span title=""> to path in backend modules in Web main module; you can now see the full path (non-truncated) as title text.
2004-03-24 Kasper Skårhøj,,, <kasper@typo3.com>
* Added RTE API and changed the "rte" extension to use that.
* Added t3lib_div::getUserObj() which returns an OBJECT , instead of executing a method call like callUserFunc() does.
2004-03-23 Kasper Skårhøj,,, <kasper@typo3.com>
* Fixed problem in Extension Manager where files and directories was not written with correct permissions. I also added t3lib_div::mkdir() general function for creating directories.
......
......@@ -10,7 +10,7 @@
* 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
......@@ -63,10 +63,10 @@
*
* SECTION: Page tree, TCA related
* 488: function BEgetRootLine ($uid,$clause='')
* 539: function getRecordPath($uid,$clause,$titleLimit)
* 539: function getRecordPath($uid,$clause,$titleLimit)
* 564: function getExcludeFields()
* 599: function readPageAccess($id,$perms_clause)
* 629: function getTCAtypes($table,$rec,$useFieldNameAsKey=0)
* 629: function getTCAtypes($table,$rec,$useFieldNameAsKey=0)
* 675: function getTCAtypeValue($table,$rec)
* 698: function getSpecConfParts($str)
* 723: function getSpecConfParametersFromArray($pArr)
......@@ -130,10 +130,10 @@
* 2317: function getTCEFORM_TSconfig($table,$row)
* 2365: function getTSconfig_pidValue($table,$uid,$pid)
* 2394: function getPidForModTSconfig($table,$uid,$pid)
* 2411: function getTSCpid($table,$uid,$pid)
* 2411: function getTSCpid($table,$uid,$pid)
* 2428: function firstDomainRecord($rootLine)
* 2451: function getDomainStartPage($domain, $path='')
* 2482: function RTEsetup($RTEprop,$table,$field,$type='')
* 2482: function RTEsetup($RTEprop,$table,$field,$type='')
* 2503: function isModuleSetInTBE_MODULES($modName)
*
* SECTION: Miscellaneous
......@@ -534,23 +534,31 @@ class t3lib_BEfunc {
* @param integer Page uid for which to create record path
* @param string $clause is additional where clauses, eg. "
* @param integer Title limit
* @return string Path of record
* @param integer Title limit of Full title (typ. set to 1000 or so)
* @return mixed Path of record (string) OR array with short/long title if $fullTitleLimit is set.
*/
function getRecordPath($uid,$clause,$titleLimit) {
if (!$titleLimit) {$titleLimit=1000;}
function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0) {
if (!$titleLimit) { $titleLimit=1000; }
$loopCheck = 100;
$output='/';
$output = $fullOutput = '/';
while ($uid!=0 && $loopCheck>0) {
$loopCheck--;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid,title', 'pages', 'uid='.intval($uid).t3lib_BEfunc::deleteClause('pages').' AND '.$clause);
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$uid = $row['pid'];
$output='/'.t3lib_div::fixed_lgd(strip_tags($row['title']),$titleLimit).$output;
$output = '/'.t3lib_div::fixed_lgd(strip_tags($row['title']),$titleLimit).$output;
if ($fullTitleLimit) $fullOutput = '/'.t3lib_div::fixed_lgd(strip_tags($row['title']),$fullTitleLimit).$fullOutput;
} else {
break;
}
}
return $output;
if ($fullTitleLimit) {
return array($output, $fullOutput);
} else {
return $output;
}
}
/**
......@@ -598,17 +606,17 @@ class t3lib_BEfunc {
*/
function readPageAccess($id,$perms_clause) {
if ((string)$id!='') {
$id=intval($id);
$id = intval($id);
if (!$id) {
if ($GLOBALS['BE_USER']->isAdmin()) {
$path='/';
$pageinfo['_thePath']=$path;
$path = '/';
$pageinfo['_thePath'] = $path;
return $pageinfo;
}
} else {
$pageinfo = t3lib_BEfunc::getRecord('pages',$id,'*',($perms_clause?' AND '.$perms_clause:''));
$pageinfo = t3lib_BEfunc::getRecord('pages',$id,'*',($perms_clause ? ' AND '.$perms_clause : ''));
if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause)) {
$pageinfo['_thePath']=t3lib_BEfunc::getRecordPath (intval($pageinfo['uid']),$perms_clause,15);
list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
return $pageinfo;
}
}
......@@ -631,6 +639,7 @@ class t3lib_BEfunc {
t3lib_div::loadTCA($table);
if ($TCA[$table]) {
// Get type value:
$fieldValue = t3lib_BEfunc::getTCAtypeValue($table,$rec);
......@@ -638,24 +647,31 @@ class t3lib_BEfunc {
$typesConf = $TCA[$table]['types'][$fieldValue];
// Get fields list and traverse it
$fieldList = explode(',',$typesConf['showitem']);
$altFieldList=array();
reset($fieldList);
while(list($k,$v)=each($fieldList)) {
$vParts=explode(';',$v);
$specConfParts = t3lib_BEfunc::getSpecConfParts($vParts[3]);
$fieldList = explode(',', $typesConf['showitem']);
$altFieldList = array();
// Traverse fields in types config and parse the configuration into a nice array:
foreach($fieldList as $k => $v) {
list($pFieldName, $pAltTitle, $pPalette, $pSpec) = t3lib_div::trimExplode(';', $v);
$defaultExtras = is_array($TCA[$table]['columns'][$pFieldName]) ? $TCA[$table]['columns'][$pFieldName]['defaultExtras'] : '';
$specConfParts = t3lib_BEfunc::getSpecConfParts($pSpec, $defaultExtras);
$fieldList[$k]=array(
'field'=>trim($vParts[0]),
'title'=>trim($vParts[1]),
'palette'=>trim($vParts[2]),
'spec'=>$specConfParts,
'origString'=>$v
'field' => $pFieldName,
'title' => $pAltTitle,
'palette' => $pPalette,
'spec' => $specConfParts,
'origString' => $v
);
if ($useFieldNameAsKey) {
$altFieldList[$fieldList[$k]['field']]=$fieldList[$k];
$altFieldList[$fieldList[$k]['field']] = $fieldList[$k];
}
}
if ($useFieldNameAsKey) $fieldList=$altFieldList;
if ($useFieldNameAsKey) {
$fieldList = $altFieldList;
}
// Return array:
return $fieldList;
}
}
......@@ -678,9 +694,9 @@ class t3lib_BEfunc {
// If no field-value, set it to zero. If there is no type matching the field-value (which now may be zero...) test field-value '1' as default.
t3lib_div::loadTCA($table);
if ($TCA[$table]) {
$field=$TCA[$table]['ctrl']['type'];
$fieldValue = $field?($rec[$field]?$rec[$field]:0):0;
if (!is_array($TCA[$table]['types'][$fieldValue])) $fieldValue=1;
$field = $TCA[$table]['ctrl']['type'];
$fieldValue = $field ? ($rec[$field] ? $rec[$field] : 0) : 0;
if (!is_array($TCA[$table]['types'][$fieldValue])) $fieldValue = 1;
return $fieldValue;
}
}
......@@ -693,21 +709,28 @@ class t3lib_BEfunc {
* Usage: 3
*
* @param string Content from the "types" configuration of TCA (the special configuration) - see description of function
* @param string The ['defaultExtras'] value from field configuration
* @return array
*/
function getSpecConfParts($str) {
if (trim($str)) {
$specConfParts = explode(':',$str);
reset($specConfParts);
while(list($k2,$v2) = each($specConfParts)) {
function getSpecConfParts($str, $defaultExtras) {
// Add defaultExtras:
$specConfParts = t3lib_div::trimExplode(':', $defaultExtras.':'.$str, 1);
if (count($specConfParts)) {
foreach($specConfParts as $k2 => $v2) {
unset($specConfParts[$k2]);
if (ereg('(.*)\[(.*)\]',$v2,$reg)) {
unset($specConfParts[$k2]);
$specConfParts[$reg[1]] = array(
'parameters'=>explode('|',$reg[2])
$specConfParts[trim($reg[1])] = array(
'parameters' => t3lib_div::trimExplode('|', $reg[2], 1)
);
} else {
$specConfParts[trim($v2)] = 1;
}
}
} else { $specConfParts = array(); }
} else {
$specConfParts = array();
}
return $specConfParts;
}
......@@ -2120,7 +2143,6 @@ class t3lib_BEfunc {
} else {die ('No menu!');}
if ($changed) {
//debug('write!');
$GLOBALS['BE_USER']->pushModuleData($modName,$settings);
}
......@@ -2404,13 +2426,13 @@ class t3lib_BEfunc {
* @param string Table name
* @param integer Record uid
* @param integer Record pid
* @return integer
* @return array Array of two integers; first is the REAL PID of a record and if its a new record negative values are resolved to the true PID, second value is the PID value for TSconfig (uid if table is pages, otherwise the pid)
* @internal
* @see t3lib_TCEmain::setHistory(), t3lib_TCEmain::process_datamap()
*/
function getTSCpid($table,$uid,$pid) {
// If pid is negative (referring to another record) the pid of the other record is fetched and returned.
$cPid = t3lib_BEfunc::getTSconfig_pidValue($table,$uid,$pid);
$cPid = t3lib_BEfunc::getTSconfig_pidValue($table,$uid,$pid);
// $TScID is the id of $table=pages, else it's the pid of the record.
$TScID = t3lib_BEfunc::getPidForModTSconfig($table,$uid,$cPid);
......@@ -2492,6 +2514,43 @@ class t3lib_BEfunc {
return $thisConfig;
}
/**
* Returns first possible RTE object if available.
*
* @return mixed If available, returns RTE object, otherwise an array of messages from possible RTEs
*/
function &RTEgetObj() {
// If no RTE object has been set previously, try to create it:
if (!isset($GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'])) {
// Set the object string to blank by default:
$GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'] = array();
// Traverse registered RTEs:
if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg'] as $extKey => $rteObjCfg) {
$rteObj = &t3lib_div::getUserObj($rteObjCfg['objRef']);
if (is_object($rteObj)) {
if ($rteObj->isAvailable()) {
$GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'] = &$rteObj;
break;
} else {
$GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'], $rteObj->errorLog);
}
}
}
}
if (!count($GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'])) {
$GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'][] = 'No RTEs configured at all';
}
}
// Return RTE object (if any!)
return $GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'];
}
/**
* Returns true if $modName is set and is found as a main- or submodule in $TBE_MODULES array
*
......
......@@ -157,9 +157,9 @@
* 2874: function loadTCA($table)
* 2893: function resolveSheetDefInDS($dataStructArray,$sheet='sDEF')
* 2921: function resolveAllSheetsInDS($dataStructArray)
* 2950: function callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$silent=0)
* 3053: function makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys='')
* 3092: function makeInstanceClassName($className)
* 2950: function callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$silent=0)
* 3053: function makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys='')
* 3092: function makeInstanceClassName($className)
* 3112: function plainMailEncoded($email,$subject,$message,$headers='',$enc='',$charset='ISO-8859-1',$dontEncodeSubject=0)
* 3159: function quoted_printable($string,$maxlen=76)
* 3202: function substUrlsInPlainText($message,$urlmode='76',$index_script_url='')
......@@ -1985,7 +1985,7 @@ class t3lib_div {
// Setting file system mode of file:
if (@is_file($file) && TYPO3_OS!='WIN') {
chmod($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
@chmod($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'])); // "@" is there because file is not necessarily OWNED by the user
}
return true;
......@@ -2968,6 +2968,7 @@ class t3lib_div {
* @param string Required prefix of class or function name
* @param boolean If set, not debug() error message is shown if class/function is not present.
* @return mixed Content from method/function call
* @see getUserObj()
*/
function callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$silent=0) {
......@@ -2985,7 +2986,7 @@ class t3lib_div {
if (strstr($funcName,':')) {
list($file,$funcRef) = t3lib_div::revExplode(':',$funcName,2);
$requireFile = t3lib_div::getFileAbsFileName($file);
require_once($requireFile);
if ($requireFile) require_once($requireFile);
} else {
$funcRef = $funcName;
}
......@@ -2996,7 +2997,7 @@ class t3lib_div {
!t3lib_div::isFirstPartOfStr(trim($funcRef),'tx_')
) {
if (!$silent) debug("Function '".$funcRef."' was not prepended with '".$checkPrefix."'",1);
return $content;
return FALSE;
}
// Call function or method:
......@@ -3044,6 +3045,62 @@ class t3lib_div {
return $content;
}
/**
* Creates and returns reference to a user defined object.
* This function can return an object reference if you like. Just prefix the function call with "&": "$objRef = &t3lib_div::getUserObj('EXT:myext/class.tx_myext_myclass.php:>tx_myext_myclass');"
*
* @param string Class reference, [file-reference]:[[">"]class-reference]. You can prefix the class name with "[file-reference]:" and t3lib_div::getFileAbsFileName() will then be used to resolve the filename and subsequently include it by "require_once()" which means you don't have to worry about including the class file either! Example: "EXT:realurl/class.tx_realurl.php:>tx_realurl". Finally; for the class name you can prefix it with ">" and you will reuse the previous instance of the object identified by the full reference string (meaning; if you ask for the same object later in another place in the code you will get a reference to the first created one!).
* @param string Required prefix of class name
* @param boolean If set, not debug() error message is shown if class/function is not present.
* @return object The instance of the class asked for. Instance is created with t3lib_div::makeInstance
* @see callUserFunction()
*/
function &getUserObj($classRef,$checkPrefix='user_',$silent=0) {
// Check persistent object and if found, call directly and exit.
if (is_object($GLOBALS['T3_VAR']['getUserObj'][$classRef])) {
return $GLOBALS['T3_VAR']['getUserObj'][$classRef];
} else {
// Check file-reference prefix; if found, require_once() the file (should be library of code)
if (strstr($classRef,':')) {
list($file,$class) = t3lib_div::revExplode(':',$classRef,2);
$requireFile = t3lib_div::getFileAbsFileName($file);
if ($requireFile) require_once($requireFile);
} else {
$class = $classRef;
}
// Check for persistent object token, ">"
if (substr($class,0,1)=='>') {
$class = substr($class,1);
$storePersistentObject = TRUE;
} else $storePersistentObject = FALSE;
// Check prefix is valid:
if ($checkPrefix &&
!t3lib_div::isFirstPartOfStr(trim($class),$checkPrefix) &&
!t3lib_div::isFirstPartOfStr(trim($class),'tx_')
) {
if (!$silent) debug("Function '".$class."' was not prepended with '".$checkPrefix."'",1);
return FALSE;
}
// Check if class/method exists:
if (class_exists($class)) {
$classObj = t3lib_div::makeInstance($class);
// If persistent object should be created, set reference:
if ($storePersistentObject) {
$GLOBALS['T3_VAR']['getUserObj'][$classRef] = &$classObj;
}
return $classObj;
} else {
if (!$silent) debug("<strong>ERROR:</strong> No class named: ".$class,1);
}
}
}
/**
* Make instance of class
* Takes the class-extensions API of TYPO3 into account
......
......@@ -37,35 +37,41 @@
*
*
*
* 100: class t3lib_parsehtml
* 117: function getSubpart($content, $marker)
* 145: function substituteSubpart($content,$marker,$subpartContent,$recursive=1,$keepMarker=0)
* 210: function splitIntoBlock($tag,$content,$eliminateExtraEndTags=0)
* 269: function splitTags($tag,$content)
* 303: function getAllParts($parts,$tag_parts=1,$include_tag=1)
* 322: function removeFirstAndLastTag($str)
* 341: function getFirstTag($str)
* 356: function getFirstTagName($str,$preserveCase=FALSE)
* 376: function checkTagTypeCounts($content,$blockTags='a,b,blockquote,body,div,em,font,form,h1,h2,h3,h4,h5,h6,i,li,map,ol,option,p,pre,select,span,strong,table,td,textarea,tr,u,ul', $soloTags='br,hr,img,input,area')
* 450: function HTMLcleaner($content, $tags=array(),$keepAll=0,$hSC=0,$addConfig=array())
* 645: function get_tag_attributes($tag,$deHSC=0)
* 687: function split_tag_attributes($tag)
* 724: function bidir_htmlspecialchars($value,$dir)
* 746: function prefixResourcePath($main_prefix,$content,$alternatives=array())
* 814: function prefixRelPath($prefix,$srcVal)
* 832: function cleanFontTags($value,$keepFace=0,$keepSize=0,$keepColor=0)
* 863: function mapTags($value,$tags=array(),$ltChar='<',$ltChar2='<')
* 880: function unprotectTags($content,$tagList='')
* 913: function stripTagsExcept($value,$tagList)
* 936: function caseShift($str,$flag,$cacheKey='')
* 960: function compileTagAttribs($tagAttrib,$meta=array(), $xhtmlClean=0)
* 989: function get_tag_attributes_classic($tag,$deHSC=0)
* 1002: function HTMLparserConfig($TSconfig,$keepTags=array())
* 1126: function XHTML_clean($content)
* 1149: function processTag($value,$conf,$endTag,$protected=0)
* 1196: function processContent($value,$dir,$conf)
* 106: class t3lib_parsehtml
* 123: function getSubpart($content, $marker)
* 151: function substituteSubpart($content,$marker,$subpartContent,$recursive=1,$keepMarker=0)
*
* TOTAL FUNCTIONS: 26
* SECTION: Parsing HTML code
* 223: function splitIntoBlock($tag,$content,$eliminateExtraEndTags=0)
* 284: function splitIntoBlockRecursiveProc($tag,$content,&$procObj,$callBackContent,$callBackTags,$level=0)
* 319: function splitTags($tag,$content)
* 353: function getAllParts($parts,$tag_parts=1,$include_tag=1)
* 372: function removeFirstAndLastTag($str)
* 391: function getFirstTag($str)
* 406: function getFirstTagName($str,$preserveCase=FALSE)
* 421: function get_tag_attributes($tag,$deHSC=0)
* 463: function split_tag_attributes($tag)
* 506: function checkTagTypeCounts($content,$blockTags='a,b,blockquote,body,div,em,font,form,h1,h2,h3,h4,h5,h6,i,li,map,ol,option,p,pre,select,span,strong,table,td,textarea,tr,u,ul', $soloTags='br,hr,img,input,area')
*
* SECTION: Clean HTML code
* 597: function HTMLcleaner($content, $tags=array(),$keepAll=0,$hSC=0,$addConfig=array())
* 791: function bidir_htmlspecialchars($value,$dir)
* 813: function prefixResourcePath($main_prefix,$content,$alternatives=array())
* 881: function prefixRelPath($prefix,$srcVal)
* 899: function cleanFontTags($value,$keepFace=0,$keepSize=0,$keepColor=0)
* 930: function mapTags($value,$tags=array(),$ltChar='<',$ltChar2='<')
* 947: function unprotectTags($content,$tagList='')
* 980: function stripTagsExcept($value,$tagList)
* 1003: function caseShift($str,$flag,$cacheKey='')
* 1027: function compileTagAttribs($tagAttrib,$meta=array(), $xhtmlClean=0)
* 1056: function get_tag_attributes_classic($tag,$deHSC=0)
* 1069: function indentLines($content, $number=1, $indentChar="\t")
* 1086: function HTMLparserConfig($TSconfig,$keepTags=array())
* 1210: function XHTML_clean($content)
* 1233: function processTag($value,$conf,$endTag,$protected=0)
* 1280: function processContent($value,$dir,$conf)
*
* TOTAL FUNCTIONS: 28
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
......@@ -196,6 +202,13 @@ class t3lib_parsehtml {
/************************************
*
* Parsing HTML code
*
************************************/
/**
* Returns an array with the $content divided by tag-blocks specified with the list of tags, $tag
* Even numbers in the array are outside the blocks, Odd numbers are block-content.
......@@ -256,6 +269,43 @@ class t3lib_parsehtml {
return $newParts;
}
/**
* Splitting content into blocks *recursively* and processing tags/content with call back functions.
*
* @param string Tag list, see splitIntoBlock()
* @param string Content, see splitIntoBlock()
* @param object Object where call back methods are.
* @param string Name of call back method for content; "function callBackContent($str,$level)"
* @param string Name of call back method for tags; "function callBackTags($tags,$level)"
* @param integer Indent level
* @return string Processed content
* @see splitIntoBlock()
*/
function splitIntoBlockRecursiveProc($tag,$content,&$procObj,$callBackContent,$callBackTags,$level=0) {
$parts = $this->splitIntoBlock($tag,$content,TRUE);
foreach($parts as $k => $v) {
if ($k%2) {
$firstTagName = $this->getFirstTagName($v, TRUE);
$tagsArray = array();
$tagsArray['tag_start'] = $this->getFirstTag($v);
$tagsArray['tag_end'] = '</'.$firstTagName.'>';
$tagsArray['tag_name'] = strtolower($firstTagName);
$tagsArray['add_level'] = 1;
if ($callBackTags) $tagsArray = $procObj->$callBackTags($tagsArray,$level);
$parts[$k] =
$tagsArray['tag_start'].
$this->splitIntoBlockRecursiveProc($tag,$this->removeFirstAndLastTag($v),$procObj,$callBackContent,$callBackTags,$level+$tagsArray['add_level']).
$tagsArray['tag_end'];
} else {
if ($callBackContent) $parts[$k] = $procObj->$callBackContent($parts[$k],$level);
}
}
return implode('',$parts);
}
/**
* Returns an array with the $content divided by tag-blocks specified with the list of tags, $tag
* Even numbers in the array are outside the blocks, Odd numbers are block-content.
......@@ -359,7 +409,87 @@ class t3lib_parsehtml {
return trim($tag);
}
/**
* Returns an array with all attributes as keys. Attributes are only lowercase a-z
* If a attribute is empty (shorthand), then the value for the key is empty. You can check if it existed with isset()
*
* @param string Tag: $tag is either a whole tag (eg '<TAG OPTION ATTRIB=VALUE>') or the parameterlist (ex ' OPTION ATTRIB=VALUE>')
* @param boolean If set, the attribute values are de-htmlspecialchar'ed. Should actually always be set!
* @return array array(Tag attributes,Attribute meta-data)
*/
function get_tag_attributes($tag,$deHSC=0) {
list($components,$metaC) = $this->split_tag_attributes($tag);
$name = ''; // attribute name is stored here
$valuemode = '';
$attributes=array();
$attributesMeta=array();
if (is_array($components)) {
while (list($key,$val) = each ($components)) {
if ($val != '=') { // Only if $name is set (if there is an attribute, that waits for a value), that valuemode is enabled. This ensures that the attribute is assigned it's value
if ($valuemode) {
if ($name) {
$attributes[$name] = $deHSC?t3lib_div::htmlspecialchars_decode($val):$val;
$attributesMeta[$name]['dashType']=$metaC[$key];
$name = '';
}
} else {
if ($namekey = ereg_replace('[^a-zA-Z0-9_-]','',$val)) {
$name = strtolower($namekey);
$attributesMeta[$name]=array();
$attributesMeta[$name]['origTag']=$namekey;
$attributes[$name] = '';
}
}
$valuemode = '';
} else {
$valuemode = 'on';
}
}
if (is_array($attributes)) reset($attributes);
return array($attributes,$attributesMeta);
}
}
/**
* Returns an array with the 'components' from an attribute list. The result is normally analyzed by get_tag_attributes
* Removes tag-name if found
*
* @param string The tag or attributes
* @return array
* @access private
* @see t3lib_div::split_tag_attributes()
*/
function split_tag_attributes($tag) {
$tag_tmp = trim(eregi_replace ('^<[^[:space:]]*','',trim($tag)));
// Removes any > in the end of the string
$tag_tmp = trim(eregi_replace ('>$','',$tag_tmp));
$metaValue = array();
$value = array();
while (strcmp($tag_tmp,'')) { // Compared with empty string instead , 030102
$firstChar=substr($tag_tmp,0,1);
if (!strcmp($firstChar,'"') || !strcmp($firstChar,"'")) {
$reg=explode($firstChar,$tag_tmp,3);
$value[]=$reg[1];
$metaValue[]=$firstChar;
$tag_tmp=trim($reg[2]);
} elseif (!strcmp($firstChar,'=')) {
$value[] = '=';
$metaValue[]='';
$tag_tmp = trim(substr($tag_tmp,1)); // Removes = chars.
} else {
// There are '' around the value. We look for the next ' ' or '>'
$reg = split('[[:space:]=]',$tag_tmp,2);
$value[] = trim($reg[0]);
$metaValue[]='';
$tag_tmp = trim(substr($tag_tmp,strlen($reg[0]),1).$reg[1]);
}
}
if (is_array($value)) reset($value);
return array($value,$metaValue);
}
/**
* Checks whether block/solo tags are found in the correct amounts in HTML content
* Block tags are tags which are required to have an equal amount of start and end tags, eg. "<table>...</table>"
......@@ -413,6 +543,23 @@ class t3lib_parsehtml {
return $analyzedOutput;
}