[TYPO3-core] RFC: Bugfix 8001: Link Wizard not working if not in RTE mode

Ralf Hettinger ng at ralfhettinger.de
Mon Apr 7 09:08:09 CEST 2008


Steffen,

thanks for pushing this further. I've tested your _v3 patch and think that there
is some regression:

(1)
http://bugs.typo3.org/view.php?id=48 reappears (you removed initialization of
$this->curUrlInfo - why?)

(2)
removing the update button seems odd to me. As far as I understand, this button
has a meaning and proper wording as well: it should only appear, if a link to
some tree element -i.e. page or file/folder- is already set (that's why it's
named "update") and is meant to update title, target or class without having to
click on the href inside the tree above again. Removing it would be a usability
regression, since for updating title, class or target it would need to scroll
down, adjust title and (here comes the regression) then scroll up again to click
on the href inside the tree.

(3)
furthermore, setting title, target and class only works if one uses the "set
link" button (which is the case for external url and mail); setting those props
from the tree mode (page or file/folder) still doesn't work


I attached a patch v4 which

(1)
solves bug 48 again by initializing $this->curUrlInfo properly

(2)
adds the update button, if a href is already set

(3)
implements updating title, target and class for all modes without the need
setting a link by "set link" button.


So I really hope, we're getting this solved in time ;)

Take care
Ralf


