# Geeklog Theme Editor Plugin [v1.1.2]

by mystral-kk [geeklog@mystral-kk.net]
Sep 26, 2008

## Table of Contents

- Description
- Version History
- Thanks!
- Installing The Plugin
- Uninstalling The Plugin
- Configuring The Plugin
- Upgrading The Plugin
- Usage
- License

### Description

The Theme Editor is an online theme editor which allows you to edit template files (*.thtml) and cascading style sheet file (*.css). With this plugin, you can edit Geeklog themes on the Web, without uploading theme files.

### Version History

Date | Version | Description
--- | --- | ---
Sep 26, 2008 | 1.1.3 | [Fix] Upgraded to prevent include-files to be directly accessed in some case-insensitive file systems (e.g. MS Windows).
Sep 14, 2008 | 1.1.2 | [Fix] Upgraded to work well with PHP-4.x by not using htmlentities() and html_entity_decode() functions.
Aug 18, 2008 | 1.1.1 | [Fix] Upgraded to properly work with DokuWiki plugin.
Aug 11, 2008 | 1.1.0 | [New] Upgraded to properly work with Geeklog-1.5.0 as well. [New] Upgraded to use Config UI with GL-1.5.0.
Mar 29, 2007 | 1.0.5 | [Fix] Modified to properly handle a path containing an apostrophe. [New] Added a new option to make all themes available automatically. (See Configuring the plugin below.) [New] Added a new option to make all theme-related files (*.thtml, *.css) available automatically. (See Configuring the plugin below.)
Dec 21, 2006 | 1.0.4 | [New] Added a functionality of uploading images to the images directory under each theme directory [New] Changed file name dropdown list so that the purposes of the files, instead of file names themselves, will appear.
Nov 7, 2006 | 1.0.3 | [Fix] Dealed with the case where default language is not Japanese (Thanks, Kemal and Tsuchi). [New] Added many more template file names(Thanks, Ivy).
Nov 2, 2006 | 1.0.2 | [Fix] Dealed with the case where magic_quotes_gpc is on (Thanks, samstone).
Oct 1, 2006 | 1.0.0 | Initial version

### Thanks!

- Geeklog.jp members for useful suggestions
- Geeklog Core Team for developing and maintaining Geeklog, the Ultimate CMS

### Install instruction for the Geeklog Theme Editor plugin

In the following descriptions

- <geeklog_dir> is the directory where the system config.php file resides
- <admin> is the directory where the administration files reside (usually, under <public_html>)

1. Back up your Geeklog Database. The themedit plugin adds tables to your Geeklog database. You can do this with the built in admin backup facility.
2. Uncompress the themedit plugin archive while in the <geeklog_dir>/plugins directory. The archive will create a directory called themedit in the plugins directory.
3. Create the admin directory. Under your <admin>/plugins/ directory create a directory called themedit.
4. Change to your <geeklog_dir>/plugins/themedit/ directory. Copy the files in the admin directory to the <admin>/plugins/themedit/ directory your created in step 3.
5. Edit the config.php in the themedit directory and confirm the table prefix (the same as Geeklog table prefix by default) and modify the names of themes and files you would like to edit with the Theme Editor plugin.
6. Log in to your Geeklog as a root user and run install.php in your <admin>/plugins/themedit/ directory. The install page will tell you if the install was successful or not. If not, examine Geeklog system errorlog for possible problems. The themedit plugin should now be installed and functioning. Clicking on the themedit Icon will take you to the admin page.
7. Set up security. On install only the root users have access to themedit administration. You can delegate control for the functions through the user and group editors.
8. [***** EXTRA STEP 1 FOR THEME EDITOR PLUGIN *****] Change the permissions of the directories where *.thtml files resides to 757. Change the permissions of the *.thtml files to 646.
9. [***** EXTRA STEP 2 FOR THEME EDITOR PLUGIN *****] Change the permissions of the files preview.html and preview.css, which reside in the <admin>/plugins/themedit/ directory, to 646.

NOTE: The Theme Editor plugin uses JavaScript a lot. For better functionality, it is strongly recommended that you enable JavaScript.

### Uninstall instruction for the Geeklog Theme Editor plugin

