[pmwiki-users] What about $SkinDir . . .

Patrick R. Michaud pmichaud at pobox.com
Fri Aug 25 20:56:50 CDT 2006


On Fri, Aug 25, 2006 at 05:59:50PM -0500, Ben Wilson wrote:
> I notice in scripts/skins.php SetSkin() that there is a global
> variable $SkinDir. During SetSkin(), it is set to the value of the
> valid skin directory, which is itself the result of checking two
> places for a skin.[1] For the remainder of the function, $SkinDir is
> used to retrieve the template file, etc. However, apart from
> SetSkin(), $SkinDir is not used. On first blush, it would appear that
> there is no need for a global $SkinDir. 

It's made available so that skins (with a skin.php file) can have
an easy way to access files relative to the skin's directory.
(Especially if the skin.php file itself is doing further
include_once() statements.)  A quick check on pmwiki.org shows
that quite a few skins make direct use of $SkinDir.

> However, I would like to suggest a change to SetSkin() that allows
> $SkinDir to be set in $LocalDir/config.php.  

Well, part of the reason it's currently not settable from
$LocalDir/config.php is because of things like the SkinChange
recipe, where the value of $SkinDir and $SkinDirUrl depend on
the skin chosen by a browser cookie.  There are also a few
sites that have a (:setskin XYZ:) markup where the skin values
are changed after all configuration has been loaded.

However, all is not lost; we could always come up with a
$SkinLocationsFmt array that specifies places to look
for skins and the corresponding urls to use.  Thus, the
default would be

    SDV($SkinLocationsFmt,
      array('./pub/skins/$1'      => '$PubDirUrl/skins/$1',
            '$FarmD/pub/skins/$1' => '$FarmPubDirUrl/skins/$1'));

This would say to look first in the local wiki's pub/skins/
directory, otherwise look in the farm's pub/skins/, and
set the values for $SkinDir and $SkinDirUrl accordingly.
Then a local/config.php could set

    SDV($SkinLocationsFmt,
      array('/var/www/pmwiki-share/pub/skins/$1' => '/pub/skins/$1'));

and it would always look for skins in .../pmwiki-share/pub/skins
and return the corresponding url as /pub/skins/... .  And, of course,
we still have the opportunity for dynamically selecting from the
available pool of skins.

Would something like that work for you?  

Another approach might be the one given in 
http://www.pmwiki.org/wiki/PITS/00708, which also is dealing with
issues surrounding placing the farm's pub/ outside of the
farm directory itself.  Notably, that version still allows
SetSkin() to determine the values of $SkinDir, rather than needing
it to be set in local/config.php.

Pm




More information about the pmwiki-users mailing list