Revision [2344]

This is an old revision of WikkaSkinEditor made by DarTar on 2004-11-22 09:58:29.

 

Wikka Skin Editor


 

This actions extends the WikkaSkinSelector giving Wikka Administrators the possibility to edit skins directly from a Wikka page.
The "edit" option is safely "masked" to normal users, who can only select alternate skins, but not modify them.
If you don't need to modify WikkaSkins, and just want to give the user the possibility to switch between alternate skins, please install the basic WikkaSkinSelector instead.
Feedback is welcome, especially on security issues.

Important note
The WikkaSkinEditor writes files to your wikka css/ folder.
Please backup all your css before testing this action and use sample css sheets if you are not sure of what you are doing.

Requirements:

Installation


Here's the three-step installation:

1. Add your custom WikkaSkins skins

Just put all your skins in the css/ folder of your Wikka installation.
Many skins can be downloaded and shared from the unofficial WikkaSkinsRepository.

2. Create the skin editor action (actions/editskin.php)

Save the code below in a new file called actions/editskin.php:

<?php
// Wikka Skin Editor
// Allows Wikka Administrators to switch, edit and modify Wikka skins.
// The "Edit" field is masked to non-administrators, who can only select alternate skins.
// The css/ folder must be write-accessible for the modifications to take effect.

$currentskin = $this->GetCookie("wikiskin");
echo $this->Format("=== Select a Wikka skin:  === --- ");
switch ($_POST["action"]) {
    case "Save modified skin":
    // saves modified skin to file 
    $css_file = fopen("css/".$currentskin, "w+");
    fwrite($css_file, $_POST["mod_css_content"]);
    fclose($css_file);
    // no break
    case "Set skin":
    $this->SetPersistentCookie("wikiskin", $_POST["skin"]);
    $this->Redirect($this->href());
    break;
    case "Edit skin":
    $css_file = fopen("css/".$currentskin, "r");
    $css_contents = fread($css_file, filesize("css/".$currentskin));
    $showskin = '<textarea name="mod_css_content" cols="50" rows="15">'.$css_contents.'</textarea><br />'.
        '<input type="submit" name="action" value="Save modified skin"><br />';
    fclose($css_file);
    break;
}
$handle = opendir('css/');
print $this->FormOpen("","","post");
echo '<select name="skin">';
while (false !== ($file = readdir($handle))) {
    if (ereg("(.*)\.css", $file)) {
        $selected = ($file == $currentskin)? " selected" : "";
        print   '<option value="'.$file.'"'.$selected.'>'.$file.'</option>';
    }
}
echo '</select>';
echo '<input type="submit" name="action" value="Set skin"><br />';
if ($this->IsAdmin()) {
    echo $this->Format(" --- **".$currentskin."**  ").'<input type="submit" name="action" value="Edit skin"><br />';
    echo $showskin;
}
print $this->FormClose();
closedir($handle);
?>


3. Modify the Wikka Header (actions/header.php)

To allow skin selection a small modification of the header is needed:

original actions/header.php
   <link rel="stylesheet" type="text/css" href="css/<?php echo $this->GetConfigValue("stylesheet") ?>" />


modified actions/header.php
 <link rel="stylesheet" type="text/css" href="css/<?php echo ($this->GetCookie("wikiskin"))? $this->GetCookie("wikiskin"): $this->GetConfigValue("stylesheet") ?>" />


How to use the skin editor


Just insert {{editskin}} in a wikka page and start playing.


-- DarTar


CategoryDevelopment CategoryLayout
There are 3 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki