[pmwiki-users] SiteAdmin.SiteAttributes
Petko Yotov
5ko at free.fr
Sat Jun 23 09:34:48 CDT 2007
On Thursday 21 June 2007, Dominique Faure wrote:
> On 6/21/07, Petko Yotov <5ko at free.fr> wrote:
> > Is there a way to have a special page Site.SiteAttributes like
> > Group.GroupAttributes, but for the whole site?
> >
> > Like: if one sets a read/edit password, or @lock on this page, the whole
> > site gets closed. Groups or Pages with the @nopass attribute will be
> > visible, that is, their attributes override the Site.SiteAttributes
> > settings.
...
> BTW, this could be a perfect place to have some other global settings
> (for now only set via config.php), such as the $WikiTitle variable,
> no?
>
> [cf. my previous unanswered post about group titles]
Actually, when Patrick doesn't reply, it is almost certain that what we beg
for can be done quite simply with a recipe.
Here is something that does all this. Patrick, can you please look at this
code to see if it is not dangerous of some kind? Or if it may be
optimized/simplified?
SDV($SiteAttributesPage, FmtPageName('$SiteGroup.SiteAttributes',
$pagename));
if(PageExists($SiteAttributesPage) )
{
$p = ReadPage($SiteAttributesPage, READPAGE_CURRENT);
foreach(array('read', 'edit', 'upload', 'attr') as $attr )
{
$k = $p["passwd$attr"];
if($k >'')foreach(explode(' ', $k) as $kk)
$DefaultPasswords[$attr][] = $kk;
}
if(PageTextVar($SiteAttributesPage, 'WikiTitle')>'')
$WikiTitle = PageTextVar($SiteAttributesPage, 'WikiTitle') ;
}
SDV($GroupAttributesPage, FmtPageName('$Group.GroupAttributes', $pagename));
if(PageExists($GroupAttributesPage) )
{
if(PageTextVar($GroupAttributesPage, 'GroupTitle')>'')
$FmtPV['$GroupTitle'] =
'"'.htmlspecialchars(PageTextVar($GroupAttributesPage, 'GroupTitle')).'"';
else $FmtPV['$GroupTitle']
= "'". $AsSpacedFunction(PageVar($pagename, '$Group'))."'";
}
Note that this code should probably be placed *after* any PageStore definition
(per-group-sub-directories), after UTF-8 (xlpage-utf-8.php, XLPage())
Now, if this page Site.SiteAttributes has some passwords, they will be added
into the $DefaultPasswords array, and my request is satisfied.
Secondly, if in that page there is a PageTextVar:
WikiTitle:My website
then the $WikiTitle variable gets set.
Thirdly, is in Grpup.GroupAttributes there is a PageTextVar:
GroupTitle:Some group
then the $GroupTitle variable gets set, or else, the "spaced" version of the
groupname is used.
And, inside the skin, you can use <a
href='{$ScriptUrl}/{$Group}'>{$GroupTitle}</a>
Thanks,
Petko
More information about the pmwiki-users
mailing list