[TYPO3-core] RFC: Feature #6442: Hook in browse_links request (for linking to records)

Daniel Pötzinger poetzinger at aoemedia.de
Fri Nov 9 16:38:08 CET 2007


This is an SVN patch request.

Type:
New feature

Bugtracker references:
http://bugs.typo3.org/view.php?id=6442

Branches:
trunk

Problem:
-----------
Intention:
A editor should be able to select a record (like tt_news) in the linkwizard.
So he can select a newsrecord and the link is trandlated to a correct 
link to the detailview of that record.

What needs to be changed:
1) the link wizard (in RTE and the normal one) needs a hook -> so that 
other extension can easily add tabs.

Solution:
-----------
add hook in relevant classes:
 >typo3/class.browse_links.php
 >ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php

avoid the coloring of not found links in RTE:
 >class.t3lib_parsehtml_proc.php

Hook can be tested with extension "linkhandler" (includes patches)


Daniel Pötzinger


Index: t3lib/class.t3lib_parsehtml_proc.php
===================================================================
--- t3lib/class.t3lib_parsehtml_proc.php	(revision 2530)
+++ t3lib/class.t3lib_parsehtml_proc.php	(working copy)
@@ -727,6 +727,9 @@
  						$page = t3lib_BEfunc::getRecord('pages', $idPart);
  						if (is_array($page))	{	// Page must exist...
  							$href = $siteUrl.'?id='.$link_param;
+						}
+						elseif (strtolower(substr($link_param,0,7))=='record:') { 
//linkHandler - start of links with "record:" is allowed
+							$href = $link_param;
  						} else {
  							#$href = '';
  							$href = $siteUrl.'?id='.$link_param;




Index: typo3/class.browse_links.php
===================================================================
--- typo3/class.browse_links.php	(revision 2530)
+++ typo3/class.browse_links.php	(working copy)
@@ -755,10 +755,12 @@
  	var $curUrlInfo;


+	/**
+	* array which hold the hook Objects (initialised in init()
+	*/
+	var $hookObjectsArr=array();


-
-
  	/**
  	 * Constructor:
  	 * Initializes a lot of variables, setting JavaScript functions in 
header etc.
@@ -782,7 +784,14 @@
  		if (!$this->mode)	{
  			$this->mode='rte';
  		}
-
+		//init hookObjectArray:
+		if 
(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['browseLinksHook'])) 
{
+		 
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['browseLinksHook'] 
as $_classData) {
+						$_procObj = & t3lib_div::getUserObj($_classData);
+						$_procObj->init($this);
+						$this->hookObjectsArr[]=$_procObj;
+					}
+		}
  			// Site URL
  		$this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');	// Current 
site url

@@ -1142,6 +1151,10 @@

  			// Initializing the action value, possibly removing blinded values etc:
  		$allowedItems = 
array_diff(explode(',','page,file,url,mail,spec'),t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
+		//call hook for extra options
+		foreach ($this->hookObjectsArr as $_hookObj) {
+			$allowedItems=$_hookObj->addAllowedItems($allowedItems);
+		}
  		reset($allowedItems);
  		if (!in_array($this->act,$allowedItems))	$this->act = 
current($allowedItems);

@@ -1183,6 +1196,10 @@
  			$menuDef['spec']['url'] = '#';
  			$menuDef['spec']['addParams'] = 
'onclick="jumpToUrl(\'?act=spec\');return false;"';
  		}
+		//call hook for extra options
+		foreach ($this->hookObjectsArr as $_hookObj) {		
+			$menuDef=$_hookObj->modifyMenuDef($menuDef);
+		}
  		$content .= $this->doc->getTabMenuRaw($menuDef);

  			// Adding the menu and header to the top of page:
@@ -1313,8 +1330,7 @@
  						';
  				}
  			break;
-			case 'page':
-			default:
+			case 'page':			
  				$pagetree = t3lib_div::makeInstance('rtePageTree');
  				$pagetree->thisScript = $this->thisScript;
  				$tree=$pagetree->getBrowsableTree();
@@ -1332,6 +1348,13 @@
  					</table>
  					';
  			break;
+			//call hook
+			default:
+				foreach ($this->hookObjectsArr as $_hookObj) {
+					$content.=$_hookObj->getTab($this->act);
+				}			
+				
+			break;
  		}

  		$content .= '
@@ -2253,7 +2276,7 @@
  				if (strtolower(substr($href,0,7))=='mailto:')	{
  					$info['value']=trim(substr($href,7));
  					$info['act']='mail';
-				}
+				}				
  			}
  			$info['info'] = $info['value'];
  		} else {	// NO value inputted:
@@ -2262,6 +2285,10 @@
  			$info['value']='';
  			$info['act']='page';
  		}
+		//let the hook have a look
+		foreach ($this->hookObjectsArr as $_hookObj) {
+			$info=$_hookObj->parseCurUrl($href,$siteUrl,$info);
+		}
  		return $info;
  	}



Index: typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php
===================================================================
--- typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php 
(revision 2530)
+++ typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php 
(working copy)
@@ -236,7 +236,14 @@
  		if (!$this->mode)	{
  			$this->mode='rte';
  		}
-		
+		//init hookObjectArray:
+		if 
(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['browseLinksHook'])) 
{
+		 
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['browseLinksHook'] 
as $_classData) {
+						$_procObj = & t3lib_div::getUserObj($_classData);
+						$_procObj->init($this);
+						$this->hookObjectsArr[]=$_procObj;
+					}
+		}
  			// Site URL
  		$this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');	// Current 
site url
  		
@@ -583,6 +590,10 @@

  			// Initializing the action value, possibly removing blinded values etc:
  		$allowedItems = explode(',','page,file,url,mail,spec');
+		//call hook for extra options
+		foreach ($this->hookObjectsArr as $_hookObj) {
+			$allowedItems=$_hookObj->addAllowedItems($allowedItems);
+		}
  		if (is_array($this->buttonConfig['options.']) && 
$this->buttonConfig['options.']['removeItems']) {
  			$allowedItems = 
array_diff($allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
  		} else {
@@ -631,6 +642,10 @@
  			$menuDef['spec']['url'] = '#';
  			$menuDef['spec']['addParams'] = 
'onclick="jumpToUrl(\'?act=spec&editorNo='.$this->editorNo.'&contentTypo3Language='.$this->contentTypo3Language.'&contentTypo3Charset='.$this->contentTypo3Charset.'\');return 
false;"';
  		}
+		//call hook for extra options
+		foreach ($this->hookObjectsArr as $_hookObj) {
+			$menuDef=$_hookObj->modifyMenuDef($menuDef);
+		}
  		$content .= $this->doc->getTabMenuRaw($menuDef);

  			// Adding the menu and header to the top of page:
@@ -780,8 +795,7 @@
  						';
  				}
  			break;
-			case 'page':
-			default:
+			case 'page':			
  				$content.=$this->addAttributesForm();
  				
  				$pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
@@ -801,6 +815,13 @@
  					</table>
  					';
  			break;
+			//call hook
+			default:
+				foreach ($this->hookObjectsArr as $_hookObj) {
+					$content.=$_hookObj->getTab($this->act);
+				}			
+				
+			break;
  		}

  			// End page, return content:


More information about the TYPO3-team-core mailing list