Steffen Kamper schrieb:
> I made an improved patch as addition to Ralf's work
> 
> * removed "update"-Button
> * added CSS-Class-Parameter for proper link generation
> * adjusted the form a bit
> * added input form for CSS-Class (including one new label for CSS-Class)
> 
> please test it.
> 
> Complete patch including Ralf's changes is attached.
> 
> vg  Steffen
> 
> 
> "Ralf Hettinger" <ng at ralfhettinger.de> schrieb im Newsbeitrag 
> news:mailman.1.1207402317.6174.typo3-team-core at lists.netfielders.de...
>> This is an SVN patch request.
>>
>> Type: Bugfix
>>
>> Bugtracker references:
>> http://bugs.typo3.org/view.php?id=8001
>> http://bugs.typo3.org/view.php?id=4923
>> http://bugs.typo3.org/view.php?id=48
>>
>> Branches: 4.2 only
>>
>> Problem:
>> If not in rte mode,
>> (8001) namespace congestion of JS functions prevents the link wizard from
>> returning email and external url to the calling TCEForm
>> (4923) type folder is not implemented for the link wizard
>> (48) reconnection of links provided by a TCEForm is not properly 
>> implemented for
>> link wizard
>>
>> Solution:
>> (8001) rename some JavaScript functions
>> (4923) implement folder type
>> (48) better handling of incoming links and setting type accordingly
>>
>> Ralf Hettinger
>>
>>
>>
> 
> 
> --------------------------------------------------------------------------------
> 
> 
>> Index: typo3/class.browse_links.php
>> ===================================================================
>> --- typo3/class.browse_links.php (revision 3534)
>> +++ typo3/class.browse_links.php (working copy)
>> @@ -552,7 +552,7 @@
>>  $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
>>
>>  // Creating blinking arrow, if applicable:
>> - if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='file' && 
>> $cmpPath==$v['row']['path']) {
>> + if (($GLOBALS['SOBE']->browser->curUrlInfo['act']=='file' || 
>> $GLOBALS['SOBE']->browser->curUrlInfo['act']=='folder') && 
>> $cmpPath==$v['row']['path']) {
>>
>> $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" 
>> height="9"').' class="c-blinkArrowR" alt="" /></td>';
>>  $bgColorClass='bgColor4';
>>  } else {
>> @@ -816,6 +816,21 @@
>>  'target' => $currentLinkParts[1]
>>  );
>>
>> $this->curUrlInfo=$this->parseCurUrl($this->siteURL.'?id='.$currentLinkParts[0],$this->siteURL);
>> + if ($this->curUrlInfo['pageid']==0) { // pageid==0 means that this is 
>> not an internal (page) link
>> + if (@file_exists(PATH_site.rawurldecode($currentLinkParts[0]))) { // 
>> check if this is a link to a file
>> + if (t3lib_div::isFirstPartOfStr($currentLinkParts[0],PATH_site)) {
>> + $currentLinkParts[0] = substr($currentLinkParts[0], strlen(PATH_site));
>> + }
>> + $this->curUrlInfo = 
>> $this->parseCurUrl($this->siteURL.$currentLinkParts[0],$this->siteURL);
>> + } elseif (strstr($currentLinkParts[0],'@')) { // check for email link
>> + if (t3lib_div::isFirstPartOfStr($currentLinkParts[0],'mailto:')) {
>> + $currentLinkParts[0] = substr($currentLinkParts[0],7);
>> + }
>> + $this->curUrlInfo = 
>> $this->parseCurUrl('mailto:'.$currentLinkParts[0],$this->siteURL);
>> + } else { // nothing of the above. this is an external link
>> + $this->curUrlInfo = 
>> $this->parseCurUrl($currentLinkParts[0],$this->siteURL);
>> + }
>> + }
>>  } else {
>>  $this->curUrlArray = t3lib_div::_GP('curUrl');
>>  if ($this->curUrlArray['all']) {
>> @@ -868,15 +883,15 @@
>>  var cur_target="'.($this->setTarget?$this->setTarget:'').'";
>>  var cur_title="'.($this->setTitle?$this->setTitle:'').'";
>>
>> - function setTarget(target) { //
>> + function browse_links_setTarget(target) { //
>>  cur_target=target;
>>  add_target="&curUrl[target]="+escape(target);
>>  }
>> - function setTitle(title) { //
>> + function browse_links_setTitle(title) { //
>>  cur_title=title;
>>  add_title="&curUrl[title]="+escape(title);
>>  }
>> - function setValue(value) { //
>> + function browse_links_setValue(value) { //
>>  cur_href=value;
>>  add_href="&curUrl[href]="+value;
>>  }
>> @@ -912,10 +927,19 @@
>>  }
>>  function link_current() { //
>>  if (cur_href!="http://" && cur_href!="mailto:") {
>> - var setValue = cur_href+" "+cur_target+" "+cur_title;
>> - if (setValue.substr(0,7)=="http://") setValue = setValue.substr(7);
>> - if (setValue.substr(0,7)=="mailto:") setValue = setValue.substr(7);
>> - updateValueInMainForm(setValue);
>> + returnBeforeCleaned = cur_href+" "+cur_target+" "+cur_title;
>> + if (returnBeforeCleaned.substr(0,7)=="http://") {
>> + returnToMainFormValue = returnBeforeCleaned.substr(7);
>> + } else if (returnBeforeCleaned.substr(0,7)=="mailto:") {
>> + if (returnBeforeCleaned.substr(0,14)=="mailto:mailto:") {
>> + returnToMainFormValue = returnBeforeCleaned.substr(14);
>> + } else {
>> + returnToMainFormValue = returnBeforeCleaned.substr(7);
>> + }
>> + } else {
>> + returnToMainFormValue = returnBeforeCleaned;
>> + }
>> + updateValueInMainForm(returnToMainFormValue);
>>  close();
>>  }
>>  return false;
>> @@ -1249,7 +1273,7 @@
>>  <tr>
>>  <td>'.$GLOBALS['LANG']->getLL('emailAddress',1).':</td>
>>  <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' 
>> value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" 
>> /> '.
>> - '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" 
>> onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); 
>> return link_current();" /></td>
>> + '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" 
>> onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+document.lurlform.lemail.value); 
>> return link_current();" /></td>
>>  </tr>
>>  </table>
>>  </form>';
>> @@ -1266,7 +1290,7 @@
>>  <tr>
>>  <td>URL:</td>
>>  <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' 
>> value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" 
>> /> '.
>> - '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" 
>> onclick="setValue(document.lurlform.lurl.value); return link_current();" 
>> /></td>
>> + '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" 
>> onclick="browse_links_setValue(document.lurlform.lurl.value); return 
>> link_current();" /></td>
>>  </tr>
>>  </table>
>>  </form>';
>> @@ -1330,7 +1354,7 @@
>>
>>  // URL + onclick event:
>>  $onClickEvent='';
>> - if (isset($v[$k2i.'.']['target'])) 
>> $onClickEvent.="setTarget('".$v[$k2i.'.']['target']."');";
>> + if (isset($v[$k2i.'.']['target'])) 
>> $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
>>  $v[$k2i.'.']['url'] = 
>> str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
>>  if (substr($v[$k2i.'.']['url'],0,7)=='http://' || 
>> substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
>>
>> $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
>> @@ -1405,7 +1429,7 @@
>>  <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
>>  <tr>
>>  <td>'.$GLOBALS['LANG']->getLL('title',1).'</td>
>> - <td><input type="text" name="ltitle" onchange="setTitle(this.value);" 
>> value="'.htmlspecialchars($this->setTitle).'"'.$this->doc->formWidth(10).' 
>> /></td>
>> + <td><input type="text" name="ltitle" 
>> onchange="browse_links_setTitle(this.value);" 
>> value="'.htmlspecialchars($this->setTitle).'"'.$this->doc->formWidth(10).' 
>> /></td>
>>  <td><input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" 
>> onclick="return link_current();" /></td>
>>  </tr>
>>  </table>
>> @@ -1425,9 +1449,9 @@
>>  <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
>>  <tr>
>>  <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
>> - <td><input type="text" name="ltarget" onchange="setTarget(this.value);" 
>> value="'.htmlspecialchars($this->setTarget).'"'.$this->doc->formWidth(10).' 
>> /></td>
>> + <td><input type="text" name="ltarget" 
>> onchange="browse_links_setTarget(this.value);" 
>> value="'.htmlspecialchars($this->setTarget).'"'.$this->doc->formWidth(10).' 
>> /></td>
>>  <td>
>> - <select name="ltarget_type" 
>> onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
>> + <select name="ltarget_type" 
>> onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
>>  <option></option>
>>  <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
>>  <option 
>> value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
>> @@ -1443,8 +1467,8 @@
>>  $selectJS = '
>>  if 
>> (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0 
>> && 
>> document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) 
>> {
>>  document.ltargetform.ltarget.value = 
>> document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value+"x"+document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value;
>> - setTarget(document.ltargetform.ltarget.value);
>> -          setTitle(document.ltitleform.ltitle.value);
>> + browse_links_setTarget(document.ltargetform.ltarget.value);
>> +           browse_links_setTitle(document.ltitleform.ltitle.value);
>>  document.ltargetform.popup_width.selectedIndex=0;
>>  document.ltargetform.popup_height.selectedIndex=0;
>>  }
>> @@ -2513,7 +2537,11 @@
>>  $rel = substr($href,strlen($siteUrl));
>>  if (@file_exists(PATH_site.rawurldecode($rel))) { // URL is a file, which 
>> exists:
>>  $info['value']=rawurldecode($rel);
>> - $info['act']='file';
>> + if (@is_dir(PATH_site.$info['value'])) {
>> + $info['act']='folder';
>> + } else {
>> + $info['act']='file';
>> + }
>>  } else { // URL is a page (id parameter)
>>  $uP=parse_url($rel);
>>  if (!trim($uP['path'])) {
>>
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 8001_v4.patch
Type: text/x-patch
Size: 15831 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20080407/91874423/attachment-0001.bin 


More information about the TYPO3-team-core mailing list