[TYPO3-core] Bug 633

Bernhard Kraft kraftb at kraftb.at
Fri Jan 6 02:52:02 CET 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

A compount mail answering all questions from Martin and Franz regarding the
Bugfix for #633.

New patch is attached.

- -----------------------------------------------------------------------
Martin Kutschker wrote:
> Why is directoryLevel a property and not a local variable? If I read the patch correct $this->directoryLevel is
> your contribution. I suggest
> a) that you initalize it to 0 as it's used later in calculations and

Done.


> b) make it local ($directoryLevel instead of $this->directoryLevel).

Done.

> 
> Is there a wrong indentation in the patch?
> 
> + return $retVal;

Was a mistake. Sorry. Fixed that also.


> The patch also adds a stdWrap to special.value. Please add the correted documentation to TSref.

(Just for completeness again ... I already answered that):
In TSRef it is already stated that this IS a stdWrap field (but it wasn't) so the documentation
is more up-to-date then the code :)


> As for the patch itself. I'm not really familiar with the menu code.

I was asked 3 times in the last few weeks for the patch because it is not available at the URL where
I published it first because the domain it was hosted on was moved. I had to direct all those people
to the bugtracker where the patch also resides.

I didn't get any single "bugfix bug report" ... meaning it seems to work properly.

This part of the menu code isn't that complicated:
      $startLevel = $directoryLevel?$directoryLevel:$this->entryLevel;
      if (is_array($this->tmpl->rootLine[$startLevel+$this->menuNumber])) {
        $nextMParray = $this->MP_array;
        if ($this->tmpl->rootLine[$startLevel+$this->menuNumber]['_MOUNT_OL'])  { // In overlay mode, add next level MPvars as well:
          $nextMParray[] = $this->tmpl->rootLine[$startLevel+$this->menuNumber]['_MP_PARAM'];
        }
        $this->nextActive = $this->tmpl->rootLine[$startLevel+$this->menuNumber]['uid'].(count($nextMParray)?':'.implode(',',$nextMParray):'');
      } else {
        $this->nextActive = '';
      }
It just get's evaluated if the "actualy rendered" menu level is in the rootline - if this is the case
the page is "active" (opened) and the sub-items shall get shown (this is done by setting this->nextActive)

- -----------------------------------------------------------------------
Holzinger Franz wrote:
> Hello Bernhard,
>
>
> from the TSRef documentation:
>
>
>>If .value is not set, the default uid is the .entryLevel uid.
>
>
> Maybe this is missing in your code.

Added it.

> This would be a usefull general function to get the depth of a page to
> the rootline.

Added it to t3lib_tstemplate.php ... i think that's the correct location as the
rootline is also stored in this object ...

If you would prefer another name than "getRootlineLevel()" let's disscuss your preference :)

> In t3lib/class.t3lib_tstemplate.php line 442 you have
>
>
>>$this->rootLine[] = $this->absoluteRootLine[$a];
>
>
> You have written:
>
>
>>+                if
>>($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber+$this->directoryLevel]['_MOUNT_OL'])
>> {    // In overlay mode, add next level MPvars as well:
>>+                    $nextMParray[] =
>>$this->tmpl->rootLine[$this->entryLevel+$this->menuNumber+$this->direcotryLevel]['_MP_PARAM'];
>>                 }
>
>
> So hopefully this works, however you are relying here on the index
> number of rootLine in the template object. This is however not
> documented anywhere that you can rely on this index number. Or am I
> missing something?

From:
http://www.php.net/manual/en/language.types.array.php
********
<?php
$arr = array(5 => 1, 12 => 2);

$arr[] = 56;    // This is the same as $arr[13] = 56;
               // at this point of the script
********
Note:  As mentioned above, if you provide the brackets with no key specified, then the maximum
of the existing integer indices is taken, and the new key will be that maximum value + 1 . If
no integer indices exist yet, the key will be 0  (zero). If you specify a key that already has
a value assigned to it, that value will be overwritten.
********

So the values will get assigned in a "defined" order starting from 0 and counting up.

This is used in many places in the core and you can rely on the indexes being in a properly sorted
order :)

> I cannot believe that this works:
>
>
>>$this->tmpl->rootLine[$this->entryLevel+$this->menuNumber+$this->directoryLevel]
>
>
> $this->directoryLevel are e.g. numbers from 1 to 10. This is added with
> entryLevel and the menuNumber to give the index of the rootLine array.
> Or is only one number valid at a call of this function?

Yes. There was a problem. Normally nobody would normally try (until now - I did :) to use special = directory
and "entryLevel =" at the same time (in the same HMENU).

Currently it behaves in such a way that it shows the menu depending if you are enough pages from the "real"
rootpage in the tree (if entryLevel=1 you need to be on a subpage of the rootpage and the menu will get shown)
But the menu get's not shown FROM the level you define by entryLevel as it is the case with "no-special=directory"
menus (So you will only see the second level items) but always from the rootpage you define by the special.value property.

I know a little bit confusing but try out with the current code how it behaves and you will know what I mean.

>>direcotryLevel
>
>
> --> directoryLevel

Fixed. (Removed and replaced by startLevel)

- -----------------------------------------------------------------------


I would really like to get this into 4.0beta2 (or RC1)

If you have any questions contact me via ICQ: 113830220


greets,
Bernhard
- --
- ----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
- ----------------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDvc0uIl4dkVkDMFkRAtj/AJ96fmG3CUbkEfFEA5g6vzXyKSHs3QCfQQQv
NOThV7a5S7AROV8VmwGWUZs=
=u+JA
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug_633_2006-01-06.diff
Type: text/x-patch
Size: 3683 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060106/549cc32c/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060106/549cc32c/attachment.pgp 


More information about the TYPO3-team-core mailing list