Wikka Menus
Last edited by NilsLindenberg:
Replaces old-style internal links with new pipe-split links.
Fri, 20 May 2016 07:38 UTC [diff]
Replaces old-style internal links with new pipe-split links.
Fri, 20 May 2016 07:38 UTC [diff]
This is an improved version of a module for creating and managing custom Wikka menus.
The module uses a dedicated wikka_menus table, in which the settings for several menus can be stored, along with their CSS selectors.
This version allows menus to be created, modified, (safely) renamed and (safely) deleted.
The output is an unordered list (<ul>) of menu items, which can then be formatted as a horizontal or vertical menu through the appropriate CSS style.
Menu items: more than links
Beside adding links, Wikka administrators will be able to add items such as text, images and action-generated content (provided there are actions that do the job).In order to use actions in WikkaMenus, the current system links that are present in the header and footer menu have to be 'modularized', i.e. saved as actions so as to let Wikka admins free to decide whether to display them or not.
See WikkaMenulets for more information on action-generated content for menu items
Why a menu table?
- it is much safer having a script modify single table entries than write into the Wikka configuration file (which contains all system settings).
- it is possible to create as many menus as needed, without cluttering up the system configuration, and store each menu in the table along with a CSS class/id that will determine its appearance on the page;
Here's how the menu interface looks like:
Menu Configuration
Please enter menu items on separate lines.
You can use on each line:
camelcase links like: PageIndex
forced links like: [[RecentChanges | What's new?]]
actions like: {{who}}
Create a new menu
Installation
1. Create the table
Updated 2004-11-16: field names modifiedYou will need to change your wikka prefix, e.g. "wikka_", to match your configuration.
Menus are identified through their name which is unique, content is a \n-separated list of links, css_class is a CSS selector. Different menus can have the same css_class.
I removed the sample INSERT, since new menus can be built using the interface below
CREATE TABLE `wikka_menus` ( `name` varchar(20) NOT NULL default '', `content` varchar(255) NOT NULL default '', `css_class` varchar(20) NOT NULL default '', UNIQUE KEY `name` (`name`) ) TYPE=MyISAM;
2. Add the menu functions in libs/Wakka.class.php
Updated 2004-11-17: more compact functionsfunction LoadMenu($name) {
$content = $this->LoadSingle("SELECT * FROM ".$this->config["table_prefix"]."menus WHERE name = '".$name."'");
return $content;
}
function LoadAllMenus() {
$menurow = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."menus");
return $menurow;
}
function SaveMenu($name, $content) {
$this->Query("UPDATE ".$this->config["table_prefix"]."menus SET content ='".mysql_real_escape_string(trim(str_replace("\r", "", $content)))."' WHERE name = '".$name."' LIMIT 1");
}
function MenuExists($name) {
if ($this->LoadMenu($name)){
return true;
}
}
function RenameMenu($oldname, $newname) {
$this->Query("UPDATE ".$this->config["table_prefix"]."menus SET name = '".$newname."' WHERE name = '".$oldname."' LIMIT 1");
}
function DeleteMenu($name) {
$this->Query("DELETE FROM ".$this->config["table_prefix"]."menus WHERE name = '".$name."' LIMIT 1");
}
function CreateMenu($name, $css_class) {
$this->Query("INSERT INTO ".$this->config["table_prefix"]."menus SET name = '".mysql_real_escape_string($name)."', content = '', css_class = '".mysql_real_escape_string($css_class)."'");
}
function TrimMenu($list) {
foreach (explode("\n", $list) as $line) {
$line = trim($line);
$trimmed_list .= $line."\n";
}
return $trimmed_list;
}
function PrintMenu($name) {
if ($menurow = $this->LoadMenu($name)) {
$menu = "<ul class=\"".$menurow["css_class"]."\">";
foreach (explode("\n", $menurow["content"]) as $menuitem){ $menu .="<li>".$this->Format($menuitem)."</li>\n";
}
$menu .= "</ul>\n";
return $menu;
}
}
$content = $this->LoadSingle("SELECT * FROM ".$this->config["table_prefix"]."menus WHERE name = '".$name."'");
return $content;
}
function LoadAllMenus() {
$menurow = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."menus");
return $menurow;
}
function SaveMenu($name, $content) {
$this->Query("UPDATE ".$this->config["table_prefix"]."menus SET content ='".mysql_real_escape_string(trim(str_replace("\r", "", $content)))."' WHERE name = '".$name."' LIMIT 1");
}
function MenuExists($name) {
if ($this->LoadMenu($name)){
return true;
}
}
function RenameMenu($oldname, $newname) {
$this->Query("UPDATE ".$this->config["table_prefix"]."menus SET name = '".$newname."' WHERE name = '".$oldname."' LIMIT 1");
}
function DeleteMenu($name) {
$this->Query("DELETE FROM ".$this->config["table_prefix"]."menus WHERE name = '".$name."' LIMIT 1");
}
function CreateMenu($name, $css_class) {
$this->Query("INSERT INTO ".$this->config["table_prefix"]."menus SET name = '".mysql_real_escape_string($name)."', content = '', css_class = '".mysql_real_escape_string($css_class)."'");
}
function TrimMenu($list) {
foreach (explode("\n", $list) as $line) {
$line = trim($line);
$trimmed_list .= $line."\n";
}
return $trimmed_list;
}
function PrintMenu($name) {
if ($menurow = $this->LoadMenu($name)) {
$menu = "<ul class=\"".$menurow["css_class"]."\">";
foreach (explode("\n", $menurow["content"]) as $menuitem){ $menu .="<li>".$this->Format($menuitem)."</li>\n";
}
$menu .= "</ul>\n";
return $menu;
}
}
3. Create the menu configuration interface (action/menu.php)
Updated 2004-11-16: Menus can be now created, deleted, renamed and modified// Menu Configuration Interface
// Version 1.0
<h3>Menu Configuration</h3>
<br />
<?php
if ($this->IsAdmin()) {
switch ($_POST["operation"]) {
case "Create Menu":
if ($this->MenuExists($_POST["newname"])) {
echo $this->Format("<<**Sorry!** --- A menu named \"".$_POST["newname"]."\" already exists. --- Please choose another name<<::c::--- --- ");
} else {
$this->CreateMenu($_POST["newname"], $_POST["css"]);
echo $this->Format("<<**Thanks!** --- Menu \"".$_POST["newname"]."\" has been created<<::c:: --- ");
}
break;
case "Delete Menu":
echo $this->Format("<<**Confirmation required**<<::c:: --- Do you really want to delete **".$_POST["name"]."**? --- --- ");
$formdelete = '<input type="hidden" name="name" value="'.$_POST["name"].'" />'.
'<input type="submit" name="operation" value="Confirm Deletion" style="width: 120px" accesskey="s" />'.
'<input type="button" value="Cancel" onClick="history.back();" style="width: 120px" /><p> </p>';
print $this->FormOpen("","","post");
print $formdelete;
print $this->FormClose();
break;
case "Confirm Deletion":
$this->DeleteMenu($_POST["name"]);
echo $this->Format("<<**Thanks!** --- Menu \"".$_POST["name"]."\" has been deleted<<::c:: --- ");
break;
case "Rename Menu":
if ($this->MenuExists($_POST["newname"])) {
echo $this->Format("<<**Sorry!** --- A menu named \"".$_POST["newname"]."\" already exists. --- Please choose another name<<::c:: --- --- ");
} else {
echo $this->Format("<<**Confirmation required**<<::c:: --- Do you really want to rename **".$_POST["name"]."** as **".$_POST["newname"]."**? --- --- ");
$formrename = '<input type="hidden" name="oldname" value="'.$_POST["name"].'" />'.
'<input type="hidden" name="newname" value="'.$_POST["newname"].'" />'.
'<input type="submit" name="operation" value="Confirm Rename" style="width: 120px" accesskey="s" />'.
'<input type="button" value="Cancel" onClick="history.back();" style="width: 120px" /><p> </p>';
print $this->FormOpen("","","post");
print $formrename;
print $this->FormClose();
}
break;
case "Confirm Rename":
$this->RenameMenu($_POST["oldname"], $_POST["newname"]);
echo $this->Format("<<**Thanks!** --- Menu has been renamed as \"".$_POST["newname"]."\"<<::c:: --- --- ");
break;
case "Update Menu":
$this->SaveMenu($_POST["name"], $this->TrimMenu($_POST["content"]));
echo $this->Format("<<**Menu configuration stored** --- Thanks for updating \"".$_POST["name"]."\"!<<::c:: --- --- ");
break;
}
// load stored menus and print menu forms
echo $this->Format('Please enter menu items on separate lines. --- You can either use //""CamelCase"" links// like ##""PageIndex""## --- or //forced links// like: ##""[[http://www.mydomain.com | External Link]]""## --- --- --- ');
$allmenus = $this->LoadAllMenus();
foreach ($allmenus as $item) {
$formarray[$item["name"]] = 'Menu: <strong>'.$item["name"].'</strong><br />'.
'<input type="hidden" name="name" value="'.$item["name"].'" />'.
'<textarea name="content" rows="6" cols="30">'.$item["content"].'</textarea><br />'.
'<input type="submit" name="operation" value="Update Menu" style="width: 120px" accesskey="s" />'.
'<input type="submit" name="operation" value="Delete Menu" style="width: 120px" /><br />'.
'<input type="text" name="newname" value="'.$item["name"].'" style="width: 120px">'.
'<input type="submit" name="operation" value="Rename Menu" style="width: 120px" /><p> </p>';
print $this->FormOpen("","","post");
echo $formarray[$item["name"]];
print($this->FormClose());
}
// "Create menu" form
$newmenuform = '<table><tr>'.
'<td>Menu name:</td><td><input type="text" name="newname" value="new_menu_name" style="width: 120px"></td></tr>'.
'<tr><td>CSS class:</td><td> <input type="text" name="css" value="css_class" style="width: 120px"><td></tr></table>'.
'<input type="submit" name="operation" value="Create Menu" style="width: 120px" /><br />';
echo $this->Format("== Create a new menu ==");
print $this->FormOpen("","","post");
echo $newmenuform;
print($this->FormClose());
} else {
print("<em>Sorry, only Wikka Administrators can modify the Menu configuration.</em>");
}
?>
// Version 1.0
<h3>Menu Configuration</h3>
<br />
<?php
if ($this->IsAdmin()) {
switch ($_POST["operation"]) {
case "Create Menu":
if ($this->MenuExists($_POST["newname"])) {
echo $this->Format("<<**Sorry!** --- A menu named \"".$_POST["newname"]."\" already exists. --- Please choose another name<<::c::--- --- ");
} else {
$this->CreateMenu($_POST["newname"], $_POST["css"]);
echo $this->Format("<<**Thanks!** --- Menu \"".$_POST["newname"]."\" has been created<<::c:: --- ");
}
break;
case "Delete Menu":
echo $this->Format("<<**Confirmation required**<<::c:: --- Do you really want to delete **".$_POST["name"]."**? --- --- ");
$formdelete = '<input type="hidden" name="name" value="'.$_POST["name"].'" />'.
'<input type="submit" name="operation" value="Confirm Deletion" style="width: 120px" accesskey="s" />'.
'<input type="button" value="Cancel" onClick="history.back();" style="width: 120px" /><p> </p>';
print $this->FormOpen("","","post");
print $formdelete;
print $this->FormClose();
break;
case "Confirm Deletion":
$this->DeleteMenu($_POST["name"]);
echo $this->Format("<<**Thanks!** --- Menu \"".$_POST["name"]."\" has been deleted<<::c:: --- ");
break;
case "Rename Menu":
if ($this->MenuExists($_POST["newname"])) {
echo $this->Format("<<**Sorry!** --- A menu named \"".$_POST["newname"]."\" already exists. --- Please choose another name<<::c:: --- --- ");
} else {
echo $this->Format("<<**Confirmation required**<<::c:: --- Do you really want to rename **".$_POST["name"]."** as **".$_POST["newname"]."**? --- --- ");
$formrename = '<input type="hidden" name="oldname" value="'.$_POST["name"].'" />'.
'<input type="hidden" name="newname" value="'.$_POST["newname"].'" />'.
'<input type="submit" name="operation" value="Confirm Rename" style="width: 120px" accesskey="s" />'.
'<input type="button" value="Cancel" onClick="history.back();" style="width: 120px" /><p> </p>';
print $this->FormOpen("","","post");
print $formrename;
print $this->FormClose();
}
break;
case "Confirm Rename":
$this->RenameMenu($_POST["oldname"], $_POST["newname"]);
echo $this->Format("<<**Thanks!** --- Menu has been renamed as \"".$_POST["newname"]."\"<<::c:: --- --- ");
break;
case "Update Menu":
$this->SaveMenu($_POST["name"], $this->TrimMenu($_POST["content"]));
echo $this->Format("<<**Menu configuration stored** --- Thanks for updating \"".$_POST["name"]."\"!<<::c:: --- --- ");
break;
}
// load stored menus and print menu forms
echo $this->Format('Please enter menu items on separate lines. --- You can either use //""CamelCase"" links// like ##""PageIndex""## --- or //forced links// like: ##""[[http://www.mydomain.com | External Link]]""## --- --- --- ');
$allmenus = $this->LoadAllMenus();
foreach ($allmenus as $item) {
$formarray[$item["name"]] = 'Menu: <strong>'.$item["name"].'</strong><br />'.
'<input type="hidden" name="name" value="'.$item["name"].'" />'.
'<textarea name="content" rows="6" cols="30">'.$item["content"].'</textarea><br />'.
'<input type="submit" name="operation" value="Update Menu" style="width: 120px" accesskey="s" />'.
'<input type="submit" name="operation" value="Delete Menu" style="width: 120px" /><br />'.
'<input type="text" name="newname" value="'.$item["name"].'" style="width: 120px">'.
'<input type="submit" name="operation" value="Rename Menu" style="width: 120px" /><p> </p>';
print $this->FormOpen("","","post");
echo $formarray[$item["name"]];
print($this->FormClose());
}
// "Create menu" form
$newmenuform = '<table><tr>'.
'<td>Menu name:</td><td><input type="text" name="newname" value="new_menu_name" style="width: 120px"></td></tr>'.
'<tr><td>CSS class:</td><td> <input type="text" name="css" value="css_class" style="width: 120px"><td></tr></table>'.
'<input type="submit" name="operation" value="Create Menu" style="width: 120px" /><br />';
echo $this->Format("== Create a new menu ==");
print $this->FormOpen("","","post");
echo $newmenuform;
print($this->FormClose());
} else {
print("<em>Sorry, only Wikka Administrators can modify the Menu configuration.</em>");
}
?>
4. Create the appropriare CSS styles
Here's a basic example for formatting a Wikka Menu as a horizontal menu. Change the CSS class (main_menu) to match the one you specified when creating a menu.
.main_menu { width: 100%; list-style-type: none; } .main_menu li { padding: 2pt; float: left; width: auto; margin-right: 3pt; text-align: center; } .main_menu .exttail { visibility: hidden; }
5. Use the menus in your wiki pages
Once you've set the appropriate CSS styles, two different usages of custom Wikka Menus are possible:
You can either print your menus in the page header, by modifying actions/header.php as follows
Updated 2004-11-17: typo in previous version - sorry!
original actions/header.php
<?php echo $this->Link($this->config["root_page"]); ?> ::
<?php
if ($this->GetUser()) {
echo $this->config["logged_in_navigation_links"] ? $this->Format($this->config["logged_in_navigation_links"])." :: " : "";
echo "You are ".$this->Format($this->GetUserName());
} else {
echo $this->config["navigation_links"] ? $this->Format($this->config["navigation_links"]) : "";
}
?>
<?php
if ($this->GetUser()) {
echo $this->config["logged_in_navigation_links"] ? $this->Format($this->config["logged_in_navigation_links"])." :: " : "";
echo "You are ".$this->Format($this->GetUserName());
} else {
echo $this->config["navigation_links"] ? $this->Format($this->config["navigation_links"]) : "";
}
?>
modified actions/header.php
<?php
if ($this->GetUser()) {
echo $this->PrintMenu("logged_in_menu");
} else {
echo $this->PrintMenu("main_menu");
}
?>
if ($this->GetUser()) {
echo $this->PrintMenu("logged_in_menu");
} else {
echo $this->PrintMenu("main_menu");
}
?>
or use them in the page body, through a simple action action/printmenu.php which can be called on the page with a syntax like {{printmenu name="main_menu"}}
Updated 2004-11-16: replaced $type with $name
actions/printmenu.php
<?php
// Print Menu action
echo $this->PrintMenu($name);
?>
// Print Menu action
echo $this->PrintMenu($name);
?>
Notes
- The code above can be easily modified to allow the creation of an indefinite number of custom menus, each with its name, content and css selector.
- The same approach might be used to allow users to modify their own custom menu (which would be stored in a dedicated row of users table)
- I wonder if menus are better handled by CSS id's or classes: do you think menus of the same type are susceptible to occur more than once on a page?
- Improvements and suggestions for the code above are welcome :)
To Do
- Integration with current menu configurations
-- DarTar
CategoryDevelopmentArchitecture
Instead of "type" i would use "menu_name" (seems more selfexplaining for me).
But that are only two small things. Otherwise I like it :-)
I understand it's still very much a "concept" but...
- using an ini maintenance web interface (which I'm making anyway) is just as "safe" as using an interface to edit a database table: so that is not really an argument for using a table
- both the current (config) solution and yours have the disadvantage of not supporting a title attribute for the actual links; an ini web interface could easily support this
- an ini web interface cannot do any "type-specific" validation (everything is just a string) while your table solution would enable this (though such validation is still missing)
- to support different menus as well as title attributes with SQL instead if ini you'd probably need two tables: one to store name and type of teh menu, another to store the data for each link
- when you use "type" that word suggests "class" but since "type" is a unique key and content is (therefore) also unique, "type" doesn't seem to be the correct name: that word suggests you can have multiple menus of the same "type"; I agree with Nils that "name" is probably better; still, in the generated HTML it should correspond to a class instead of an ID to enable to have the _same_ menu both at the top and at the bottom of the page (for instance)
- apart from the missing validation, your configuration interface has hard-coded types instead of picking these up from what is actually in the table; you could loop through them or have an action parameter to choose one and then present the interface to edit only that one menu; the action parameter itself would then need to be validated -OR- a non-existing menu name would lead to a form to actually create a new menu (which is missing now), with a note that no menu of that name was found; anyway there needs to be an interface to create a new menu, and delete an existing one, apart from merely editing what's in the table already
On balance I think this idea might indeed be better than having the menu definition in a config/ini file - but it needs work (also in separating logic from interface - mixing it all up makes it hard to understand and maintain). Nice job though! (Especially in convincing me a table solution is probably better than keeping it in an in file ;o))
True, but the "ini" in question is the wakka system configuration, or you were thinking of a menu.config.inc?
> oth the current (config) solution and yours have the disadvantage of not supporting a title attribute for the actual links
The menu configuration interface just uses standard Wikka formatting. I think the right place to discuss about title attributes in links (which are a good idea, indeed) is the wikka formatter.
> types, classes, id's
I agree "type" is a bad word. I just wanted to wait for some reactions before deciding whether menus must have unique occurrences on the page, or if multiple occurrences are allowed (I think two distinct tables for menu categories and menu content could be avoided).
And yes, the menu name should be retrieved/stored from the table and not hardcoded like in my very first draft, I'll fix this ASAP.
"does any function use the GetConfigValue"
Yes, I've seen this a lot (without doing global search, but I've seen it in multiple locations); I suspect it's a precursor of the more direct $this->config['some_name']. It would probably be a good idea to standardize this to the latter method (and then maybe get rid of the GetConfigValu() altogether so we don't keep bouncing back).
Should be part of a "code cleanup" action, I think.
"> using an ini maintenance web interface (which I'm making anyway) is just as "safe" as using an interface to edit a database table
True, but the "ini" in question is the wakka system configuration, or you were thinking of a menu.config.inc?"
I meant a general config ini file for Wikka instead of the current file with an array, and read/write/maintenance functions to handle such files. It would also enable one to easily put the configuration "above" the web document root and so make it more secure. PHP does have some functionality to read an ini file, but it's very poor (and I've found it uses this internally for the ini-get() function as well - I just saw it fall over in a bad way this morning after I changed a setting in my php.ini...). So I'm writing my own class (set of classes, really) to handle ini files. Will handle and maintain even comments. Integration with Wikka will be easy, I promise!
(And if Wikka doesn't adopt it, I can still use it for a lot of other things ;-))
Still, I now like your idea of using a table rather than a config file (in whatever form) to store menu data, with a dedicated UI for it.
Ok, just wanted to know which method should be preferred (I remember vaguely reading some things about getting variables through functions and not calling it directly, but that was some years ago and I don't remember any details).
"I remember vaguely reading some things about getting variables through functions and not calling it directly"
Probably some advice about OO? Wikka is about "half" OO, I'd say. :) The idea which you probably read about is that an object encapsulates data and its methods and one should only be able to "get at" (read, write) an object's data via the methods the object exposes.
That said, all of the actions code is not a set of functions external to a (the) Wakka object, but bits of code that are included dynamically (in fact, not actual functions at all); any method (and thus also "part of" a method) that's internal to an object has direct access to all of the object's data.
That said, I'd have to check where exactly GetConfigValue() is used - maybe we do still need it: it depends where it's used (internally or externally from the object).
Good you're brining that up!
...
OK, at least one place where it's used from an "external" function - so we need to keep the function; but also places where it's used but not needed, actions, handlers, even in functions in the Wakka class file itself.
What code has to be removed exactly?
Sorry, but I'm not a programmer.
The block that has to be replace in header.php is the following (hope it's the original one):
<?php
if ($this->GetUser()) {
echo $this->config["logged_in_navigation_links"] ? $this->Format($this->config["logged_in_navigation_links"])." :: " : "";
echo "You are ".$this->Format($this->GetUserName());
} else {
echo $this->config["navigation_links"] ? $this->Format($this->config["navigation_links"]) : "";
}
?>
The old one was giving me error messages.
I don't know if it was me (most likely) or an error in the code or a config problem.
I tried the modified header but I'm still getting an error.
Fatal error: Call to undefined function: printmenu() in /home/www/xxx/xxx/actions/header.php on line 43
Can you offer any help.
------------------------------------
class Wakka
{
var $dblink;
var $page;
var $tag;
var $queryLog = array();
var $interWiki = array();
var $VERSION;
------------------------------------
Thanks DarTar and Christian.
It's not a good idea to have methods *before* the constructor in a class definition. While the menu functions surely must be *within* the class definition they should probably be withina section of their own, much as we already have otehr sections marked with // comments. I'd recomment creating a //MENUS section to place the functions in.
@DarTar:
- The forms look somewhat unwieldy - no need to create such *big* buttons with "menu' in them when it's already clear the form is *for* a menu. Just Update, Delete and Rename should do fine.
- CSS: why hide the exttail at all? And if you do want to hide it, why not use display: none; instead of visibility: hidden; - so it won't take up any space either?
I'd already been wondering how to integrate the current "You are [Name]" and using the "mini actions" modules is a nice solution!
It could be like {{footer menus="edit,history,revisions,owner,referrers,search"}}
it could be equally practical and customisable i think.
for header menu there could be a similar proposal ...
{{header menus_logged="HomePage, Categories, PageIndex, RecentChanges, RecentlyCommented, usersettings(Change Settings/Logout), who" menus_notlogged="HomePage, CategoryCategory(Categories), RecentChanges, PageIndex, UserSettings(Login / Register)}}
Note:
{{menu_name menu_state="target_page_name(display_text), another_page_name(display text for 'another page name'), ... and so on. .. }}
I hope it is clear ..
OTOH, I don't like that much the idea of coding the whole menu content as a single comma-separated action parameter. Using menu tables gives you much more flexibility than just using action parameters. For instance, how would you embed an existing action in an action parameter? And isn't a GUI for menus more user-friendly than your header menu action?
all that the gui will be doing is interfacing the attributes and the values of the action...
"how would you embed an existing action in an action parameter?"
Maybe this could do it ..
{{menu_name menu_state="PageName(Display text for PageName), ![action_here]! , ...}}
I just thought it would be a bit more practical,.. but if it is not doing it then its fine with me ;)
- PageName(Text) for links
- ![action]! for actions
which require dedicated parsers and further learning for the user.
My approach OTOH only uses standard Wikka Syntax. No need of further parsers and the syntax is already known to the user:
[[PageName Text]]
{{action}}
Moreover, I don't understand why you are suggesting an "action". Where would you use such an action? In every page? In the page header/footer? Your proposal looks more like an extension of the current menu entries in wikka.config.php: I've already tried to convince JavaWoman of the advantages of having menus handled by tables instead of config files (take a look at the comments above).
about the syntax yes it is true it can be hard to make,.. although a gui could overcome this..
I am on your side about quiting the configuration file.
( I think that the configuration file should only be needed to setup the connection to mysql variables,... the remaining conf vars should IMHO be in a mysql table (easier to interface, safer)
Well, the discussion was really about using a GUI to define menus: your action does provide that but a GUI for a config file could do it just as well. I like what you're doing (no opposition). But, I'm not convinced a table is _necessary_. But I did say already "On balance I think this idea might indeed be better than having the menu definition in a config/ini file"
I still don't see support for providing a title attribute though. That's really needed, I think.
Actually, currently header.php and footer.php are themselves actions (they're in the actions directory!) - not "source" files that could be edited to themselves include actions.
That said, I'm not conviced they should _be_ (or be treated as) actions; looking at the code they could just as easily be "includable" files. Which mean they don't really belong in the actions directory either. An extra argument is that while you could include {{header}} or {{footer}} in a page, doing the former would actually create a totally invalid "HTML" document, since it not only generates the visible page header with the menu, but also the DOCTYPE declaration and the head section of the document.
Real actions should be written in such a way as to allow inclusion in a page *without* causing invalid (X)HTML.
now there are header_action and footer_action in the config ...
they provide to assign the strings that define the actions to include anyway.
if we take for granted this in the config:
'footer_action' = '{{footer menus="edit,history,revisions,owner,referrers,search"}}
I was thinking that alterning the Header() and Footer() in the core to smth like
function Footer() { echo $this->Format($this->config['footer-action']) }
instead of $this->Action($this->config['footer-action'])
it should call the footer.php as it does now but should give a bit more flexibility..
on the issue of {{footer}} inside a wikipage :
I suggest to do this simple patch to keep people from including the footer.php or header.php files in their wikipages ...
/* in formatters/wakka.php */
// Actions
else if (preg_match("/^\{\{(.*?)\}\}$/s", $thing, $matches))
{
if ($matches[1]) {
return (substr($matches[1],0,6)==('header' || 'footer')) ? '{{}}' : $wakka->Action($matches[1]) ;
}
}
instead of the existing code that doesnt have any prevention 'if' ...
// Actions
else if (preg_match("/^\{\{(.*?)\}\}$/s", $thing, $matches))
{
if ($matches[1])
return $wakka->Action($matches[1]);
else
return "{{}}";
}
JW, as I said before, I completely agree bu I think this is not an issue to be discussed here: WikkaMenus only apply Wikka formatting rules to menu entries, so if there is a title issue it has to be addressed here: http://wikka.jsnx.com/WantedFormatters.
As for header.php and footer.php:
<what JavaWoman said>
And your "menulets" are actions and thus could provide title attribute support in the same way the {{image}} action does.
BTW, main_menu could optionally also contain {{who}} - does your menulet for that support displaying remote address for a not-logged-in user?
I changed to type to "mediumtext" and increased the size. It works fine but wanted to check with you if you see any problems.
something like that
[[Home Home]] ::
[[PageIndex Sitemap]] ::
[[CategoryCategory Categories]] ::
[[RecentChanges Changes]] ::
[[RecentlyCommented Comments]] ::
[[UserSettings Profile]] ::
[[MyPages My Pages]] ::
[[http://wiki.blahblah.de/UserSettings?action=logout Logout]]
If I want to include other "direct links" (e.g. Logout) which require the full url, I need more characters than (just) 255.
----
Cool! It works :)
I agree with you that using CSS is the best solution but IE has unfortunately some major bugs with the CSS interpretation.