1. Run the install.php page in your <admin>/plugins/themedit directory. This will remove all the data from your database.
2. Delete the two plugin directories created in the install process: <geeklog-dir>/plugins/themedit/ and <admin>/plugins/themedit/
3. [***** EXTRA STEP FOR THEME EDITOR PLUGIN *****] Restore the permissions of the directories and files you changed during the installation. For example, change the permissions of the directories to 755 and those of the files to 644.

### Configuring the plugin

In the plugin's config.php, you can modify these values:

Name | Type | Description
--- | --- | ---
`$_THM_CONF['allowed_themes']` | Array of theme names | The theme names (case-sensitive) you can edit with the plugin. The default value is 'professional'.
`$_THM_CONF['allowed_files']` | Array of file names | The file names (case-sensitive) you can edit with the plugin. Template files (*.thtml) and cascading style sheet files (*.css) are supported.
`$_THM_CONF['resync_database']` | One of 'auto', 'manual', 'ignore' | When you add/remove a theme to/from `$_THM_CONF['allowed_themes']`, or a template file to/from `$_THM_CONF['allowed_files']`, The Theme Editor plugin will detect it automatically. 'auto' -- the plugin will update the data stored in databse automatically. 'manual' -- the plugin will display the information and 'UPDATE database' button. 'ignore' -- the plugin will do nothing about the change.
`$_THM_CONF['allow_upload']` | Boolean (true or false) | Whether you allow images to be uploaded to the images directories under the theme directories. The default value is true.
`$_THM_CONF['image_width']` | Integer | The width (in pixels) of thumb nail images. The default value is 120.
`$_THM_CONF['image_height']` | Integer | The height (in pixels) of thumb nail images. The default value is 100.
`$_THM_CONF['image_max_col']` | Integer | The number of columns of thumb nail images. The default value is 6.
`$_THM_CONF['upload_max_size']` | Integer | The max size (in bytes) of images to be uploaded to the web server. The default value is 1048576, that is, 1M bytes.
`$_THM_CONF['enable_all_themes']` (ver.1.0.5 or later) | Boolean | If set true, all themes are allowed automatically regardless of the value of `$_THM_CONF['allowed_themes']`. The default value is false.
`$_THM_CONF['enable_all_files']` (ver.1.0.5 or later) | Boolean | If set true, all theme-related files (*.thtml, *.css) are allowed automatically regardless of the value of `$_THM_CONF['allowed_files']`. The default value is false.
`$_THM_CONF['enable_csrf_protection']` (ver.1.1.0 or later) | Boolean | If set true, CSRF protection will be enabled when you are using Geeklog-1.5.0.

### Upgrading The Plugin

First, after you download and unpack a new archive, upload all the files to the Web server. Then, log in as admin and go to the Plugin Editor. Click the edit icon and click "upgrade" button.

### Usage

The Theme Editor plugin is so simple that you can use it almost intuitively.

1. Choose a theme you want to edit at a dropdown menu.
   NOTE: theme names you can choose from are defined as the `$_THM_CONF['allowed_themes']` array in `config.php`. Please edit it as you like.
2. Choose a file you want to edit at a dropdown menu.
   NOTE: file names you can choose from are defined as the `$_THM_CONF['allowed_files']` array in `config.php`. Please edit it as you like.
3. A list of template vars available in the current file will be displayed.
4. When you hit one of the buttons with a template var name on it, the corresponding tag will be inserted into the caret position.
   NOTE: you have to enable JavaScript to use these buttons.
5. When you hit the "Preview" button, the current content will be previewed in another page.
6. When you hit the "Save" button, the current content will be saved on the Web.
7. When you hit the "Initialize" button, the content of the file will be reverted to what it used to be when you installed the Theme Editor plugin.
8. When you hit the "Image" button, a simple image browser will be displayed. Supported file types are 'jpg', 'jpeg', 'png', and 'gif'. In the screen, you can choose a theme and a directory from dropdown lists. When you want to upload an image file to the current directory, hit the 'Browse...' button and select an image file to upload and then hit the 'Upload' button. If you want to delete an image file(s), check all the files you'd like to and hit the 'Delete' button. The deleting process will be carried out WITHOUT CONFIRMATION, so be very careful! There is no undoing it.

### License

The Theme Editor plugin is licensed under the GPL.

Copyright © 2006-2008 mystral-kk