WikkaMenusAdmin Action
This is the development page for the WikkaMenusAdmin action for Wikka version > 1.2.
DarTar did WikkaMenus, a solution to manage users customized menus stored in MySql database. WikkaMenusAdmin is a "downgraded" version which manages menulets files introduced with Wikka version 1.2.
Usage
Place in a page {{wikkamenusadmin}}, you can also apply ACLs restriction (despite this action is made for admin user only).Installation
- Save the code block below as /plugins/actions/wikkamenusadmin.php- Give it the same file permissions as the other php files in that directory
- Customized menulets directory if needed
Code
- <h3>Menu Configuration</h3>
- <br />
- <?php
- /* My Menu Configuration Interface
- * http:\\emerald-island.eu
- * 20090917
- * version 1.0
- */
- /*Change the path below if needed */
- function WriteMyMenu($file, $content) {
- $file = $file.'.inc';
- }
- function ReadMyMenu($file) {
- $menu_content = '';
- if ($size)
- else
- $menu_content = '';
- return $menu_content;
- }
- function DeleteMyMenu($filename) {
- }
- }
- }
- function LoadAllMyMenus() {
- $menu['name'] .= $file;
- $menu['content'] .= ReadMyMenu($file);
- $menulist[] = $menu;
- }
- }
- return $menulist;
- } else {
- return FALSE;
- }
- }
- function TrimMenu($list) {
- $trimmed_list .= $line."\n";
- }
- return $trimmed_list;
- }
- /*Only admin can create/edit/delete menus*/
- if ($this->IsAdmin()) {
- switch ($_POST['operation']) {
- case 'Create Menu':
- echo $this->Format('<<**Sorry!** --- A menu named "'.$_POST['newname'].'" already exists. --- Please choose another name<<::c::--- --- ');
- } else {
- WriteMyMenu($_POST["newname"], $_POST["menu"]);
- 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 = '<fieldset><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" /></fieldset><p> </p>';
- echo $this->FormOpen('','','post')."\n";
- echo $formdelete."\n";
- echo $this->FormClose()."\n";
- break;
- case 'Confirm Deletion':
- DeleteMyMenu($_POST['name']);
- echo $this->Format('<<**Thanks!** --- Menu "'.$_POST['name'].'" has been deleted<<::c:: --- ');
- break;
- case 'Rename Menu':
- 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 = '<fieldset><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" /><fieldset><p> </p>';
- echo $this->FormOpen('','','post')."\n";
- echo $formrename."\n";
- echo $this->FormClose()."\n";
- }
- break;
- case 'Confirm Rename':
- echo $this->Format('<<**Thanks!** --- Menu has been renamed as "'.$_POST["newname"].'"<<::c:: --- --- ');
- break;
- case 'Update Menu':
- WriteMyMenu($_POST['name'], 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 = LoadAllMyMenus();
- foreach ($allmenus as $item) {
- $formarray[$item['name']] = '<fieldset>Menu: <strong>'.$item['name'].'</strong><br />'.
- '<input type="hidden" name="name" value="'.$item['name'].'" />'.
- '<textarea name="content" rows="6" cols="120">'.$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" /></fieldset><p> </p>';
- print $this->FormOpen('','','post');
- echo $formarray[$item['name']];
- print($this->FormClose());
- }
- // "Create menu" form
- $newmenuform = '<fieldset><table><tr>'.
- '<td>Menu name:</td><td><input type="text" name="newname" value="new_menu_name" style="width: 120px" /></td></tr></table>'.
- '<input type="submit" name="operation" value="Create Menu" style="width: 120px" /><br /></fieldset>';
- echo $this->Format('== Create a new menu ==');
- echo $this->FormOpen('','','post')."\n";
- echo $newmenuform;
- echo $this->FormClose()."\n";
- } else {
- echo '<em>Sorry, only Wikka Administrators can modify the Menu configuration.</em>';
- }
- ?>
That's all !
CategoryUserContributions - CategoryDevelopmentActions